From c7bcb4a5eaaa23f3b26d124e74286d305eb24bd6 Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Wed, 4 Sep 2024 12:28:01 -0700 Subject: [PATCH] UpdateIteration --- .vscode/launch.json | 11 +++++----- Day/Q32024/Helper-2024-08-09.cs | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 97f39a7..cbdf429 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -13,17 +13,18 @@ "args": [ "s", "X", - "L:/DevOps/Mesa_FI/File-Folder-Helper/.vscode/helper/tfs", - "Day-Helper-2024-08-30", + "T:/MESAFIBACKLOG/06_SourceCode/MESAFIBACKLOG/Adaptation/.vscode/helper", + "Day-Helper-2024-08-09", "MES", "https://tfs.intra.infineon.com", "/tfs/FactoryIntegration", "ART SPS", "/0d06e969-e1f5-4835-a359-620d557c7595/_apis/wit", - "/wiql/28112411-4edf-44bb-adf3-ffbc4b402681", + "/wiql/3373b300-8de3-4301-9795-e990c3b226f9", "4n7d2jcql6bkq32f66tohddonfxajkypq66lm5y3zqemtlohawsa", - "https://tfs.intra.infineon.com/tfs/FactoryIntegration/0d06e969-e1f5-4835-a359-620d557c7595/_backlogs/backlog/LEO%20Team/Features/", - "https://tfs.intra.infineon.com/tfs/FactoryIntegration/0d06e969-e1f5-4835-a359-620d557c7595/_backlogs/backlog/MES%20Team/Features/" + "FI Backlog Mesa - Request List.json", + "Chase|infineon\\TuckerC,Dakota(SRP)|infineon\\Mitchem,Daniel|infineon\\StieberD,Jonathan|infineon\\Ouellette,Mike|infineon\\Phares", + "Chad B|infineon\\cbecker1,Debra Q|infineon\\Quinones,Jeanne M|infineon\\jmcinty2,Jessica F|infineon\\jfuente1,Jonathon S|infineon\\jsperli1,Justin H|infineon\\jhollan2,Kelly C|infineon\\kclark1,Mark C|infineon\\mcouste1,Marti J|infineon\\mjarsey1,Nik C|infineon\\nclark1,Peyton M|infineon\\McChesne,Ron O|infineon\\HendersS,Susan H|infineon\\HendersS,Tiffany M|infineon\\tmunoz1,Todd C|infineon\\tcarrie1" ], "cwd": "${workspaceFolder}", "console": "integratedTerminal", diff --git a/Day/Q32024/Helper-2024-08-09.cs b/Day/Q32024/Helper-2024-08-09.cs index 8ca69e6..61f8e7b 100644 --- a/Day/Q32024/Helper-2024-08-09.cs +++ b/Day/Q32024/Helper-2024-08-09.cs @@ -218,6 +218,41 @@ internal static partial class Helper20240809 } } + private static void UpdateIteration(HttpClient httpClient, + string basePage, + string api, + int id, + int rev) + { + string json = /*lang=json,strict*/ string.Concat("[ { \"op\": \"test\", \"path\": \"/rev\", \"value\": ", rev, " }, { \"op\": \"replace\", \"path\": \"/fields/System.IterationPath\", \"value\": \"ART SPS\" } ]"); + StringContent stringContent = new(json, Encoding.UTF8, "application/json-patch+json"); + string requestUri = string.Concat(basePage, api, $"/workitems/{id}?api-version=1.0"); + Task httpResponseMessageTask = httpClient.PatchAsync(requestUri, stringContent); + httpResponseMessageTask.Wait(); + if (!httpResponseMessageTask.Result.IsSuccessStatusCode) + throw new Exception(httpResponseMessageTask.Result.StatusCode.ToString()); + Task streamTask = httpResponseMessageTask.Result.Content.ReadAsStreamAsync(); + streamTask.Wait(); + if (!streamTask.Result.CanRead) + throw new NullReferenceException(nameof(streamTask)); + JsonElement? result = JsonSerializer.Deserialize(streamTask.Result); + if (result is null || result.Value.ValueKind != JsonValueKind.Object) + throw new NullReferenceException(nameof(result)); + } + + private static void UpdateAllFeaturesNotArtSPS(HttpClient httpClient, + string basePage, + string api, + ReadOnlyCollection valueWithReqCollection) + { + foreach (ValueWithReq valueWithReq in valueWithReqCollection) + { + if (valueWithReq.Value.Fields.SystemIterationPath != "ART SPS\\2024") + continue; + UpdateIteration(httpClient, basePage, api, valueWithReq.Value.Id, valueWithReq.Value.Rev); + } + } + private static DateTime? GetCommitDate(FIBacklogMesa fiBacklogMesa) { DateTime? result; @@ -587,6 +622,7 @@ internal static partial class Helper20240809 int updated = SetSyncTag(httpClient, basePage, api, workItemTrackingHttpClient, assignedToNameToUser, requestorNameToUser, keyToFIBacklogMesa, valueWithReqCollection); if (updated == 0) { + UpdateAllFeaturesNotArtSPS(httpClient, basePage, api, valueWithReqCollection); UpdateAllWorkItemsPharesComment(httpClient, basePage, api, sourceDirectory, keyToFIBacklogMesa, valueWithReqCollection); ReadOnlyCollection extra = RemoveFrom(keyToFIBacklogMesa, valueWithReqCollection); foreach (KeyValuePair keyValuePair in keyToFIBacklogMesa)