141 lines
5.8 KiB
C#
141 lines
5.8 KiB
C#
using Mesa_Backlog.Library;
|
|
using Mesa_Backlog.Library.WorkItems;
|
|
|
|
namespace Mesa_Backlog.ViewModels;
|
|
|
|
public class WorkItem
|
|
{
|
|
|
|
public string Systems { init; get; }
|
|
public string Requestor { init; get; }
|
|
public string Submitted { init; get; }
|
|
public string CMPDate { init; get; }
|
|
public string Definition { init; get; }
|
|
public string Updates { init; get; }
|
|
public string EstEffortDays { init; get; }
|
|
public string HypertextReference { init; get; }
|
|
public int Id { init; get; }
|
|
public string Status { init; get; }
|
|
public string Req { init; get; }
|
|
public string UATAsOf { init; get; }
|
|
public string Priority { init; get; }
|
|
public string State { init; get; }
|
|
public string AssignedTo { init; get; }
|
|
public string CommitDate { init; get; }
|
|
public string Title { init; get; }
|
|
public string WorkItemType { init; get; }
|
|
|
|
public WorkItem(string workItemsAddress, FIBacklogMesa fIBacklogMesa, int? id)
|
|
{
|
|
string hypertextReference;
|
|
string state = fIBacklogMesa.Status switch
|
|
{
|
|
"Hold" => "New",
|
|
"Open" => "New",
|
|
"CMP" => "Closed",
|
|
"UAT" => "Active",
|
|
"In process" => "Active",
|
|
_ => "New"
|
|
};
|
|
if (id is null)
|
|
hypertextReference = workItemsAddress;
|
|
else
|
|
hypertextReference = $"{workItemsAddress}{id}";
|
|
string workItemType = fIBacklogMesa.Priority switch { "BugFix" => "Bug", _ => "Feature" };
|
|
State = state;
|
|
Req = fIBacklogMesa.Req;
|
|
Title = fIBacklogMesa.Title;
|
|
WorkItemType = workItemType;
|
|
Status = fIBacklogMesa.Status;
|
|
CMPDate = fIBacklogMesa.CMPDate;
|
|
Id = id is null ? -1 : id.Value;
|
|
Systems = fIBacklogMesa.SystemS;
|
|
UATAsOf = fIBacklogMesa.UATAsOf;
|
|
Updates = fIBacklogMesa.Updates;
|
|
Priority = fIBacklogMesa.Priority;
|
|
Requestor = fIBacklogMesa.Requestor;
|
|
Submitted = fIBacklogMesa.Submitted;
|
|
AssignedTo = fIBacklogMesa.AssignedTo;
|
|
CommitDate = fIBacklogMesa.CommitDate;
|
|
Definition = fIBacklogMesa.Definition;
|
|
HypertextReference = hypertextReference;
|
|
EstEffortDays = fIBacklogMesa.EstEffortDays;
|
|
}
|
|
|
|
public WorkItem(Dictionary<int, string> keyValuePairs, Root raw)
|
|
{
|
|
string req;
|
|
string[] words;
|
|
if (string.IsNullOrEmpty(raw.Fields.MicrosoftVSTSTCMSystemInfo))
|
|
words = Array.Empty<string>();
|
|
else
|
|
words = raw.Fields.MicrosoftVSTSTCMSystemInfo.Split(' ');
|
|
if (words.Length < 3 || words[0] != "Req" || words[1] != ":")
|
|
req = raw.Id.ToString();
|
|
else
|
|
{
|
|
req = words[2].Split('<')[0];
|
|
if (keyValuePairs.ContainsKey(raw.Id))
|
|
keyValuePairs[raw.Id] = req;
|
|
else
|
|
keyValuePairs.Add(raw.Id, req);
|
|
req = $"{req} => {raw.Id}";
|
|
}
|
|
string updates = $"{raw.Fields.SystemCommentCount} update(s) / comment(s)";
|
|
string systemAreaPath = raw.Fields.SystemAreaPath.Replace(@"Mesa_FI\", string.Empty);
|
|
string iterationPath = raw.Fields.SystemIterationPath.Replace(@"Mesa_FI\", string.Empty);
|
|
string hypertextReference = string.IsNullOrEmpty(raw.Links?.Html?.Href) ? string.Empty : raw.Links.Html.Href;
|
|
string systemAssignedToDisplayName = raw.Fields.SystemAssignedTo is null ? string.Empty : raw.Fields.SystemAssignedTo.DisplayName;
|
|
string effort = raw.Fields.MicrosoftVSTSSchedulingEffort < 0.1 ? "" : Math.Floor(raw.Fields.MicrosoftVSTSSchedulingEffort).ToString("0");
|
|
string createdDate = raw.Fields.SystemCreatedDate == DateTime.MinValue ? string.Empty : raw.Fields.SystemCreatedDate.ToString("dd-MMM-yy");
|
|
string closedDate = raw.Fields.MicrosoftVSTSCommonClosedDate == DateTime.MinValue ? string.Empty : raw.Fields.MicrosoftVSTSCommonClosedDate.ToString("dd-MMM-yy");
|
|
string resolvedDate = raw.Fields.MicrosoftVSTSCommonResolvedDate == DateTime.MinValue ? string.Empty : raw.Fields.MicrosoftVSTSCommonResolvedDate.ToString("dd-MMM-yy");
|
|
string targetDate = raw.Fields.MicrosoftVSTSSchedulingTargetDate == DateTime.MinValue ? string.Empty : raw.Fields.MicrosoftVSTSSchedulingTargetDate.ToString("dd-MMM-yy");
|
|
string priority = raw.Fields.SystemWorkItemType == "Bug" ? "BugFix" : raw.Fields.MicrosoftVSTSCommonPriority switch
|
|
{
|
|
1 => "High",
|
|
2 => "Med",
|
|
3 => "Low",
|
|
4 => "TBD",
|
|
_ => throw new NotImplementedException(),
|
|
};
|
|
Systems = systemAreaPath;
|
|
Requestor = systemAssignedToDisplayName;
|
|
Submitted = createdDate;
|
|
CMPDate = closedDate;
|
|
Definition = raw.Fields.SystemDescription;
|
|
Updates = updates;
|
|
EstEffortDays = effort;
|
|
HypertextReference = hypertextReference;
|
|
Id = raw.Id;
|
|
Status = iterationPath;
|
|
Priority = priority;
|
|
Req = req;
|
|
UATAsOf = resolvedDate;
|
|
State = raw.Fields.SystemState;
|
|
AssignedTo = raw.Fields.SystemTags;
|
|
CommitDate = targetDate;
|
|
Title = raw.Fields.SystemTitle;
|
|
WorkItemType = raw.Fields.SystemWorkItemType;
|
|
}
|
|
|
|
public static List<WorkItem> GetWorkItems(Dictionary<string, int?> keyValuePairs, string workItemsAddress, FIBacklogMesa[] fIBacklogMesaCollection)
|
|
{
|
|
List<WorkItem> results = new();
|
|
int? id;
|
|
WorkItem view;
|
|
foreach (FIBacklogMesa fIBacklogMesa in fIBacklogMesaCollection)
|
|
{
|
|
if (string.IsNullOrEmpty(fIBacklogMesa.Submitted))
|
|
continue;
|
|
if (!keyValuePairs.ContainsKey(fIBacklogMesa.Req))
|
|
id = null;
|
|
else
|
|
id = keyValuePairs[fIBacklogMesa.Req];
|
|
view = new(workItemsAddress, fIBacklogMesa, id);
|
|
results.Add(view);
|
|
}
|
|
return results;
|
|
}
|
|
|
|
} |