One of the coolest benefits of working for Google is that all employees get to spend 20% of their time on personal R&D projects – this helps keep the company innovative and keep the competitive edge. Conchango doesn’t offer 1 day a week but we do have the notions of “Communities”. We set aside 1 day every 6 weeks where the entire company gathers, generally in the London office, for a “Community Day”.
The company is split into two main groups – technical and business; technical encompasses all developers (.NET & J2EE), business intelligence and infrastructure folks whereas business contains all business analysts, project managers, sales and creative folks (both technical and business people are certified Scrum Masters). Communities were created as a means to allow special interest groups to get together and facilitate learning, R&D, internal projects and team bonding. We have numerous communities covering every aspect of our business: Agile, .NET Development, Mobility, User Experience, SQL Server, BizTalk, Infrastructure, Quality Assurance, Application Architecture, Collaboration, Security and Project Management – to name a few.
A “Community Day” is split into several “Community Sessions”; a session can contain anything from a technical demo, round table discussion, brainstorming, Q&A, briefings (such as experiences on Agile projects or a technology that will affect all sectors, such as Vista) or a talk by an external guest speaker (we’ve had people like Donald Farmer the Group Program Manager at Microsoft for SQL Server 2005 Integration Services and Microsoft Development Evangelist Marcus Perryman).
After coming back from PDC 2005 I decided to do a presentation to the .NET Development community about some of great new technologies that were announced. I wasn’t brave enough to do a Don Box style demo from scratch (I’d experienced numerous “glitches” with the beta code that had been shipped as part of “the goods”), so I decided to try and create a pre-canned tech demo that would demonstrate the power of CodeSmith, MSBuild, Monad and Windows Workflow.
The demo is based around the notion of a Vehicle Congestion Charging System, i.e. the one currently in operation in Central London – for those of you who are outside the UK and unaware – to drive within Central London at peak times you have to pay a Congestion Charge - £8 per day – there are thousands of CCTV cameras monitoring the roads which link into an Automatic Number Plate Recognition system which reads a Vehicle Registration Number (VRN) and check them against a database of vehicles that have paid for the day. If you haven’t paid by midnight you are automatically fined £100. I’ve also added the notion of “suspect vehicles” i.e. vehicles that are flagged as stolen by the Police (I've added this so I can use a Parallel Activity, thus we can check to see if the vehicle has paid the congestion change AND is stolen).
The very simple logical architecture I came up with is illustrated below:
Because I don’t have time to write an entire Optical Character Recognition (OCR) application that can analyse a real time video feed (I know - shame on me) I decided to mimic the behaviour in a WinForm application that “reads” a list of VRNs from a feed (as an OCR application would recognise VRN’s from a video feed). The feed is simply a serialized collection of vehicles (which have a single property - RegistrationNumber) which are randomly generated by the build process, using CodeSmith and Monad.
Once the VRN has been “recognised” the Windows Workflow Runtime is started and the VRN is passed into a simple sequential workflow:
The logic in the workflow is quite simple; firstly the VRN is extracted from the workflow parameters collection, next there are two logic branches that run in parallel – the left hand branch determines if the vehicle has paid the congestion charge and the right hand branch determines if the vehicle is suspect. If a vehicle hasn’t paid the charge an external payment web service is invoked and the vehicles registration details are passed in and in turn persisted to a file. If the vehicle is "suspect", an external security services web services is invoked and the vehicles registration details are passed in and persisted to a file.
The workflow also prints out the status of the current vehicle to the debug output window:
CodeSmith and Monad are used as part of the build process; CodeSmith is used to generate n Vehicle Registration Numbers (where n is specified in the C:\Projects\Conchango\CommunityDay\Build\CodeGeneration\Properties.xml file – FYI the demo must be unzipped to C:\Projects\Conchango) which is then saved as C:\Projects\Conchango\CommunityDay\DataSources\Conchango.CongestionCharge.CommonTypes.CameraFeed.xml.
The custom Monad cmdlet parses the CameraFeed.xml file and randomly decides whether a vehicle has or hasn’t paid the congestion charge and if that vehicle is also suspect; it generates two new files C:\Projects\Conchango\CommunityDay\DataSources\Conchango.CongestionCharge.CommonTypes.PaidVehicles.xml and C:\Projects\Conchango\CommunityDay\DataSources\Conchango.CongestionCharge.CommonTypes.SuspectVehicles.xml which are used as the "Suspect Vehicles" and "Paid Vehicles" databases as shown on the bottom left of the logical architecture diagram above.
The demo solution is structured in the following way:
C:\PROJECTS\CONCHANGO\COMMUNITYDAY
├───Build
│ ├───CodeGeneration – contains the CodeSmith template for generating registration numbers
│ ├───MonadScripts – contains the monad script which parses the CameraFeed xml file
│ ├───MonadShell – contains the generated Monad Shell
│ └───OutputArtefacts – contains common dlls generated by the build process
├───DataSources – contains the camerafeed, unpaid vehicles list, suspect vehicles list
├───Projects
│ ├───Conchango.CongestionCharge.CCTVCameraHost – this is the start up project – winforms app which mimics the cctv camera
│ ├───Conchango.CongestionCharge.CommonTypes – common vehicle types used throughout the project
│ ├───Conchango.CongestionCharge.Monad.DataSourceConfig – Monad cmdlet for generating the datasources
│ ├───Conchango.CongestionCharge.Providers – Helper classes for datasources and workflow
│ ├───Conchango.CongestionCharge.SuspectVehicleService – external security services web service – called by the workflow
│ ├───Conchango.CongestionCharge.UnpaidVehicleService – external payment web service – called by the workflow
│ └───Conchango.CongestionCharge.Workflow – contains the WWF sequential workflow and associated code
└───WebServiceDataSources – contains feeds generated by the external payment and security web services
Once you have unzipped the demo (and have installed all the prerequisites), the "Build" folder contains four batch files which will invoke the MSBuild task. For the initial build you should use "BuildAll.bat" as this will run the complete build process and generate all the required datasources; the other batch files just run the individual steps - these are useful for debugging and investigating what is going on.
Next open up the solution and start debugging (you'll need this so that the web services are hosted in the ASP.NET Development Server) - the CCTV Camera Host WinForms application should be the start-up application (if not, set it to be) - once the form has loaded click the "Start Workflow" button to start. One the application has finished parsing the 1000 VRN (CodeSmith generated 1000 by default - you can reduce this number by editing the properties.xml file mentioned earlier) check the WebServiceDataSources directory - there should now be 2 new files - Conchango.CongestionCharge.CommonTypes.SuspectVehicles.xml and Conchango.CongestionCharge.CommonTypes.UnpaidVehicles.xml which list all the discovered suspect and unpaid vehicles.
You can download the demo from my Project Distributor workspace.