New Posts New Posts RSS Feed: Tech Tip: Supporting Disconnected Applications
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Tech Tip: Supporting Disconnected Applications

 Post Reply Post Reply
Author
IdeaBlade View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 30-May-2007
Location: United States
Posts: 353
Post Options Post Options   Quote IdeaBlade Quote  Post ReplyReply Direct Link To This Post Topic: Tech Tip: Supporting Disconnected Applications
    Posted: 06-Jun-2007 at 3:45pm

Level 200
DevForce Enterprise

June 30, 2006

With vacations upon us, we felt you might find this Tech Tip especially useful.

Many applications enable end users to work on data while offline. Users of Microsoft Outlook, for example, can review and create new emails while on a plane or in some other disconnected location. Changes can be saved back to the host database when the connection is restored.

Of course we can only work disconnected with data that have been stored locally. The application must anticipate the user's disconnected data needs and provide mechanisms to transition between online and offline operation.

DevForce can help you build such applications. The DevForce PersistenceManager’s “EntitySet” methods, for example, shuttle business object data between the manager’s in-memory entity cache and local storage.

The SaveEntitySet methods convert object state to “EntitySet” format.

                C#:

void SaveEntitySet(String pFileName);
void SaveEntitySet(IEnumerable pDataRows, String pFileName);
void SaveEntitySet(Stream pStream, bool pCloseOnExit);
void SaveEntitySet(IEnumerable pDataRows, Stream pStream,
  bool pCloseOnExit);


VB.NET:

SaveEntitySet can preserve the entire entity cache or just some selected objects. The destination file may reside anywhere in the local file system although it is often wise to save to the user's "Isolated Storage". The "stream" signatures facilitate piping the data through intermediate filters before they get to their ultimate destination. For example, we might want to flow object data through an encryption filter before storing them. We can also append custom bytes to the same stream if you're up to managing that yourself.

When the user re-launches the application, it should locate the saved file (or stream) and restore its contents to the PersistenceManager’s entity cache, using one of the following methods.


C#:

void RestoreEntitySet(String pFileName);
void RestoreEntitySet(String pFileName, RestoreStrategy pStrategy);
void RestoreEntitySet(Stream pStream, RestoreStrategy pStrategy,
  bool pCloseOnExit);


VB.NET:

Sub RestoreEntitySet(pFileName as String)
Sub RestoreEntitySet(pFileName as String, pStrategy as RestoreStrategy)
Sub RestoreEntitySet(pStream as Stream, pStrategy as RestoreStrategy, _
  pCloseOnExit as Boolean)

The RestoreStrategy parameter prescribes how to handle entity set objects that already exist in the target PersistenceManager’s cache. The default RestoreStrategy preserves the cache's pending business objects changes – additions, modifications, and deletions.

When the application obtains a server connection, it can synchronize local objects with the remote data source. It can save local pending changes, relying upon DevForce optimistic concurrency checking to prevent overwriting other users’ changes. It might refresh local copies of business objects with objects updated by other users previously.

Remember: the application must pre-fill the cache with entities the user will need offline before saving the cache and disconnecting. While disconnected, queries and object navigation can only access cached entities.


Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down