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

View File

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

View File

@ -8,14 +8,15 @@ public class Fields
public Fields(int customRRminusOE, public Fields(int customRRminusOE,
CustomRequester? customRequester, CustomRequester? customRequester,
float customWSJF, float customWSJF,
float? microsoftVSTSSchedulingEffort,
int microsoftVSTSCommonBusinessValue, int microsoftVSTSCommonBusinessValue,
DateTime microsoftVSTSCommonClosedDate, DateTime microsoftVSTSCommonClosedDate,
int microsoftVSTSCommonPriority, int microsoftVSTSCommonPriority,
DateTime microsoftVSTSCommonResolvedDate, DateTime microsoftVSTSCommonResolvedDate,
DateTime microsoftVSTSCommonStateChangeDate, DateTime microsoftVSTSCommonStateChangeDate,
float microsoftVSTSCommonTimeCriticality, float microsoftVSTSCommonTimeCriticality,
float? microsoftVSTSSchedulingEffort,
DateTime microsoftVSTSSchedulingStartDate, DateTime microsoftVSTSSchedulingStartDate,
DateTime microsoftVSTSSchedulingTargetDate,
string systemAreaPath, string systemAreaPath,
SystemAssignedTo systemAssignedTo, SystemAssignedTo systemAssignedTo,
SystemChangedBy systemChangedBy, SystemChangedBy systemChangedBy,
@ -26,25 +27,26 @@ public class Fields
string systemDescription, string systemDescription,
string systemHistory, string systemHistory,
string systemIterationPath, string systemIterationPath,
int systemParent,
string systemReason, string systemReason,
string systemState, string systemState,
string systemTags, string systemTags,
string systemTeamProject, string systemTeamProject,
string systemTitle, string systemTitle,
string systemWorkItemType, string systemWorkItemType)
DateTime microsoftVSTSSchedulingTargetDate)
{ {
CustomRRminusOE = customRRminusOE;
CustomRequester = customRequester; CustomRequester = customRequester;
CustomRRminusOE = customRRminusOE;
CustomWSJF = customWSJF; CustomWSJF = customWSJF;
MicrosoftVSTSSchedulingEffort = microsoftVSTSSchedulingEffort;
MicrosoftVSTSCommonBusinessValue = microsoftVSTSCommonBusinessValue; MicrosoftVSTSCommonBusinessValue = microsoftVSTSCommonBusinessValue;
MicrosoftVSTSCommonClosedDate = microsoftVSTSCommonClosedDate; MicrosoftVSTSCommonClosedDate = microsoftVSTSCommonClosedDate;
MicrosoftVSTSCommonPriority = microsoftVSTSCommonPriority; MicrosoftVSTSCommonPriority = microsoftVSTSCommonPriority;
MicrosoftVSTSCommonResolvedDate = microsoftVSTSCommonResolvedDate; MicrosoftVSTSCommonResolvedDate = microsoftVSTSCommonResolvedDate;
MicrosoftVSTSCommonStateChangeDate = microsoftVSTSCommonStateChangeDate; MicrosoftVSTSCommonStateChangeDate = microsoftVSTSCommonStateChangeDate;
MicrosoftVSTSCommonTimeCriticality = microsoftVSTSCommonTimeCriticality; MicrosoftVSTSCommonTimeCriticality = microsoftVSTSCommonTimeCriticality;
MicrosoftVSTSSchedulingEffort = microsoftVSTSSchedulingEffort;
MicrosoftVSTSSchedulingStartDate = microsoftVSTSSchedulingStartDate; MicrosoftVSTSSchedulingStartDate = microsoftVSTSSchedulingStartDate;
MicrosoftVSTSSchedulingTargetDate = microsoftVSTSSchedulingTargetDate;
SystemAreaPath = systemAreaPath; SystemAreaPath = systemAreaPath;
SystemAssignedTo = systemAssignedTo; SystemAssignedTo = systemAssignedTo;
SystemChangedBy = systemChangedBy; SystemChangedBy = systemChangedBy;
@ -55,17 +57,17 @@ public class Fields
SystemDescription = systemDescription; SystemDescription = systemDescription;
SystemHistory = systemHistory; SystemHistory = systemHistory;
SystemIterationPath = systemIterationPath; SystemIterationPath = systemIterationPath;
SystemParent = systemParent;
SystemReason = systemReason; SystemReason = systemReason;
SystemState = systemState; SystemState = systemState;
SystemTags = systemTags; SystemTags = systemTags;
SystemTeamProject = systemTeamProject; SystemTeamProject = systemTeamProject;
SystemTitle = systemTitle; SystemTitle = systemTitle;
SystemWorkItemType = systemWorkItemType; SystemWorkItemType = systemWorkItemType;
MicrosoftVSTSSchedulingTargetDate = microsoftVSTSSchedulingTargetDate;
} }
[JsonPropertyName("Custom.RRminusOE")] public int CustomRRminusOE { get; } // { init; get; }
[JsonPropertyName("Custom.Requester")] public CustomRequester? CustomRequester { 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("Custom.WSJF")] public float CustomWSJF { get; } // { init; get; }
[JsonPropertyName("Microsoft.VSTS.Common.BusinessValue")] public int MicrosoftVSTSCommonBusinessValue { 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; } [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.Common.TimeCriticality")] public float MicrosoftVSTSCommonTimeCriticality { get; } // { init; get; }
[JsonPropertyName("Microsoft.VSTS.Scheduling.Effort")] public float? MicrosoftVSTSSchedulingEffort { 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.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.AreaPath")] public string SystemAreaPath { get; } // { init; get; }
[JsonPropertyName("System.AssignedTo")] public SystemAssignedTo? SystemAssignedTo { get; } // { init; get; } [JsonPropertyName("System.AssignedTo")] public SystemAssignedTo? SystemAssignedTo { get; } // { init; get; }
[JsonPropertyName("System.ChangedBy")] public SystemChangedBy SystemChangedBy { 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.Description")] public string SystemDescription { get; } // { init; get; }
[JsonPropertyName("System.History")] public string SystemHistory { get; } // { init; get; } [JsonPropertyName("System.History")] public string SystemHistory { get; } // { init; get; }
[JsonPropertyName("System.IterationPath")] public string SystemIterationPath { 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.Reason")] public string SystemReason { get; } // { init; get; }
[JsonPropertyName("System.State")] public string SystemState { get; } // { init; get; } [JsonPropertyName("System.State")] public string SystemState { get; } // { init; get; }
[JsonPropertyName("System.Tags")] public string SystemTags { get; } // { init; get; } [JsonPropertyName("System.Tags")] public string SystemTags { get; } // { init; get; }
[JsonPropertyName("System.TeamProject")] public string SystemTeamProject { get; } // { init; get; } [JsonPropertyName("System.TeamProject")] public string SystemTeamProject { get; } // { init; get; }
[JsonPropertyName("System.Title")] public string SystemTitle { get; } // { init; get; } [JsonPropertyName("System.Title")] public string SystemTitle { get; } // { init; get; }
[JsonPropertyName("System.WorkItemType")] public string SystemWorkItemType { 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 id,
int rev, int rev,
Fields fields, Fields fields,
object[] relations,
CommentVersionRef commentVersionRef, CommentVersionRef commentVersionRef,
string url string url
) )
@ -16,6 +17,7 @@ public class Value
Id = id; Id = id;
Rev = rev; Rev = rev;
Fields = fields; Fields = fields;
Relations = relations;
CommentVersionRef = commentVersionRef; CommentVersionRef = commentVersionRef;
Url = url; Url = url;
} }
@ -29,6 +31,9 @@ public class Value
[JsonPropertyName("fields")] [JsonPropertyName("fields")]
public Fields Fields { get; } public Fields Fields { get; }
[JsonPropertyName("relations")]
public object[] Relations { get; }
[JsonPropertyName("commentVersionRef")] [JsonPropertyName("commentVersionRef")]
public CommentVersionRef CommentVersionRef { get; } public CommentVersionRef CommentVersionRef { get; }