Esempio n. 1
0
        public async System.Threading.Tasks.Task Synchronize(SyncResultAction action)
        {
            Dataset dataset = SyncManagerInstance.OpenOrCreateDataset(TASK_DATASET);

            dataset.OnSyncSuccess += (object sender, SyncSuccessEventArgs e) =>
            {
                action(null);
            };
            dataset.OnDatasetDeleted = delegate
            {
                //basically use what ever we got in remote
                return(true);
            };
            dataset.OnSyncConflict = delegate(Dataset ds, List <SyncConflict> conflicts)
            {
                //trust the remote
                List <Record> resolved = new List <Record>();
                foreach (SyncConflict sc in conflicts)
                {
                    resolved.Add(sc.ResolveWithRemoteRecord());
                }
                dataset.Resolve(resolved);
                return(true);
            };
            dataset.OnSyncFailure += (object sender, SyncFailureEventArgs e) =>
            {
                action(e.Exception);
            };
            await dataset.SynchronizeAsync();
        }
 //------------------------------------------------------------------------------
 public static void SetSyncAction(SyncResultAction action)
 {
     s_Action = action;
 }
 public async System.Threading.Tasks.Task Synchronize(SyncResultAction action)
 {
     Dataset dataset = SyncManagerInstance.OpenOrCreateDataset(TASK_DATASET);
     dataset.OnSyncSuccess += (object sender, SyncSuccessEventArgs e) =>
     {
         action(null);
     };
     dataset.OnDatasetDeleted = delegate
     {
         //basically use what ever we got in remote
         return true;
     };
     dataset.OnSyncConflict = delegate (Dataset ds, List<SyncConflict> conflicts)
     {
         //trust the remote
         List<Record> resolved = new List<Record>();
         foreach (SyncConflict sc in conflicts)
         {
             resolved.Add(sc.ResolveWithRemoteRecord());
         }
         dataset.Resolve(resolved);
         return true;
     };
     dataset.OnSyncFailure += (object sender, SyncFailureEventArgs e) =>
     {
         action(e.Exception);
     };
     await dataset.SynchronizeAsync();
 }