Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHinsh committed Sep 3, 2024
1 parent 9da1817 commit 8728530
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 32 deletions.
26 changes: 13 additions & 13 deletions docs/Reference/Generated/MigrationTools.Clients.TfsObjectModel.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions docs/Reference/Generated/MigrationTools.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
using Serilog.Context;
using Serilog.Events;
using ILogger = Serilog.ILogger;
using MigrationTools.Tools.Interfaces;

namespace MigrationTools.Processors
{
Expand All @@ -60,12 +61,12 @@ public class TfsWorkItemMigrationProcessor : TfsProcessor
private ILogger workItemLog;
private List<string> _itemsInError;

public TfsWorkItemMigrationProcessor(IOptions<TfsWorkItemOverwriteProcessorOptions> options, TfsCommonTools tfsCommonTools, ProcessorEnricherContainer processorEnrichers, IServiceProvider services, ITelemetryLogger telemetry, ILogger<TfsWorkItemMigrationProcessor> logger) : base(options, tfsCommonTools, processorEnrichers, services, telemetry, logger)
public TfsWorkItemMigrationProcessor(IOptions<TfsWorkItemMigrationProcessorOptions> options, TfsCommonTools tfsCommonTools, ProcessorEnricherContainer processorEnrichers, IServiceProvider services, ITelemetryLogger telemetry, ILogger<TfsWorkItemMigrationProcessor> logger) : base(options, tfsCommonTools, processorEnrichers, services, telemetry, logger)
{
contextLog = Serilog.Log.ForContext<TfsWorkItemMigrationProcessor>();
}

new TfsWorkItemOverwriteProcessorOptions Options => (TfsWorkItemOverwriteProcessorOptions)base.Options;
new TfsWorkItemMigrationProcessorOptions Options => (TfsWorkItemMigrationProcessorOptions)base.Options;

new TfsTeamProjectEndpoint Source => (TfsTeamProjectEndpoint)base.Source;

Expand Down Expand Up @@ -277,8 +278,7 @@ private void ValidateAllWorkItemTypesHaveReflectedWorkItemIdField(List<WorkItemD
private void ValiddateWorkItemTypesExistInTarget(List<WorkItemData> sourceWorkItems)
{
contextLog.Information("Validating::Check that all work item types needed in the Target exist or are mapped");
var workItemTypeMappingTool = Services.GetRequiredService<WorkItemTypeMappingTool>();
// get list of all work item types
// get list of all work item types
List<String> sourceWorkItemTypes = sourceWorkItems.SelectMany(x => x.Revisions.Values)
//.Where(x => x.Fields[fieldName].Value.ToString().Contains("\\"))
.Select(x => x.Type)
Expand All @@ -299,7 +299,7 @@ private void ValiddateWorkItemTypesExistInTarget(List<WorkItemData> sourceWorkIt
foreach (var missingWorkItemType in missingWorkItemTypes)
{
bool thisTypeMapped = true;
if (!workItemTypeMappingTool.Mappings.ContainsKey(missingWorkItemType))
if (!CommonTools.WorkItemTypeMapping.Mappings.ContainsKey(missingWorkItemType))
{
thisTypeMapped = false;
}
Expand Down Expand Up @@ -664,7 +664,6 @@ private void ProcessWorkItemLinks(IWorkItemMigrationClient sourceStore, IWorkIte

private WorkItemData ReplayRevisions(List<RevisionItem> revisionsToMigrate, WorkItemData sourceWorkItem, WorkItemData targetWorkItem)
{
var workItemTypeMappingTool = Services.GetRequiredService<WorkItemTypeMappingTool>();
try
{
//If work item hasn't been created yet, create a shell
Expand All @@ -678,9 +677,9 @@ private WorkItemData ReplayRevisions(List<RevisionItem> 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);
}
Expand All @@ -701,9 +700,9 @@ private WorkItemData ReplayRevisions(List<RevisionItem> 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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace MigrationTools.Processors
{

public class TfsWorkItemOverwriteProcessorOptions : ProcessorOptions, IWorkItemProcessorConfig
public class TfsWorkItemMigrationProcessorOptions : ProcessorOptions, IWorkItemProcessorConfig
{


Expand Down
1 change: 1 addition & 0 deletions src/MigrationTools.Clients.TfsObjectModel/TfsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using MigrationTools.Processors;
using MigrationTools.Processors.Infrastructure;
using MigrationTools.Tools.Infrastructure;
using MigrationTools.Tools.Interfaces;

namespace MigrationTools.Tools
{
Expand All @@ -27,7 +28,7 @@ public TfsValidateRequiredFieldTool(IOptions<TfsValidateRequiredFieldToolOptions

public bool ValidatingRequiredField(TfsProcessor processor, string fieldToFind, List<WorkItemData> sourceWorkItems)
{
var workItemTypeMappingTool = Services.GetRequiredService<WorkItemTypeMappingTool>();
var workItemTypeMappingTool = Services.GetRequiredService<IWorkItemTypeMappingTool>();
var sourceWorkItemTypes = sourceWorkItems.Select(wid => wid.ToWorkItem().Type).Distinct();
var targetTypes = processor.Target.WorkItems.Project.ToProject().WorkItemTypes;
var result = true;
Expand Down
7 changes: 6 additions & 1 deletion src/MigrationTools/Services/TelemetryClientAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class TelemetryClientAdapter : ITelemetryLogger

public TelemetryClientAdapter(IMigrationToolVersion migrationToolVersion)
{

_MigrationToolVersion = migrationToolVersion;
elmahIoClient = ElmahioAPI.Create("7589821e832a4ae1a1170f8201def634", new ElmahIoOptions
{
Timeout = TimeSpan.FromSeconds(30),
Expand Down Expand Up @@ -68,6 +68,11 @@ public void TrackException(Exception ex, IDictionary<string, string> properties)

public void TrackException(Exception ex, IEnumerable<KeyValuePair<string, string>> properties = null)
{
if (properties == null)
{
TrackException(ex, null);
return;
}
TrackException(ex, properties.ToDictionary(k => k.Key, v => v.Value));
}

Expand Down

0 comments on commit 8728530

Please sign in to comment.