Project Nimbus
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
543
On Slideshare
538
From Embeds
5
Number of Embeds
1

Actions

Shares
Downloads
1
Comments
0
Likes
0

Embeds 5

http://www.limchenglei.com 5

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Lim Cheng Lei Microsoft Student Partners SingaporeData and Services Marketplace for Innovators
  • 2. What is Project Nimbus?
  • 3. Datasets Available Cinema Online Project Hungry Go Where Nimbus Land Transport Authority National Library Board National Environment Agency Singapore Tourism Board Sing Post Show Near By Urban Redevelopment Authority
  • 4. Behind Project Nimbus Architecture Existing Data Service Deliver to Service in Project End Users Nimbus Easy access to data services
  • 5. Project Nimbus Architecture Applications used by Data services built inExisting Service End Users Project Nimbus (Consumers)
  • 6. Project Nimbus Architecture Data information from Content Providers Web Service – http://api.projectnimbus.org/yourodataservice.svc/
  • 7. Sample Application Architecture Cinema Hungry Online Go Where http://api.projectnimbus.org/ Show yourodataservice.svc/ Near By http://<yourapp>.com
  • 8. Getting Started
  • 9. 3 Steps to Use Get access to Call the Web Start Project Nimbus Service Developing Developing on Project Nimbus
  • 10. Get access to ProjectNimbus Project Nimbus Credentials
  • 11. How do I get access?• Email us: projectnimbus@live.com.sg – Account Key [Request from Project Nimbus] – Unique User ID [Generate your own 32 characters GUID] eg. 00000000000000000000000000000001
  • 12. Call the Web Service Project Nimbus Data Service
  • 13. Querying Data Service • http://api.projectnimbus.org/tool.aspx – http://api.projectnimbus.org/coodataservice.svc/MovieSet – http://api.projectnimbus.org/snbodataservice.svc/ATMSethttp://api.projectnimbus.org/coodataservice.svc/ XML Data of available properties (ODATA Format) $metadata
  • 14. Start Developing Mesh with Project Nimbus
  • 15. Mesh the data servicesInnovate Applications
  • 16. Getting Started with C#
  • 17. Calling the Web Service Ipublic List<MovieEntry> GetMovieFromNimbusCO(){ WebRequest wr = HttpWebRequest.Create("http://api.projectnimbus.org/coodataservice.svc/MovieSet?"); wr.Headers.Add("AccountKey", "YourAccountKeyHere"); wr.Headers.Add("UniqueUserID", Guid.NewGuid().ToString()); wr.Method = "GET"; WebResponse res = wr.GetResponse(); string resStr = new System.IO.StreamReader(res.GetResponseStream()).ReadToEnd(); XNamespace atomNS = "http://www.w3.org/2005/Atom"; XNamespace dNS = "http://schemas.microsoft.com/ado/2007/08/dataservices"; XNamespace mNS = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";
  • 18. Calling the Web Service IIList<MovieEntry> results = (from item in XElement.Parse(resStr).Descendants(atomNS + "entry") let movie = item.Element(atomNS + "content").Element(mNS +"properties") select new MovieEntry() { MovieID = movie.Element(dNS +"MovieID").Value, Name = movie.Element(dNS +"Name").Value, ReleaseDate = movie.Element(dNS + "ReleaseDate").Value, Classification = movie.Element(dNS + "Classification").Value }).ToList(); return results; }
  • 19. What are proxy classes?• Individual class files for each datasets of the data services• Easier for developers to call the datasets from the data services without much effort• Pre-generated proxy classes – Developers do not need to code anything
  • 20. Why should I use proxy classes?• Simplifies coding process• .NET to process all the consummation of data back end• 5 lines of code – Able to select specific data to display• Using LINQ to query data services
  • 21. How can I use it?• ADO.NET Data Services v1.5 CTP2• Add Reference > Browse Tab > C:Program FilesADO.NET Data Services V1.5 CTP2binMicrosoft.Data.Services.Client.dll• Import in the relevant *Proxy.cs class file into your project (For example, SNBProxy.cs)
  • 22. Calling the Web Service I (Using LINQ)protected void Page_Load(object sender, EventArgs e){ SNBModel.SNBEntities snbEntities = new SNBModel.SNBEntities(new Uri("http://api.projectnimbus.org/snbodataservice.svc/")); snbEntities.SendingRequest += ModifyRequest; GridView1.AutoGenerateColumns = true; GridView1.DataSource = snbEntities.ATMSet.ToArray(); GridView1.DataBind();}private static void ModifyRequest(object sender, SendingRequestEventArgs e){ e.Request.Headers.Add("AccountKey", “YourAccountKeyHere"); e.Request.Headers.Add("UniqueUserID", Guid.NewGuid().ToString());}
  • 23. Calling the Web Service II (Using LINQ)protected void Page_Load(object sender, EventArgs e){ SNBModel.SNBEntities snbEntities = new SNBModel.SNBEntities(new Uri("http://api.projectnimbus.org/snbodataservice.svc/")); snbEntities.SendingRequest += ModifyRequest; GridView1.AutoGenerateColumns = true; GridView1.DataSource = snbEntities.ATMSet.ToArray(); GridView1.DataSource = (from c in snbEntities.ATMSet select new { c.Name, c.Latitude, c.Longitude }).ToArray(); GridView1.DataBind();}
  • 24. Getting Started with Silverlight
  • 25. Why Silverlight?
  • 26. What do I need?• ADO.NET Data Services for Silverlight 3 CTP 3• Add Reference > Browse Tab > C:Program FilesADO.NET Data Services for Silverlight 3 CTP 3System.Data.Services.Client.dll
  • 27. Calling the Web Service IDataServiceCollection<SNBModel.ATM> atms;public MainPage(){ InitializeComponent(); SNBModel.SNBEntities snbEntities = new SNBModel.SNBEntities (new Uri("http://api.projectnimbus.org/snbodataservice.svc/")); snbEntities.SendingRequest += ModifyRequest; DataServiceQuery<SNBModel.ATM> query = snbEntities.ATMSet; try { // Begin the query execution. query.BeginExecute(OnATMSQueryComplete, query); }
  • 28. Calling the Web Service IIprivate void OnATMSQueryComplete(IAsyncResult result){ // Use the Dispatcher to ensure that the asynchronous call returns in the correct thread. Dispatcher.BeginInvoke(() => { // Get the original query back from the result. DataServiceQuery<SNBModel.ATM> query = result.AsyncState as DataServiceQuery<SNBModel.ATM>; try { List<SNBModel.ATM> returnedATMs = new List<SNBModel.ATM>(); …
  • 29. Calling the Web Service III foreach (var atm in (query.EndExecute(result))) { returnedATMs.Add(atm); } if (returnedATMs != null) { DataGrid1.ItemsSource = returnedATMs; DataGrid1.DataContext = returnedATMs; DataGrid1.UpdateLayout(); } } catch(DataServiceQueryException) { } });}
  • 30. Getting Started with Java
  • 31. Parsing the Atom Feedpublic static String getStringBetween(String src, String start, String end) { StringBuilder sb = new StringBuilder(); int startIdx = src.indexOf(start) + start.length(); int endIdx = src.indexOf(end); while(startIdx < endIdx){ sb.append(“” + String.valueOf(src.charAt(startIdx))); startIdx++; } return sb.toString();}
  • 32. Calling the Web Service Ipublic ArrayList<ATM> getATMS() { atmList = new ArrayList<ATM>(); try { URL _url = new URL(“http://api.projectnimbus.org/snbodataservice.svc/ATMSet?”); URLConnection _urlConn = _url.openConnection(); _urlConn.setRequestProperty(“accept”, “*/*”); _urlConn.addRequestProperty(“AccountKey”, “YourAccountKeyHere”); _urlConn.addRequestProperty(“UniqueUserID”, “YourUniqueUserID”); BufferedReader br = new BufferedReader(new InputStreamReader(_urlConn.getInputStream())); …
  • 33. Calling the Web Service II String line = null; StringBuilder strBuilder = new StringBuilder(); while ((line = br.readLine()) != null) { strBuilder.append(line); System.out.println(line); }}
  • 34. Calling the Web Service III String[] IProperties = strBuilder.toString().split("<m:properties>"); for (String str : IProperties) { ATM atm = new ATM(); atm.setName(Utils.getStringBetween(str, “<d:Name>”, “</d:Name>”)); atm.setRoad(Utils.getStringBetween(str, “<d:Road>”, “</d:Road>”)); atm.setPostal(Utils.getStringBetween(str, “<d:Postal>”, “</d:Postal>”)); atmList.add(atm); } } catch(...) { } return atmList;}
  • 35. www.projectnimbus.org
  • 36. innovativesingapore.comtwitter.com/innovativesg