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; }
protected async override Task <bool> MigrateItemAsync(SingleMigrationWorkItem migrationItem) { var sucessFlag = false; var exponentialBackoffFactor = 5000; var retryCount = 3; await ExecutionSupports.Retry(async() => { await client.UpdateWorkItemFieldsAsync(migrationItem.WorkItemRef.Id, migrationItem.Fields); Insights.Trace($"{migrationItem.WorkItemRef.Id}", migrationItem.Fields); Insights.Debug("$Migrated item: {migrationItem.WorkItemRef.Id}"); sucessFlag = true; }, exception => { Insights.TrackException(exception); sucessFlag = false; }, exponentialBackoffFactor, retryCount); return(sucessFlag); }