State WIP
This commit is contained in:
parent
b4c91e3f2c
commit
e148c181ec
@ -129,13 +129,14 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dictionary<int, Record> GetKeyValuePairs(ReadOnlyDictionary<int, WorkItem> workItems, WorkItem workItem)
|
private static ReadOnlyCollection<Record> GetKeyValuePairs(ReadOnlyDictionary<int, WorkItem> workItems, WorkItem workItem)
|
||||||
{
|
{
|
||||||
Dictionary<int, Record> results = new();
|
List<Record> results = new();
|
||||||
int? childId;
|
int? childId;
|
||||||
WorkItem? childWorkItem;
|
WorkItem? childWorkItem;
|
||||||
|
WorkItem? parentWorkItem;
|
||||||
List<WorkItem> collection = new();
|
List<WorkItem> collection = new();
|
||||||
Dictionary<int, Record> keyValuePairs;
|
ReadOnlyCollection<Record> records;
|
||||||
if (workItem.Relations is not null && workItem.Relations.Length > 0)
|
if (workItem.Relations is not null && workItem.Relations.Length > 0)
|
||||||
{
|
{
|
||||||
collection.Clear();
|
collection.Clear();
|
||||||
@ -149,23 +150,31 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
collection = (from l in collection orderby l.State != "Closed", l.Id select l).ToList();
|
collection = (from l in collection orderby l.State != "Closed", l.Id select l).ToList();
|
||||||
foreach (WorkItem item in collection)
|
foreach (WorkItem item in collection)
|
||||||
{
|
{
|
||||||
keyValuePairs = GetKeyValuePairs(workItems, item);
|
if (item.Parent is null)
|
||||||
results.Add(item.Id, new(item, new(keyValuePairs)));
|
parentWorkItem = null;
|
||||||
|
else
|
||||||
|
_ = workItems.TryGetValue(item.Parent.Value, out parentWorkItem);
|
||||||
|
records = GetKeyValuePairs(workItems, item);
|
||||||
|
results.Add(new(item, parentWorkItem, records));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results;
|
return new(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReadOnlyDictionary<int, Record> GetWorkItemAndChildren(ReadOnlyDictionary<int, WorkItem> workItems)
|
private static ReadOnlyCollection<Record> GetRecords(ReadOnlyDictionary<int, WorkItem> workItems)
|
||||||
{
|
{
|
||||||
Dictionary<int, Record> results = new();
|
List<Record> results = new();
|
||||||
Dictionary<int, Record> keyValuePairs;
|
WorkItem? parentWorkItem;
|
||||||
|
ReadOnlyCollection<Record> records;
|
||||||
foreach (KeyValuePair<int, WorkItem> keyValuePair in workItems)
|
foreach (KeyValuePair<int, WorkItem> keyValuePair in workItems)
|
||||||
{
|
{
|
||||||
// if (keyValuePair.Key != 119185)
|
if (keyValuePair.Value.Parent is null)
|
||||||
// continue;
|
parentWorkItem = null;
|
||||||
keyValuePairs = GetKeyValuePairs(workItems, keyValuePair.Value);
|
else
|
||||||
results.Add(keyValuePair.Key, new(keyValuePair.Value, new(keyValuePairs)));
|
_ = workItems.TryGetValue(keyValuePair.Value.Parent.Value, out parentWorkItem);
|
||||||
|
records = GetKeyValuePairs(workItems, keyValuePair.Value);
|
||||||
|
results.Add(new(keyValuePair.Value, parentWorkItem, records));
|
||||||
|
|
||||||
}
|
}
|
||||||
return new(results);
|
return new(results);
|
||||||
}
|
}
|
||||||
@ -176,50 +185,50 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetLine(List<char> spaces, WorkItem workItem, KeyValuePair<int, Record> keyValuePair, bool condensed, bool sprintOnly) =>
|
private static string GetLine(List<char> spaces, WorkItem workItem, Record record, bool condensed, bool sprintOnly) =>
|
||||||
sprintOnly ? $"\t- [ ] {workItem.IterationPath}" :
|
sprintOnly ? $"\t- [ ] {workItem.IterationPath}" :
|
||||||
condensed ? $"{new string(spaces.Skip(1).ToArray())}- {GetClosed(workItem)} {keyValuePair.Key} - {workItem.Title}" :
|
condensed ? $"{new string(spaces.Skip(1).ToArray())}- {GetClosed(workItem)} {record.WorkItem.Id} - {workItem.Title}" :
|
||||||
$"{new string(spaces.Skip(1).ToArray())}- {GetClosed(workItem)} {keyValuePair.Key} - {workItem.Title} ~~~ {workItem.AssignedTo} - {workItem.IterationPath.Replace('\\', '-')} - {workItem.CreatedDate} --- {workItem.ClosedDate}";
|
$"{new string(spaces.Skip(1).ToArray())}- {GetClosed(workItem)} {record.WorkItem.Id} - {workItem.Title} ~~~ {workItem.AssignedTo} - {workItem.IterationPath.Replace('\\', '-')} - {workItem.CreatedDate} --- {workItem.ClosedDate}";
|
||||||
|
|
||||||
private static void AppendLines(List<char> spaces, List<string> lines, Record record, bool condensed, bool sprintOnly)
|
private static void AppendLines(List<char> spaces, List<string> lines, Record record, bool condensed, bool sprintOnly)
|
||||||
{
|
{
|
||||||
string line;
|
string line;
|
||||||
spaces.Add('\t');
|
spaces.Add('\t');
|
||||||
WorkItem workItem;
|
WorkItem workItem;
|
||||||
foreach (KeyValuePair<int, Record> keyValuePair in record.Children)
|
foreach (Record child in record.Children)
|
||||||
{
|
{
|
||||||
workItem = keyValuePair.Value.WorkItem;
|
workItem = child.WorkItem;
|
||||||
line = GetLine(spaces, workItem, keyValuePair, condensed, sprintOnly).TrimEnd();
|
line = GetLine(spaces, workItem, child, condensed, sprintOnly).TrimEnd();
|
||||||
lines.Add(line);
|
lines.Add(line);
|
||||||
AppendLines(spaces, lines, keyValuePair.Value, condensed, sprintOnly);
|
AppendLines(spaces, lines, child, condensed, sprintOnly);
|
||||||
}
|
}
|
||||||
spaces.RemoveAt(0);
|
spaces.RemoveAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AppendLines(string url, List<char> spaces, List<string> lines, ReadOnlyDictionary<int, Record> workItemAndChildren, string workItemType)
|
private static void AppendLines(string url, List<char> spaces, List<string> lines, ReadOnlyCollection<Record> records, string workItemType)
|
||||||
{
|
{
|
||||||
List<string> results = new();
|
List<string> results = new();
|
||||||
WorkItem workItem;
|
WorkItem workItem;
|
||||||
string? maxIterationPath;
|
string? maxIterationPath;
|
||||||
List<string> distinct = new();
|
List<string> distinct = new();
|
||||||
foreach (KeyValuePair<int, Record> keyValuePair in workItemAndChildren)
|
foreach (Record record in records)
|
||||||
{
|
{
|
||||||
workItem = keyValuePair.Value.WorkItem;
|
workItem = record.WorkItem;
|
||||||
// if (keyValuePair.Key != 109724)
|
// if (record.WorkItem.Id != 109724)
|
||||||
// continue;
|
// continue;
|
||||||
if (workItem.WorkItemType != workItemType)
|
if (workItem.WorkItemType != workItemType)
|
||||||
continue;
|
continue;
|
||||||
results.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}");
|
results.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}");
|
||||||
results.Add(string.Empty);
|
results.Add(string.Empty);
|
||||||
results.Add($"- [{workItem.Id}]({url}{workItem.Id})");
|
results.Add($"- [{workItem.Id}]({url}{workItem.Id})");
|
||||||
if (keyValuePair.Value.Children.Count == 0)
|
if (record.Children.Count == 0)
|
||||||
results.Add(string.Empty);
|
results.Add(string.Empty);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AppendLines(spaces, results, keyValuePair.Value, condensed: true, sprintOnly: false);
|
AppendLines(spaces, results, record, condensed: true, sprintOnly: false);
|
||||||
results.Add(string.Empty);
|
results.Add(string.Empty);
|
||||||
distinct.Clear();
|
distinct.Clear();
|
||||||
AppendLines(spaces, distinct, keyValuePair.Value, condensed: false, sprintOnly: true);
|
AppendLines(spaces, distinct, record, condensed: false, sprintOnly: true);
|
||||||
if (distinct.Count > 1)
|
if (distinct.Count > 1)
|
||||||
{
|
{
|
||||||
results.Add($"## Distinct Iteration Path(s) - {workItem.WorkItemType} - {workItem.AssignedTo} - {workItem.Id} - {workItem.Title} - {workItem.IterationPath}");
|
results.Add($"## Distinct Iteration Path(s) - {workItem.WorkItemType} - {workItem.AssignedTo} - {workItem.Id} - {workItem.Title} - {workItem.IterationPath}");
|
||||||
@ -238,7 +247,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
}
|
}
|
||||||
results.Add($"## Extended - {workItem.Id} - {workItem.Title}");
|
results.Add($"## Extended - {workItem.Id} - {workItem.Title}");
|
||||||
results.Add(string.Empty);
|
results.Add(string.Empty);
|
||||||
AppendLines(spaces, results, keyValuePair.Value, condensed: false, sprintOnly: false);
|
AppendLines(spaces, results, record, condensed: false, sprintOnly: false);
|
||||||
results.Add(string.Empty);
|
results.Add(string.Empty);
|
||||||
}
|
}
|
||||||
lines.AddRange(results);
|
lines.AddRange(results);
|
||||||
@ -246,7 +255,16 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void WriteFiles(string destinationDirectory, string fileName, ReadOnlyCollection<string> lines, ReadOnlyCollection<WorkItem> workItems)
|
private static void WriteFiles(string destinationDirectory, ReadOnlyCollection<Record> records, string fileName)
|
||||||
|
{
|
||||||
|
string json = JsonSerializer.Serialize(records, new JsonSerializerOptions() { WriteIndented = true });
|
||||||
|
string jsonFile = Path.Combine(destinationDirectory, $"{fileName}.json");
|
||||||
|
string jsonOld = !File.Exists(jsonFile) ? string.Empty : File.ReadAllText(jsonFile);
|
||||||
|
if (json != jsonOld)
|
||||||
|
File.WriteAllText(jsonFile, json);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteFiles(string destinationDirectory, ReadOnlyCollection<string> lines, ReadOnlyCollection<WorkItem> workItems, string fileName)
|
||||||
{
|
{
|
||||||
string text = string.Join(Environment.NewLine, lines);
|
string text = string.Join(Environment.NewLine, lines);
|
||||||
string markdownFile = Path.Combine(destinationDirectory, $"{fileName}.md");
|
string markdownFile = Path.Combine(destinationDirectory, $"{fileName}.md");
|
||||||
@ -258,7 +276,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
string htmlOld = !File.Exists(htmlFile) ? string.Empty : File.ReadAllText(htmlFile);
|
string htmlOld = !File.Exists(htmlFile) ? string.Empty : File.ReadAllText(htmlFile);
|
||||||
if (html != htmlOld)
|
if (html != htmlOld)
|
||||||
File.WriteAllText(htmlFile, html);
|
File.WriteAllText(htmlFile, html);
|
||||||
string json = JsonSerializer.Serialize(workItems.ToArray(), new JsonSerializerOptions() { WriteIndented = true });
|
string json = JsonSerializer.Serialize(workItems, new JsonSerializerOptions() { WriteIndented = true });
|
||||||
string jsonFile = Path.Combine(destinationDirectory, $"{fileName}.json");
|
string jsonFile = Path.Combine(destinationDirectory, $"{fileName}.json");
|
||||||
string jsonOld = !File.Exists(jsonFile) ? string.Empty : File.ReadAllText(jsonFile);
|
string jsonOld = !File.Exists(jsonFile) ? string.Empty : File.ReadAllText(jsonFile);
|
||||||
if (json != jsonOld)
|
if (json != jsonOld)
|
||||||
@ -269,9 +287,9 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
{
|
{
|
||||||
List<WorkItem> results = new();
|
List<WorkItem> results = new();
|
||||||
WorkItem workItem;
|
WorkItem workItem;
|
||||||
foreach (KeyValuePair<int, Record> keyValuePair in record.Children)
|
foreach (Record item in record.Children)
|
||||||
{
|
{
|
||||||
workItem = keyValuePair.Value.WorkItem;
|
workItem = item.WorkItem;
|
||||||
if (!workItemTypes.Contains(workItem.WorkItemType))
|
if (!workItemTypes.Contains(workItem.WorkItemType))
|
||||||
continue;
|
continue;
|
||||||
results.Add(workItem);
|
results.Add(workItem);
|
||||||
@ -293,34 +311,33 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReadOnlyCollection<WorkItem> FeatureCheckIterationPath122508(string url, List<string> lines, ReadOnlyCollection<string> workItemTypes, ReadOnlyDictionary<int, Record> workItemAndChildren, string workItemType)
|
private static ReadOnlyCollection<WorkItem> FeatureCheckIterationPath122508(string url, List<string> lines, ReadOnlyCollection<string> workItemTypes, ReadOnlyCollection<Record> records, string workItemType)
|
||||||
{
|
{
|
||||||
List<WorkItem> collection = new();
|
List<WorkItem> results = new();
|
||||||
WorkItem workItem;
|
WorkItem workItem;
|
||||||
string? maxIterationPath;
|
string? maxIterationPath;
|
||||||
List<string> results = new();
|
List<string> collection = new();
|
||||||
ReadOnlyCollection<WorkItem> childrenWorkItems;
|
ReadOnlyCollection<WorkItem> childrenWorkItems;
|
||||||
foreach (KeyValuePair<int, Record> keyValuePair in workItemAndChildren)
|
foreach (Record record in records)
|
||||||
{
|
{
|
||||||
workItem = keyValuePair.Value.WorkItem;
|
workItem = record.WorkItem;
|
||||||
if (workItem.WorkItemType != workItemType)
|
if (workItem.WorkItemType != workItemType)
|
||||||
continue;
|
continue;
|
||||||
results.Clear();
|
collection.Clear();
|
||||||
if (keyValuePair.Value.Children.Count == 0)
|
if (record.Children.Count == 0)
|
||||||
continue;
|
continue;
|
||||||
childrenWorkItems = FilterChildren(keyValuePair.Value, workItemTypes);
|
childrenWorkItems = FilterChildren(record, workItemTypes);
|
||||||
maxIterationPath = GetMaxIterationPath(childrenWorkItems);
|
maxIterationPath = GetMaxIterationPath(childrenWorkItems);
|
||||||
if (string.IsNullOrEmpty(maxIterationPath) || workItem.IterationPath == maxIterationPath)
|
if (string.IsNullOrEmpty(maxIterationPath) || workItem.IterationPath == maxIterationPath)
|
||||||
continue;
|
continue;
|
||||||
results.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}");
|
collection.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}");
|
||||||
results.Add(string.Empty);
|
collection.Add(string.Empty);
|
||||||
results.Add($"- [ ] [{workItem.Id}]({url}{workItem.Id}) => {workItem.IterationPath} != {maxIterationPath}");
|
collection.Add($"- [ ] [{workItem.Id}]({url}{workItem.Id}) => {workItem.IterationPath} != {maxIterationPath}");
|
||||||
results.Add(string.Empty);
|
collection.Add(string.Empty);
|
||||||
lines.AddRange(results);
|
lines.AddRange(collection);
|
||||||
collection.Add(WorkItem.Get(workItem, $"IterationPath:{workItem.Id};{workItem.IterationPath} != {maxIterationPath}"));
|
results.Add(WorkItem.Get(workItem, $"IterationPath:<a target='_blank' href='{url}{workItem.Id}'>{workItem.Id}</a>;{workItem.IterationPath} != {maxIterationPath}"));
|
||||||
collection.Add(workItem);
|
|
||||||
}
|
}
|
||||||
return new(collection);
|
return new(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReadOnlyCollection<WorkItem> GetWorkItemsNotMatching(string tags, ReadOnlyCollection<WorkItem> workItems)
|
private static ReadOnlyCollection<WorkItem> GetWorkItemsNotMatching(string tags, ReadOnlyCollection<WorkItem> workItems)
|
||||||
@ -338,44 +355,44 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
return new(results);
|
return new(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReadOnlyCollection<WorkItem> FeatureCheckTag122514(string url, List<string> lines, ReadOnlyCollection<string> workItemTypes, ReadOnlyDictionary<int, Record> workItemAndChildren, string workItemType)
|
private static ReadOnlyCollection<WorkItem> FeatureCheckTag122514(string url, List<string> lines, ReadOnlyCollection<string> workItemTypes, ReadOnlyCollection<Record> records, string workItemType)
|
||||||
{
|
{
|
||||||
List<WorkItem> collection = new();
|
List<WorkItem> results = new();
|
||||||
WorkItem workItem;
|
WorkItem workItem;
|
||||||
List<string> results = new();
|
List<string> collection = new();
|
||||||
List<string> violations = new();
|
List<string> violations = new();
|
||||||
ReadOnlyCollection<WorkItem> childrenWorkItems;
|
ReadOnlyCollection<WorkItem> childrenWorkItems;
|
||||||
ReadOnlyCollection<WorkItem> workItemsNotMatching;
|
ReadOnlyCollection<WorkItem> workItemsNotMatching;
|
||||||
foreach (KeyValuePair<int, Record> keyValuePair in workItemAndChildren)
|
foreach (Record record in records)
|
||||||
{
|
{
|
||||||
workItem = keyValuePair.Value.WorkItem;
|
workItem = record.WorkItem;
|
||||||
if (workItem.WorkItemType != workItemType)
|
if (workItem.WorkItemType != workItemType)
|
||||||
continue;
|
continue;
|
||||||
results.Clear();
|
collection.Clear();
|
||||||
violations.Clear();
|
violations.Clear();
|
||||||
if (keyValuePair.Value.Children.Count == 0)
|
if (record.Children.Count == 0)
|
||||||
continue;
|
continue;
|
||||||
if (string.IsNullOrEmpty(workItem.Tags))
|
if (string.IsNullOrEmpty(workItem.Tags))
|
||||||
workItemsNotMatching = new(new WorkItem[] { workItem });
|
workItemsNotMatching = new(new WorkItem[] { workItem });
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
childrenWorkItems = FilterChildren(keyValuePair.Value, workItemTypes);
|
childrenWorkItems = FilterChildren(record, workItemTypes);
|
||||||
workItemsNotMatching = GetWorkItemsNotMatching(workItem.Tags, childrenWorkItems);
|
workItemsNotMatching = GetWorkItemsNotMatching(workItem.Tags, childrenWorkItems);
|
||||||
if (!string.IsNullOrEmpty(workItem.Tags) && workItemsNotMatching.Count == 0)
|
if (!string.IsNullOrEmpty(workItem.Tags) && workItemsNotMatching.Count == 0)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
results.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}");
|
collection.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}");
|
||||||
results.Add(string.Empty);
|
collection.Add(string.Empty);
|
||||||
foreach (WorkItem item in workItemsNotMatching)
|
foreach (WorkItem item in workItemsNotMatching)
|
||||||
results.Add($"- [ ] [{item}]({url}{item}) {nameof(workItem.Tags)} != {workItem.Tags}");
|
collection.Add($"- [ ] [{item}]({url}{item}) {nameof(workItem.Tags)} != {workItem.Tags}");
|
||||||
results.Add(string.Empty);
|
collection.Add(string.Empty);
|
||||||
lines.AddRange(results);
|
lines.AddRange(collection);
|
||||||
violations.Add($"Tag:{workItem.Tags};");
|
violations.Add($"Tag:{workItem.Tags};");
|
||||||
foreach (WorkItem item in workItemsNotMatching)
|
foreach (WorkItem item in workItemsNotMatching)
|
||||||
violations.Add($"{item.Id}:{item.Tags};");
|
violations.Add($"<a target='_blank' href='{url}{item.Id}'>{item.Id}</a>:{item.Tags};");
|
||||||
collection.Add(WorkItem.Get(workItem, string.Join(" ", violations)));
|
results.Add(WorkItem.Get(workItem, string.Join(" ", violations)));
|
||||||
}
|
}
|
||||||
return new(collection);
|
return new(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReadOnlyCollection<WorkItem> GetWorkItemsNotMatching(int? priority, ReadOnlyCollection<WorkItem> workItems)
|
private static ReadOnlyCollection<WorkItem> GetWorkItemsNotMatching(int? priority, ReadOnlyCollection<WorkItem> workItems)
|
||||||
@ -390,91 +407,160 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
return new(results);
|
return new(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReadOnlyCollection<WorkItem> FeatureCheckPriority126169(string url, List<string> lines, ReadOnlyCollection<string> workItemTypes, ReadOnlyDictionary<int, Record> workItemAndChildren, string workItemType)
|
private static ReadOnlyCollection<WorkItem> FeatureCheckPriority126169(string url, List<string> lines, ReadOnlyCollection<string> workItemTypes, ReadOnlyCollection<Record> records, string workItemType)
|
||||||
{
|
{
|
||||||
List<WorkItem> collection = new();
|
List<WorkItem> results = new();
|
||||||
WorkItem workItem;
|
WorkItem workItem;
|
||||||
List<string> results = new();
|
List<string> collection = new();
|
||||||
List<string> violations = new();
|
List<string> violations = new();
|
||||||
ReadOnlyCollection<WorkItem> childrenWorkItems;
|
ReadOnlyCollection<WorkItem> childrenWorkItems;
|
||||||
ReadOnlyCollection<WorkItem> workItemsNotMatching;
|
ReadOnlyCollection<WorkItem> workItemsNotMatching;
|
||||||
foreach (KeyValuePair<int, Record> keyValuePair in workItemAndChildren)
|
foreach (Record record in records)
|
||||||
{
|
{
|
||||||
workItem = keyValuePair.Value.WorkItem;
|
workItem = record.WorkItem;
|
||||||
if (workItem.WorkItemType != workItemType)
|
if (workItem.WorkItemType != workItemType)
|
||||||
continue;
|
continue;
|
||||||
results.Clear();
|
collection.Clear();
|
||||||
violations.Clear();
|
violations.Clear();
|
||||||
if (keyValuePair.Value.Children.Count == 0)
|
if (record.Children.Count == 0)
|
||||||
continue;
|
continue;
|
||||||
childrenWorkItems = FilterChildren(keyValuePair.Value, workItemTypes);
|
childrenWorkItems = FilterChildren(record, workItemTypes);
|
||||||
workItemsNotMatching = GetWorkItemsNotMatching(workItem.Priority, childrenWorkItems);
|
workItemsNotMatching = GetWorkItemsNotMatching(workItem.Priority, childrenWorkItems);
|
||||||
if (workItemsNotMatching.Count == 0)
|
if (workItemsNotMatching.Count == 0)
|
||||||
continue;
|
continue;
|
||||||
results.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}");
|
collection.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}");
|
||||||
results.Add(string.Empty);
|
collection.Add(string.Empty);
|
||||||
results.Add($"- [{workItem.Id}]({url}{workItem.Id})");
|
collection.Add($"- [{workItem.Id}]({url}{workItem.Id})");
|
||||||
foreach (WorkItem item in workItemsNotMatching)
|
foreach (WorkItem item in workItemsNotMatching)
|
||||||
results.Add($"- [ ] [{item}]({url}{item}) {nameof(workItem.Priority)} != {workItem.Priority}");
|
collection.Add($"- [ ] [{item.Id}]({url}{item.Id}) {nameof(workItem.Priority)} != {workItem.Priority}");
|
||||||
results.Add(string.Empty);
|
collection.Add(string.Empty);
|
||||||
lines.AddRange(results);
|
lines.AddRange(collection);
|
||||||
violations.Add($"Priority:{workItem.Priority};");
|
violations.Add($"Priority:{workItem.Priority};");
|
||||||
foreach (WorkItem item in workItemsNotMatching)
|
foreach (WorkItem item in workItemsNotMatching)
|
||||||
violations.Add($"{item.Id}:{item.Priority};");
|
violations.Add($"<a target='_blank' href='{url}{item.Id}'>{item.Id}</a>:{item.Priority};");
|
||||||
collection.Add(WorkItem.Get(workItem, string.Join(" ", violations)));
|
results.Add(WorkItem.Get(workItem, string.Join(" ", violations)));
|
||||||
}
|
}
|
||||||
return new(collection);
|
return new(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ReadOnlyCollection<WorkItem> GetWorkItemsNotMatching(int state, ReadOnlyCollection<WorkItem> workItems)
|
||||||
|
{
|
||||||
|
List<WorkItem> results = new();
|
||||||
|
int check;
|
||||||
|
List<KeyValuePair<int, WorkItem>> collection = new();
|
||||||
|
foreach (WorkItem workItem in workItems)
|
||||||
|
{
|
||||||
|
check = GetState(workItem);
|
||||||
|
if (check != state)
|
||||||
|
continue;
|
||||||
|
collection.Add(new(check, workItem));
|
||||||
|
}
|
||||||
|
foreach (KeyValuePair<int, WorkItem> keyValuePair in collection.OrderByDescending(l => l.Key))
|
||||||
|
results.Add(keyValuePair.Value);
|
||||||
|
return new(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int GetState(WorkItem workItem) =>
|
||||||
|
workItem.State switch
|
||||||
|
{
|
||||||
|
"New" => 1,
|
||||||
|
"Active" => 2,
|
||||||
|
"Resolved" => 3,
|
||||||
|
"Closed" => 4,
|
||||||
|
"Removed" => 5,
|
||||||
|
_ => 8
|
||||||
|
};
|
||||||
|
|
||||||
|
private static ReadOnlyCollection<WorkItem> FeatureCheckState123066(string url, List<string> lines, ReadOnlyCollection<string> workItemTypes, ReadOnlyCollection<Record> records, string workItemType)
|
||||||
|
{
|
||||||
|
List<WorkItem> results = new();
|
||||||
|
int state;
|
||||||
|
WorkItem workItem;
|
||||||
|
List<string> collection = new();
|
||||||
|
List<string> violations = new();
|
||||||
|
ReadOnlyCollection<WorkItem> childrenWorkItems;
|
||||||
|
ReadOnlyCollection<WorkItem> workItemsNotMatching;
|
||||||
|
foreach (Record record in records)
|
||||||
|
{
|
||||||
|
workItem = record.WorkItem;
|
||||||
|
if (workItem.WorkItemType != workItemType)
|
||||||
|
continue;
|
||||||
|
collection.Clear();
|
||||||
|
violations.Clear();
|
||||||
|
if (record.Children.Count == 0)
|
||||||
|
continue;
|
||||||
|
state = GetState(workItem);
|
||||||
|
childrenWorkItems = FilterChildren(record, workItemTypes);
|
||||||
|
workItemsNotMatching = GetWorkItemsNotMatching(state, childrenWorkItems);
|
||||||
|
if (workItemsNotMatching.Count == 0)
|
||||||
|
continue;
|
||||||
|
collection.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}");
|
||||||
|
collection.Add(string.Empty);
|
||||||
|
collection.Add($"- [{workItem.Id}]({url}{workItem.Id})");
|
||||||
|
foreach (WorkItem item in workItemsNotMatching)
|
||||||
|
collection.Add($"- [ ] [{item.Id}]({url}{item.Id}) {nameof(workItem.State)} != {workItem.State}");
|
||||||
|
collection.Add(string.Empty);
|
||||||
|
lines.AddRange(collection);
|
||||||
|
violations.Add($"State:{workItem.State};");
|
||||||
|
foreach (WorkItem item in workItemsNotMatching)
|
||||||
|
violations.Add($"<a target='_blank' href='{url}{item.Id}'>{item.Id}</a>:{item.State};");
|
||||||
|
results.Add(WorkItem.Get(workItem, string.Join(" ", violations)));
|
||||||
|
}
|
||||||
|
return new(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void WriteFiles(FileConnectorConfiguration fileConnectorConfiguration, string url, ReadOnlyCollection<string> workItemTypes, ReadOnlyCollection<WorkItem> workItems)
|
private static void WriteFiles(FileConnectorConfiguration fileConnectorConfiguration, string url, ReadOnlyCollection<string> workItemTypes, ReadOnlyCollection<WorkItem> workItems)
|
||||||
{
|
{
|
||||||
string json;
|
|
||||||
List<char> spaces = new();
|
List<char> spaces = new();
|
||||||
List<string> lines = new();
|
List<string> lines = new();
|
||||||
ReadOnlyCollection<WorkItem> results;
|
ReadOnlyCollection<WorkItem> results;
|
||||||
ReadOnlyDictionary<int, WorkItem> collection = GetWorkItems(workItems);
|
ReadOnlyDictionary<int, WorkItem> collection = GetWorkItems(workItems);
|
||||||
ReadOnlyDictionary<int, Record> keyValuePairs = GetWorkItemAndChildren(collection);
|
ReadOnlyCollection<Record> records = GetRecords(collection);
|
||||||
ReadOnlyCollection<string> bugUserStoryWorkItemTypes = new(new string[] { "Bug", "User Story" });
|
ReadOnlyCollection<string> bugUserStoryWorkItemTypes = new(new string[] { "Bug", "User Story" });
|
||||||
ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes = new(new string[] { "Bug", "User Story", "Task" });
|
ReadOnlyCollection<string> bugUserStoryTaskWorkItemTypes = new(new string[] { "Bug", "User Story", "Task" });
|
||||||
if (!Directory.Exists(fileConnectorConfiguration.TargetFileLocation))
|
if (!Directory.Exists(fileConnectorConfiguration.TargetFileLocation))
|
||||||
_ = Directory.CreateDirectory(fileConnectorConfiguration.TargetFileLocation);
|
_ = Directory.CreateDirectory(fileConnectorConfiguration.TargetFileLocation);
|
||||||
if (keyValuePairs.Count == -1)
|
WriteFiles(fileConnectorConfiguration.TargetFileLocation, records, "with-parents");
|
||||||
{
|
|
||||||
json = JsonSerializer.Serialize(keyValuePairs, new JsonSerializerOptions() { WriteIndented = true });
|
|
||||||
File.WriteAllText(Path.Combine(fileConnectorConfiguration.TargetFileLocation, ".json"), json);
|
|
||||||
}
|
|
||||||
foreach (string workItemType in workItemTypes)
|
foreach (string workItemType in workItemTypes)
|
||||||
{
|
{
|
||||||
lines.Clear();
|
lines.Clear();
|
||||||
lines.Add($"# {workItemType}");
|
lines.Add($"# {workItemType}");
|
||||||
lines.Add(string.Empty);
|
lines.Add(string.Empty);
|
||||||
AppendLines(url, spaces, lines, keyValuePairs, workItemType);
|
AppendLines(url, spaces, lines, records, workItemType);
|
||||||
results = new(Array.Empty<WorkItem>());
|
results = new(Array.Empty<WorkItem>());
|
||||||
WriteFiles(fileConnectorConfiguration.TargetFileLocation, workItemType, new(lines), results);
|
WriteFiles(fileConnectorConfiguration.TargetFileLocation, new(lines), results, workItemType);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
lines.Clear();
|
lines.Clear();
|
||||||
string workItemType = "Feature";
|
string workItemType = "Feature";
|
||||||
lines.Add($"# {nameof(FeatureCheckIterationPath122508)}");
|
lines.Add($"# {nameof(FeatureCheckIterationPath122508)}");
|
||||||
lines.Add(string.Empty);
|
lines.Add(string.Empty);
|
||||||
results = FeatureCheckIterationPath122508(url, lines, bugUserStoryTaskWorkItemTypes, keyValuePairs, workItemType);
|
results = FeatureCheckIterationPath122508(url, lines, bugUserStoryTaskWorkItemTypes, records, workItemType);
|
||||||
WriteFiles(fileConnectorConfiguration.TargetFileLocation, "check-122508", new(lines), results);
|
WriteFiles(fileConnectorConfiguration.TargetFileLocation, new(lines), results, "check-122508");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
lines.Clear();
|
lines.Clear();
|
||||||
string workItemType = "Feature";
|
string workItemType = "Feature";
|
||||||
lines.Add($"# {nameof(FeatureCheckTag122514)}");
|
lines.Add($"# {nameof(FeatureCheckTag122514)}");
|
||||||
lines.Add(string.Empty);
|
lines.Add(string.Empty);
|
||||||
results = FeatureCheckTag122514(url, lines, bugUserStoryWorkItemTypes, keyValuePairs, workItemType);
|
results = FeatureCheckTag122514(url, lines, bugUserStoryWorkItemTypes, records, workItemType);
|
||||||
WriteFiles(fileConnectorConfiguration.TargetFileLocation, "check-122514", new(lines), results);
|
WriteFiles(fileConnectorConfiguration.TargetFileLocation, new(lines), results, "check-122514");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
lines.Clear();
|
lines.Clear();
|
||||||
string workItemType = "Feature";
|
string workItemType = "Feature";
|
||||||
lines.Add($"# {nameof(FeatureCheckPriority126169)}");
|
lines.Add($"# {nameof(FeatureCheckPriority126169)}");
|
||||||
lines.Add(string.Empty);
|
lines.Add(string.Empty);
|
||||||
results = FeatureCheckPriority126169(url, lines, bugUserStoryWorkItemTypes, keyValuePairs, workItemType);
|
results = FeatureCheckPriority126169(url, lines, bugUserStoryWorkItemTypes, records, workItemType);
|
||||||
WriteFiles(fileConnectorConfiguration.TargetFileLocation, "check-126169", new(lines), results);
|
WriteFiles(fileConnectorConfiguration.TargetFileLocation, new(lines), results, "check-126169");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
lines.Clear();
|
||||||
|
string workItemType = "Feature";
|
||||||
|
lines.Add($"# {nameof(FeatureCheckState123066)}");
|
||||||
|
lines.Add(string.Empty);
|
||||||
|
results = FeatureCheckState123066(url, lines, bugUserStoryTaskWorkItemTypes, records, workItemType);
|
||||||
|
WriteFiles(fileConnectorConfiguration.TargetFileLocation, new(lines), results, "check-123066");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,13 +7,15 @@ public class Record
|
|||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
|
||||||
public Record(WorkItem workItem, ReadOnlyDictionary<int, Record> children)
|
public Record(WorkItem workItem, WorkItem? parent, ReadOnlyCollection<Record> children)
|
||||||
{
|
{
|
||||||
WorkItem = workItem;
|
WorkItem = workItem;
|
||||||
|
Parent = parent;
|
||||||
Children = children;
|
Children = children;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorkItem WorkItem { get; set; }
|
public WorkItem WorkItem { get; set; }
|
||||||
public ReadOnlyDictionary<int, Record> Children { get; set; }
|
public WorkItem? Parent { get; set; }
|
||||||
|
public ReadOnlyCollection<Record> Children { get; set; }
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user