diff --git a/docs/Reference/Generated/MigrationTools.Clients.TfsObjectModel.xml b/docs/Reference/Generated/MigrationTools.Clients.TfsObjectModel.xml index 85083cf5c..1b9693a43 100644 --- a/docs/Reference/Generated/MigrationTools.Clients.TfsObjectModel.xml +++ b/docs/Reference/Generated/MigrationTools.Clients.TfsObjectModel.xml @@ -234,7 +234,7 @@ ready Work Items - + If this is enabled the creation process on the target project will create the items with the original creation date. (Important: The item history is always pointed to the date of the migration, it's change only the data column CreateDate, @@ -242,7 +242,7 @@ true - + If this is enabled the creation process on the target project will create the items with the original creation date. (Important: The item history is always pointed to the date of the migration, it's change only the data column CreateDate, @@ -250,13 +250,13 @@ true - + A work item query based on WIQL to select only important work items. To migrate all leave this empty. See [WIQL Query Bits](#wiql-query-bits) SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [[System.WorkItemType] NOT IN ('Test Suite', 'Test Plan','Shared Steps','Shared Parameter','Feedback Request') ORDER BY [System.ChangedDate] desc - + **beta** If enabled this will fix any image attachments URL's, work item mention URL's or user mentions in the HTML fields as well as discussion comments. You must specify a PersonalAccessToken in the Source project for Azure DevOps; @@ -264,57 +264,57 @@ ? - + **beta** If set to a number greater than 0 work items that fail to save will retry after a number of seconds equal to the retry count. This allows for periodic network glitches not to end the process. 5 - + This loads all of the work items already saved to the Target and removes them from the Source work item list prior to commencing the run. While this may take some time in large data sets it reduces the time of the overall migration significantly if you need to restart. true - + Pause after each work item is migrated false - + This will create a json file with the revision history and attach it to the work item. Best used with `MaxRevisions` or `ReplayRevisions`. ? - + If enabled, adds a comment recording the migration false - + A list of work items to import [] - + The maximum number of failures to tolerate before the migration fails. When set above zero, a work item migration error is logged but the migration will continue until the number of failed items reaches the configured value, after which the migration fails. 0 - + This will skip a revision if the source iteration has not been migrated i.e. it was deleted - + When set to true, this setting will skip a revision if the source area has not been migrated, has been deleted or is somehow invalid, etc. diff --git a/docs/Reference/Generated/MigrationTools.xml b/docs/Reference/Generated/MigrationTools.xml index c4eff3a1b..852c1ecc6 100644 --- a/docs/Reference/Generated/MigrationTools.xml +++ b/docs/Reference/Generated/MigrationTools.xml @@ -263,27 +263,27 @@ - => @"98df924d" + => @"9da18171" - => @"98df924d09b8dc4a6119dc205362104fa34ebde5" + => @"9da18171b9a1938f37b1bf62e4ac8a7e63e2706e" - => @"2024-09-03T14:43:07+01:00" + => @"2024-09-03T15:15:23+01:00" - => @"2" + => @"7" - => @"v16.0.0-Preview.6-2-g98df924d" + => @"v16.0.0-Preview.6-7-g9da18171" @@ -318,7 +318,7 @@ - => @"2" + => @"7" diff --git a/src/MigrationTools.Clients.TfsObjectModel/Processors/TfsWorkItemMigrationProcessor.cs b/src/MigrationTools.Clients.TfsObjectModel/Processors/TfsWorkItemMigrationProcessor.cs index acfb56a2f..26cbf2afa 100644 --- a/src/MigrationTools.Clients.TfsObjectModel/Processors/TfsWorkItemMigrationProcessor.cs +++ b/src/MigrationTools.Clients.TfsObjectModel/Processors/TfsWorkItemMigrationProcessor.cs @@ -37,6 +37,7 @@ using Serilog.Context; using Serilog.Events; using ILogger = Serilog.ILogger; +using MigrationTools.Tools.Interfaces; namespace MigrationTools.Processors { @@ -60,12 +61,12 @@ public class TfsWorkItemMigrationProcessor : TfsProcessor private ILogger workItemLog; private List _itemsInError; - public TfsWorkItemMigrationProcessor(IOptions options, TfsCommonTools tfsCommonTools, ProcessorEnricherContainer processorEnrichers, IServiceProvider services, ITelemetryLogger telemetry, ILogger logger) : base(options, tfsCommonTools, processorEnrichers, services, telemetry, logger) + public TfsWorkItemMigrationProcessor(IOptions options, TfsCommonTools tfsCommonTools, ProcessorEnricherContainer processorEnrichers, IServiceProvider services, ITelemetryLogger telemetry, ILogger logger) : base(options, tfsCommonTools, processorEnrichers, services, telemetry, logger) { contextLog = Serilog.Log.ForContext(); } - new TfsWorkItemOverwriteProcessorOptions Options => (TfsWorkItemOverwriteProcessorOptions)base.Options; + new TfsWorkItemMigrationProcessorOptions Options => (TfsWorkItemMigrationProcessorOptions)base.Options; new TfsTeamProjectEndpoint Source => (TfsTeamProjectEndpoint)base.Source; @@ -277,8 +278,7 @@ private void ValidateAllWorkItemTypesHaveReflectedWorkItemIdField(List sourceWorkItems) { contextLog.Information("Validating::Check that all work item types needed in the Target exist or are mapped"); - var workItemTypeMappingTool = Services.GetRequiredService(); - // get list of all work item types + // get list of all work item types List sourceWorkItemTypes = sourceWorkItems.SelectMany(x => x.Revisions.Values) //.Where(x => x.Fields[fieldName].Value.ToString().Contains("\\")) .Select(x => x.Type) @@ -299,7 +299,7 @@ private void ValiddateWorkItemTypesExistInTarget(List sourceWorkIt foreach (var missingWorkItemType in missingWorkItemTypes) { bool thisTypeMapped = true; - if (!workItemTypeMappingTool.Mappings.ContainsKey(missingWorkItemType)) + if (!CommonTools.WorkItemTypeMapping.Mappings.ContainsKey(missingWorkItemType)) { thisTypeMapped = false; } @@ -664,7 +664,6 @@ private void ProcessWorkItemLinks(IWorkItemMigrationClient sourceStore, IWorkIte private WorkItemData ReplayRevisions(List revisionsToMigrate, WorkItemData sourceWorkItem, WorkItemData targetWorkItem) { - var workItemTypeMappingTool = Services.GetRequiredService(); try { //If work item hasn't been created yet, create a shell @@ -678,9 +677,9 @@ private WorkItemData ReplayRevisions(List revisionsToMigrate, Work TraceWriteLine(LogEventLevel.Information, $"WorkItem has changed type at one of the revisions, from {targetType} to {finalDestType}"); } - if (workItemTypeMappingTool.Mappings.ContainsKey(targetType)) + if (CommonTools.WorkItemTypeMapping.Mappings.ContainsKey(targetType)) { - targetType = workItemTypeMappingTool.Mappings[targetType]; + targetType = CommonTools.WorkItemTypeMapping.Mappings[targetType]; } targetWorkItem = CreateWorkItem_Shell(Target.WorkItems.Project, sourceWorkItem, targetType); } @@ -701,9 +700,9 @@ private WorkItemData ReplayRevisions(List revisionsToMigrate, Work // Decide on WIT var destType = currentRevisionWorkItem.Type; - if (workItemTypeMappingTool.Mappings.ContainsKey(destType)) + if (CommonTools.WorkItemTypeMapping.Mappings.ContainsKey(destType)) { - destType = workItemTypeMappingTool.Mappings[destType]; + destType = CommonTools.WorkItemTypeMapping.Mappings[destType]; } bool typeChange = (destType != targetWorkItem.Type); diff --git a/src/MigrationTools.Clients.TfsObjectModel/Processors/TfsWorkItemMigrationProcessorOptions.cs b/src/MigrationTools.Clients.TfsObjectModel/Processors/TfsWorkItemMigrationProcessorOptions.cs index 9a0ac5789..e20be9559 100644 --- a/src/MigrationTools.Clients.TfsObjectModel/Processors/TfsWorkItemMigrationProcessorOptions.cs +++ b/src/MigrationTools.Clients.TfsObjectModel/Processors/TfsWorkItemMigrationProcessorOptions.cs @@ -8,7 +8,7 @@ namespace MigrationTools.Processors { - public class TfsWorkItemOverwriteProcessorOptions : ProcessorOptions, IWorkItemProcessorConfig + public class TfsWorkItemMigrationProcessorOptions : ProcessorOptions, IWorkItemProcessorConfig { diff --git a/src/MigrationTools.Clients.TfsObjectModel/TfsExtensions.cs b/src/MigrationTools.Clients.TfsObjectModel/TfsExtensions.cs index 28d4381cc..fb2b6aa3d 100644 --- a/src/MigrationTools.Clients.TfsObjectModel/TfsExtensions.cs +++ b/src/MigrationTools.Clients.TfsObjectModel/TfsExtensions.cs @@ -37,6 +37,7 @@ public static WorkItemData GetRevision(this WorkItemData context, int rev) { // internalObject = context.internalObject // TODO: Had to revert to calling revision load again untill WorkItemMigrationContext.PopulateWorkItem can be updated to pull from WorkItemData + internalObject = originalWi.Store.GetWorkItem(originalWi.Id, rev) }; diff --git a/src/MigrationTools.Clients.TfsObjectModel/Tools/TfsValidateRequiredFieldTool.cs b/src/MigrationTools.Clients.TfsObjectModel/Tools/TfsValidateRequiredFieldTool.cs index 149eaef5e..b5b9f0063 100644 --- a/src/MigrationTools.Clients.TfsObjectModel/Tools/TfsValidateRequiredFieldTool.cs +++ b/src/MigrationTools.Clients.TfsObjectModel/Tools/TfsValidateRequiredFieldTool.cs @@ -11,6 +11,7 @@ using MigrationTools.Processors; using MigrationTools.Processors.Infrastructure; using MigrationTools.Tools.Infrastructure; +using MigrationTools.Tools.Interfaces; namespace MigrationTools.Tools { @@ -27,7 +28,7 @@ public TfsValidateRequiredFieldTool(IOptions sourceWorkItems) { - var workItemTypeMappingTool = Services.GetRequiredService(); + var workItemTypeMappingTool = Services.GetRequiredService(); var sourceWorkItemTypes = sourceWorkItems.Select(wid => wid.ToWorkItem().Type).Distinct(); var targetTypes = processor.Target.WorkItems.Project.ToProject().WorkItemTypes; var result = true; diff --git a/src/MigrationTools/Services/TelemetryClientAdapter.cs b/src/MigrationTools/Services/TelemetryClientAdapter.cs index 393108398..17aaea2e5 100644 --- a/src/MigrationTools/Services/TelemetryClientAdapter.cs +++ b/src/MigrationTools/Services/TelemetryClientAdapter.cs @@ -17,7 +17,7 @@ public class TelemetryClientAdapter : ITelemetryLogger public TelemetryClientAdapter(IMigrationToolVersion migrationToolVersion) { - + _MigrationToolVersion = migrationToolVersion; elmahIoClient = ElmahioAPI.Create("7589821e832a4ae1a1170f8201def634", new ElmahIoOptions { Timeout = TimeSpan.FromSeconds(30), @@ -68,6 +68,11 @@ public void TrackException(Exception ex, IDictionary properties) public void TrackException(Exception ex, IEnumerable> properties = null) { + if (properties == null) + { + TrackException(ex, null); + return; + } TrackException(ex, properties.ToDictionary(k => k.Key, v => v.Value)); }