| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
It's a database-agnostic synchronization framework based on .NET Standard 2.0 to synchronize data between multiple clients and a single server, where both platforms are using technologies that compatible with .NET Standard 2.0, such as Xamarin Forms for the mobile clients and ASP .NET Core for the backend server. The main purpose of this framework is to enable multiple clients (where each client may have one or more devices) to synchronize data among their own devices against a single server that act as a repository for all of the clients data. Data which are stored locally within each device of a single client can all be synchronized after each device have successfully performed the synchronization operation.
Add the NETCoreSync NuGet Package into your ASP .NET Core project (for the backend server), and also add the package into your client project (if you are using Xamarin Forms, add the package into the core project). NETCoreSync is designed with the most minimum dependency to avoid conflicts with existing packages.
Why oh why...
Data synchronization between server and clients will use the world clock (the system's Date Time) when comparing a data that exist in both source and destination, to determine whether the source data is newer or not than the destination data.
Pros:
Cons:
Data synchronization between server and clients will use their own internal time stamp (represented in long value) when comparing a data that exist in both source and destination. These so-called internal time stamp will correctly determine whether the source data is newer or not than the destination data, regardless of what the system's world clock is.
Pros:
Cons:
Here they come...
Soft Delete
Your existing database design MUST use the Soft Delete approach when deleting record from tables, means that the data is not physically deleted from the table, but only flag the record with a boolean column (such as IsDeleted) that indicates whether this record is already deleted or not.
Unique Primary Key
Your existing database tables must use Primary Keys that is unique, such as UUID / Guid, to ensure correct comparison of data during synchronization.
Data Representation as Objects
Your server and client database tables must be represented as objects in the server and client applications, known as POCO (Plain Old CLR Objects), because NETCoreSync needs to mark the object properties with some special attributes to indicate which field is the Primary Key, etc.
Since there are two kinds of synchronization approach, there's also two samples, one for the GlobalTimeStamp, and the other one for the DatabaseTimeStamp.
These samples are demonstrating the proper use of this library. Both server and client have the necessary tables to be synchronized with each other, and both also have proper CRUD functions for testing inserts, updates, and deletes, and then synchronize them to see the results. The SQLite database in GlobalTimeStamp was chosen on both components to allow quick test of these samples while keeping the dependency to minimum. While the PostgreSQL and Realm in DatabaseTimeStamp shows an advance usage of the library where it involves the usage of database transactions, and very close to a real-world situation. To run the sample, set your Visual Studio startup projects to start the Web project and Mobile project (either Android or iOS) simultaneously.
Still interested? :)
For GlobalTimeStamp approach:
For DatabaseTimeStamp approach:
This synchronization library is admittedly still far from being an ideal solution for perfect synchronization mechanism, considering data synchronization is VERY HARD and can have different implementations for different solutions. But still this may work if the required conditions and are met and the limitations are still accepted.
Please contact me if you have comments or suggestions. Thanks.
| Back | FazBrowse Home | New Git URL |