UpdateIteration

This commit is contained in:
2024-09-04 12:28:01 -07:00
parent ee7841d9c3
commit c7bcb4a5ea
2 changed files with 42 additions and 5 deletions

View File

@ -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<HttpResponseMessage> httpResponseMessageTask = httpClient.PatchAsync(requestUri, stringContent);
httpResponseMessageTask.Wait();
if (!httpResponseMessageTask.Result.IsSuccessStatusCode)
throw new Exception(httpResponseMessageTask.Result.StatusCode.ToString());
Task<Stream> streamTask = httpResponseMessageTask.Result.Content.ReadAsStreamAsync();
streamTask.Wait();
if (!streamTask.Result.CanRead)
throw new NullReferenceException(nameof(streamTask));
JsonElement? result = JsonSerializer.Deserialize<JsonElement>(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<ValueWithReq> 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<ValueWithReq> extra = RemoveFrom(keyToFIBacklogMesa, valueWithReqCollection);
foreach (KeyValuePair<string, FIBacklogMesa> keyValuePair in keyToFIBacklogMesa)