320 likes | 601 Views
Occasionally Connected Smart Clients . Steve Lasker Program Manager Visual Studio Microsoft Corporation Steve.Lasker@Microsoft.com blogs.msdn.com/SmartClientData. What Is: Occasionally Connected.
E N D
Occasionally Connected Smart Clients Steve Lasker Program Manager Visual Studio Microsoft Corporation Steve.Lasker@Microsoft.com blogs.msdn.com/SmartClientData
What Is: Occasionally Connected • Empowering users to leverage their computer, applications, data and files regardless of network availability • Application proactively retrieves necessary data necessary to work offline • As the network comes available, the application will automatically sync their work and log conflicts for the user to resolve • Network operations occur in the background so the user can stay focused on their task • Example: Outlook 2003
Agenda • Resources for working offline • Occasionally Connected Systems Common Architecture • Demo Scenario • Demo Architecture • Database Options • Sync Options • Application Updates • Running Background Tasks Asynchronously
Resources Needed Offline • Data • A subset of the data from the server(s) • Heterogeneous Sync (SQL Server, Oracle, DB2, …) • Files • Not all data exists within the database • Media files, Office Files, … • Application Messaging (Web Services, WCF, …) • Ability to queue outbound messages • Ability to async process inbound messages • Read Only Informational/Reference Data Services • Ability to pre-fetch data from existing services
Visual Studio Microsoft Windows / Windows Mobile Occasionally Connected Smart Client Smart Client Application / UI Background Tasks Canned UI Controls Data Sync Services File Sync Services Data Access API Network Resources Message Queuing Message Caching Data Store Files Application Updates
Adventure Works Sales • Field Sales • Multi-level marketing • Consumers sell Adventure Works Products • Need for the app to run disconnected • Sellers are independent • Hardware not owned by Adventure Works • Many platforms • Browser • Desktop • Tablet PC • Pocket PC • Smart Phone
Adventure Works Sales Architecture Weather Services Adventure Works Corp Adventure Works Sales Smart Client Background Tasks Desktop TabletPC PocketPC Smart Phone Sync Services Sync Services App Logic Data Server Weather Caching Data Store Network Services Order Services Order Submission Queue PromoVideos • Product Catalog • My Customers • Order Scratchpad • My Inventory App Updates
Which Local Data Store? Microsoft Database Technologies • SQL Server 2005 • SQL Server Express Edition • SQL Server Mobile Edition • Jet (Access) • Microsoft Visual FoxPro (.dbf) • Excel • XML • WinFS • Something new
SQL Server Express • Great improvements over MSDE • Simple install from web or local MSI • ClickOnce will BootStrap SSE if not installed • Connect w/File Path Connection String • User Instance feature for File Path Connecitons • Great for VS Development
Deploying SSE For Occasionally Connected Scenarios • Base Install of SSE • ClickOnce Bootstrapper • Requires Admin Rights • Replication w/SSE • Replication not supported w/User Instances • Enable SQL Server Authentication • Add DBO Privileged Account • Script creation of database • Verify / Create / Attach database at startup • Deploy SQL Server Replication .Dlls
Occasionally Connected Devices • Servers • Desktops • Laptops • Tablet PC’s • Windows CE • Pocket PC • Smart Phone ? Sweet spot Win 32
MultiUser Single User Scenarios Local Database Options Server SQLServer Workgroup Desktop SQL ServerExpress Laptop Tablet PC Win 32 Windows CE Device SQL Mobile SQL Mobile Pocket PC Smart Phone
Deploying SQL Server Mobile • SQL Server Mobile Engine • Add runtime dlls to project (sqlce*.dll) C:\Program Files\Microsoft Visual Studio 8\Common7\IDE • File size <1.4mb • Set files to Copy to Output Directory = Copy if newer • ADO for SQL Server Mobile • Add reference to Microsoft SQL Mobile • Located in: C:\Program Files\Microsoft Visual Studio 8\ _ Common7\IDE\PublicAssemblies\System.Data.SqlServerCE.dll • File Size ~224k
How - To Sync • Roll your own • Ultimate in flexibility • Highest cost to develop and maintain • Merge Replication • Most power, broadest features for different data partitions, spans all devices • Need DBO/DBA privileges, must “own” server • Remote Data Access (RDA) • Easy entry point for well partitioned data, no config to database • Limited to SQL Server Mobile
RDA Sync Architecture Local App UI IIS w / Sync ISAPI dll Server Data DAL RDA Sync Engine Out In Database Engine SQL Server Mobile
RDA: Initializing Reference Data • RDA.Pull(“Products", _ • "SELECT ProductId, Name, Description, Category, UnitPrice " & _ • "FROM Products", _ • My.Settings.ServerOleDBConnectionString, _ • RdaTrackOption.TrackingOff) Reference Data Product Catalog
RDA: Initializing Updatable Data • Rda.Pull(“Customers", _ • "SELECT CustomerId, Name, Address, Phone, Fax" & _ • "FROM Customers", _ • My.Settings.ServerOleDbConnectionString, _ • RdaTrackOption.TrackingOn) Updateable Data Customers
RDA: Pushing Changes Back • Rda.Push(“Customers", _ • My.Settings.ServerOleDbConnectionString, _ • SyncBatching.BatchingOn) Updateable Data Customers In
Incorporating WCF w/RDA Smart Client Accounting Transport Logic Controls WCF Queue Validation Logic* Transport Sales Logic Logic Rules WCF Cache Inventory Logic Logic Rules Rules Local Data Store Sync Client Fulfillment Sync Logic Rules
Configuring RDA • Configure Web Sync Point • Write client side code • Dim rda AsNew SqlCeRemoteDataAccess() • rda.InternetUrl = "http://www.YourCompany.com/SqlMobileSync/sqlcesa30.dll" • rda.LocalConnectionString = "Data Source =.\AdventureWorksSales.sdf" • rda.Pull("LocalTableName", _ • "Query To Execture on the Server", _ • "OLEDB ConnectionString from Web Server to SQL Server", _ • RdaTrackOption.TrackingOnWithIndexes, _ • "Local Table for Errors on Push") • Dim rda AsNew SqlCeRemoteDataAccess() • rda.InternetUrl = "http://www.YourCompany.com/SqlMobileSync/sqlcesa30.dll" • rda.LocalConnectionString = "Data Source =.\AdventureWorksSales.sdf" • rda.Pull("Customer", _ • "SELECT CustomerID, Name, FROM Customer ", _ • "Provider=SQLOLEDB.1;Data Source=YourSQLServer;" & _ • "User ID=YourServerUserName;Password=YourServerPassword;" & _ • "Initial Catalog=AdventureWorksSales", _ • RdaTrackOption.TrackingOnWithIndexes, _ • "Customer_Errors")
RDA Limitations • Based on Snapshot Push, Push, Push • Changes at server aren’t pulled down until next snapshot • Limits the Product Catalog scenarios • Updates are limited to last client wins • Comparison based on PK only
App Updates With ClickOnce • ClickOnce Background API’s • Imports System.Deployment.Application.ApplicationDeployment • ... • Private Function CheckForAppUpdates() As UpdateCheckInfo • If ApplicationDeployment.IsNetworkDeployed Then • Dim updateInfo As UpdateCheckInfo • updateInfo = CurrentDeployment.CheckForDetailedUpdate() • If updateInfo.UpdateAvailable Then • ' download the update • If ApplicationDeployment.CurrentDeployment.Update() Then • ' Update Downloaded • EndIf • EndIf • Return updateInfo • EndIf • End Function
BackgroundTasks / Steps • Runs on a background thread of the application • Executes collection of steps • Start / Stop similar to Windows Services • Executes in a loop based on a Timer • Can be triggered by Network Resources • Marshals progress / completed infoto UI thread
Summary • Smart Client Advantages • Ability to work offline • Ability to work on behalf of the user • Leverage, embrace reference data • Leverage Microsoft local data stores • SQL Server Express Edition • SQL Server Mobile Edition • Build sync APIs as background tasks • Composable Sync APIs are coming… • Leverage Occasionally Connected Systems Architectures to be well positioned • Leverage ClickOnce APIs for updates
Data Designers & Occasionally Connected Systems Discussions:http://blogs.msdn.com/SmartClientData Drag Once Databinding:http://www.Code-Magazine.com/Article.aspx?quickid=0409051 Drag Once w/Custom Controls:http://www.Code-Magazine.com/Article.aspx?quickid=0411071 Windows Forms: http://www.WindowsForms.nethttp://msdn.Microsoft.com/WindowsForms/http://forums.Microsoft.com/msdn/default.aspx?ForumGroupID=2 Data Runtime:http://msdn.Microsoft.com/Data/ Patterns & Practices: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/SCAG.asp Resources
Community Resources • At PDC • For more information, go see • Wed 1pm & 3:15pm PRS402 Erik EllisHarnessing the Power and Flexibility of Windows Forms 2.0 • Thur 11:30am PRS321 Mark BoulterWindows Forms: Integrating Windows Forms and Windows Presentation Foundation ("Avalon") • Fri 10:30am PRS334 Chris Sells, Doug PurdyWindows Presentation Foundation ("Avalon") + Windows Communications Foundation ("Indigo") = Magic • Fri 1pm FUN222 Jamie CoolWhat’s New in Software Installation for Windows Vista: Exploring the Windows Installer (MSI) and ClickOnce Options • Labs: • FUNHOL15 ClickOnce Deployment • PRSHOL17 New UI Features in Windows Forms • PRSHOL18 New Data Features in Windows Forms • PRSHOL19 Windows Forms: Advanced Layout • Ask The Experts
© 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.