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

Sunday, October 29, 2006

More pictures from the DevReach Conference

Martin published pictures from the DevReach conference on his blog!

AJAX and Pocket PC

Having my Vista gadget from my previous posts(1,2), I decided to see if I'll be able to monitor the status of my Cruise Control.NET projects from my Pocket PC.

My Pocket PC is running WM2003 SE and hopefully it turns out to be possible.

PocketIE provides support for Ajax, however in order to run the javascript code from the CC.NET gadget some changes should take place:

  • All invocation to the SideBar Gadget API should be removed. It includes all and System.Gadget.Settings.write statements
  • The XmlHttpRequest instance creation should be done by creating an ActiveX object(See example bellow)
  • PocketIE does not support setInterval , so it may be replaced with setTimeout. It must be called again and again on every successful postback in order to get a similar behavior

The XmlHttpRequest instance may be created with the following code:

xmlHttp = false;
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
catch (error1)
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
catch (error2)

You may download the source code from here

Pocket IE and Ajax 1(IEMobile Team blog)
Pocket IE and Ajax 2(IEMobile Team blog)
IEMobile Team blog

Sunday, October 22, 2006

Vista Sidebar Gadget for Cruise Control.NET - Explained

My previous post was about my Vista Sidebar Gadget for Cruise Control.NET. Today I'll drop few lines about the gadget source code.
As you see on the diagram in the previous post, the gadget is making http requests to a home made xml web service in order to get the status of the projects registered in the CC.NET service. The requests are performed with the help of the XmlHttpRequest object. The javascript code looks like this:

1 xmlHttp = new XMLHttpRequest();
2 var url ="url");
4 xmlHttp.setRequestHeader("Content-Type","text/xml");
5 xmlHttp.setRequestHeader("SOAPAction","");
6 xmlHttp.onreadystatechange=HandleResponse;
7 xmlHttp.send(soapEnvelop);

This sinpset creates a fresh XMLHttpRequest instance and performs the web service invocation.

  • Line 2 reads the Url of the web service from the gadget's setting
  • Line 3 prepares the request. The "true" argument specifies that it will be an async request.
  • Line 6 passes a function to the XMLHttpRequest instance , which will handle the response from the web service, when available - that's because we are making an async request.
  • Lines 4 and 5 prepare Http headers to send with the request
  • and finally Line 7 sends the envelop

One may ask the following questions:

  • How do you know what the lines 3,4, and 5 should looks like?
  • What the content of the soapEnvelop variable should be?
In order to get the answers of these two questions you should browse the url of the xml web service(hopefully it is a .NET web service) .You will see the list of the methods(actions) provided by this web service:

Clicking the GetProjectStatuses method will bring the following screen:

This screen actually shows you what the 3,4 and 5th lines should contain. The first gray area shows what request should be sent. You just may copy the xml content provided and paste it in your source code. This is the content that should be placed in the soapEnvelop variable.

The second gray area shows what the response from the service looks like. It is obvious from the picture, that we will get a list of strings. So, we may use an Xml parser to navigate to the GetProjectsStatusesResult tag to extract its content.This is what the HandleResponse function does:

1 function HandleResponse()
2 var xmldoc = xmlHttp.responseXML;
3 var responseNode =
4 for (var iNode = 0;iNode <
responseNode.childNodes.length; iNode++){
5 var projectContent=
6 var tokens = projectContent.split('|');
8 var imgTag=" ";
9 if(tokens[1]=="Success"){
10 imgTag=imgSuccess;
11 }else{
12 imgTag=imgFailure;
13 }
14 ...
15 }

  • Line 1 gets the xml response from the web service
  • Line 3 locates the GetProjectStatusesResult tag.
  • Lines 4 through 13 iterates over the GetProjectStatusesResult tag children. Every children here contains the status of a particular CC.NET project

You may download the gadget's source code from here

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

Thursday, October 12, 2006

DevReach conference just finished

The first DevReach conference just finished and I'm back to my daily (and nightly activities :) )
I really enjoyed this 2 days . I liked the drinks, I liked the food - what more you may want from a dev conference :)
The content was pretty cool. Although, I could bear sessions that dig into deeper tech. matters , I may say the content was good enough. The interesting part was the Q&A panel first day, which turns out to be a live .NET Rocks!.
There was I great foreign speakers and few local guys as well. I really enjoyed all the sessions of Ted Neward - unfortunately he had 3 sessions only. I also liked the cool and easy session of Carl Franklin about RSS, Podcasting, and Syndication - I've learn some simple and valuable tips that I had no time to learn before. And hey , he had I great trick with playing cards at the end of the session and I'm really waiting to see if Carl will publish the code for it! :)
I liked the session of Hirsto Deshev about Atlas. I think the session was quite hard for most of the audience , but it was just what I needed.

Check out this interesting comments from Carl Franklin
See this pictures by Julie Lerman
Check out some comments and pictures by Sahil Malik

Sunday, October 01, 2006

Rubby On Rails: WEBrick may fail to start if ActiveSync Connection Manager is running

I decided to spent some time playing with Ruby On Rails on my Windows XP box. I've downloaded the InstantRails and found some good starting points to create my first app. I found this great webcast from Matt Griffith. Everything worked fine until I had to start WEBrck and got an error message saying:

WARN TCPServer Error: Bad file descriptor - bind(2)
D:/Ruby/lib/ruby/1.8/webrick/utils.rb:73:in `initialize': Bad file descriptor -
bind(2) (Errno::EBADF)

Google said this error message may appear if WEBrick can't open port 3000.
Netstat showed that port 3000 is opened by process called "wcescomm.exe" and that is the process name of the Microsoft Active Sync Connection Manager.
I've just synced my PocketPC few minutes ago and the device was still in its cradle. I removed it from the cradle and tried again to start WEBrick ... I was so pleased to get it running.

InstantRails: one-stop Rails runtime solution containing Ruby, Rails, Apache, and MySQL
Getting started with InstantRails by Matt Griffith
Programming Ruby book
RadRails Ruby on Rails editor