Beispiel #1
0
 public void CreateSyncContentStream(ISyncPartnership partnership, SyncStartType type, SyncStoppedReason reason, TimeSpan syncDuration)
 {
     if ((partnership != null) && this.isSqmEnabled)
     {
         SqmSyncContentStream stream = new SqmSyncContentStream();
         SetSyncType(partnership, type, stream);
         if (partnership.Device != null)
         {
             string winMoDeviceId = partnership.Device.WinMoDeviceId;
             long? nullable = (long?) DeviceSettings.Get(winMoDeviceId, "SyncCount");
             uint num = 0;
             if (nullable.HasValue)
             {
                 num = (uint) nullable.Value;
             }
             stream.SyncIndex = ++num;
             DeviceSettings.Set(winMoDeviceId, "SyncCount", num);
         }
         ISyncRules ruleManager = partnership.RuleManager;
         SetGlobalRules(stream, ruleManager);
         CalculateMusicSyncSelections(partnership.MusicAndMovieProvider, partnership.RuleManager, stream);
         this.CalculatePhotoSyncSelections(partnership.PhotoAndVideoProvider, partnership.RuleManager, stream);
         CalculateSyncResults(partnership, stream);
         stream.OperationTime = (uint) syncDuration.TotalMilliseconds;
         SetSyncResult(reason, stream);
         this.sqmManager.SetStream(stream);
     }
 }
Beispiel #2
0
        private static void SetSyncResult(SyncStoppedReason reason, SqmSyncContentStream stream)
        {
            switch (reason)
            {
            case SyncStoppedReason.Completed:
                stream.SyncResult = SqmSyncTerminationMethods.Completed;
                return;

            case SyncStoppedReason.Cancelled:
                stream.SyncResult = SqmSyncTerminationMethods.Canceled;
                return;

            case SyncStoppedReason.Aborted:
                stream.SyncResult = SqmSyncTerminationMethods.Aborted;
                return;

            case SyncStoppedReason.Paused:
            case SyncStoppedReason.CouldNotStart:
            case SyncStoppedReason.Unknown:
                break;

            case SyncStoppedReason.Disposed:
                stream.SyncResult = SqmSyncTerminationMethods.Quit;
                break;

            default:
                return;
            }
        }
 private void FireSyncStopped(SyncStoppedReason reason)
 {
     this.OnSyncStopped(reason);
     if (this._syncStopped != null)
     {
         this._syncStopped(this, new SyncStoppedEventArgs(reason));
     }
 }
 private void OnSyncStopped(SyncStoppedReason reason)
 {
     using (new OperationLogger())
     {
         if (this.Device != null)
         {
             this.Device.RefreshProperties();
         }
         if ((((bool)GlobalSetting.GetApplicationSetting("PlaySoundOnSyncComplete")) && (reason != SyncStoppedReason.Cancelled)) && (reason != SyncStoppedReason.Paused))
         {
             SystemSounds.Asterisk.Play();
         }
         this.FireSyncErrors();
     }
 }
Beispiel #5
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();
         }
     }
 }
 private void OnSyncStopped(SyncStoppedReason reason)
 {
     using (new OperationLogger())
     {
         if (this.Device != null)
         {
             this.Device.RefreshProperties();
         }
         if ((((bool) GlobalSetting.GetApplicationSetting("PlaySoundOnSyncComplete")) && (reason != SyncStoppedReason.Cancelled)) && (reason != SyncStoppedReason.Paused))
         {
             SystemSounds.Asterisk.Play();
         }
         this.FireSyncErrors();
     }
 }
 private void FireSyncStopped(SyncStoppedReason reason)
 {
     this.OnSyncStopped(reason);
     if (this._syncStopped != null)
     {
         this._syncStopped(this, new SyncStoppedEventArgs(reason));
     }
 }
 public SyncStoppedEventArgs(SyncStoppedReason reason)
 {
     this.Reason = reason;
 }
Beispiel #9
0
        private static void SetSyncResult(SyncStoppedReason reason, SqmSyncContentStream stream)
        {
            switch (reason)
            {
                case SyncStoppedReason.Completed:
                    stream.SyncResult = SqmSyncTerminationMethods.Completed;
                    return;

                case SyncStoppedReason.Cancelled:
                    stream.SyncResult = SqmSyncTerminationMethods.Canceled;
                    return;

                case SyncStoppedReason.Aborted:
                    stream.SyncResult = SqmSyncTerminationMethods.Aborted;
                    return;

                case SyncStoppedReason.Paused:
                case SyncStoppedReason.CouldNotStart:
                case SyncStoppedReason.Unknown:
                    break;

                case SyncStoppedReason.Disposed:
                    stream.SyncResult = SqmSyncTerminationMethods.Quit;
                    break;

                default:
                    return;
            }
        }
Beispiel #10
0
 public void CreateSyncContentStream(ISyncPartnership partnership, SyncStartType type, SyncStoppedReason reason, TimeSpan syncDuration)
 {
     if ((partnership != null) && this.isSqmEnabled)
     {
         SqmSyncContentStream stream = new SqmSyncContentStream();
         SetSyncType(partnership, type, stream);
         if (partnership.Device != null)
         {
             string winMoDeviceId = partnership.Device.WinMoDeviceId;
             long?  nullable      = (long?)DeviceSettings.Get(winMoDeviceId, "SyncCount");
             uint   num           = 0;
             if (nullable.HasValue)
             {
                 num = (uint)nullable.Value;
             }
             stream.SyncIndex = ++num;
             DeviceSettings.Set(winMoDeviceId, "SyncCount", num);
         }
         ISyncRules ruleManager = partnership.RuleManager;
         SetGlobalRules(stream, ruleManager);
         CalculateMusicSyncSelections(partnership.MusicAndMovieProvider, partnership.RuleManager, stream);
         this.CalculatePhotoSyncSelections(partnership.PhotoAndVideoProvider, partnership.RuleManager, stream);
         CalculateSyncResults(partnership, stream);
         stream.OperationTime = (uint)syncDuration.TotalMilliseconds;
         SetSyncResult(reason, stream);
         this.sqmManager.SetStream(stream);
     }
 }
 public SyncStoppedEventArgs(SyncStoppedReason reason)
 {
     this.Reason = reason;
 }