Beispiel #1
0
 public void DoSync(SyncStartType syncStartType)
 {
     using (new OperationLogger())
     {
         ISyncEngine engine;
         SyncResult syncResult;
         if ((this.CurrentSyncPartnership == null) || !this.CurrentSyncPartnership.LockForSyncing())
         {
             Logger.TraceInformation("Managed:UI", "Not syncing.  Partnership null or refused to sync.", syncStartType.ToString());
         }
         else if (this.DoStorageCardChangedCheck())
         {
             Logger.TraceInformation("Managed:UI", "Not syncing.  User canceled due to sd card changed.", syncStartType.ToString());
             this.CurrentSyncPartnership.UnlockForSyncing();
         }
         else
         {
             engine = this.CurrentSyncPartnership.Engine;
             new Thread(delegate {
                 using (new OperationLogger("MainController sync"))
                 {
                     Thread.CurrentThread.SetApartmentState(ApartmentState.MTA);
                     SyncType syncType = SyncType.Calculated;
                     if ((syncStartType != SyncStartType.AutoSync) && (syncStartType != SyncStartType.ManualSync))
                     {
                         syncType = SyncType.Specific;
                     }
                     this.CurrentSyncPartnership.SyncStartType = syncStartType;
                     syncResult = engine.CalculateSyncOperations(syncType);
                     if (syncResult == null)
                     {
                         DateTime now = DateTime.Now;
                         SyncStoppedReason reason = engine.DoSyncOperations();
                         TimeSpan syncDuration = (TimeSpan) (DateTime.Now - now);
                         if (reason != SyncStoppedReason.Paused)
                         {
                             this.sqmHelper.CreateSyncContentStream(this.CurrentSyncPartnership, syncStartType, reason, syncDuration);
                         }
                     }
                     else
                     {
                         Logger.TraceInformation("Managed:UI", "Didn't do sync.  CalculateSyncOperations returned error.", syncResult.Details);
                     }
                 }
             }).Start();
         }
     }
 }
Beispiel #2
0
 public void DoSync(SyncStartType syncStartType)
 {
     using (new OperationLogger())
     {
         ISyncEngine engine;
         SyncResult  syncResult;
         if ((this.CurrentSyncPartnership == null) || !this.CurrentSyncPartnership.LockForSyncing())
         {
             Logger.TraceInformation("Managed:UI", "Not syncing.  Partnership null or refused to sync.", syncStartType.ToString());
         }
         else if (this.DoStorageCardChangedCheck())
         {
             Logger.TraceInformation("Managed:UI", "Not syncing.  User canceled due to sd card changed.", syncStartType.ToString());
             this.CurrentSyncPartnership.UnlockForSyncing();
         }
         else
         {
             engine = this.CurrentSyncPartnership.Engine;
             //new Thread(delegate {
             using (new OperationLogger("MainController sync"))
             {
                 Thread.CurrentThread.SetApartmentState(ApartmentState.MTA);
                 SyncType syncType = SyncType.Calculated;
                 if ((syncStartType != SyncStartType.AutoSync) && (syncStartType != SyncStartType.ManualSync))
                 {
                     syncType = SyncType.Specific;
                 }
                 this.CurrentSyncPartnership.SyncStartType = syncStartType;
                 syncResult = engine.CalculateSyncOperations(syncType);
                 if (syncResult == null)
                 {
                     DateTime          now          = DateTime.Now;
                     SyncStoppedReason reason       = engine.DoSyncOperations();
                     TimeSpan          syncDuration = (TimeSpan)(DateTime.Now - now);
                     if (reason != SyncStoppedReason.Paused)
                     {
                         this.sqmHelper.CreateSyncContentStream(this.CurrentSyncPartnership, syncStartType, reason, syncDuration);
                     }
                 }
                 else
                 {
                     Logger.TraceInformation("Managed:UI", "Didn't do sync.  CalculateSyncOperations returned error.", syncResult.Details);
                 }
             }
             //}).Start();
         }
     }
 }