Microsoft Visual Source Safe Client






4.78/5 (28 votes)
Microsoft Visual Source Safe client which can notify of check-ins.
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
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 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.
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.
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.
Show History
Show history will allow the user to filter the history according to the user name, from date, and to date.
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.
System Tray Icon
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.