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); } }
private static void SetSyncType(ISyncPartnership partnership, SyncStartType type, SqmSyncContentStream stream) { if (partnership.IsFirstSync) { stream.SyncType = SqmSyncType.FirstTimeSync; } else { switch (type) { case SyncStartType.AutoSync: stream.SyncType = SqmSyncType.AutoSync; return; case SyncStartType.ManualSync: stream.SyncType = SqmSyncType.ManualSync; return; case SyncStartType.Delete: stream.SyncType = SqmSyncType.Delete; return; case SyncStartType.CopyToPC: stream.SyncType = SqmSyncType.CopyToPC; return; case SyncStartType.SendRingtones: stream.SyncType = SqmSyncType.Ringtones; return; } } }
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 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(); } } }
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(); } } }
public void DoSync(SyncStartType syncStartType) { throw new NotImplementedException(); }