public override void Configure(IProcessorConfig config) { _config = (FixGitCommitLinksConfig)config; _GitRepositoryEnricher = new GitRepositoryEnricher(Engine); }
protected override void InternalExecute() { if (_config == null) { throw new Exception("You must call Configure() first"); } var workItemServer = Engine.Source.GetService <WorkItemServer>(); attachmentEnricher = new AttachmentMigrationEnricher(workItemServer, _config.AttachmentWorkingPath, _config.AttachmentMaxSize); embededImagesEnricher = new EmbededImagesRepairEnricher(); gitRepositoryEnricher = new GitRepositoryEnricher(Engine); nodeStructureEnricher = new NodeStructureEnricher(Engine); VssClientCredentials adoCreds = new VssClientCredentials(); _witClient = new WorkItemTrackingHttpClient(Engine.Target.Config.Collection, adoCreds); //Validation: make sure that the ReflectedWorkItemId field name specified in the config exists in the target process, preferably on each work item type. ConfigValidation(); PopulateIgnoreList(); nodeStructureEnricher.MigrateAllNodeStructures(_config.PrefixProjectToNodes, _config.NodeBasePaths); var stopwatch = Stopwatch.StartNew(); ////////////////////////////////////////////////// string sourceQuery = string.Format( @"SELECT [System.Id], [System.Tags] FROM WorkItems WHERE [System.TeamProject] = @TeamProject {0} ORDER BY {1}", _config.WIQLQueryBit, _config.WIQLOrderBit); var sourceWorkItems = Engine.Source.WorkItems.GetWorkItems(sourceQuery); contextLog.Information("Replay all revisions of {sourceWorkItemsCount} work items?", sourceWorkItems.Count); ////////////////////////////////////////////////// var destProject = Engine.Source.WorkItems.GetProject(); contextLog.Information("Found target project as {@destProject}", destProject.Name); //////////////////////////////////////////////////////////FilterCompletedByQuery if (_config.FilterWorkItemsThatAlreadyExistInTarget) { sourceWorkItems = FilterWorkItemsThatAlreadyExistInTarget(sourceWorkItems); } ////////////////////////////////////////////////// _current = 1; _count = sourceWorkItems.Count; _elapsedms = 0; _totalWorkItem = sourceWorkItems.Count; foreach (WorkItemData sourceWorkItemData in sourceWorkItems) { var sourceWorkItem = sourceWorkItemData.ToWorkItem(); workItemLog = contextLog.ForContext("SourceWorkItemId", sourceWorkItem.Id); using (LogContext.PushProperty("sourceWorkItemTypeName", sourceWorkItem.Type.Name)) using (LogContext.PushProperty("currentWorkItem", _current)) using (LogContext.PushProperty("totalWorkItems", _totalWorkItem)) using (LogContext.PushProperty("sourceWorkItemId", sourceWorkItem.Id)) using (LogContext.PushProperty("sourceRevisionInt", sourceWorkItem.Revision)) using (LogContext.PushProperty("targetWorkItemId", null)) { ProcessWorkItem(Engine.Source.WorkItems, Engine.Target.WorkItems, destProject, sourceWorkItemData, _config.WorkItemCreateRetryLimit); if (_config.PauseAfterEachWorkItem) { Console.WriteLine("Do you want to continue? (y/n)"); if (Console.ReadKey().Key != ConsoleKey.Y) { workItemLog.Warning("USER ABORTED"); break; } } } } ////////////////////////////////////////////////// stopwatch.Stop(); contextLog.Information("DONE in {Elapsed}", stopwatch.Elapsed.ToString("c")); }
public override void Configure(IProcessorConfig config) { _config = (FixGitCommitLinksConfig)config; _GitRepositoryEnricher = Services.GetRequiredService <GitRepositoryEnricher>(); }