private void AddWorkItemMigrationDefault(EngineConfiguration ec) { var config = new WorkItemMigrationConfig { NodeBasePaths = new[] { "Product\\Area\\Path1", "Product\\Area\\Path2" } }; ec.Processors.Add(config); }
public WorkItemMigrationContext(MigrationEngine me, WorkItemMigrationConfig config) : base(me, config) { _config = config; PopulateIgnoreList(); VssClientCredentials adoCreds = new VssClientCredentials(); _witClient = new WorkItemTrackingHttpClient(me.Target.Collection.Uri, adoCreds); var workItemServer = me.Source.Collection.GetService <WorkItemServer>(); attachmentOMatic = new AttachmentOMatic(workItemServer, config.AttachmentWorkingPath); }
private WorkItem CreateAndPopulateWorkItem(WorkItemMigrationConfig config, WorkItem oldWi, Project destProject, String destType, WorkItem newwit = null) { Stopwatch fieldMappingTimer = new Stopwatch(); Trace.Write("... Building", "WorkItemMigrationContext"); var NewWorkItemstartTime = DateTime.UtcNow; Stopwatch NewWorkItemTimer = new Stopwatch(); var isNewWorkItem = true; if (newwit == null) { newwit = destProject.WorkItemTypes[destType].NewWorkItem(); newwit.Fields["System.ChangedDate"].Value = oldWi.Fields["System.ChangedDate"].Value; } else { newwit.Open(); isNewWorkItem = false; newwit.Fields["System.ChangedDate"].Value = DateTime.Now; newwit.Fields["Microsoft.VSTS.Common.StateChangeDate"].Value = DateTime.Now; } NewWorkItemTimer.Stop(); Telemetry.Current.TrackDependency("TeamService", "NewWorkItem", NewWorkItemstartTime, NewWorkItemTimer.Elapsed, true); Trace.WriteLine(string.Format("Dependancy: {0} - {1} - {2} - {3} - {4}", "TeamService", "NewWorkItem", NewWorkItemstartTime, NewWorkItemTimer.Elapsed, true), "WorkItemMigrationContext"); newwit.Title = oldWi.Title; newwit.State = oldWi.State; newwit.Reason = oldWi.Reason; foreach (Field f in oldWi.Fields) { if (newwit.Fields.Contains(f.ReferenceName) && !_ignore.Contains(f.ReferenceName) && newwit.Fields[f.ReferenceName].IsEditable) { newwit.Fields[f.ReferenceName].Value = oldWi.Fields[f.ReferenceName].Value; } } if (config.PrefixProjectToNodes) { newwit.AreaPath = string.Format(@"{0}\{1}", newwit.Project.Name, oldWi.AreaPath); newwit.IterationPath = string.Format(@"{0}\{1}", newwit.Project.Name, oldWi.IterationPath); } else { var regex = new Regex(Regex.Escape(oldWi.Project.Name)); newwit.AreaPath = regex.Replace(oldWi.AreaPath, newwit.Project.Name, 1); newwit.IterationPath = regex.Replace(oldWi.IterationPath, newwit.Project.Name, 1); } switch (destType) { case "Test Case": newwit.Fields["Microsoft.VSTS.TCM.Steps"].Value = oldWi.Fields["Microsoft.VSTS.TCM.Steps"].Value; newwit.Fields["Microsoft.VSTS.Common.Priority"].Value = oldWi.Fields["Microsoft.VSTS.Common.Priority"].Value; break; default: break; } if (newwit.Fields.Contains("Microsoft.VSTS.Common.BacklogPriority") && newwit.Fields["Microsoft.VSTS.Common.BacklogPriority"].Value != null && !isNumeric(newwit.Fields["Microsoft.VSTS.Common.BacklogPriority"].Value.ToString(), NumberStyles.Any)) { newwit.Fields["Microsoft.VSTS.Common.BacklogPriority"].Value = 10; } StringBuilder description = new StringBuilder(); description.Append(oldWi.Description); newwit.Description = description.ToString(); StringBuilder history = new StringBuilder(); BuildCommentTable(oldWi, history); if (isNewWorkItem) { BuildFieldTable(oldWi, history); } //history.Append("<p>Migrated by <a href='https://github.com/nkdAgility/VstsMigrator'>VSTS/TFS Sync Migration Tool</a> open source.</p>"); newwit.History = history.ToString(); fieldMappingTimer.Stop(); Telemetry.Current.TrackMetric("FieldMappingTime", fieldMappingTimer.ElapsedMilliseconds); Trace.WriteLine(string.Format("FieldMapOnNewWorkItem: {0} - {1}", NewWorkItemstartTime, fieldMappingTimer.Elapsed.ToString("c")), "WorkItemMigrationContext"); return(newwit); }
public WorkItemMigrationContext(MigrationEngine me, WorkItemMigrationConfig config) : base(me, config) { _me = me; _config = config; PopulateIgnoreList(me.IgnoreFields); }
public override void Configure(IProcessorConfig config) { _config = (WorkItemMigrationConfig)config; }
public override void Configure(IProcessorConfig config) { _config = (WorkItemMigrationConfig)config; validateConfig = Services.GetRequiredService <TfsValidateRequiredField>(); }