Browse DevX
Sign up for e-mail newsletters from DevX


Managing Offline Clients with the Smart Client Offline Application Block : Page 3

The offline functionality provided by smart clients offers a lot of opportunity for developers, but there are numerous implementation approaches. The Smart Client Offline Application Block from Microsoft will disperse the confusion and let you leverage this technology in your own smart clients right away.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Figure 6. ReferenceDataCache: This figure shows how reference data can be retrieved from a backend Web service through the Smart Client Offline Application Block.
Offline Orders: A Sample Application
Now that you're familiar with the components of the Smart Client Offline Application Block, let's give it a workout. Here's a typical use case: You have an application that allows sales reps to enter new order data for their customers. Before the smart client switches to the offline mode, the DataLoaderManager stores all reference data (custmers, products) locally. This way, during the offline phase the user can create orders normally. The orders are stored in a local queue, awaiting the network connection. To store reference data locally an application service agent uses the DataLoadManager class to start the download process. The DataLoaderManager calls the QueueManager, which stores a service request in the local queue. When the network connection is restored, the Executor takes the service requests from the queue and calls the appropriate online proxy using Reflection. The online proxy calls the back end Web service, which returns the requested reference data. This data is stored with the component ReferenceDataCache in the local cache. Up to this point the requested data is available to the smart client for further processing (see Figure 6).

Figure 7. The Executor: This figure shows how the service agent works with other components to execute a Web service request.
To transmit an order to the Web service within the fiefdom, the client calls a service agent to handle the service request. The service agent creates an instance of the class Payload, which contains the current context and the current service request. Then the QueueManager wraps the payload instance to an instance of the class QueueMessage and stores this instance in the local queue. As soon as the smart client is back in online mode the Executor starts up on a separate thread. As described above, it reads all cached messages (instances of the class QueueMessage) from and calls the appropriate methods on the online proxy using Reflection. The proxy itself receives instances of the class Payload as a parameter. Once the proxy has executed the service request, the Executor returns the payload instance (including the result from the Web service call) back to the application service agent, whose only job is to raise an event to inform the UI that the Request was executed successfully (see Figure 7).

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date