protected async override Task PrepareMigrationAsync() { var sessionId = string.Empty; if (!string.IsNullOrWhiteSpace(options.SpecPath)) { if (!File.Exists(options.SpecPath)) { throw new ArgumentException($"'{nameof(options.SpecPath)}' points to a file ({options.SpecPath}) that doesn't exist."); } spec = Deserialize <WorkItemMigrationSpec>(File.ReadAllText(options.SpecPath)); sessionId = $"{nameof(WorkItemMigrationTask)}:{Guid.NewGuid()}"; } if (!string.IsNullOrWhiteSpace(options.Base64Content)) { var interopPayload = Deserialize <INTEROP_Payload>( UTF8Encoding.UTF8.GetString( Convert.FromBase64String(options.Base64Content))); spec = interopPayload.ConvertToSpec(); sessionId = interopPayload.Id; Insights.Debug($"Base64Content parsed: Session ID: {interopPayload.Id}"); Insights.Debug($"Body: {UTF8Encoding.UTF8.GetString(Convert.FromBase64String(options.Base64Content))}"); } Insights.InitializeSession(sessionId); client = GetWorkItemService(); await Task.CompletedTask; }
public WorkItemMigrationSpec ConvertToSpec() { var spec = new WorkItemMigrationSpec { Source = new MigrationSource { ProjectName = this.Source.Name, Query = this.Query }, Destination = new MigrationDestination { ProjectName = this.Destination.Name }, FieldMaps = new WorkItemMigrationMapping { AreaPath = new WorkItemFieldMigrationMap { Default = this.AreaPath.DefaultValue }, IterationPath = new WorkItemFieldMigrationMap { Default = this.IterationPath.DefaultValue }, WorkItemType = new WorkItemFieldMigrationMap { Default = this.WorkitemType.DefaultValue }, State = new WorkItemFieldMigrationMap { Default = this.State.DefaultValue } } }; if (this.AreaPath.Rules != null && this.AreaPath.Rules.Any()) { spec.FieldMaps.AreaPath.Rules.AddRange( this.AreaPath.Rules.Select(x => new FieldMapRuleSpec { SourcePattern = x.SourcePattern, Destination = x.Target })); } if (this.IterationPath.Rules != null && this.IterationPath.Rules.Any()) { spec.FieldMaps.IterationPath.Rules.AddRange( this.IterationPath.Rules.Select(x => new FieldMapRuleSpec { SourcePattern = x.SourcePattern, Destination = x.Target })); } if (this.WorkitemType.Rules != null && this.WorkitemType.Rules.Any()) { spec.FieldMaps.WorkItemType.Rules.AddRange( this.WorkitemType.Rules.Select(x => new FieldMapRuleSpec { SourcePattern = x.SourcePattern, Destination = x.Target })); } if (this.State.Rules != null && this.State.Rules.Any()) { spec.FieldMaps.State.Rules.AddRange( this.State.Rules.Select(x => new FieldMapRuleSpec { SourcePattern = x.SourcePattern, Destination = x.Target })); } return(spec); }