diff --git a/Adaptation/FileHandlers/Markdown/FileRead.cs b/Adaptation/FileHandlers/Markdown/FileRead.cs index 1ae4a36..23bae67 100644 --- a/Adaptation/FileHandlers/Markdown/FileRead.cs +++ b/Adaptation/FileHandlers/Markdown/FileRead.cs @@ -246,7 +246,7 @@ public class FileRead : Shared.FileRead, IFileRead } } - private static void WriteFiles(string destinationDirectory, string fileName, ReadOnlyCollection lines) + private static void WriteFiles(string destinationDirectory, string fileName, ReadOnlyCollection lines, ReadOnlyCollection workItems) { string text = string.Join(Environment.NewLine, lines); string markdownFile = Path.Combine(destinationDirectory, $"{fileName}.md"); @@ -258,6 +258,11 @@ public class FileRead : Shared.FileRead, IFileRead string htmlOld = !File.Exists(htmlFile) ? string.Empty : File.ReadAllText(htmlFile); if (html != htmlOld) File.WriteAllText(htmlFile, html); + string json = JsonSerializer.Serialize(workItems.ToArray(), 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 ReadOnlyCollection FilterChildren(Record record, ReadOnlyCollection workItemTypes) @@ -288,12 +293,13 @@ public class FileRead : Shared.FileRead, IFileRead return result; } - private static void FeatureCheckIterationPath(string url, List lines, ReadOnlyCollection workItemTypes, ReadOnlyDictionary workItemAndChildren, string workItemType) + private static ReadOnlyCollection FeatureCheckIterationPath122508(string url, List lines, ReadOnlyCollection workItemTypes, ReadOnlyDictionary workItemAndChildren, string workItemType) { + List collection = new(); WorkItem workItem; string? maxIterationPath; List results = new(); - ReadOnlyCollection workItems; + ReadOnlyCollection childrenWorkItems; foreach (KeyValuePair keyValuePair in workItemAndChildren) { workItem = keyValuePair.Value.WorkItem; @@ -302,8 +308,8 @@ public class FileRead : Shared.FileRead, IFileRead results.Clear(); if (keyValuePair.Value.Children.Count == 0) continue; - workItems = FilterChildren(keyValuePair.Value, workItemTypes); - maxIterationPath = GetMaxIterationPath(workItems); + childrenWorkItems = FilterChildren(keyValuePair.Value, workItemTypes); + maxIterationPath = GetMaxIterationPath(childrenWorkItems); if (string.IsNullOrEmpty(maxIterationPath) || workItem.IterationPath == maxIterationPath) continue; results.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}"); @@ -311,12 +317,15 @@ public class FileRead : Shared.FileRead, IFileRead results.Add($"- [ ] [{workItem.Id}]({url}{workItem.Id}) => {workItem.IterationPath} != {maxIterationPath}"); results.Add(string.Empty); lines.AddRange(results); + collection.Add(WorkItem.Get(workItem, $"IterationPath:{workItem.Id};{workItem.IterationPath} != {maxIterationPath}")); + collection.Add(workItem); } + return new(collection); } - private static ReadOnlyCollection GetIdsNotMatching(string tags, ReadOnlyCollection workItems) + private static ReadOnlyCollection GetWorkItemsNotMatching(string tags, ReadOnlyCollection workItems) { - List results = new(); + List results = new(); string[] segments; string[] parentTags = tags.Split(';'); foreach (WorkItem workItem in workItems) @@ -324,81 +333,97 @@ public class FileRead : Shared.FileRead, IFileRead segments = tags.Split(';'); if (segments.Length > 0 && parentTags.Any(l => segments.Contains(l))) continue; - results.Add(workItem.Id); + results.Add(workItem); } return new(results); } - private static void FeatureCheckTag(string url, List lines, ReadOnlyCollection workItemTypes, ReadOnlyDictionary workItemAndChildren, string workItemType) + private static ReadOnlyCollection FeatureCheckTag122514(string url, List lines, ReadOnlyCollection workItemTypes, ReadOnlyDictionary workItemAndChildren, string workItemType) { + List collection = new(); WorkItem workItem; List results = new(); - ReadOnlyCollection idsNotMatching; - ReadOnlyCollection workItems; + List violations = new(); + ReadOnlyCollection childrenWorkItems; + ReadOnlyCollection workItemsNotMatching; foreach (KeyValuePair keyValuePair in workItemAndChildren) { workItem = keyValuePair.Value.WorkItem; if (workItem.WorkItemType != workItemType) continue; results.Clear(); + violations.Clear(); if (keyValuePair.Value.Children.Count == 0) continue; if (string.IsNullOrEmpty(workItem.Tags)) - idsNotMatching = new(new int[] { workItem.Id }); + workItemsNotMatching = new(new WorkItem[] { workItem }); else { - workItems = FilterChildren(keyValuePair.Value, workItemTypes); - idsNotMatching = GetIdsNotMatching(workItem.Tags, workItems); - if (!string.IsNullOrEmpty(workItem.Tags) && idsNotMatching.Count == 0) + childrenWorkItems = FilterChildren(keyValuePair.Value, workItemTypes); + workItemsNotMatching = GetWorkItemsNotMatching(workItem.Tags, childrenWorkItems); + if (!string.IsNullOrEmpty(workItem.Tags) && workItemsNotMatching.Count == 0) continue; } results.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}"); results.Add(string.Empty); - foreach (int id in idsNotMatching) - results.Add($"- [ ] [{id}]({url}{id}) {nameof(workItem.Tags)} != {workItem.Tags}"); + foreach (WorkItem item in workItemsNotMatching) + results.Add($"- [ ] [{item}]({url}{item}) {nameof(workItem.Tags)} != {workItem.Tags}"); results.Add(string.Empty); lines.AddRange(results); + violations.Add($"Tag:{workItem.Tags};"); + foreach (WorkItem item in workItemsNotMatching) + violations.Add($"{item.Id}:{item.Tags};"); + collection.Add(WorkItem.Get(workItem, string.Join(" ", violations))); } + return new(collection); } - private static ReadOnlyCollection GetIdsNotMatching(int? priority, ReadOnlyCollection workItems) + private static ReadOnlyCollection GetWorkItemsNotMatching(int? priority, ReadOnlyCollection workItems) { - List results = new(); + List results = new(); foreach (WorkItem workItem in workItems) { if (workItem.Priority == priority) continue; - results.Add(workItem.Id); + results.Add(workItem); } return new(results); } - private static void FeatureCheckPriority(string url, List lines, ReadOnlyCollection workItemTypes, ReadOnlyDictionary workItemAndChildren, string workItemType) + private static ReadOnlyCollection FeatureCheckPriority126169(string url, List lines, ReadOnlyCollection workItemTypes, ReadOnlyDictionary workItemAndChildren, string workItemType) { + List collection = new(); WorkItem workItem; List results = new(); - ReadOnlyCollection idsNotMatching; - ReadOnlyCollection workItems; + List violations = new(); + ReadOnlyCollection childrenWorkItems; + ReadOnlyCollection workItemsNotMatching; foreach (KeyValuePair keyValuePair in workItemAndChildren) { workItem = keyValuePair.Value.WorkItem; if (workItem.WorkItemType != workItemType) continue; results.Clear(); + violations.Clear(); if (keyValuePair.Value.Children.Count == 0) continue; - workItems = FilterChildren(keyValuePair.Value, workItemTypes); - idsNotMatching = GetIdsNotMatching(workItem.Priority, workItems); - if (idsNotMatching.Count == 0) + childrenWorkItems = FilterChildren(keyValuePair.Value, workItemTypes); + workItemsNotMatching = GetWorkItemsNotMatching(workItem.Priority, childrenWorkItems); + if (workItemsNotMatching.Count == 0) continue; results.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}"); results.Add(string.Empty); results.Add($"- [{workItem.Id}]({url}{workItem.Id})"); - foreach (int id in idsNotMatching) - results.Add($"- [ ] [{id}]({url}{id}) {nameof(workItem.Priority)} != {workItem.Priority}"); + foreach (WorkItem item in workItemsNotMatching) + results.Add($"- [ ] [{item}]({url}{item}) {nameof(workItem.Priority)} != {workItem.Priority}"); results.Add(string.Empty); lines.AddRange(results); + violations.Add($"Priority:{workItem.Priority};"); + foreach (WorkItem item in workItemsNotMatching) + violations.Add($"{item.Id}:{item.Priority};"); + collection.Add(WorkItem.Get(workItem, string.Join(" ", violations))); } + return new(collection); } private static void WriteFiles(FileConnectorConfiguration fileConnectorConfiguration, string url, ReadOnlyCollection workItemTypes, ReadOnlyCollection workItems) @@ -406,15 +431,16 @@ public class FileRead : Shared.FileRead, IFileRead string json; List spaces = new(); List lines = new(); - ReadOnlyDictionary keyValuePairs = GetWorkItems(workItems); - ReadOnlyDictionary workItemAndChildren = GetWorkItemAndChildren(keyValuePairs); + ReadOnlyCollection results; + ReadOnlyDictionary collection = GetWorkItems(workItems); + ReadOnlyDictionary keyValuePairs = GetWorkItemAndChildren(collection); ReadOnlyCollection bugUserStoryWorkItemTypes = new(new string[] { "Bug", "User Story" }); ReadOnlyCollection bugUserStoryTaskWorkItemTypes = new(new string[] { "Bug", "User Story", "Task" }); if (!Directory.Exists(fileConnectorConfiguration.TargetFileLocation)) _ = Directory.CreateDirectory(fileConnectorConfiguration.TargetFileLocation); - if (workItemAndChildren.Count == -1) + if (keyValuePairs.Count == -1) { - json = JsonSerializer.Serialize(workItemAndChildren, new JsonSerializerOptions() { WriteIndented = true }); + json = JsonSerializer.Serialize(keyValuePairs, new JsonSerializerOptions() { WriteIndented = true }); File.WriteAllText(Path.Combine(fileConnectorConfiguration.TargetFileLocation, ".json"), json); } foreach (string workItemType in workItemTypes) @@ -422,32 +448,33 @@ public class FileRead : Shared.FileRead, IFileRead lines.Clear(); lines.Add($"# {workItemType}"); lines.Add(string.Empty); - AppendLines(url, spaces, lines, workItemAndChildren, workItemType); - WriteFiles(fileConnectorConfiguration.TargetFileLocation, workItemType, new(lines)); + AppendLines(url, spaces, lines, keyValuePairs, workItemType); + results = new(Array.Empty()); + WriteFiles(fileConnectorConfiguration.TargetFileLocation, workItemType, new(lines), results); } { lines.Clear(); string workItemType = "Feature"; - lines.Add($"# {nameof(FeatureCheckIterationPath)}"); + lines.Add($"# {nameof(FeatureCheckIterationPath122508)}"); lines.Add(string.Empty); - FeatureCheckIterationPath(url, lines, bugUserStoryTaskWorkItemTypes, workItemAndChildren, workItemType); - WriteFiles(fileConnectorConfiguration.TargetFileLocation, $"{nameof(FeatureCheckIterationPath)}", new(lines)); + results = FeatureCheckIterationPath122508(url, lines, bugUserStoryTaskWorkItemTypes, keyValuePairs, workItemType); + WriteFiles(fileConnectorConfiguration.TargetFileLocation, "check-122508", new(lines), results); } { lines.Clear(); string workItemType = "Feature"; - lines.Add($"# {nameof(FeatureCheckTag)}"); + lines.Add($"# {nameof(FeatureCheckTag122514)}"); lines.Add(string.Empty); - FeatureCheckTag(url, lines, bugUserStoryWorkItemTypes, workItemAndChildren, workItemType); - WriteFiles(fileConnectorConfiguration.TargetFileLocation, $"{nameof(FeatureCheckTag)}", new(lines)); + results = FeatureCheckTag122514(url, lines, bugUserStoryWorkItemTypes, keyValuePairs, workItemType); + WriteFiles(fileConnectorConfiguration.TargetFileLocation, "check-122514", new(lines), results); } { lines.Clear(); string workItemType = "Feature"; - lines.Add($"# {nameof(FeatureCheckPriority)}"); + lines.Add($"# {nameof(FeatureCheckPriority126169)}"); lines.Add(string.Empty); - FeatureCheckPriority(url, lines, bugUserStoryWorkItemTypes, workItemAndChildren, workItemType); - WriteFiles(fileConnectorConfiguration.TargetFileLocation, $"{nameof(FeatureCheckPriority)}", new(lines)); + results = FeatureCheckPriority126169(url, lines, bugUserStoryWorkItemTypes, keyValuePairs, workItemType); + WriteFiles(fileConnectorConfiguration.TargetFileLocation, "check-126169", new(lines), results); } } @@ -457,10 +484,8 @@ public class FileRead : Shared.FileRead, IFileRead { string json = File.ReadAllText(reportFullPath); WorkItem[]? workItems = JsonSerializer.Deserialize(json); - string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(reportFullPath); if (workItems is null) throw new Exception(nameof(workItems)); - string[] alternateTargetFolders = _FileConnectorConfiguration.AlternateTargetFolder.Split('|'); if (workItems.Length > 0) WriteFiles(_FileConnectorConfiguration, _URL, _WorkItemTypes, new(workItems)); } diff --git a/Adaptation/FileHandlers/json/FileRead.cs b/Adaptation/FileHandlers/json/FileRead.cs index 68b145e..6f8add4 100644 --- a/Adaptation/FileHandlers/json/FileRead.cs +++ b/Adaptation/FileHandlers/json/FileRead.cs @@ -141,8 +141,9 @@ public class FileRead : Shared.FileRead, IFileRead fields.MicrosoftVSTSSchedulingTargetDate == DateTime.MinValue ? null : fields.MicrosoftVSTSSchedulingTargetDate, fields.MicrosoftVSTSCommonTimeCriticality == 0 ? null : fields.MicrosoftVSTSCommonTimeCriticality, fields.SystemTitle, - fields.SystemWorkItemType, - fields.CustomWSJF == 0 ? null : fields.CustomWSJF); + null, + fields.CustomWSJF == 0 ? null : fields.CustomWSJF, + fields.SystemWorkItemType); results.Add(workItem); } return new(results); diff --git a/Adaptation/FileHandlers/json/StaticSite/leo.html b/Adaptation/FileHandlers/json/StaticSite/leo.html index 1fbcb68..c13b486 100644 --- a/Adaptation/FileHandlers/json/StaticSite/leo.html +++ b/Adaptation/FileHandlers/json/StaticSite/leo.html @@ -6,15 +6,15 @@ FI Backlog HiRel (Leominster) - - + + - - - - - - + + + + + + @@ -33,9 +33,6 @@