Silverlight DataPortalProxy using it as Local and Remote

Silverlight DataPortalProxy using it as Local and Remote

Old forum URL: forums.lhotka.net/forums/t/11676.aspx


Jaans posted on Sunday, November 04, 2012

My fellow CSLA developers

I'm seeking some suggestions from the CSLA Dev Team & the community regarding ways to dynamically toggle / switch / reconfigure the data portal to be local or remote.

Let me begin with what I'm trying to achieve. We have an Silverlight application that will run in both an "online" and "offline" mode. By this I mean that as a user you might run the out of browser Silverlight application and "synchronise" data from an online source (here this would be a DataPortalProxy running on the remote server). This is typically data that is used to start an offline workflow.

 

After this synchronise completes, the user is able to make (mostly updates and a few object inserts) to the CSLA business objects in a purely "offline" scenario in that there may not even be any Internet connectivity (here I'm thinking that I could have a local DataPortalProxy that updates to a local Silverlight database (NinjaDB, SQLLite, etc.).

 

Then at some future point in time, the user has connectivity again and has finished his workflow. Then any changes is then "synchronised" back to the online store.

 

Put simply and more condensed: a Silverlight client application downloads data from a server (remote data portal proxy) and stores it in a local database (local data portal proxy), makes changes locally and later sends the data with changes back to the remote server (remote data portal proxy - which is always the same as where we downloaded from to begin with).

 

The key aspect is a dynamic mix a local and remote data portal proxy.

So I'm asking whether any of you have some experience of what works well for something like this.

 

Some thoughts I'm having is to have duplicated dedicated Business Objects that has one set used for the local data store and the other set used for the remote data. For my purposes, these object structures will be very similar if not exactly the same. 

  * Would I be able to use something like the "RunLocal" attribute with the local set of objects?

 

What about using one set of objects, but somehow mix and match when the call goes local or remote.

At first glance a really flexible and powerful options would be if I could somehow control the dataportal proxy desitnation on a per call bases (typically the "root" call to an object factory Get/Fetch/Delete/Save).

 

A coding usage scenario that has come to mind would be something where I could do something like this:

MyBusinessObject myBo = null;

using (DataPortal.Local)

{

  myBO = MyBusinessObject.Get(...);

  myBO.Property = newValue;

  myBO.Save(); // Saves it to local data store

}

 

using (DataPortal.Remote)

{

  myBO.Save(); // Saves it to Remote Data portal proxy

}

 

Is there parhaps some usefull objects that might in assisting me to "plug in" the online/offline logic? Some sort of ProxyManager/Factory?

I'd be looking to implement this using CSLA 4.5 (or earlier if need be).

I'd love to get your feedback.

Thanks,

Jaans

JonnyBee replied on Sunday, November 04, 2012

My best suggestion is this one from an earlier thread:

http://forums.lhotka.net/forums/p/11622/53824.aspx#53824

Jaans replied on Sunday, November 04, 2012

Thanks JonnyBee

I didn't see that one - useful indeed. I would seem that a custom client-side data portal proxy is the way to go.

Pity there isn't much to learn yet from others' past experiences - let's see how I go.

Copyright (c) Marimer LLC