Switch to Datagrid

This commit is contained in:
Mike Phares 2024-10-07 19:27:14 -07:00
parent 3977727168
commit b4c91e3f2c
5 changed files with 129 additions and 74 deletions

View File

@ -246,7 +246,7 @@ public class FileRead : Shared.FileRead, IFileRead
}
}
private static void WriteFiles(string destinationDirectory, string fileName, ReadOnlyCollection<string> lines)
private static void WriteFiles(string destinationDirectory, string fileName, ReadOnlyCollection<string> lines, ReadOnlyCollection<WorkItem> 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<WorkItem> FilterChildren(Record record, ReadOnlyCollection<string> workItemTypes)
@ -288,12 +293,13 @@ public class FileRead : Shared.FileRead, IFileRead
return result;
}
private static void FeatureCheckIterationPath(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, ReadOnlyDictionary<int, Record> workItemAndChildren, string workItemType)
{
List<WorkItem> collection = new();
WorkItem workItem;
string? maxIterationPath;
List<string> results = new();
ReadOnlyCollection<WorkItem> workItems;
ReadOnlyCollection<WorkItem> childrenWorkItems;
foreach (KeyValuePair<int, Record> 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<int> GetIdsNotMatching(string tags, ReadOnlyCollection<WorkItem> workItems)
private static ReadOnlyCollection<WorkItem> GetWorkItemsNotMatching(string tags, ReadOnlyCollection<WorkItem> workItems)
{
List<int> results = new();
List<WorkItem> 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<string> lines, ReadOnlyCollection<string> workItemTypes, ReadOnlyDictionary<int, Record> workItemAndChildren, string workItemType)
private static ReadOnlyCollection<WorkItem> FeatureCheckTag122514(string url, List<string> lines, ReadOnlyCollection<string> workItemTypes, ReadOnlyDictionary<int, Record> workItemAndChildren, string workItemType)
{
List<WorkItem> collection = new();
WorkItem workItem;
List<string> results = new();
ReadOnlyCollection<int> idsNotMatching;
ReadOnlyCollection<WorkItem> workItems;
List<string> violations = new();
ReadOnlyCollection<WorkItem> childrenWorkItems;
ReadOnlyCollection<WorkItem> workItemsNotMatching;
foreach (KeyValuePair<int, Record> 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<int> GetIdsNotMatching(int? priority, ReadOnlyCollection<WorkItem> workItems)
private static ReadOnlyCollection<WorkItem> GetWorkItemsNotMatching(int? priority, ReadOnlyCollection<WorkItem> workItems)
{
List<int> results = new();
List<WorkItem> 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<string> lines, ReadOnlyCollection<string> workItemTypes, ReadOnlyDictionary<int, Record> workItemAndChildren, string workItemType)
private static ReadOnlyCollection<WorkItem> FeatureCheckPriority126169(string url, List<string> lines, ReadOnlyCollection<string> workItemTypes, ReadOnlyDictionary<int, Record> workItemAndChildren, string workItemType)
{
List<WorkItem> collection = new();
WorkItem workItem;
List<string> results = new();
ReadOnlyCollection<int> idsNotMatching;
ReadOnlyCollection<WorkItem> workItems;
List<string> violations = new();
ReadOnlyCollection<WorkItem> childrenWorkItems;
ReadOnlyCollection<WorkItem> workItemsNotMatching;
foreach (KeyValuePair<int, Record> 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<string> workItemTypes, ReadOnlyCollection<WorkItem> workItems)
@ -406,15 +431,16 @@ public class FileRead : Shared.FileRead, IFileRead
string json;
List<char> spaces = new();
List<string> lines = new();
ReadOnlyDictionary<int, WorkItem> keyValuePairs = GetWorkItems(workItems);
ReadOnlyDictionary<int, Record> workItemAndChildren = GetWorkItemAndChildren(keyValuePairs);
ReadOnlyCollection<WorkItem> results;
ReadOnlyDictionary<int, WorkItem> collection = GetWorkItems(workItems);
ReadOnlyDictionary<int, Record> keyValuePairs = GetWorkItemAndChildren(collection);
ReadOnlyCollection<string> bugUserStoryWorkItemTypes = new(new string[] { "Bug", "User Story" });
ReadOnlyCollection<string> 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<WorkItem>());
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<WorkItem[]>(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));
}

View File

@ -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);

View File

@ -6,15 +6,15 @@
<meta name="viewport" content="width=device-width" />
<title>FI Backlog HiRel (Leominster)</title>
<link href="/styles/bootstrap.min.css?no-cache=2024-10-04-08-34" rel="stylesheet" />
<link href="/igniteui/css/themes/bootstrap3/default/infragistics.theme.css?v=2024-10-07-10-09" rel="stylesheet" />
<link href="/igniteui/css/structure/infragistics.css?v=2024-10-07-10-09" rel="stylesheet" />
<link href="/igniteui/css/themes/bootstrap3/default/infragistics.theme.css?v=2024-10-07-18-50" rel="stylesheet" />
<link href="/igniteui/css/structure/infragistics.css?v=2024-10-07-18-50" rel="stylesheet" />
<link href="/styles/leo.css?no-cache=2024-10-04-08-34" rel="stylesheet" />
<script src="/js/jquery-3.6.0.min.js?v=2024-10-07-10-09" type="text/javascript"></script>
<script src="/js/jquery-ui.min.js?v=2024-10-07-10-09" type="text/javascript"></script>
<script src="/js/leo.js?v=2024-10-07-10-09" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.core.js?v=2024-10-07-10-09" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.lob.js?v=2024-10-07-10-09" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.dv.js?v=2024-10-07-10-09" type="text/javascript"></script>
<script src="/js/jquery-3.6.0.min.js?v=2024-10-07-18-50" type="text/javascript"></script>
<script src="/js/jquery-ui.min.js?v=2024-10-07-18-50" type="text/javascript"></script>
<script src="/js/leo.js?v=2024-10-07-18-50" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.core.js?v=2024-10-07-18-50" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.lob.js?v=2024-10-07-18-50" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.dv.js?v=2024-10-07-18-50" type="text/javascript"></script>
</head>
<body>
@ -33,9 +33,6 @@
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a target="_blank" href="/markdown/Feature.html">Feature(s)</a></li>
<li><a target="_blank" href="/markdown/FeatureCheckTag.html">Tag</a></li>
<li><a target="_blank" href="/markdown/FeatureCheckPriority.html">Priority</a></li>
<li><a target="_blank" href="/markdown/FeatureCheckIterationPath.html">Iteration Path</a></li>
</ul>
<p class="navbar-text navbar-right">
&nbsp;
@ -59,7 +56,7 @@
<script>
$(document).ready(function () {
initIndex("/json/work-items.json?v=2024-10-07-10-09");
initIndex("/json/work-items.json?v=2024-10-07-18-50");
});
</script>

View File

@ -6,15 +6,15 @@
<meta name="viewport" content="width=device-width" />
<title>FI Backlog Mesa</title>
<link href="/styles/bootstrap.min.css?no-cache=2024-10-04-08-34" rel="stylesheet" />
<link href="/igniteui/css/themes/bootstrap3/default/infragistics.theme.css?v=2024-10-07-10-09" rel="stylesheet" />
<link href="/igniteui/css/structure/infragistics.css?v=2024-10-07-10-09" rel="stylesheet" />
<link href="/igniteui/css/themes/bootstrap3/default/infragistics.theme.css?v=2024-10-07-18-50" rel="stylesheet" />
<link href="/igniteui/css/structure/infragistics.css?v=2024-10-07-18-50" rel="stylesheet" />
<link href="/styles/mes.css?no-cache=2024-10-04-08-34" rel="stylesheet" />
<script src="/js/jquery-3.6.0.min.js?v=2024-10-07-10-09" type="text/javascript"></script>
<script src="/js/jquery-ui.min.js?v=2024-10-07-10-09" type="text/javascript"></script>
<script src="/js/mes.js?v=2024-10-07-10-09" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.core.js?v=2024-10-07-10-09" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.lob.js?v=2024-10-07-10-09" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.dv.js?v=2024-10-07-10-09" type="text/javascript"></script>
<script src="/js/jquery-3.6.0.min.js?v=2024-10-07-18-50" type="text/javascript"></script>
<script src="/js/jquery-ui.min.js?v=2024-10-07-18-50" type="text/javascript"></script>
<script src="/js/mes.js?v=2024-10-07-18-50" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.core.js?v=2024-10-07-18-50" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.lob.js?v=2024-10-07-18-50" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.dv.js?v=2024-10-07-18-50" type="text/javascript"></script>
</head>
<body>
@ -33,9 +33,6 @@
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a target="_blank" href="/markdown/Feature.html">Feature(s)</a></li>
<li><a target="_blank" href="/markdown/FeatureCheckTag.html">Tag</a></li>
<li><a target="_blank" href="/markdown/FeatureCheckPriority.html">Priority</a></li>
<li><a target="_blank" href="/markdown/FeatureCheckIterationPath.html">Iteration Path</a></li>
</ul>
<p class="navbar-text navbar-right">
&nbsp;
@ -59,7 +56,7 @@
<script>
$(document).ready(function () {
initIndex("/json/work-items.json?v=2024-10-07-10-09");
initIndex("/json/work-items.json?v=2024-10-07-18-50");
});
</script>

View File

@ -33,8 +33,9 @@ public class WorkItem
DateTime? targetDate,
float? timeCriticality,
string title,
string workItemType,
float? weightedShortestJobFirst)
string? violation,
float? weightedShortestJobFirst,
string workItemType)
{
AreaPath = areaPath;
AssignedTo = assignedTo;
@ -60,8 +61,41 @@ public class WorkItem
TargetDate = targetDate;
TimeCriticality = timeCriticality;
Title = title;
WorkItemType = workItemType;
Violation = violation;
WeightedShortestJobFirst = weightedShortestJobFirst;
WorkItemType = workItemType;
}
public static WorkItem Get(WorkItem workItem, string? violation)
{
WorkItem result = new(workItem.AreaPath,
workItem.AssignedTo,
workItem.BusinessValue,
workItem.ChangedDate,
workItem.ClosedDate,
workItem.CommentCount,
workItem.CreatedDate,
workItem.Description,
workItem.Effort,
workItem.Id,
workItem.IterationPath,
workItem.Parent,
workItem.Priority,
workItem.Relations,
workItem.Requester,
workItem.ResolvedDate,
workItem.Revision,
workItem.RiskReductionMinusOpportunityEnablement,
workItem.StartDate,
workItem.State,
workItem.Tags,
workItem.TargetDate,
workItem.TimeCriticality,
workItem.Title,
workItem.Violation is null ? violation : workItem.Violation,
workItem.WeightedShortestJobFirst,
workItem.WorkItemType);
return result;
}
public string AreaPath { get; set; }
@ -88,6 +122,7 @@ public class WorkItem
public DateTime? TargetDate { get; set; }
public float? TimeCriticality { get; set; }
public string Title { get; set; }
public string? Violation { get; set; }
public string WorkItemType { get; set; }
public float? WeightedShortestJobFirst { get; set; }