Click here to Skip to main content
15,867,308 members
Articles / Programming Languages / C#
Article

Microsoft Visual Source Safe Client

Rate me:
Please Sign up or sign in to vote.
4.78/5 (29 votes)
20 Sep 2006CPOL3 min read 148.7K   4.1K   96   30
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.

C#
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.

C#
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.

C#
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)


Written By
Software Developer (Senior) KAZ Software Limited
Bangladesh Bangladesh
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralYou did a great job. thanks. Pin
xwyangjshb16-May-14 1:56
xwyangjshb16-May-14 1:56 
QuestionTaking long time while populating 5000 more file details using FillupListView Pin
sahithib26-Jul-12 4:55
sahithib26-Jul-12 4:55 
QuestionGreat Work - My vote of 5 - and have a question Pin
Muhammad Idrees GS28-Jun-12 19:47
Muhammad Idrees GS28-Jun-12 19:47 
GeneralMy vote of 5 Pin
Dhol Gaurav3-Jul-10 23:14
professionalDhol Gaurav3-Jul-10 23:14 
QuestionAutomatically refresh Solution Explorer source control status icon ? Pin
Alexandru Matei3-Oct-09 21:46
Alexandru Matei3-Oct-09 21:46 
GeneralNice work Pin
JoeW24-Mar-08 10:33
JoeW24-Mar-08 10:33 
GeneralGreat work! Pin
jmiller427-Nov-07 4:53
jmiller427-Nov-07 4:53 
GeneralSmall addition - add sorting Pin
darcraver22-Jun-07 11:51
darcraver22-Jun-07 11:51 
GeneralVery good work, i'll try to make a remote version Pin
leomicheloni26-Apr-07 5:58
leomicheloni26-Apr-07 5:58 
GeneralIn order to run this application do we need to have VSS installed in our machine Pin
Akhilec12-Apr-07 1:00
Akhilec12-Apr-07 1:00 
GeneralViewing History Pin
eidnolb86-Mar-07 3:38
eidnolb86-Mar-07 3:38 
QuestionFinding sourcesafetypelib help Pin
Mushtaque Nizamani12-Feb-07 2:10
Mushtaque Nizamani12-Feb-07 2:10 
GeneralChecking out by right-clicking a file Pin
Veener11-Jan-07 10:02
Veener11-Jan-07 10:02 
GeneralDid you consider changing your team to allow the multiple check out support in VSS Pin
Matt Adamson26-Sep-06 3:12
Matt Adamson26-Sep-06 3:12 
GeneralRe: Did you consider changing your team to allow the multiple check out support in VSS Pin
H. S. Masud27-Sep-06 21:35
H. S. Masud27-Sep-06 21:35 
GeneralThere are another world outside source safe Pin
dbesoli25-Sep-06 23:42
dbesoli25-Sep-06 23:42 
QuestionVery Good Work and a question Pin
Mushtaque Nizamani20-Sep-06 21:23
Mushtaque Nizamani20-Sep-06 21:23 
AnswerRe: Very Good Work and a question Pin
H. S. Masud20-Sep-06 22:03
H. S. Masud20-Sep-06 22:03 
GeneralNeatly Done! Pin
Shahriar Hyder20-Sep-06 18:53
Shahriar Hyder20-Sep-06 18:53 
GeneralRe: Neatly Done! Pin
H. S. Masud20-Sep-06 20:39
H. S. Masud20-Sep-06 20:39 
GeneralRe: Neatly Done! Pin
schwinbp21-Sep-06 4:27
schwinbp21-Sep-06 4:27 
GeneralRe: Neatly Done! Pin
pallep25-Sep-06 20:46
pallep25-Sep-06 20:46 
GeneralRe: Neatly Done! Pin
H. S. Masud26-Sep-06 1:59
H. S. Masud26-Sep-06 1:59 
GeneralNice work. Pin
zhlee20-Sep-06 11:10
zhlee20-Sep-06 11:10 
AnswerRe: Nice work. Pin
H. S. Masud20-Sep-06 18:41
H. S. Masud20-Sep-06 18:41 

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

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