Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Offline synchronization options with .NET

I've been asked to research approaches to deal with an app we're supposed to be building. This app, hypothetically a Windows form written in C#, will issue commands directly to the server if it's connected, but if the app is offline, the state must be maintained as if it was connected and then sync up and issue data changes/commands to the server once it is connected.

I'm not sure where to start looking. This is something akin to Google Gears, but I don't think I have that option if we go a Winform route (which looks likely, given that there are other functions the application needs that a web app couldn't perform). Is the Microsoft Sync framework a viable option? Does Silverlight do anything like this? Any other options? I've Googled around a bit but would like the community input on what's best given the scenario.

like image 552
Chris Avatar asked Sep 30 '09 19:09

Chris


People also ask

What is offline data synchronization?

Offline data sync is not all about pushing the records to the server but you also have to pull the new records from the server. Now we've two events push and pull. Offline mode is more complex than online mode. Following are the complexities with offline mode: Master Data Sync.

How do I fix sync offline files?

Open “Sync Center” and click “View sync partnerships”, then select the Offline Files folder and click “Sync” to start file synchronization. If you want to schedule sync offline files, click “Schedule” and follow the on-screen instructions to set it up.

What is offline synchronization in android?

Offline sync allows end users to interact with a mobile app—viewing, adding, or modifying data—even when there's no network connection. Changes are stored in a local database. Once the device is back online, these changes are synced with the remote backend.

Which component do you need to use the offline sync capability of mobile apps?

The data synchronization in Android apps can be achieved using Sync Service and Sync Adapter. A Sync Adapter is a plug-in that handles background syncs on the Android platform to sync data from your app to a server.


2 Answers

The Microsoft Sync Framework definitely supports the scenario you describe, although I would say that it's fairly complicated to get it working.

One thing to understand about the Sync Framework is that it's really two quite distinct frameworks shipping in the same package:

  • Sync Framework
  • ADO.NET Sync services v. 2

The ADO.NET Sync services are by far the easiest to set up, but they are constrained to synchronizing two relational data stores (although you can set up a web service as a remote facade between the two).

The core Sync Framework has no such limitations, but is far more complex to implement. When I used it about six months ago, I found that the best source to learn from was the SDK, and particularly the File/Folder sync sample code.

As far as I could tell, there was little to no sharing of code and types between the two 'frameworks', so you will have to pick one or the other.

In either case, there are no constraints on how you host the sync code, so Windows Forms is just one option among many.

like image 110
Mark Seemann Avatar answered Oct 10 '22 12:10

Mark Seemann


If I understand correctly, this doesn't sound like an actual data synchronization issue to me where you want to keep two databases in sync. it sounds more like you want a reliable mechanism for a client to call functions on a server in an environment where the connection is unstable, and if the connection is not present at the time, you want the function called as soon as the connection is back up.

If my understanding is right, this is one option. if not, this will probably not be helpful.


This is a very short answer to an in-depth problem, but we had a similar situation and this is how we handled it.

We have a client application that needs to monitor some data on a PC in a store. When certain events happen, this client application needs to update our server in the corporate offices, preferably Real-Time. However, the connection is not 100% reliable, so we needed a similar mechanism.

We solved this by trying to write to the server via a web service. If there is an error calling the web service, the command is serialized as an XML file in a folder named "waiting to upload".

We have a routine running in our client app on a timer set for every n minutes. When the timer elapses, it checks for XML files in this folder. If found, it attempts to call the web service using the information saved in the file, and so on until it is successful. Upon a successful call, the XML file is deleted.

It sounds hack-ish, but it was simple to code and has worked flawlessly for five years now. It's actually been our most trouble-free application all-around and we've implemented the pattern elsewhere successfully

like image 27
David Avatar answered Oct 10 '22 12:10

David