Silverlight from the Client to the Cloud: Part 1

This post is part 1 in one of several series.  The series gives you a glimpse into some of the experiences and capabilities available with Silverlight and gives pointers on how to get started with them.

From March 30th to April 22nd this year, the Developer & Platform Evangelism Team at Microsoft Canada delivered a combination of all-day From Client to the the Cloud tour  and evening Community Connection Series events in 19+ cities across Canada as part of EnergizeIT 2010.

The EnergizeIT events give an idea of what’s possible.  To compliment those events, the TechDays events by Microsoft Canada coming up again this year in the Autumn season, give attendees the opportunity to learn more about how they can use Microsoft products and technologies.  I’ll be speaking there again this year on topics that may include Silverlight, Azure, OData and Windows Phone 7. 

At each of the recent EnergizeIT events, a 2.5 hour demo showed the tip of the iceberg in terms of what’s possible with some of the latest Microsoft tools and technologies from the viewpoint of developers and IT professionals.  They covered technologies and products included .NET 4.0, Visual Studio 2010 (including Lab Manager), Hyper-V, Windows Mobile, Office 2010, SharePoint 2010, PowerShell, System Center, the Windows Azure Platform and Silverlight.

The demo covered the user, developer and IT pro experience for a new car insurance business.  It showed how a consumer could use software on a Windows Mobile device to capture critical information when a collision occurs as well as how they can review and connect with the insurance company back at home.  It continued to show the construction of the application on the backend, how the back office workflow can operate, and how the application can be deployed to the cloud to take advantage of various benefits.

About two months before EnergizeIT, the DPE team contacted me to produce the Silverlight portion of the demo.  I had the pleasure of working closely with Christian Beauclair and Rick Claus to integrate the Silverlight application into the demo experience.

The user experience starts when they use their Windows Mobile device to capture collision incident information and submit a claim to the insurance company which is stored it in a SQL Server database via WCF Web Services and ADO.NET Entity Framework.  You can read about the mobile application portion in Mark Artega’s blog post

The Silverlight experience begins when the user gets home and follows up with the insurance company on their home computer.

First the user logs into the application…

20100514 login 

To reflect the ‘electric energy’ style of the the Energize ‘brand’ and the logo, the UI reveals areas using a specific ‘energy bar’ animation.  This grows from a spot…

20100514 reveal 1

…to the full width of the element to be revealed…

20100514 reveal 2

… and ‘materializes’ the element as the energy bar sweeps down over the area…

20100514 reveal 3

… after which the energy bar then shrinks until it disappears.  We joked about putting a ‘vudgzzz’ sound with this, but the demo didn’t have sound up. 

20100514 reveal 4

The Silverlight application uses ADO.NET Data Services in Silverlight 3 (now WCF Data Service in Silverlight 4 including OData support), to pull down a series of connected entities including a customer record, policies, claims, related employees, pictures, etc.  You can see how the sections of this application UI could lend themselves to display on Windows Phone 7.  The policy type icons are XAML resources bulit into User Controls, built from vectors allowing for a great scaling experience.  Unfortunately the release of Silverlight 4 was too close to the tour launch for us to use Silverlight 4 features like global implied styling.

20100514 home

When the user select the Claim activity, an animation storyboard acts on the UI to fade it and tilt it away using the Perspective 3D capabilities in Silverlight 3…

20100514 fade back

… and the claim details are revealed.  This includes binary image data transfered from the backend database.  The geospatial data in the claim is used with the Bing Maps Silverlight control to show the location of the collision on a map (with full zoom and pan support aloing with road and aerial views).

20100514 claim

It would then be possible to store updated information back to the SQL Server database via the WCF Data Service wrapping around the ADO.NET Entity framework model wrapping the database.

The asynchronous nature of all network calling libraries in Silverlight ensures that the user interface does not freeze up when the application is talking to services in the cloud.

The demo goes on to demonstrate a chat session between the user and an insurance adjuster which results in an appointment being placed in the users pending activities list.

