Sort
This commit is contained in:
parent
ba9b7d8d64
commit
6bda42fe67
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
@ -17,8 +17,8 @@
|
|||||||
"Day-Helper-2024-09-11",
|
"Day-Helper-2024-09-11",
|
||||||
"*.json",
|
"*.json",
|
||||||
".kanbn",
|
".kanbn",
|
||||||
"444",
|
"Epic|Feature|User Story",
|
||||||
"555",
|
"L:/DevOps/Mesa_FI/File-Folder-Helper/.vscode/helper/tfs",
|
||||||
"666",
|
"666",
|
||||||
"777",
|
"777",
|
||||||
"888",
|
"888",
|
||||||
|
@ -92,16 +92,23 @@ internal static partial class Helper20240911
|
|||||||
Dictionary<int, Record> results = [];
|
Dictionary<int, Record> results = [];
|
||||||
int? childId;
|
int? childId;
|
||||||
WorkItem? childWorkItem;
|
WorkItem? childWorkItem;
|
||||||
|
List<WorkItem> collection = [];
|
||||||
Dictionary<int, Record> keyValuePairs;
|
Dictionary<int, Record> keyValuePairs;
|
||||||
if (workItem.Relations is not null && workItem.Relations.Length > 0)
|
if (workItem.Relations is not null && workItem.Relations.Length > 0)
|
||||||
{
|
{
|
||||||
|
collection.Clear();
|
||||||
foreach (Relation relation in workItem.Relations)
|
foreach (Relation relation in workItem.Relations)
|
||||||
{
|
{
|
||||||
childId = GetIdFromUrlIfChild(relation);
|
childId = GetIdFromUrlIfChild(relation);
|
||||||
if (childId is null || !workItems.TryGetValue(childId.Value, out childWorkItem))
|
if (childId is null || !workItems.TryGetValue(childId.Value, out childWorkItem))
|
||||||
continue;
|
continue;
|
||||||
keyValuePairs = GetKeyValuePairs(workItems, childWorkItem);
|
collection.Add(childWorkItem);
|
||||||
results.Add(childId.Value, new(childWorkItem, new(keyValuePairs)));
|
}
|
||||||
|
collection = (from l in collection orderby l.State != "Closed", l.Id select l).ToList();
|
||||||
|
foreach (WorkItem item in collection)
|
||||||
|
{
|
||||||
|
keyValuePairs = GetKeyValuePairs(workItems, item);
|
||||||
|
results.Add(item.Id, new(item, new(keyValuePairs)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
@ -123,34 +130,48 @@ internal static partial class Helper20240911
|
|||||||
|
|
||||||
private static string GetClosed(WorkItem workItem)
|
private static string GetClosed(WorkItem workItem)
|
||||||
{
|
{
|
||||||
string result = workItem.ClosedDate is null ? "[ ]" : "[x]";
|
string result = workItem.State != "Closed" ? "[ ]" : "[x]";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AppendLines(List<char> spaces, List<string> lines, Record record)
|
private static string GetLine(List<char> spaces, WorkItem workItem, KeyValuePair<int, Record> keyValuePair, bool condensed) =>
|
||||||
|
condensed ? $"{new string(spaces.Skip(1).ToArray())}- {GetClosed(workItem)} {keyValuePair.Key} - {workItem.Title}" :
|
||||||
|
$"{new string(spaces.Skip(1).ToArray())}- {GetClosed(workItem)} {keyValuePair.Key} - {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)
|
||||||
{
|
{
|
||||||
spaces.Add('\t');
|
spaces.Add('\t');
|
||||||
WorkItem workItem;
|
WorkItem workItem;
|
||||||
foreach (KeyValuePair<int, Record> keyValuePair in record.Children)
|
foreach (KeyValuePair<int, Record> keyValuePair in record.Children)
|
||||||
{
|
{
|
||||||
workItem = keyValuePair.Value.WorkItem;
|
workItem = keyValuePair.Value.WorkItem;
|
||||||
lines.Add($"{new string(spaces.ToArray())}- {GetClosed(workItem)} {keyValuePair.Key} - {workItem.Title} - {workItem.ClosedDate}");
|
lines.Add(GetLine(spaces, workItem, keyValuePair, condensed));
|
||||||
AppendLines(spaces, lines, keyValuePair.Value);
|
AppendLines(spaces, lines, keyValuePair.Value, condensed);
|
||||||
}
|
}
|
||||||
spaces.RemoveAt(0);
|
spaces.RemoveAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AppendLines(List<char> spaces, List<string> lines, ReadOnlyDictionary<int, Record> workItemAndChildren)
|
private static void AppendLines(List<char> spaces, List<string> lines, ReadOnlyDictionary<int, Record> workItemAndChildren, string workItemType)
|
||||||
{
|
{
|
||||||
WorkItem workItem;
|
WorkItem workItem;
|
||||||
foreach (KeyValuePair<int, Record> keyValuePair in workItemAndChildren)
|
foreach (KeyValuePair<int, Record> keyValuePair in workItemAndChildren)
|
||||||
{
|
{
|
||||||
workItem = keyValuePair.Value.WorkItem;
|
workItem = keyValuePair.Value.WorkItem;
|
||||||
lines.Add($"## {keyValuePair.Key} - {workItem.Title}");
|
if (workItem.WorkItemType != workItemType)
|
||||||
|
continue;
|
||||||
|
lines.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}");
|
||||||
lines.Add(string.Empty);
|
lines.Add(string.Empty);
|
||||||
lines.Add($"{new string(spaces.ToArray())}- {GetClosed(workItem)} {keyValuePair.Key} - {workItem.Title} - {workItem.ClosedDate}");
|
lines.Add($"- [{workItem.Id}](https://tfs.intra.infineon.com/tfs/FactoryIntegration/ART%20SPS/_workitems/edit/{workItem.Id})");
|
||||||
AppendLines(spaces, lines, keyValuePair.Value);
|
|
||||||
lines.Add(string.Empty);
|
lines.Add(string.Empty);
|
||||||
|
if (keyValuePair.Value.Children.Count > 0)
|
||||||
|
{
|
||||||
|
AppendLines(spaces, lines, keyValuePair.Value, condensed: true);
|
||||||
|
lines.Add(string.Empty);
|
||||||
|
lines.Add($"## Extended - {workItem.Id} - {workItem.Title}");
|
||||||
|
lines.Add(string.Empty);
|
||||||
|
AppendLines(spaces, lines, keyValuePair.Value, condensed: false);
|
||||||
|
lines.Add(string.Empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,8 +180,12 @@ internal static partial class Helper20240911
|
|||||||
List<char> spaces = [];
|
List<char> spaces = [];
|
||||||
string searchPattern = args[2];
|
string searchPattern = args[2];
|
||||||
string filterDirectory = args[3];
|
string filterDirectory = args[3];
|
||||||
|
string[] workItemTypes = args[4].Split('|');
|
||||||
List<string> lines = ["# WorkItems", string.Empty];
|
List<string> lines = ["# WorkItems", string.Empty];
|
||||||
string sourceDirectory = Path.GetFullPath(args[0]);
|
string sourceDirectory = Path.GetFullPath(args[0]);
|
||||||
|
string destinationDirectory = Path.GetFullPath(args[5]);
|
||||||
|
if (!Directory.Exists(destinationDirectory))
|
||||||
|
_ = Directory.CreateDirectory(destinationDirectory);
|
||||||
string[] files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.AllDirectories);
|
string[] files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.AllDirectories);
|
||||||
logger.LogInformation("With search pattern '{SearchPattern}' found {files} file(s)", searchPattern, files.Length);
|
logger.LogInformation("With search pattern '{SearchPattern}' found {files} file(s)", searchPattern, files.Length);
|
||||||
ReadOnlyDictionary<int, WorkItem> workItems = GetWorkItems(filterDirectory, files);
|
ReadOnlyDictionary<int, WorkItem> workItems = GetWorkItems(filterDirectory, files);
|
||||||
@ -172,8 +197,11 @@ internal static partial class Helper20240911
|
|||||||
string json = JsonSerializer.Serialize(workItemAndChildren, new JsonSerializerOptions() { WriteIndented = true });
|
string json = JsonSerializer.Serialize(workItemAndChildren, new JsonSerializerOptions() { WriteIndented = true });
|
||||||
File.WriteAllText(".json", json);
|
File.WriteAllText(".json", json);
|
||||||
}
|
}
|
||||||
AppendLines(spaces, lines, workItemAndChildren);
|
foreach (string workItemType in workItemTypes)
|
||||||
File.WriteAllText(".md", string.Join(Environment.NewLine, lines));
|
{
|
||||||
|
AppendLines(spaces, lines, workItemAndChildren, workItemType);
|
||||||
|
File.WriteAllText(Path.Combine(destinationDirectory, $"{workItemType}.md"), string.Join(Environment.NewLine, lines));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user