2023-01-24
This commit is contained in:
79
Adaptation/FileHandlers/json/ViewModels/WorkItem.cs
Normal file
79
Adaptation/FileHandlers/json/ViewModels/WorkItem.cs
Normal file
@ -0,0 +1,79 @@
|
||||
using Adaptation.FileHandlers.json.WorkItems;
|
||||
using System;
|
||||
|
||||
namespace Adaptation.FileHandlers.json.ViewModels;
|
||||
|
||||
public class WorkItem
|
||||
{
|
||||
|
||||
public string AreaPath { get; set; } // { init; get; }
|
||||
public string AssignedToDisplayName { get; set; } // { init; get; }
|
||||
public int CommentCount { get; set; } // { init; get; }
|
||||
public string CreatedDate { get; set; } // { init; get; }
|
||||
public string ClosedDate { get; set; } // { init; get; }
|
||||
public string Description { get; set; } // { init; get; }
|
||||
public string Discussion { get; set; } // { init; get; }
|
||||
public string Effort { get; set; } // { init; get; }
|
||||
public string HypertextReference { get; set; } // { init; get; }
|
||||
public int Id { get; set; } // { init; get; }
|
||||
public string IterationPath { get; set; } // { init; get; }
|
||||
public string Req { get; set; } // { init; get; }
|
||||
public string ResolvedDate { get; set; } // { init; get; }
|
||||
public string Priority { get; set; } // { init; get; }
|
||||
public string State { get; set; } // { init; get; }
|
||||
public string Tags { get; set; } // { init; get; }
|
||||
public string TargetDate { get; set; } // { init; get; }
|
||||
public string Title { get; set; } // { init; get; }
|
||||
public string WorkItemType { get; set; } // { init; get; }
|
||||
|
||||
public WorkItem(Root raw)
|
||||
{
|
||||
string req;
|
||||
string[] words;
|
||||
if (string.IsNullOrEmpty(raw.Fields.SystemHistory))
|
||||
words = Array.Empty<string>();
|
||||
else
|
||||
words = raw.Fields.SystemHistory.Split(' ');
|
||||
if (words.Length < 3 || words[0] != "Req" || words[1] != ":")
|
||||
req = raw.Id.ToString();
|
||||
else
|
||||
req = words[2].Split('<')[0];
|
||||
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(),
|
||||
};
|
||||
AreaPath = systemAreaPath;
|
||||
AssignedToDisplayName = systemAssignedToDisplayName;
|
||||
CommentCount = raw.Fields.SystemCommentCount;
|
||||
CreatedDate = createdDate;
|
||||
ClosedDate = closedDate;
|
||||
Description = raw.Fields.SystemDescription;
|
||||
Discussion = raw.Fields.SystemHistory;
|
||||
Effort = effort;
|
||||
HypertextReference = hypertextReference;
|
||||
Id = raw.Id;
|
||||
IterationPath = iterationPath;
|
||||
Priority = priority;
|
||||
Req = req;
|
||||
ResolvedDate = resolvedDate;
|
||||
State = raw.Fields.SystemState;
|
||||
Tags = raw.Fields.SystemTags;
|
||||
TargetDate = targetDate;
|
||||
Title = raw.Fields.SystemTitle;
|
||||
WorkItemType = raw.Fields.SystemWorkItemType;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user