This demo application scratches the surface of what’s possible.  Features like mic/webcam capture, WCF RIA Services, Templating, Deep Zoom, DRM, Streaming A/V Support, Printing, Out-of-browser execution, etc. really empower developers to take Silverlight to the max.

In upcoming series posts, I’ll give you pointers on the Silverlight experiences and capabilities of this application and the technologies it uses.

Advertisement

Quick Tip: Setting up OData Support In Silverlight 3

So the shiny new Visual Studio 2010 released yesterday and the final Silverlight 4 releases in 2 days.

What if you are still using Visual Studio 2008 and Silverlight 3 and you want to consume  all the latest OData goodness?

Background on OData

You know what OData is right?

Well first there was ADO.NET Data Services which provides production and consumption of data via a RESTful architecture using HTTP verbs to perform CRUD-like operations.  Client ‘consumer’ and server ‘producer’ classes where included in .NET 3.5 SP1 and client classes where included in Silverlight 3, under System.Data.Services.Client in both cases.

OData at http://odata.org is the evolution of that in the form of a full-on open protocol standard that Microsoft has ‘put out there’ for querying and updating data based on extensions to AtomPub.  Products such as SQL Azure, SharePoint 2010, SQL Server 2008 R2 Reporting Services and Windows Azure Table Storage will expose OData-accessible data and there a growing number of SDKs available on both ends of the communication channel.

For .NET 4.0, ADO.NET Data Services evolves into WCF Data Services (built on WCF) and the associated classes support the OData protocol.  Silverlight 4 will also have WCF Data Services supporting OData.

For .NET 3.5 SP1, the Data Services Update for .NET 3.5 SP1 was made available as a full release.  For Silverlight 3, only a CTP release is available – the ADO.NET Data Services for Silverlight 3 Update CTP3 (eat your heart out long-name marketing folks).

I installed VS2010 yesterday which installed the SL3 toolset (given that SL4 tools don’t come until this Thursday).  I thought it would be good to explain a few things for people that are still using Silverlight 3.

To do anything, you need some OData-accessible data.  Right now, you can go to the Netflix public catalog at http://odata.netflix.com/catalog and just start exploring the data by tinkering with the URL, following the examples at http://www.odata.org/developers/protocols/uri-conventions

OData repositories appear to have a version of 2 and cannot be accessed properly from “V1” ADO.NET Services Clients – you need the WCF Services (OData-compatible) client.

Getting OData Client support in your Silverlight 3 application in VS2008

So for those using Silverlight 3 in VS2008 you can give OData a fairly solid go by downloading that CTP.

To use the update OData friendly libraries, you need to:

  • Extract the System.Data.Services.Client.dll file to somewhere you remember.
  • Add System.Data.Services.Client as a normal reference to your application.
  • Go to the project properties, select the References tab, go into Reference Paths, add the directory that you put your extracted class in to.  As you come out of there, you should see your new path listed for System.Data.Services.Client.

You can now write OData-friendly client code for Silverlight 3 in VS 2008.

Using DataServiceCollection

One of the great new classes is DataServiceCollection.  It enables fully bound updateable observable collection behaviour so you can bind something like a DataGrid to an OData service (with it’s CRUD-like operations).  Think about that 🙂

Using DataServiceCollection requires that the objects you pass in, support INotifyPropertyChanged interface. 

In a Silverilght 3 app in VS2008 (and even VS2010), the Add Service Reference tool (which apparently runs DataSvcUtil.exe from the V3 framework) does not support adding this when it creates the service client proxy.

The .NET 4 version of this tool does do this work for you, so you may want to installed the 4.0 framework and use it like this to get fully-functional binding classes you can use with DataServiceCollection.

%windir%\Microsoft.NET\Framework\v4.0.30319\DataSvcUtil.exe /dataservicecollection /version:2.0 /language:CSharp /out:myproxyclass.vb /uri:http://odata
.netflix.com/catalog

Voila…

 odata in silverlight 3