Click here to Skip to main content
15,879,613 members
Articles / Programming Languages / Visual Basic
Article

Visual SourceSafe Journal Monitor Service

Rate me:
Please Sign up or sign in to vote.
4.94/5 (12 votes)
27 Jan 200412 min read 151.8K   853   59   42
VMS is a windows service developed in .Net that monitors a Microsoft Visual SourceSafe (VSS) database. Customized alerts may be sent based on the defined filters.

Introduction

VMS is a free utility that was written to monitor the actions users perform on a VSS database. This project was created from scratch, but had the inspiration of a free utility written by Doug Schmidt called SSMonitor. You can acquire his utility at the CodeProject web site:

SSMonitor was created as a windows scripting component. The general idea behind his code has been presented here, but everything else was built from scratch.

A message is compiled after changes are detected matching certain criteria that you define. It can then be sent via email, windows messenger, or through a 3rd party service component that you may develop yourself. Several examples have been provided to get you started that define different types of filter criteria. Such examples may provide a way to detect only the changes that occur to a specific project, or detect specific types of changes (such as check in delete, purges, etc.) For those of you who are very determinant about your developers commenting what they have done with each check in, I have setup a filter to send out an email each day summarizing who did not leave comments for particular types of actions (for Sql Server only).

Coding Technologies

  • VB.Net code
  • Windows Service
  • Deployment project (install / uninstall)
  • XML Serialization and Deserialization
  • Configuration sections within application configuration
  • Format Provider and Custom Provider (String formatting)
  • Load 3rd party assemblies through reflection.
  • Typed datasets
  • Threading (limited)
  • Microsoft Instant Messenger API
  • Data adapter (for multiple updates)
  • Streams
  • Embedded Files
  • Regular Expressions
  • Sql Server
  • SMTP mail service
  • Event Logging
  • Windows Registry

Features

  • Monitor a VSS journal file on your own machine, or on a network share (providing your service has permission to access the file)
  • Store results of changes to Sql Server, Xml file, or a custom built data store.
  • Define time zone information for each user, with a default time zone applied to all other undocumented users.
  • Send alerts after a set amount of time, or at a specific time each day.
  • Alerts may be sent through customized services such as SMTP, MS Instant Messenger, or a custom built service handler.
  • Each alert has a filter that can be defined in the configuration file, or reference another file to allow easier management/organization of code.
  • Each alert defines its own users, enabling different alerts to notify a different group of individuals.
  • Each message within the alert is divided into 4 sections. Header, Footer, Item, and Alternate Item. These elements can contain text, or reference external files for easier management of code.
  • Messages use formatted strings to display data.
  • A customized formatter is used to format dates to your preferred time zone. You may use the standard date formatting strings, but append the number of hours to add or subtract from Universal time.
  • Installation program installs program files, registers service, and offers option to create a Sql Server database

Requirements

A VSS client is required along with administrative access in order to instruct it to save a journal file. Anyone using the Sql Server data store will need to have access to a Sql Server database in order to create a table and a stored procedure. VMS has only been tested with Sql Server 2000. You must create a database on your SQL Server before running the setup program. I had also developed this with Microsoft Visual Studio 2003, so the Microsoft .Net Framework 1.1 must be installed on the machine that runs this service.

Installation

Installation is pretty strait forward. In fact, an added project to the solution is a setup/deployment project that will install the files, and even register the service for you. After installation, you will be able to go to your control panel, open administrative tools, and open the services application. You will see an entry for VMS. If you open add/remove programs, you will see that VMS has an entry with its own icon and support information.

One thing the installation does not do is that it does not install the database that caches information. A script file is provided for you to run on your Sql Server to create a table and stored procedure that VMS will use. It is called “Database.SQL” and will be found in the root directory of the source code (and the installation directory after running the setup file).

You will also need to login to the Admin utility provided with VSS and instruct it to save a journal. I commonly set the file to be named journal.txt. Once you have taken care of these important steps, you will need to look at the applications configuration file. C:\Program Files\Lewis Moten\Visual SourceSafe Monitor Service\VssMonitorService.exe.config

Most of the settings are self explanatory along with observing the features of this documentation, but comments are also provided within the configuration file. After the installation, you will need to go to the services application and run your application. You may wish to also set the startup type to automatic so that it starts up when your machine starts – regardless if you have logged in or not.

If you make a change to the VssMonitorService.exe.config file, you must pause or stop the service and start it back up in order for your changes to take effect. If the VSS journal file could not be read, an event will appear in your event log telling you about this problem. Another event will appear when the file is found again. This could be useful for determining when a remote machine containing the file went down and came back up. Other reasons for failing to read the file may be due to permissions.

Permissions

Most problems that many of you will have at first will be due to a lack of permissions. The service installs under the local system account by default. This will get you past a lot of obstacles. However, for those of you who are observing a VSS File over the network, you may need to change the Log On information to a user account that has permission to view that file. Make sure that they also have access to read, create, and modify files within the VMS installation folder. A settings file is created within that folder to remember the last time a file was found, and the time it was last modified.

Why this code came into existence

I’m a weekend warrior. I create tons of small projects. Most will never be heard of again, but some deserve a chance to sing in front of the world. This is one of them. It all started with the curiosity about creating a windows service. A co-worker installed SSMonitor where I worked and thus a reason was developed for my first service. Actually, after it was completed I spent an additional 2 weeks adding more features, cleaning up, and documenting – so I can’t really say it was a weekend project (except for the alpha label).

The other thing that made it enticing is that I’m a big proponent on using regular expressions to parse text (that is not within Xml format). It makes me feel great to have the knowledge to use such a powerful technology. Due to the nature of the VSS Journal format, it was an excellent candidate to express the power of using regular expressions. Although I can get really deep into regular expressions, I have kept them simple in this project and commented each portion well.

A lot of my experience came together into this project and made it even quicker to pump out. Most of the hardships actually came from working with, and converting to/from universal dates, as well as adjusting time zone offsets. The other long and invigorating task was to create this document and document the source code. I hope it was worth it.

Problems Encountered

It appears that clients with VSS databases have control over the dates. It would have been great if VSS used universal dates to begin with along with a standard format. If a fellow developer worked in the east coast of the United States, and another developer on the same project was in the United Kingdom – you would no doubt, wind up with conflicting dates within VSS. You would also have two different formats of dates. Individuals swap months with the day. Due to the nature of how daylight savings time works, this would be the largest problem with dates going out of synch for international users.

I ran into a bug that may seem a bit rare when users name a file in a particular manner. If the filename begins with “Label “(Including a space after that last “l”), then the event of “Label” is assumed. This can be odd if someone deliberately creates a file called “Label .txt” and starts performing actions on it. Each action may register as a Label rather then the correct action.

Developing the service to communicate with the Windows Messenger was tough. It took a little time to determine how to sign on and sign off. Sending a message was hard as well due to lack of documentation. (This method is no longer supported … blah, blah, blah). Well, eventually I was able to determine the correct format of the header to pass along with messages and what the header actually composed of. The hardest part with instant messenger was to be able to sign on, send a message, and sign rite back off in a very short time. I ended up doing some checks to verify each stage of the process and waiting for it through threading (giving up if something didn’t happen).

Another problem was debugging services. It is tricky because you can not instantly jump into the debugger after you compile your code. You need to compile, install, and start the service. Then, with Visual Studio, you need to attach to the running process manually. After you have completed debugging, you will need to stop and uninstall the process before you make new changes. It can be tricky at times – especially if you recompile your code before you uninstall your service. I ended up running amuck in the registry and then rebooting my machine in order to set things back on track.

Towards the end, I had to slap myself silly. I realized that I was so busy working with the problem, that I couldn’t step back and find a simple solution until it was too late to be of much help. I only needed to create a test application to verify that the program worked properly. I referenced all the projects, copied my service into the application, and added a method that would invoke the Start, Stop, Pause, and Continue methods. From there and on, it was easy to debug the service and development time improved.

Performance Issues to workout

The journal file continues to grow over time. I have sped up the program so that it will read only the newer events from the file since the last time it looked at it. This should help the application scale for larger journals. I have not tested this with large journal files, but if performance is a problem, you may need to backup your journal file and delete the existing one for a clean start. The program is limited to journal files that are less then 2 GB in size. The first run at a large journal file may take some time.

Attempts have been made to prevent redundant journal entries from being sent to the data store. However, these attempts do not account for all possible scenarios. It is the responsibility of the data store to determine what items already exist within its cache. A composite key combination to consider would be Date, Path, Version, and Action. Comparing these fields with your existing data should remove the possibility of duplicates.

Using dates provided from VSS isn’t 100% dependable. Using these dates sets your service to have full trust that each client is reporting action times accurately. I had setup an extra field “Logged” within the entry data schema that makes the application accurate when reporting new entries. This can almost be considered as redundant data if all clients report dates accurately.

VSS Shortcomings

I may be wrong, but the VSS server doesn’t actually appear to be a server. It appears to be a bunch of files that each client modifies on its own. It could be compared to someone saying that a network share is an FTP server. The content read from within configuration files tells the client what permissions it has.

In a ray of optimistic hope, it would be great if VSS actually did become a service and took more control over its content. In the world of client-server architecture, the server will NEVER trust the client. There are many checks and balances that must be performed before any action takes place. VSS may perform better if its internal database was actually changed to use an SQL Server database, or another external database for easier reporting. Also, with the benefit of connection to VSS over TCP/IP rather then network connections – it would be quicker to communicate over the Internet or with VPN. Also, if VSS saved its journal in a recognized format, such as Xml along with a DTD – it would be very beneficial for exporting to other systems.

Future Development Ideas

  • Create other Instant Messaging services to send alerts (ICQ, AOL, and Yahoo!)
  • Store data within other data stores (MySQL, Oracle, Access, or even another VSS journal file)
  • Create user interface to adjust settings
  • Monitor journal with a file watcher.

I could go on with ideas, but it is time for me to move on. If you wish, you may make these changes on your own. I have made base types that you may inherit that the program will be able to recognize. Just make sure that you put your DLL’s into the applications “bin” directory.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
If you got this far, you are probably interested in who exactly I am and are eager to pick some knowledge out of my head.

I am a programmer - no doubt. I grew up with an Atari 400 using BASIC and PILOT and saving my programs to a casset tape. Over the years, I would rush to the library looking for books with source code of computer games in them that I could create with basic. After long hours of coding, I would save, then load, and then spend the next few days figuring out where I made a mistake - and even the book for that matter! What I'm trying to say is, you got to learn by doing. Don't give up, and always get help from someone else - wether it be source code, a book, or actually communicating with them on a one-on-one relationship.

I'll admit it - I'm a book worm. I have a shelf full of red books (if you know what I mean), and tons of other shelves of other books. I can't recommend just one, but I have found that Wrox is the best for me. After that, I have O'Reilly and Sams in third.

As far as source code goes, I have my own personal site with source code (and lots of working demos), and other sites that I post code to.

Ok, so we are down to contact info. I have ICQ. If you need the number it is 364308. Pretty low eh? I've been a die hard at this computer stuff for years on end. I even ran my own BBS and was a SysOp on many other BBS's in the Pittsburgh area when the Internet was still known as a toy called "the information super highway".

Ok, I'll close with that and let you go on your way. If you see my code - please vote. If it is bad, put up some feedback letting me know. And if you want to see more to me then just code (I'm an artist too), then just visit my web site.

Comments and Discussions

 
AnswerRe: Can someone suggest a tool for automating the getlatest process Pin
Ashaman17-May-05 7:07
Ashaman17-May-05 7:07 
GeneralMultiple labels with the same name Pin
sheriff77774-Mar-04 21:10
susssheriff77774-Mar-04 21:10 
GeneralRe: Multiple labels with the same name Pin
Mardoek W28-Jun-04 3:01
Mardoek W28-Jun-04 3:01 
GeneralSomekind of error log would be nice Pin
TMS_735-Feb-04 3:04
TMS_735-Feb-04 3:04 
GeneralRe: Somekind of error log would be nice Pin
Lewis Moten5-Feb-04 15:56
Lewis Moten5-Feb-04 15:56 
GeneralRe: Somekind of error log would be nice Pin
TMS_739-Feb-04 0:17
TMS_739-Feb-04 0:17 
GeneralRe: Somekind of error log would be nice Pin
Lewis Moten9-Feb-04 17:04
Lewis Moten9-Feb-04 17:04 
GeneralRe: Somekind of error log would be nice Pin
TMS_739-Feb-04 21:39
TMS_739-Feb-04 21:39 
QuestionHow do you set it up for SQL Server? Pin
Mortman30-Jan-04 8:20
Mortman30-Jan-04 8:20 
AnswerRe: How do you set it up for SQL Server? Pin
Lewis Moten1-Feb-04 14:48
Lewis Moten1-Feb-04 14:48 
GeneralRe: How do you set it up for SQL Server? Pin
Mortman3-Feb-04 10:49
Mortman3-Feb-04 10:49 
GeneralRe: How do you set it up for SQL Server? Pin
Lewis Moten3-Feb-04 15:38
Lewis Moten3-Feb-04 15:38 

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.