Skip to content

OfflineSync is Nuget package which puts the DB on client side in sync with DB on server side and viceversa.

License

Notifications You must be signed in to change notification settings

ShekharReddy4/OfflineSync

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


OfflineSync Client

OfflineSync Client

Table of Contents

Introduction

Offline Sync is a Nuget Package which can be used to keep client and server side Databases in sync with no data loss and tuned to configure all possible scenarios.

Diagrammatical representation of a typical project using Offline Sync


  • Note:
    • Currently only SQLite DB is supported on the client side and SQLServer DB on the server side. Future implementation would include other databases too.

Supported Frameworks

Please refer the following table to know the frameworks we support and tested so far.

Frameworks Version
WPF 1.0.0
UWP 1.0.0
Xamarin native 1.0.0
Xamarin forms 1.0.0

How to Use OfflineSync?

There are two dll's you need to add to your project. One in the client side and the other in the server side application and whichever table you are trying to sync you need to do the following in the client side application.

Diagrammatical heirarchy representation of tables in a typical project using Offline Sync


Types of Sync

Offline Sync suppports any of the below mentioned types of Sync.

  1. Client to Server.
  2. Client to Server and Hard Delete.
  3. Server to Client.
  4. TwoWay Sync.

Client To Server

  • Client to Sever sync will Sync the server table records to match with the client table records.

  • Note:

    • Discards the client changes if there are any.

Client To Server And Hard Delete

  • Client to Server and Hard Delete is same as the Client to Server but hard deletes the Client records upon successful Sync.

Server To Client

  • Server to client will Sync the client table records with that of server table records.

  • Note:

    • Discards the server changes if there are any. Use Case: Any Metadata tables(like Dropdown options etc..) in an application.

TwoWay Sync

  • TwoWay Sync will sync both client and server depending upon the autosync/priority configured in the project.

  • Note:

    • Here we resolve the conflicts if there are any based on the priority provided and then keep both client and server in Sync with the other

Terminology

These are a few terms that you would come across while you use the offline sync in your project.

AutoSync

Priority

When the sync type is Twoway Sync the priority value for a table will be setup before we do a sync. These values could be any of these 3.

  • Server
  • The record on the server side will be considered over the client side record.
  • Client
  • The record on the client side will be considered over the server side record.
  • LastUpdated
  • Lastupdated priority means the record which was recently updated will be considered.

When in conflict the priority value will be crucial in making the changes.

Version ID

This column value for a record in a tables holds a unique id for that record.

Transaction ID

Is Synced

This column value for a record in a table says if the record is synced or not at that point of time.

Sync Created At

This column value for a record in a table holds the timestamp of the record created at.

Sync Modified At

This column value for a record in a table holds the timestamp of the record modified at last time.


Configure a sample project to use OfflineSync

Following steps illustrate the configuration and usage of offline sync in a project.

Client Side

In the client project install this nuget package, please follow below steps.

Nuget

Note: Examples below isllustrate using offlinesync to sync one table on client side with that of a respective one on the server side.

Step 1
Adding Global Configurations on the client side:
  • In the client application add the following lines which adds global configuration (API URL, Client DB Path, Auth Token, Client DB Type)
SyncGlobalConfig.DBPath = @"SyncDB.db";
SyncGlobalConfig.Token = "";
SyncGlobalConfig.APIUrl = @"http://localhost:64115/API/";
SyncGlobalConfig.APIUrl = ClientDBType.SQLite;

For reference Enum ClientDBType.cs is as follows:

public enum ClientDBType
{
  SQLite = 0
}
Step 2
Add Device ID

new DeviceIDUtility().InitializeDeviceID();
Step 3
Add Settings for each of the tables you want to sync as follows.

SyncSettingsUtility syncSettings = new SyncSettingsUtility();
syncSettings.Add(
    new SQLiteSyncSettingsModel
    {
        AutoSync = true,
        ClientTableName = typeof(tblTestClient).Name,
        Priority = OveridePriority.LastUpdated,
        SyncType = SyncType.SyncClientToServer,
        ServerAssemblyName = "User.APIApp",
        ServerTableName = "tblTestModelServer"
    }
);
Step 4
Call SyncAsync

new SyncUtility<tblTestACTS>().StartSyncAsync();

Server Side Configurations

Please install the nuget package on the server application and follow below steps to enable offlinesync successfully.

Nuget

  • add connnection string in the web.config check the below example.

Contribute

Contributions are always welcome! Please read the contribution guidelines here.

ToDo

  • Support for .net core

License

License: MIT

Contact Us

We have a dedicated telegram channel for the support. You may reach us there. We will follow up as and when we are free.

Click this link to join the channel.

About

OfflineSync is Nuget package which puts the DB on client side in sync with DB on server side and viceversa.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.9%
  • ASP.NET 0.1%