Click here to Skip to main content
Click here to Skip to main content
Go to top

Microsoft Visual Source Safe Client

, 20 Sep 2006
Rate this:
Please Sign up or sign in to vote.
Microsoft Visual Source Safe client which can notify of check-ins.

Sample Image - notify.jpg

Introduction

I’m working in a project having a big developer team. To manage our source code we are using Microsoft Source Safe. But source safe client could not satisfy all my needs. Most of the time I waited for a file checked out my another member of my team. I opened the visual source safe client and find who checked out the file. I contact him and request him to check in the file I waited for. When he finishes his work with the file he check-in the file. Most of the time he doesn’t notify me that he had finished with the file. So, I wait and wait for the file. Even if he check-in the file he has to contact me to notify me that he had checked in the file. This is a very slow process. So, I thought why not to write a VSS client which will notify me if my interested file has been checked in. I first looked at codeproject, if someone has already developed such project. I could not found any project which satisfy my requirements. So, this is the project which satisfy my requirements.

Description

Login to VSS

Login to VSS

The login window is similar to Microsoft Visual Source Safe Client. VSSDatabaseClass in SourceSafeTypeLib namespace manages the VSS. To use this namespace you need to reference the COM provided with Microsoft Visual Source Safe.

try

{
    vssDB = new VSSDatabaseClass();
    vssDB.Open(this.txtDatabase.Text, txtUserName.Text, txtPassword.Text);
}

catch(System.Runtime.InteropServices.COMException comex)

