accounting fulfillment service proxies models
TRANSCRIPT
Offline Microsoft Silverlight ApplicationsDEV339
Steve LaskerLead Program ManagerMicrosoft Silverlight
Offline & Silverlight
Basics of enabling your app for offline scenariosSilverlight Implementation
Recipe
Determining Online/Offline State Local Storage Defined Offline Operations Categorized Data How To Retrieve Data
Not just about services
Data via MessagingHow to Sync ChangesSaving
Silverlight Application - MVVM
Accounting
Fulfillment
Views
View Models
ServiceProxies
Models
Silverlight Offline Application
Local Storage
Accounting
Fulfillment
ServiceProxies
Views
View Models
Models
demo
Determining Offline State
return NetworkInterface.GetIsNetworkAvailable();
Determining Online/Offline State
Use: NetworkInterfaceWrap w/WorkOffline
Monitor NetworkAddressChanged Event
// Monitor Network Changes (Online/Offline)NetworkChange.NetworkAddressChanged += NetworkAddressChanged;…void NetworkAddressChanged(object sender, EventArgs e) { CheckOnlineState();}
private bool _isOnline;
public bool IsOnline { get { if (WorkOffline) return false; return NetworkInterface.GetIsNetworkAvailable(); }}private void CheckOnlineState() { if (IsOnline != _isOnline) { _isOnline = this.IsOnline; NotifyPropertyChanged("IsOnline"); }}
Recipe
Determining Online/Offline State √Local Storage Defined Offline Operations Categorized Data How To Retrieve Data
Not just about services
Data via MessagingHow to Sync ChangesSaving
Canonical RequirementsPersistence – survive app restartsIndexed – data grows quickly, need quick accessDisk Paging – Only pull what you need from diskRelationships & GraphsLocking – multi threaded/app accessTransactionsProgramming Model (T-SQL, LINQ, …)
Local Storage
Customer_IdNameAddress
CustomerVehicle_IdYearMakeModel
Vehicle
Claim_IdCustomer_IdVehicle_Id
Claim
HTML5
IndexDBWEB SQL Database
Too much to cover in this session
Application Overview
demo
Calendar of AppointmentsClaimsDamages
Upload Images, w/descriptions & vehicle location
ReportsVehiclesNewsBranch StylesHelp
Operations – What Should Work Offline?
Offline Operations
Calendar of AppointmentsClaimsDamages
Upload Images, w/descriptions & vehicle location
ReportsVehiclesNewsBranch StylesHelp
demo
Disabling Online Operations
Check Point
Determining Online/Offline State √Local Storage √Defined Offline Operations √Categorized Data How To Retrieve Data
Not just about services
Data via MessagingHow to Sync ChangesSaving
User/Branch Info
Branch_Id
Appointments & Claims
LookupsVehicle Info
StandardVehicleInfo
State*
BranchOffice
BranchStyles
Claim
ClaimStatus
Appointment
ClaimDamage
VehicleBodyType
StandardVehicleInfo
State*
BranchOffice
BranchStyles
Claim
ClaimStatus
Appointment
ClaimDamage
VehicleBodyType
Reference Data Typically cached in completeness
Activity Data Typically partitioned per user
Appraiser_Id
Categorize Your Data
UserInfoUserInfo
Partitioned Reference Data Cached for offlinePartitioned, per user
VehicleReferencePhoto
VehicleReferencePhoto
How’d My Data Get Local
Passive CachingCache results as requested
Active CachingAlways work locallySync all changes
HybridActively cache Reference & Activity dataWhen online, request from remote
Passively cache results
Entity Managerentity Manager
Silverlight Offline Application w/Messaging
Local Storage
Accounting
Fulfillment
ServiceProxies
Message
Views
View Models
Models
entity Manager
public class GetAppointmentsMessage : Message {
Message Pipeline
ProcessMessage(Message message)
OnlineOperation(){ … }
ProcessMessageResults(List<MessageResult> messageResults) {MessageCompleted.Invoke(message);
}
OfflineOperation() { … }
Views
View Models OnEntityChanged(…)
demo
Messaging Operations
entity Manager
Sync Groups
Synching Local Data
Local Storage
Accounting
Fulfillment
ServiceProxies
Message
Views
View Models
Models
Reference Data
Activity Data
Getting Deltas
ChallengeHow to manage changes for N users
SolutionsServer Side Tracking
Client asks for “my” changes?Simple for the client, hard for the server – scalability limits
Client Side TrackingClient asks give me changes since XA little more work for the client, but endless scale
Anchor Based Changes
Client stores “Last Sync Time” for each collectionCreate “Sync Groups”
Group Collections / Sync Group
SyncGroup Frequency (TimeSpan)
Reference 24 hours
Activity 5 minutes
Entity SyncGroup Anchor
States Reference 5/1/11 7:00:00 AM UTC
ClaimStatus Reference 5/1/11 7:00:00 AM UTC
StandardVehicleInfo Reference 5/1/11 7:00:00 AM UTC
VehicleReferencePhoto Reference 5/1/11 7:32:05 AM UTC
Appointments Activity 5/16/11 8:08:15 AM UTC
Claims Activity 5/16/11 8:08:15 AM UTC
ClaimDamage Activity 5/16/11 8:08:15 AM UTC
Deltas Include…
InsertsUpdatesDeletes
But, how do I get a delete, if it’s deleted?
Tombstones
Tombstones???
Maintained by Database Triggers
Appointment Appointment_Tombstone
Appointment_IdAppraiser_IdDeletedDate
Appointment_IdAppraiser_IdCustomer_IdVehicle_Id…CreatedLastEdit
Claim
ClaimDamage
Claim_Tombstone
ClaimDamage_Tombstone
CREATE TRIGGER AdjusterAppointment_Delete_UpdateTombstone ON AdjusterAppointment AFTER DELETEAS INSERT INTO AdjusterAppointment_Tombstone ( AdjusterAppointmentGuid, Adjuster_Id ) SELECT AppointmentGuid, Adjuster_Id FROM deleted
demo
Getting Deltas
Check Point
Determining Online/Offline State √Defined Offline Operations √Categorized Data Local Storage √How To Retrieve Data √
Not just about services
Data via Messaging √How to Sync Changes √Saving
Saving
Save LocallySync w/Server
Just another message
demo
Saving
entity Manager
Sync Groups
Offline Silverlight Application w/Messaging
Local Storage
Accounting
Fulfillment
ServiceProxies
Message
Views
View Models
Models
Reference Data
Activity Data
Check Point
Determining Online/Offline State √Defined Offline Operations √Categorized Data √Local Storage √How To Retrieve Data √
Not just about services
Data via Messaging √How to Sync Changes √Saving √
Summary
Network resiliency doesn’t happen as an afterthoughtBuilding resilient applications is the future, not a stop gap
It’s how all important resources are managed
Design your apps to work offline from the beginningWhen things are connected, they work greatWhen “stuff” happens, your business continues to function
Contribute to usability & business stability
Hands On Labs
DEV386HOL: Microsoft Silverlight Data BindingDEV388HOL: Web Services and Microsoft SilverlightDEV389HOL: Using WCF RIA ServicesDEV390HOL: Using the MVVM Pattern in Microsoft Silverlight Applications
Find Me Later At the Silverlight Boothhttp://Blogs.MSDN.com/SteveLasker
Related Sessions
DEV330: Delivering End-End Video Workflow Using Microsoft SharePoint, IIS Media Services,Microsoft Expression Encoder and Microsoft Silverlight
DEV340: Tackle the Complexity of Async Calls in Microsoft Silverlight and WPF ClientsDEV209: From Zero to Silverlight in 75 MinutesDEV331: A Lap around Microsoft Silverlight 5DEV210: Microsoft Silverlight, WCF RIA Services and Your Business ObjectsDEV339: Offline Microsoft Silverlight ApplicationsDEV337: Moving Your App and Skills from Windows Forms to Microsoft Silverlight (and WPF)DEV356: Integrating Security Roles into Microsoft Silverlight Applications
http://Silverlight.net Find Me Later At the Silverlight Boothhttp://Blogs.MSDN.com/SteveLasker http://SLOfflineDemo.codeplex.com/
Complete an evaluation on CommNet and enter to win!
Related Sessions
DEV330: Delivering End-End Video Workflow Using Microsoft SharePoint, IIS Media Services,Microsoft Expression Encoder and Microsoft Silverlight
DEV340: Tackle the Complexity of Async Calls in Microsoft Silverlight and WPF ClientsDEV209: From Zero to Silverlight in 75 MinutesDEV331: A Lap around Microsoft Silverlight 5DEV210: Microsoft Silverlight, WCF RIA Services and Your Business ObjectsDEV339: Offline Microsoft Silverlight ApplicationsDEV337: Moving Your App and Skills from Windows Forms to Microsoft Silverlight (and WPF)DEV356: Integrating Security Roles into Microsoft Silverlight Applications
http://Silverlight.net Find Me Later At the Silverlight Boothhttp://Blogs.MSDN.com/SteveLasker http://SLOfflineDemo.codeplex.com/
© 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to
be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS
PRESENTATION.