ADO System Parent

This commit is contained in:
Mike Phares 2024-09-11 12:24:45 -07:00
parent d2cc0c0e0b
commit 5d679ae04c
4 changed files with 49 additions and 20 deletions

22
.vscode/launch.json vendored
View File

@ -13,17 +13,17 @@
"args": [
"s",
"X",
"\\\\mesfs.infineon.com\\EC_EAFLog\\Staging\\Logs\\EAF-Info-Warn-002-020-010\\T41",
"Day-Helper-2024-09-10",
"*.log*",
"333",
"444",
"555",
"666",
"777",
"888",
"999"
],
"L:/DevOps/Mesa_FI/File-Folder-Helper/.vscode/helper/tfs",
"Day-Helper-2024-08-30",
"MES",
"https://tfs.intra.infineon.com",
"/tfs/FactoryIntegration",
"ART SPS",
"/0d06e969-e1f5-4835-a359-620d557c7595/_apis/wit",
"/wiql/3373b300-8de3-4301-9795-e990c3b226f9",
"4n7d2jcql6bkq32f66tohddonfxajkypq66lm5y3zqemtlohawsa",
"FI Backlog Mesa - Request List.json"
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"stopAtEntry": false

View File

@ -25,7 +25,9 @@ internal static partial class Helper20240830
float? Effort,
int Id,
string IterationPath,
int? Parent,
int? Priority,
object[] Relations,
string? Requester,
DateTime? ResolvedDate,
int Revision,
@ -68,6 +70,21 @@ internal static partial class Helper20240830
return result.ToString();
}
private static void GetSingle(HttpClient httpClient, string basePage, string api, string targetFileLocation, int id)
{
Task<HttpResponseMessage> httpResponseMessageTask = httpClient.GetAsync(string.Concat(basePage, api, $"/workitems/{id}?%24expand=1"));
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);
string file = Path.Combine(targetFileLocation, $"{-9}-{id}.json");
File.WriteAllText(file, result.ToString());
}
private static ReadOnlyCollection<ValueWithReq> GetWorkItems(HttpClient httpClient, string basePage, string api, string targetFileLocation, string ids)
{
List<ValueWithReq> results = [];
@ -75,7 +92,7 @@ internal static partial class Helper20240830
string file;
Value? value;
JsonElement[] jsonElements;
Task<HttpResponseMessage> httpResponseMessageTask = httpClient.GetAsync(string.Concat(basePage, api, $"/workitems?ids={ids}"));
Task<HttpResponseMessage> httpResponseMessageTask = httpClient.GetAsync(string.Concat(basePage, api, $"/workitems?ids={ids}&$expand=Relations"));
httpResponseMessageTask.Wait();
if (!httpResponseMessageTask.Result.IsSuccessStatusCode)
throw new Exception(httpResponseMessageTask.Result.StatusCode.ToString());
@ -98,6 +115,8 @@ internal static partial class Helper20240830
value = JsonSerializer.Deserialize(json, ValueSourceGenerationContext.Default.Value);
if (value is null)
continue;
if (value.Id == 120593)
GetSingle(httpClient, basePage, api, targetFileLocation, value.Id);
file = Path.Combine(targetFileLocation, $"{-1}-{value.Id}.json");
File.WriteAllText(file, json);
results.Add(new(value, -1, json));
@ -125,7 +144,9 @@ internal static partial class Helper20240830
fields.MicrosoftVSTSSchedulingEffort == 0 ? null : fields.MicrosoftVSTSSchedulingEffort,
valueWithReq.Value.Id,
fields.SystemIterationPath,
fields.SystemParent == 0 ? null : fields.SystemParent,
fields.MicrosoftVSTSCommonPriority == 0 ? null : fields.MicrosoftVSTSCommonPriority,
valueWithReq.Value.Relations,
fields.CustomRequester?.DisplayName,
fields.MicrosoftVSTSCommonResolvedDate == DateTime.MinValue ? null : fields.MicrosoftVSTSCommonResolvedDate,
valueWithReq.Value.Rev,

View File

@ -8,14 +8,15 @@ public class Fields
public Fields(int customRRminusOE,
CustomRequester? customRequester,
float customWSJF,
float? microsoftVSTSSchedulingEffort,
int microsoftVSTSCommonBusinessValue,
DateTime microsoftVSTSCommonClosedDate,
int microsoftVSTSCommonPriority,
DateTime microsoftVSTSCommonResolvedDate,
DateTime microsoftVSTSCommonStateChangeDate,
float microsoftVSTSCommonTimeCriticality,
float? microsoftVSTSSchedulingEffort,
DateTime microsoftVSTSSchedulingStartDate,
DateTime microsoftVSTSSchedulingTargetDate,
string systemAreaPath,
SystemAssignedTo systemAssignedTo,
SystemChangedBy systemChangedBy,
@ -26,25 +27,26 @@ public class Fields
string systemDescription,
string systemHistory,
string systemIterationPath,
int systemParent,
string systemReason,
string systemState,
string systemTags,
string systemTeamProject,
string systemTitle,
string systemWorkItemType,
DateTime microsoftVSTSSchedulingTargetDate)
string systemWorkItemType)
{
CustomRRminusOE = customRRminusOE;
CustomRequester = customRequester;
CustomRRminusOE = customRRminusOE;
CustomWSJF = customWSJF;
MicrosoftVSTSSchedulingEffort = microsoftVSTSSchedulingEffort;
MicrosoftVSTSCommonBusinessValue = microsoftVSTSCommonBusinessValue;
MicrosoftVSTSCommonClosedDate = microsoftVSTSCommonClosedDate;
MicrosoftVSTSCommonPriority = microsoftVSTSCommonPriority;
MicrosoftVSTSCommonResolvedDate = microsoftVSTSCommonResolvedDate;
MicrosoftVSTSCommonStateChangeDate = microsoftVSTSCommonStateChangeDate;
MicrosoftVSTSCommonTimeCriticality = microsoftVSTSCommonTimeCriticality;
MicrosoftVSTSSchedulingEffort = microsoftVSTSSchedulingEffort;
MicrosoftVSTSSchedulingStartDate = microsoftVSTSSchedulingStartDate;
MicrosoftVSTSSchedulingTargetDate = microsoftVSTSSchedulingTargetDate;
SystemAreaPath = systemAreaPath;
SystemAssignedTo = systemAssignedTo;
SystemChangedBy = systemChangedBy;
@ -55,17 +57,17 @@ public class Fields
SystemDescription = systemDescription;
SystemHistory = systemHistory;
SystemIterationPath = systemIterationPath;
SystemParent = systemParent;
SystemReason = systemReason;
SystemState = systemState;
SystemTags = systemTags;
SystemTeamProject = systemTeamProject;
SystemTitle = systemTitle;
SystemWorkItemType = systemWorkItemType;
MicrosoftVSTSSchedulingTargetDate = microsoftVSTSSchedulingTargetDate;
}
[JsonPropertyName("Custom.RRminusOE")] public int CustomRRminusOE { get; } // { init; get; }
[JsonPropertyName("Custom.Requester")] public CustomRequester? CustomRequester { get; } // { init; get; }
[JsonPropertyName("Custom.RRminusOE")] public int CustomRRminusOE { get; } // { init; get; }
[JsonPropertyName("Custom.WSJF")] public float CustomWSJF { get; } // { init; get; }
[JsonPropertyName("Microsoft.VSTS.Common.BusinessValue")] public int MicrosoftVSTSCommonBusinessValue { get; } // { init; get; }
[JsonPropertyName("Microsoft.VSTS.Common.ClosedDate")] public DateTime MicrosoftVSTSCommonClosedDate { get; } // { init; get; }
@ -75,6 +77,7 @@ public class Fields
[JsonPropertyName("Microsoft.VSTS.Common.TimeCriticality")] public float MicrosoftVSTSCommonTimeCriticality { get; } // { init; get; }
[JsonPropertyName("Microsoft.VSTS.Scheduling.Effort")] public float? MicrosoftVSTSSchedulingEffort { get; } // { init; get; }
[JsonPropertyName("Microsoft.VSTS.Scheduling.StartDate")] public DateTime MicrosoftVSTSSchedulingStartDate { get; } // { init; get; }
[JsonPropertyName("Microsoft.VSTS.Scheduling.TargetDate")] public DateTime MicrosoftVSTSSchedulingTargetDate { get; } // { init; get; }
[JsonPropertyName("System.AreaPath")] public string SystemAreaPath { get; } // { init; get; }
[JsonPropertyName("System.AssignedTo")] public SystemAssignedTo? SystemAssignedTo { get; } // { init; get; }
[JsonPropertyName("System.ChangedBy")] public SystemChangedBy SystemChangedBy { get; } // { init; get; }
@ -85,12 +88,12 @@ public class Fields
[JsonPropertyName("System.Description")] public string SystemDescription { get; } // { init; get; }
[JsonPropertyName("System.History")] public string SystemHistory { get; } // { init; get; }
[JsonPropertyName("System.IterationPath")] public string SystemIterationPath { get; } // { init; get; }
[JsonPropertyName("System.Parent")] public int SystemParent { get; } // { init; get; }
[JsonPropertyName("System.Reason")] public string SystemReason { get; } // { init; get; }
[JsonPropertyName("System.State")] public string SystemState { get; } // { init; get; }
[JsonPropertyName("System.Tags")] public string SystemTags { get; } // { init; get; }
[JsonPropertyName("System.TeamProject")] public string SystemTeamProject { get; } // { init; get; }
[JsonPropertyName("System.Title")] public string SystemTitle { get; } // { init; get; }
[JsonPropertyName("System.WorkItemType")] public string SystemWorkItemType { get; } // { init; get; }
[JsonPropertyName("Microsoft.VSTS.Scheduling.TargetDate")] public DateTime MicrosoftVSTSSchedulingTargetDate { get; } // { init; get; }
}

View File

@ -9,6 +9,7 @@ public class Value
int id,
int rev,
Fields fields,
object[] relations,
CommentVersionRef commentVersionRef,
string url
)
@ -16,6 +17,7 @@ public class Value
Id = id;
Rev = rev;
Fields = fields;
Relations = relations;
CommentVersionRef = commentVersionRef;
Url = url;
}
@ -29,6 +31,9 @@ public class Value
[JsonPropertyName("fields")]
public Fields Fields { get; }
[JsonPropertyName("relations")]
public object[] Relations { get; }
[JsonPropertyName("commentVersionRef")]
public CommentVersionRef CommentVersionRef { get; }