void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorkerArgs args = (BackgroundWorkerArgs)e.Argument; IMigrationService migrationService = (IMigrationService)MigrationServiceManager.GetService(typeof(IMigrationService)); switch (args.Task) { case BackgroundWorkerTask.Start: migrationService.StartSessionGroup(args.SessionGroupUniqueId); e.Result = args; break; case BackgroundWorkerTask.Resume: migrationService.ResumeSessionGroup(args.SessionGroupUniqueId); break; case BackgroundWorkerTask.Stop: migrationService.StopSessionGroup(args.SessionGroupUniqueId); break; case BackgroundWorkerTask.Pause: migrationService.PauseSessionGroup(args.SessionGroupUniqueId); break; } }
void m_refreshBW_DoWork(object sender, DoWorkEventArgs e) { IMigrationService migrationService = (IMigrationService)MigrationServiceManager.GetService(typeof(IMigrationService)); SessionGroupInitializationStatus status = SessionGroupInitializationStatus.Unknown; if (DataModel != null && DataModel.Configuration != null) { status = migrationService.GetSessionGroupInitializationStatus(DataModel.Configuration.SessionGroupUniqueId); } switch (status) { case SessionGroupInitializationStatus.Initialized: if (migrationService.GetRunningSessionGroups().Contains(DataModel.Configuration.SessionGroupUniqueId)) { ISyncStateManager stateManager = SqlSyncStateManager.GetInstance(); PipelineState newPipelineState = stateManager.GetCurrentState(OwnerType.SessionGroup, DataModel.Configuration.SessionGroupUniqueId); if (s_canTransitionFrom[(int)m_currentPipelineState, (int)newPipelineState]) { e.Result = newPipelineState; } else { Console.WriteLine("Cannot transition from " + m_currentPipelineState + " to " + newPipelineState); } IsCompleted = false; } else { e.Result = PipelineState.Default; using (Microsoft.TeamFoundation.Migration.EntityModel.RuntimeEntityModel context = Microsoft.TeamFoundation.Migration.EntityModel.RuntimeEntityModel.CreateInstance()) { var query = from sg in context.RTSessionGroupSet where sg.GroupUniqueId.Equals(DataModel.Configuration.SessionGroupUniqueId) select sg.State; int?state = query.FirstOrDefault(); if (state != null && (Microsoft.TeamFoundation.Migration.BusinessModel.BusinessModelManager.SessionStateEnum)state == BusinessModelManager.SessionStateEnum.Completed && ConflictManager != null && ConflictManager.TotalConflicts == 0) { IsCompleted = true; } else { IsCompleted = false; } } } break; case SessionGroupInitializationStatus.Initializing: IsCompleted = false; break; case SessionGroupInitializationStatus.NotInitialized: case SessionGroupInitializationStatus.Unknown: e.Result = PipelineState.Default; IsCompleted = false; break; } }