February 7, 2009

Surround SCM Web Part

Surround SCM

Applies to Surround SCM 2009

This is an example of how you could use the data accessible from the Surround SCM database to display information on your company's intranet.
For this example we are using Microsoft Sharepoint, but in theory you could use any web technology that allows you to query the database and has similar controls, namely the tree view controls and the data grid view control. [toc]

About the Web Part

The web part allows you to browse your Surround SCM branches and select a specific repository within a selected branch. When the repository is selected, the web part displays the history for the files that belong to the selected repository in the selected branch. The history events are sorted by date, showing the latest events first.
Figure 1 - Surround SCM web part
The web part was developed using Visual Studio 2005 and it is written in C#. A lot of the code used is very similar to the one I used in the Applying Concepts - MS Project Add-in Toolbar example. The web part uses the Sharepoint SDK to access Sharepoint controls, namely the SPGridView and SPTreeView controls. The web part was tested using SharePoint 2007 on a Windows 2003 server running SQL Server 2005.

Deploying the web part

If you are interested in deploying this web part, I have made the CAB file available for download. There are also some basic instructions below. NOTE: Consult with your sharepoint documentation and/or sharepoint administrator on how to deploy cab files before doing anything.

Download

You can download the CAB file from here. Unzip the file to obtain the CAB file.

Deployment

The following is meant to be an overview of how to deploy the web part. Please consult with your sharepoint administrator on the best approach to deploy the web part in your environment. Use the Stsadm.exe tool to deploy the .cab file provided. Stsadm.exe is a command-line tool that an Administrator can use to manage a Windows SharePoint Services computer. For more information about a specific Stsadm.exe command-line option, type the following line at a command prompt: stsadm –help option Also, visit the following page on the MSDN web site: http://msdn.microsoft.com/en-us/library/ms916839.aspx Both are great resources for learning more about this tool. To install the web part, run the following command:
stsadm.exe -o addwppack -force -filename <path to CAB file>
This adds the DLL file to the bin directory in the directory associated with the web site’s virtual directory and also adds this to the list of Safe Controls.

Adding the Web Part

To add the web part, ensure that you have the proper permissions in Share Point to do this. Select Site Actions > Site Settings > Modify All Site Settings. On the Site Settings page, under Galleries, select Web Parts. This opens the Web Part Gallery page. Click on the New button to add the web part. This opens the Web Part Gallery: New Web Parts page. Look for a web part named SeapineWebParts.SCMWebPart and place a check next to it. Click on the Populate Gallery button to finish. The web part is now available from the home gallery to be selected and added to a specific page.

Configuring the Web Part

The web part queries the SQL Server that houses the Surround SCM database. The connection parameters must be configured for the Web Part to work. Once the web part has been added to a page, select Modify Shared Web Part from the dropdown options menu. The SCMWebPart window opens, as shown on figure 2 below.
Figure 2 - SCMWebPart Connection Settings
The following parameters are required: Data Source – Enter the host name of the SQL Server User – Enter the username to use to connect to the SQL Server. The user only needs to be able to query the server. The safest approach is to use a user that does not have permissions to modify the database. Password – Enter the password for the user above. The password will be visible in clear text. Another reason why you should use a user that can only query the database. Database – Enter the name of the database where you store the Surround SCM mainlines.

Known Issues/Gotchas

The following issues have been identified:
  • In order to use the Sharepoint web controls, I had to set the sharepoint server to "Full trust" mode. I believe that this can also be done for a specific web part or site, but I am not sure. Refer to the sharepoint documentation for this.
  • Whenever you click on anything that calls an event, the entire page is refreshed.
  • When you select a node in any of the trees, the entire page is refreshed and the node you selected is no longer selected. I did not find a way to re-select the node after the refresh, so that is why I added the labels at the top of the tree view controls to let us know which is the current branch and repository.

Enhancements

If I were to develop this for a customer, I would consider adding the following enhancements.
  • Paging: Allows you to only display a set number of records per page in the grid view.
  • Sorting: Allow you to sort by any column in the grid view.
  • Filters: Allow you to filter by user, event, file, etc...