{
    vssDB=null;
    if (comex.ErrorCode == -2147166526 || comex.ErrorCode == -2147352566)
    {
        MessageBox.Show("User Name or Password is incorrect.", 
                        "Login Failed",MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
    }
    else
    {
        MessageBox.Show("Unknown VSS COM Exception:\n\n" + comex.ToString(),
                        "Login Failed",MessageBoxButtons.OK,MessageBoxIcon.Error);
    }

}

VSS Explorer

VSS Client

VSS explorer is similar to Microsoft VSS Client. It has a tree view in the left side which, displays the projects and a list view on the right side to display files of a particular project. It also displays which file are checked in by alone with the user name, machine name and checked in folder. The left side tree control is loaded on demand. It doesn't load the complete projects list at a time. Because it takes a long time.

private void BuildTreeView(TreeNode parentNode,VSSItem itm)

{
    TreeNode newNode;
    if (parentNode==null&&itm==null)
    {
        VSSItem vssProj = vssDB.get_VSSItem("$/", false);
        newNode = new TreeNode();
        newNode.Text="$";
        newNode.Tag=vssProj;
        trvSSProjects.Invoke(new AddNodeDelegate(AddNode), 
              new object [] {parentNode,newNode,vssProj});
        IVSSItems childItems = vssProj.get_Items(false);
        if (childItems != null && childItems.Count > 0)
        {
            parentNode=newNode;
            foreach(VSSItem childItem in childItems)
            {
                if (childItem.Type==0)
                {
                    newNode = new TreeNode();
                    newNode.Text=childItem.Name;
                    newNode.Tag=childItem;
                    trvSSProjects.Invoke(new AddNodeDelegate(AddNode), 
                        new object [] {parentNode,newNode,childItem});
                    break;
                }
            }
        }
    }
    else if (itm.Type==0)
    {
        newNode = new TreeNode();
        newNode.Text=itm.Name;
        newNode.Tag=itm;
        trvSSProjects.Invoke(new AddNodeDelegate(AddNode), 
                  new object [] {parentNode,newNode,itm});
        IVSSItems childItems = itm.get_Items(false);
        if (childItems != null && childItems.Count > 0)
        {
            parentNode=newNode;
            foreach(VSSItem childItem in childItems)
            {
                if (childItem.Type==0)
                {
                    newNode = new TreeNode();
                    newNode.Text=childItem.Name;
                    newNode.Tag=childItem;
                    trvSSProjects.Invoke(new AddNodeDelegate(AddNode), 
                        new object [] {parentNode,newNode,childItem});
                    break;
                }
            }
        }
    }



}

private void AddNode(TreeNode parentNode,TreeNode newNode,VSSItem itm )
{
    if (parentNode==null)
    {
        trvSSProjects.Nodes.Clear();
        trvSSProjects.Nodes.Add(newNode);
    }
    else
    {
        parentNode.Nodes.Add(newNode);
    }
    Application.DoEvents();
}

When user selects any project on the tree view FillupListView method fill up the list view with file list of the selected project.

private void FillupListView(VSSItem itm)
{
    this.lvFileList.Items.Clear();
    IVSSItems childItems = itm.get_Items(false);
    if (childItems != null && childItems.Count > 0)
    {
        ListViewItem item;
        foreach(VSSItem childItem in childItems)
        {
            if (childItem.Type==1)
            {
                item = new ListViewItem();
                item.Text=childItem.Name;
                int i=childItem.IsCheckedOut;
                if (childItem.IsCheckedOut==1||childItem.IsCheckedOut==2)
                {
                    foreach (VSSCheckout checkOut in childItem.Checkouts)
                    {
                        item.SubItems.Add(checkOut.Username);
                        item.SubItems.Add(checkOut.Date.ToString());
                        item.SubItems.Add("["+checkOut.Machine+"]"+
                                              checkOut.LocalSpec);
                    }
                }
                item.ImageIndex=2;
                item.Tag=childItem;
                lvFileList.Items.Add(item);
            }
        }
    }
}

Notify If Check In

If the user right clicks a file which has been checked in then a pop-up menu will display. It has two menu. One is for Notify If Check In which will start monitoring the file unless it is checked in. The other menu will show the history window for the file.

Notify Menu

Check In Notification

If user requested for notification for a file then it started a notification monitoring. When the file is checked in a toast will display near the system tray to notify the user that the file he requested to monitor is checked in.

Sample screenshot

It also allow the user to check-out the file by clicking on the link button. It will check in to the current local path.

Sample screenshot

Show History

Show history will allow the user to filter the history according to the user name, from date, and to date.

show History

To display the history of an entire project, the user can right click on the project on the tree view and click the Show History menu. In this case, it will display the history for all files satisfying the user's criterion.

Show Pending Check-in

User can get all the files in a project which are pending for check in. To get the pending check in, the user can right click on the tree node of the project and click the Pending Check-in menu. It will display all the files which are pending for check in.

Pending Check-in

System Tray Icon

Tray Menu

The user will get a menu at the system tray.

Special Thanks

I used the TaskbarNotifier designed by John O'Byrne. You can get the TaskbarNotifier from here.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

H. S. Masud
Software Developer (Senior) KAZ Software Limited
Bangladesh Bangladesh
No Biography provided

Comments and Discussions

 
GeneralYou did a great job. thanks. Pinmemberxwyangjshb16-May-14 1:56 
QuestionTaking long time while populating 5000 more file details using FillupListView Pinmembersahithib26-Jul-12 4:55 
QuestionGreat Work - My vote of 5 - and have a question PinmemberM-Idrees-pk28-Jun-12 19:47 
GeneralMy vote of 5 PinmemberDhol Gaurav3-Jul-10 23:14 
QuestionAutomatically refresh Solution Explorer source control status icon ? PinmemberAlexandru Matei3-Oct-09 21:46 
Hello,
 
Please allow me an off-topic question.
 
In Visual Studio's Solution Explorer, do you know a tool/add-in to automatically
refresh the source control status icon (checked out icon, blue locked icon) ?
 
Usually, this is done manually from
File->Source Control->Refresh Status
 
but I need an automatic way to see the icon change, say every 2 minutes.
 
Thanks.
GeneralNice work PinmemberJoeW24-Mar-08 10:33 
GeneralGreat work! Pinmemberjmiller427-Nov-07 4:53 
GeneralSmall addition - add sorting Pinmemberdarcraver22-Jun-07 11:51 
GeneralVery good work, i'll try to make a remote version Pinmemberleomicheloni26-Apr-07 5:58 
GeneralIn order to run this application do we need to have VSS installed in our machine PinmemberAkhilec12-Apr-07 1:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 20 Sep 2006
Article Copyright 2006 by H. S. Masud
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid