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).
- 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)
- Embedded Files
- Regular Expressions
- Sql Server
- SMTP mail service
- Event Logging
- Windows Registry
- 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
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 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
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.
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.
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.
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.