Skip to content

Commit

Permalink
Merge pull request #46 from nkdAgility/topic/fix-exception
Browse files Browse the repository at this point in the history
Fix for null rferecne.
  • Loading branch information
MrHinsh authored Jul 11, 2024
2 parents f9d27c6 + f27463c commit 2da9872
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ await AnsiConsole.Progress()
var task3 = ctx.AddTask("[bold]Stage 3[/]: Get Target Project", false);
var task4 = ctx.AddTask("[bold]Stage 4[/]: Create Output Plan", false);
var task5 = ctx.AddTask("[bold]Stage 5[/]: Create Output Plan Relations ", false);
//var task51 = ctx.AddTask("[bold]Stage 5.1[/]: Validate Data ", false);
var task6 = ctx.AddTask("[bold]Stage 6[/]: Create Work Items", false);
string cacheTemplateWorkItemsFile = $"{config.CachePath}\\templateCache-{config.templateOrganization}-{config.templateProject}-{config.templateParentId}.json";
Expand Down Expand Up @@ -233,9 +234,12 @@ await AnsiConsole.Progress()
//AnsiConsole.WriteLine($"Stage 5: Completed second pass.");
// --------------------------------------------------------------
// Task 6: Create work items in target
task6.MaxValue = buildItems.Count();
int taskCount = 1;
AnsiConsole.WriteLine($"Processing {buildItems.Count()} items");
Expand Down Expand Up @@ -278,14 +282,15 @@ private async IAsyncEnumerable<WorkItemToBuild> generateWorkItemsToBuildList(JAr
foreach (var item in jsonWorkItems)
{
WorkItemFull templateWorkItem = null;
if (item["id"] != null)
int jsonItemTemplateId = 0;
if (int.TryParse(item["id"].Value<string>(),out jsonItemTemplateId))
{
templateWorkItem = templateWorkItems.Find(x => x.id == (int)item["id"]);
templateWorkItem = templateWorkItems.Find(x => x.id == jsonItemTemplateId);
}
WorkItemToBuild newItem = new WorkItemToBuild();
newItem.guid = Guid.NewGuid();
newItem.hasComplexRelation = false;
newItem.templateId = (int)item["id"];
newItem.templateId = jsonItemTemplateId;
newItem.workItemType = templateWorkItem != null ? templateWorkItem.fields.SystemWorkItemType : "Deliverable";
newItem.fields = new Dictionary<string, string>();
newItem.fields.Add("System.Description", templateWorkItem != null ? templateWorkItem.fields.SystemDescription : "");
Expand Down Expand Up @@ -325,7 +330,7 @@ private async IAsyncEnumerable<WorkItemToBuild> generateWorkItemsToBuildRelation
foreach (WorkItemToBuild item in workItemsToBuild)
{
WorkItemFull templateWorkItem = null;
if (item.templateId != null)
if (item.templateId != 0)
{
templateWorkItem = templateWorkItems.Find(x => x.id == item.templateId);
foreach (var relation in templateWorkItem.relations)
Expand Down

0 comments on commit 2da9872

Please sign in to comment.