NAVmoble - the pocket-sized ERP
Optimized for Microsoft Dynamics NAV and Windows Mobile powered devices

Tuesday, October 17, 2006

Vista Sidebar Gadget for Cruise Control.NET

I am a Cruise Control.NET fan. I'm also playing with Windows Vista for quite some time and decided to create a Sidebar Gadget for Windows Vista to monitor my Cruise Control.NET enabled projects Although I've played with Sidebar gadgets before (see this post) this time is even more challenging as I'm not a Javascript geek. In general my goal was to duplicate the functionality provided by the CCTry. The CCTry application is intended to give developers to monitor the status of the projects registered into CC.NET. It also provides additional functionality ,which is out of the scope of my gadget. Actually the main reason to create this gadget was to play a little with a stuff like async web services invocation and xml parsing in he Sidebar gadget environment. So, first of all I had to decide what kind of communication scheme to use between my gadget and CC.NET Service. The CC.NET Service is running on machine other than my Vista box. As far as I know there are 2 basic communication options within the Sidebar Gadgets:
1. Making HTTP requests via XmlHttpRequest object
2. Using ActiveX objects
I decided to use the 1st option and then google provided me with this useful post about using CCTry managed API to communicate with the CC.NET service through .NET Remoting. I then quickly came with the following scheme:

The white squares are the components that I had to implement:
1. CC.NET Sidebar Gadget
2. CC.NET Xml Web Service
I've opened VS2005 and quickly implemented the CC.NET Web Service. I've implemented one method with the following signature:
public string[] GetProjectStatuses()

This method gets all projects and their statuses from the CC.NET Service by using .NET Remoting. It returns a string array (a string per registered project) then. The string contains the name of the project , its status and the CC.NET Dashboard url - all delimited by the | symbol.
My Project 1|Success|http://ccnetserver/ccnet
My Project|Failure|http://ccnetserver/ccnet

That was not quite elegant solution, but it was the shorter dev path :)
I've power up my Vista box then and soon I had my gadget running: The gadget displays a list of projects registered in the CC.NET Service. Green light means that the project is in good health and red means that the projects build is bad:

The gadget provides a settings dialog where the user may provide the CC.NET Web Service Url and time interval to poll the web service.

The CC.NET Gadget(and CC.NET Web Service) source code may be download from here.
Next time I'll blog about the CC.NET Gadget source code...stay tuned

Sidebar Gadget Links:
Vista Sidebar and Gadgets
Windows Sidebar team's blog
Daniel Moth blog


Anonymous said...

Sweet :)

If you don't mind I might pick this up and enhance it a bit -- hopefully exposing some of the more advanced functionality seen in the tray app :)

Mostly because it will be an interesting challenge and it saves me the 20mb or so that the tray tool pinches for the framework :P

Plus... I have developers that are remote to the central build server so yes... really sweet that http can be used ;)

Ruslan Trifonov said...

No problem! Feel free to use it as you wish. You may also post some comments on that topic later if you want.

Armand du Plessis said...

Actually one of the first useful widgets I've seen :)
I tried it on Vista RC2 (haven't gotten around to upgrading to RTM yet) and while the web service works fine the Gadget text just stays on "warming up...". Any pointers?

Ruslan Trifonov said...

Did you tried to enter the url of the web service?
You may enter it from the Gadget Settings.

Armand du Plessis said...

I entered the url, tried on different machine as well. Still just warming up. When I get a chance will download the source and see if I can debug.

Adrian Spear said...

Have you considered the possibility of using .Net Interop for your gadget? You can wrap the .Net type loading in a COM interop assembly callable from your gadget script.

See this article on The Code Project:

You can directly consume CruiseControl .Net object libraries directly within the gadget script and utilise their API to get the full functionality from your gadget.

Ruslan Trifonov said...

This is a very interesting and powerfull approach, indeed.

However, in my implementation you do not have to deploy the Cruise Control .NET client components on every dev machine. You should deploy them on the machine where the Web Service resides , only.

Note that the motivation behind this gadget was to playing a little bit with the Ajax thing. I'm sure there might be even better approaches.

Thanks for the article!