/// <summary> /// Migrates the shared steps from source to destination. /// </summary> private void MigrateSharedStepsFromSourceToDestinationInternal() { if (!string.IsNullOrEmpty(this.MigrationSharedStepsRetryJsonPath) && File.Exists(this.MigrationSharedStepsRetryJsonPath)) { this.sharedStepsMigrationLogManager = new MigrationLogManager(this.MigrationSharedStepsRetryJsonPath); this.sharedStepsMigrationLogManager.LoadCollectionFromExistingFile(); this.sharedStepsMapping = this.sharedStepsMigrationLogManager.GetProssedItemsMappings(); } else { this.sharedStepsMigrationLogManager = new MigrationLogManager("sharedSteps", this.DefaultJsonFolder); } List <SharedStep> sourceSharedSteps = SharedStepManager.GetAllSharedStepsInTestPlan(this.sourceTeamProject); foreach (SharedStep currentSourceSharedStep in sourceSharedSteps) { if (this.executionCancellationToken.IsCancellationRequested) { break; } // If it's already processed skip it if (this.sharedStepsMigrationLogManager.MigrationEntries.Count(e => e.SourceId.Equals(currentSourceSharedStep.ISharedStep.Id) && e.IsProcessed.Equals(true)) > 0) { continue; } string infoMessage = String.Empty; try { infoMessage = String.Format("Start Migrating Shared Step with Source Id= {0}", currentSourceSharedStep.Id); log.Info(infoMessage); this.ProgressConcurrentQueue.Enqueue(infoMessage); List <TestStep> testSteps = TestStepManager.GetTestStepsFromTestActions(this.sourceTeamProject, currentSourceSharedStep.ISharedStep.Actions); SharedStep newSharedStep = currentSourceSharedStep.Save(this.destinationTeamProject, true, testSteps, false); newSharedStep.ISharedStep.Refresh(); this.sharedStepsMapping.Add(currentSourceSharedStep.ISharedStep.Id, newSharedStep.ISharedStep.Id); this.sharedStepsMigrationLogManager.Log(currentSourceSharedStep.Id, newSharedStep.ISharedStep.Id, true); infoMessage = String.Format("Shared Step Migrated SUCCESSFULLY: Source Id= {0}, Destination Id= {1}", currentSourceSharedStep.Id, newSharedStep.ISharedStep.Id); log.Info(infoMessage); this.ProgressConcurrentQueue.Enqueue(infoMessage); } catch (Exception ex) { this.sharedStepsMigrationLogManager.Log(currentSourceSharedStep.Id, -1, false, ex.Message); log.Error(ex); this.ProgressConcurrentQueue.Enqueue(ex.Message); } finally { this.sharedStepsMigrationLogManager.Save(); this.MigrationSharedStepsRetryJsonPath = this.sharedStepsMigrationLogManager.FullResultFilePath; } } this.IsSharedStepsMigrationFinished = true; }
/// <summary> /// Refreshes the shared steps /// </summary> public void RefreshSharedSteps() { this.ObservableSharedSteps.Clear(); ExecutionContext.Preferences.TestPlan.Refresh(); ExecutionContext.Preferences.TestPlan.RootSuite.Refresh(); List <SharedStep> sharedStepsList = SharedStepManager.GetAllSharedStepsInTestPlan(ExecutionContext.TestManagementTeamProject); sharedStepsList.Sort(); sharedStepsList.ForEach(t => this.ObservableSharedSteps.Add(t)); }
/// <summary> /// Initializes a new instance of the <see cref="TestCasesBatchDuplicateViewModel"/> class. /// </summary> public TestCasesBatchDuplicateViewModel(bool loadTestCases, bool loadSpecificTestCases) { this.InitializeInnerCollections(); this.loadTestCases = loadTestCases; this.ShowTestCaseSpecificFields = loadTestCases; this.InitializeTeamFoundationIdentityNames(); this.ReplaceContext = new ReplaceContext(); if (loadTestCases) { if (!loadSpecificTestCases) { this.InitializeTestCases(); } else { this.InitializeTestCasesFromSpecificSelectedTestCases(); } this.InitializeInitialTestCaseCollection(); this.EntitiesCount = this.ObservableTestCases.Count.ToString(); this.InitializeTestSuiteList(); this.ReplaceContext.SelectedSuite = this.ObservableTestSuites[0]; } else { this.ObservableSharedSteps = new ObservableCollection <SharedStep>(); List <SharedStep> allSharedSteps = SharedStepManager.GetAllSharedStepsInTestPlan(ExecutionContext.TestManagementTeamProject); allSharedSteps.ForEach(s => this.ObservableSharedSteps.Add(s)); this.InitialSharedStepsCollection = new ObservableCollection <SharedStep>(); allSharedSteps.ForEach(s => this.InitialSharedStepsCollection.Add(s)); this.EntitiesCount = this.ObservableSharedSteps.Count.ToString(); } if (this.ObservableTeamFoundationIdentityNames.Count > 0) { this.ReplaceContext.SelectedTeamFoundationIdentityName = this.ObservableTeamFoundationIdentityNames[0]; } this.SelectedEntitiesCount = "0"; var setting = SearchQueryCompilerBuilder.Instance.BuildUpDefaultObjectCompilerSetting <TestCase>(); testCasesCompiler = SearchQueryCompilerBuilder.Instance.BuildUpCompiler <TestCase>(setting); var sharedSteposSetting = SearchQueryCompilerBuilder.Instance.BuildUpDefaultObjectCompilerSetting <SharedStep>(); sharedStepsCompiler = SearchQueryCompilerBuilder.Instance.BuildUpCompiler <SharedStep>(sharedSteposSetting); }