290 likes | 439 Views
Creare applicazioni Windows Store data-centric con C# e XAML. Ken Casada Technical Evangelist, Microsoft Switzerland kcasada@microsoft.com. Line of Business apps. control density data visualization data analysis CRUD for the enterprise business logic n-tier
E N D
Creare applicazioni Windows Store data-centric con C# e XAML Ken Casada Technical Evangelist, Microsoft Switzerland kcasada@microsoft.com
Line of Business apps control density data visualization data analysis CRUD for the enterprise business logicn-tier MVVM test-driven development data driven domain specific existing patterns & frameworks for the enterprise
Demo Summary Working with services to access data • No direct communication with server-side DB • Communication is done asynchrounous • only Task-based methods are available (no blocking calls) • No XML config file is being created Configuration done in code use the ConfigureEndpoint partial method Your app needs to adapt in order to bring the best possible experience • XAML Controls are designed for touch • Apps on a table device can resize an re-orient
Services Windows Store apps supports all kinds of services • ASMX • WCF • REST (JSON/XML) • RSS • oData services • WCF RIA Services support
WCF Which Bindings are supported? • BasicHttpBinding • NetTcpBinding • NetHttpBinding • CustomBinding • WSHttpBinding Documentation: Accessing WCF Services with a Windows Store client app
WCF and Security Securing the communication… • Authentication WinRT supports sending credentials In case my service requires credentials (server-side code sample) BasicHttpBindingbasicBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly); //Usingdomaincredentials basicBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; the generated proxy class will reflect this (have a look at Reference.cs) the default domain credentials will be provided to the service by default (no code required by the developer!!) • Use HTTPS in order to encrypt communication!!!!
REST services Using HttpClient object • It’s an object for sending HTTP Requests / for accessing content from an HTTP Server • Works with async • Implements HTTP VERBS: Get(Async), Put(Async), Post(Async), Delete(Async) RESTful Parse the response (XML/JSON) • XML • Linq to XML • xmlReader/xmlWriter • xmlSerializer • JSON • Use Objects (like JsonObject) and methods available within namespace Windows.Data.Json • DataContractJsonSerializer
HttpClient and Security In case authentication is required… • WinRTsupports sending default credentials (domain credentials) HttpClientHandlerhandler = newHttpClientHandler(); handler.UseDefaultCredentials= true; HttpClienthttpclient = newHttpClient(handler); • WinRT supports sending custom credentials HttpClientHandlerhandler = newHttpClientHandler(); handler.Credentials= newNetworkCredential("username", "pw", "domain");HttpClienthttpclient = newHttpClient(handler); • Use HTTPS in order to encrypt communication!!!!
Collectingusercredentials CredentialPicker and CredentialPickerOptions CredentialPickerOptionscredentialPickerOptions = newCredentialPickerOptions(); credentialPickerOptions.CredentialSaveOption= CredentialSaveOption.Selected; credentialPickerOptions.CallerSavesCredential= false; credentialPickerOptions.AlwaysDisplayDialog= true; credentialPickerOptions.AuthenticationProtocol= AuthenticationProtocol.Basic ; credentialPickerOptions.TargetName= "myTargetComputer"; credentialPickerOptions.Message= "Please enter your credentials"; CredentialPickerResultscredPickerResults = awaitCredentialPicker.PickAsync(credentialPickerOptions); CredentialPickerSample: http://code.msdn.microsoft.com/windowsapps/Credential-picker-sample-30fcba2e Also have a look at the CredentialLockerSample!!! for storing user credentials!!! (http://code.msdn.microsoft.com/windowsapps/PasswordVault-f01be74a)
oData Services / WCF Data Services Builds on top of HTTP and REST Consuming oData Services • Download and Install Odata Client Tools for Windows Store appshttp://msdn.microsoft.com/en-us/jj658961 • Support for Add Service Referencewithin Visual Studio 2012
Enterprise Authentication capability To beusedonlywhenyourapprequiresprogrammaticaccess!!!
Gettingaccesstodata… Remote database vs Local Database • Relational databases should be behind a service working with services is preferred in most cases! • Local databases for offline or occasionally connected systems no out-of-the-box database built into WinRT (no SQLCE support) the only option you have is SQLite (using SQLite in Windows Store apps) the requirements can be satisfied using the Application Data API!!!!! Windows.Storage.ApplicationData.Current Tip: https://metrostoragehelper.codeplex.com/ (helper for reading/writing/deleting structured data in Isolated Storage)
Background Transfers Why? • Only 1 single application can run at a time • Can be annoying if you want to implement specific scenario (download/upload of a file, …) How? • Managed through separate process: BackgroundTransferHost.exe Keeps running in the background, also when your app get suspended • Have a look at the BackgroundTransfer API: • BackgroundDownloaderobject • BackgroundUploader object • Documentation / Sample
Background Tasks Lock screen triggers (AC or battery power) • UserPresent, UserAway, TimeTrigger System triggers (AC power, non-lock screen) • InternetAvailable, NetworkStateChange for connectivity, … Maintenance triggers (AC power, non-lock screen) • Run periodically on AC power All taks subject to CPU and networking activity quotas Being productive in the background
In-Box Controls for Windows 8 Apps Button Grid View Text Box Clear Button Spell Checking Checkbox Radio Button Progress Ring Progress Bar Hyperlink Combo Box Password Reveal Button List View Semantic Zoom Context Menu Flyout Rating Radio Button Scroll Bar Flip View List Box Toggle Switch Tooltip Panning Indicator App Bar
Third Party Controls Vendors ComponentOne • http://apps.microsoft.com/webpdp/app/23b1c950-b54c-4dbd-95d0-db75438cd57f DevExpress • http://apps.microsoft.com/webpdp/app/519d8870-6661-4bd9-9e41-d395c6389b47 Telerik • http://apps.microsoft.com/webpdp/app/7cdb9bc0-e3a7-47b5-b6d6-658d88d4125d Mindscape • http://apps.microsoft.com/webpdp/app/c68cfba7-a24a-4ac9-86c3-be10167e8b1d Perpetuum • http://www.perpetuumsoft.com/Windows8-UI-Controls.aspx Syncfusion • https://www.syncfusion.com/products/winrt?src=winrtxamltoolkit OhZee • http://apps.microsoft.com/webpdp/app/34dcb5b8-b54f-4a1b-a79f-8aaa228359c0 Actipro • http://apps.microsoft.com/webpdp/app/a36f2163-4d44-4ed9-b19f-d1fe1007c3c6
Demo: Chart control http://modernuitoolkit.codeplex.com/
App deployment Consumer B2C LOB ISV Custom LOB Examples Distribution Windows Store Windows Store Windows Store or Side-loaded Side-loaded Consumer Business Used by
Sideloadingstepbystep The app must be signed with an enterprise code-signing certificatethat is trusted by devices. Where do I get them? Option 1: purchase from a Public CA (Verisign, Geotrust etc.).Microsoft Root Certificate Program Member List Option 2: create your own using the company’s Internal CA, who’s Root Certificate is linked to a Public CA (Verisign, Geotrust etc.). Option 3: create you own using the company’s Internal CA. The devices you are deploying the app to, must have appropriate root certificate installed (company’s internal CA certificate) to be able to trust the code signing certificate (Certificate chain) code-signing certificate is chained to a trusted root certificate!!!
Sideloadingstepbystep Devices must be enabled for sideloading to install and launch apps How to enable devices for sideloading? Windows 8 Enterprise, domain joined sideloading automatically enabled (group policy must be set to “Allow trusted apps to install”) Windows 8 Enterprise, not domain joined Windows 8 Pro sideloading product activation key Windows RT (*) available via Volume Licensing (provided for free if you have Software Assurance)
Resources Windows store app samples http://code.msdn.microsoft.com/windowsapps Developing Windows Store apps: Start Here! http://msdn.microsoft.com/en-us/windows/apps/jj679957 Design case study: Enterprise line of business Windows Store app http://msdn.microsoft.com/en-us/library/windows/apps/jj659079.aspx Enterprise CA: Active Directory Certificate Services Overview http://technet.microsoft.com/library/hh831740 Enterprise CA: Active Directory Certification Authority Guidance http://technet.microsoft.com/en-us/library/hh831574.aspx