OccasionallyConnected

Download Report

Transcript OccasionallyConnected

Occasionally Connected
Smart Clients
Steve Lasker
Program Manager
Visual Studio
Microsoft Corporation
[email protected]
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
2
Agenda
Resources for working offline
Occasionally Connected Systems
Common Architecture
Demo Scenario
Demo Architecture
Database Options
Sync Options
Application Updates
Running Background Tasks Asynchronously
3
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
4
Occasionally Connected Smart Client
Smart Client Application / UI
Canned
UI
Controls
Data Sync
Services
File Sync
Services
Message Queuing
Data Access API
Visual Studio
Network Resources
Background Tasks
Message Caching
Application
Updates
Files
Data Store
Microsoft Windows / Windows Mobile
5
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
6
Adventure Works Sales Architecture
Weather
Services
Adventure Works Sales
Smart Client
Background
Tasks
Desktop
Sync
Services
Network Services
Order
Service
s
Data
Server
Sync
Service
s
Adventure Works
Corp
TabletPC
PocketPC
Smart
Phone
App Logic
Weather
Caching
Order
Submission
Queue
App
Updates
Data Store
Promo
Videos
•Product Catalog
•My Customers
•Order Scratchpad
•My Inventory
7
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
8
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
9
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
10
Occasionally Connected Devices
Servers
Desktops
Laptops
Tablet PC’s
Windows CE
Pocket PC
Smart Phone
?
Win 32
Sweet
spot
11
Windows CE Device
Pocket PC
Smart Phone
SQL Mobile
Win 32
SQL Server
Express
Workgroup
Desktop
Laptop
Tablet PC
Single User Scenarios
Server
SQL
Multi
User
Server
Local Database Options
12
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.dl
l
File Size ~224k
13
Deploying SQL Server Mobile
14
SQL Server Mobile Runtime
.dll file
Functionality
sqlcese30.dll
sqlceqp30.dll
SQL Server Mobile Engine.
SQL Server Mobile Query Processor.
Required for all SQL Server Mobile applications.
Required for ADO.net, System.Data.SqlServerCe.dll
Contains error strings for SQL Server Mobile-generated
errors.
sqlceme30.dll
sqlceer30[language].dll
Required for all SQL Server Mobile applications.
sqlceca30.dll
sqlcecompact30.dll
sqlceoledb30.dll
The SQL Server Mobile Client Agent. Required for
applications that connect to SQL Server by using
replication or remote data access.
Provides the compact database functionality.
Provides OLE DB connectivity to SQL Server Mobile
databases. Required only if your application uses OLE DB
to connect to the SQL Server Mobile database. Used by
RDA.
Total File Size
1.34mb
15
How - To Sync
Technology
XML - DataSets
SQL Server Express
SQL Server Mobile
Roll your
own
Merge
Replication
Remote
Data Access






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
16
RDA Sync Architecture
Local App
UI
DAL
Database
Engine
RDA Sync
Engine
IIS
w / Sync ISAPI dll
Server
Data
Out
In
SQL Server
Mobile
17
RDA: Initializing Reference Data
Accounting
Logic
Logic
Transport
WCF
Queue
Controls
Validation
Logic*
Transport
Smart Client
Sales
Logic
Rules
WCF
Cache
RDA.Pull(“Products", _
"SELECT ProductId, Name, Description, Category, UnitPrice " & _
"FROM Products", _
ReferenceInventory
My.Settings.ServerOleDBConnectionString, _
Data
Logic
Product Logic
RdaTrackOption.TrackingOff)
Rules
Rules
Fulfillment
Sync
Sync
Client
Local
Data
Store
Catalog
Logic
Rules
18
RDA: Initializing Updatable Data
Sales
Logic
Rules
UpdateableInventory
Data
Logic
Customers Rules
Fulfillment
Sync
Sync
Client
Local
Data
Store
Accounting
Rules
Logic
WCF
Cache
Rda.Pull(“Customers", _
"SELECT CustomerId, Name, Address, Phone, Fax" & _
"FROM Customers", _
My.Settings.ServerOleDbConnectionString, _
Logic
RdaTrackOption.TrackingOn)
Logic
Transport
WCF
Queue
Controls
Validation
Logic*
Transport
Smart Client
Logic
Rules
19
RDA: Pushing Changes Back
Logic
Rules
Fulfillment
Sync
Sync
Client
Local
Data
Store
Sales
Logic
Rules
Inventory
Logic
Rules Updateable
Data
Customers
Accounting
Logic
Logic
WCF
Cache
Rda.Push(“Customers", _
My.Settings.ServerOleDbConnectionString, _
SyncBatching.BatchingOn)
Transport
WCF
Queue
Controls
Validation
Logic*
Transport
Smart Client
Logic
Rules
In
20
Incorporating WCF w/RDA
Accounting
Logic
Sales
Logic
Rules
Inventory
Logic
Rules
Logic
Rules
Fulfillment
Sync
Sync
Client
Local
Data
Store
Logic
WCF
Cache
Transport
WCF
Queue
Controls
Validation
Logic*
Transport
Smart Client
Logic
Rules
21
Remote Data Access (RDA)
22
Configuring RDA
Configure Web Sync Point
Write client side code
Dim rda As New SqlCeRemoteDataAccess()
rda.InternetUrl = "http://www.YourCompany.com/SqlMobileSync/sqlcesa30.dll"
rda.LocalConnectionString = "Data Source =.\AdventureWorksSales.sdf"
rda.Pull("LocalTableName", _
Dim rda As New SqlCeRemoteDataAccess()
"Query To Execture on the Server", _
rda.InternetUrl = "http://www.YourCompany.com/SqlMobileSync/sqlcesa30.dll"
"OLEDB ConnectionString from Web Server to SQL Server", _
rda.LocalConnectionString = "Data Source =.\AdventureWorksSales.sdf"
RdaTrackOption.TrackingOnWithIndexes, _
rda.Pull("Customer", _
"Local Table for Errors on Push")
"SELECT CustomerID, Name, FROM Customer ", _
"Provider=SQLOLEDB.1;Data Source=YourSQLServer;" & _
"User ID=YourServerUserName;Password=YourServerPassword;" & _
"Initial Catalog=AdventureWorksSales", _
RdaTrackOption.TrackingOnWithIndexes, _
"Customer_Errors")
23
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
24
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
End If
End If
Return updateInfo
End If
End Function
25
App Updates - ClickOnce
26
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 info
to UI thread
27
Background Tasks
28
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
29
Resources
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.net
http://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/enus/dnpag/html/SCAG.asp
30
Community Resources
At PDC
For more information, go see
Wed 1pm & 3:15pm PRS402 Erik Ellis
Harnessing the Power and Flexibility of Windows Forms 2.0
Thur 11:30am PRS321 Mark Boulter
Windows Forms: Integrating Windows Forms and Windows
Presentation Foundation ("Avalon")
Fri 10:30am PRS334 Chris Sells, Doug Purdy
Windows Presentation Foundation ("Avalon") + Windows
Communications Foundation ("Indigo") = Magic
Fri 1pm FUN222 Jamie Cool
What’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
31
© 2005 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Existing Architectures
34
Standalone Application Evolution
Local Data App
UI
Validation
Logic
DAL
Local
Database
Central
Database
35
Data Island  Shared Data
Users lose offline functionality
Applications aren’t typically written with
multi-user in mind
Rearchitecture typically required to make
multi-user
36
DataSets Over Web Services
Customers
Orders
Logic
Web Service
Web Service
Client
Controls
Validation
Logic*
Logic
SELECT *
FROM Customers
Accounting
Smart Client
Sales
Logic
Rules
Inventory
XML
XML
Logic
Rules
Fulfillment
Logic
Rules
37
DataSet Caching
Excellent for serialization and change tracking
Contain different views of the same data
Storage is based on XML / Binary
Querying requires loading the entire dataset into memory *
Updating the local dataset requires loading the entire dataset
into memory
Transaction support *
Query processor *
No canned, E2E, sync technology
Has change tracking w/DataAdapters
XML DiffGram based
38
Message Based Queuing / Caching
Customers
Orders
Logic
Service
Service
Client
Controls
Validation
Logic*
Logic
SELECT *
FROM Customers
Accounting
Smart Client
Sales
Logic
Rules
Service
Cache
Inventory
Logic
Rules
Fulfillment
Logic
Rules
39
Message Based Caching
Similar to DataSet Caching
Blobs are now stored in queues
No ability to query on uncommitted data
40
Logical Queuing
Sending mail in outlook
Pressing send a little too quickly
Submitting Expense Reports
Found a receipt in the bottom of your bag
41
Logical Queuing
42
Sync Components
Occasionally Connected Systems Services
Sync Groups
Sync Group Items
Database
Items
File
Items
Message
Items
Message
Pre-Fetch
Items
App
Update
Items
43