Sync to Distinct Max Iteration Path
This commit is contained in:
parent
dc5a369e55
commit
59231ad9e2
16
.vscode/launch.json
vendored
16
.vscode/launch.json
vendored
@ -13,16 +13,12 @@
|
||||
"args": [
|
||||
"s",
|
||||
"X",
|
||||
"L:/Git/Linux-Ubuntu-Server/etc/nginx/include",
|
||||
"Day-Helper-2024-09-16",
|
||||
"*.conf",
|
||||
"L:/Git/Linux-Ubuntu-Server/etc/nginx/sites-available/default",
|
||||
"include /etc/nginx/include/",
|
||||
"proxy_pass",
|
||||
"666",
|
||||
"777",
|
||||
"888",
|
||||
"999"
|
||||
"D:/5-Other-Small/Kanban-messa010ec/Kanban/Work-Items",
|
||||
"Day-Helper-2024-09-11",
|
||||
"*.json",
|
||||
".kanbn",
|
||||
"Epic|Feature|User Story",
|
||||
"L:/DevOps/Mesa_FI/File-Folder-Helper/.vscode/helper/tfs"
|
||||
],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"console": "integratedTerminal",
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace File_Folder_Helper.Day.Q32024;
|
||||
@ -8,6 +9,17 @@ namespace File_Folder_Helper.Day.Q32024;
|
||||
internal static partial class Helper20240828
|
||||
{
|
||||
|
||||
public record HeaderCommon(DateTime Date,
|
||||
string? Employee,
|
||||
string? Layer,
|
||||
string? MesEntity,
|
||||
string? PSN,
|
||||
string? Quantity,
|
||||
string? RDS,
|
||||
string? Reactor,
|
||||
string? Recipe,
|
||||
string? Zone);
|
||||
|
||||
public record Record(string? CassetteId,
|
||||
ReadOnlyCollection<string>? CassetteSegments,
|
||||
DateTime? Date,
|
||||
@ -139,46 +151,64 @@ internal static partial class Helper20240828
|
||||
|
||||
internal static void MoveWaferCounterToArchive(ILogger<Worker> logger, List<string> args)
|
||||
{
|
||||
Record record;
|
||||
string json;
|
||||
string keyFile;
|
||||
string? recipe;
|
||||
string[] lines;
|
||||
int totalMinutes;
|
||||
string checkFile;
|
||||
TimeSpan timeSpan;
|
||||
string weekOfYear;
|
||||
string directory;
|
||||
string? quantity;
|
||||
string runDataSheet;
|
||||
string checkDirectory;
|
||||
HeaderCommon headerCommon;
|
||||
string logDateFormat = args[3];
|
||||
string wcSearchPattern = args[5];
|
||||
string logSearchPattern = args[2];
|
||||
ReadOnlyCollection<Record>? records;
|
||||
string logSearchPattern = $"SKIP---{args[2]}";
|
||||
string logDirectory = Path.GetFullPath(args[0]);
|
||||
string sourceDirectory = Path.GetFullPath(args[4]);
|
||||
string archiveDirectory = Path.GetFullPath(args[6]);
|
||||
Calendar calendar = new CultureInfo("en-US").Calendar;
|
||||
Dictionary<int, ReadOnlyCollection<Record>> keyValuePairs = GetKeyValuePairs(logSearchPattern, logDirectory);
|
||||
logger.LogInformation("Mapped {keyValuePairs}(s)", keyValuePairs.Count);
|
||||
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
|
||||
FileInfo[] collection = Directory.GetFiles(sourceDirectory, wcSearchPattern, SearchOption.AllDirectories).Select(l => new FileInfo(l)).ToArray();
|
||||
logger.LogInformation("Found {collection}(s)", collection.Length);
|
||||
foreach (FileInfo fileInfo in collection)
|
||||
{
|
||||
if (fileInfo.DirectoryName is null || !fileInfo.DirectoryName.Contains('-'))
|
||||
continue;
|
||||
lines = File.ReadAllLines(fileInfo.FullName);
|
||||
recipe = lines.Length < 2 ? null : lines[1];
|
||||
quantity = lines.Length < 1 ? null : lines[0];
|
||||
keyFile = $"{fileInfo.FullName}.txt";
|
||||
if (!File.Exists(keyFile))
|
||||
continue;
|
||||
lines = File.ReadAllLines(keyFile);
|
||||
if (lines.Length != 1)
|
||||
continue;
|
||||
checkDirectory = Path.Combine(fileInfo.DirectoryName, lines[0].Replace('*', '.'));
|
||||
runDataSheet = Regex.Replace(lines[0], @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", ".").Split('\r')[0].Split('\n')[0];
|
||||
directory = Path.Combine(fileInfo.DirectoryName, runDataSheet);
|
||||
checkDirectory = Path.Combine(directory, fileInfo.LastWriteTime.Ticks.ToString());
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
_ = Directory.CreateDirectory(checkDirectory);
|
||||
checkFile = Path.Combine(checkDirectory, fileInfo.Name);
|
||||
checkFile = Path.Combine(directory, fileInfo.Name);
|
||||
if (File.Exists(checkFile))
|
||||
continue;
|
||||
headerCommon = new(fileInfo.LastWriteTime, null, null, null, null, quantity, runDataSheet, null, recipe, null);
|
||||
json = JsonSerializer.Serialize(headerCommon, jsonSerializerOptions);
|
||||
File.Move(fileInfo.FullName, checkFile);
|
||||
File.Delete(keyFile);
|
||||
checkFile = Path.Combine(checkDirectory, $"{fileInfo.Name}.json");
|
||||
if (File.Exists(checkFile))
|
||||
continue;
|
||||
File.WriteAllText(checkFile, json);
|
||||
Directory.SetLastWriteTime(checkDirectory, fileInfo.LastWriteTime);
|
||||
}
|
||||
Record record;
|
||||
int totalMinutes;
|
||||
string weekOfYear;
|
||||
TimeSpan timeSpan;
|
||||
ReadOnlyCollection<Record>? records;
|
||||
Calendar calendar = new CultureInfo("en-US").Calendar;
|
||||
Dictionary<int, ReadOnlyCollection<Record>> keyValuePairs = GetKeyValuePairs(logSearchPattern, logDirectory);
|
||||
logger.LogInformation("Mapped {keyValuePairs}(s)", keyValuePairs.Count);
|
||||
foreach (FileInfo fileInfo in collection)
|
||||
{
|
||||
if (fileInfo.DirectoryName is null || fileInfo.DirectoryName.Contains('-'))
|
||||
|
@ -120,8 +120,6 @@ internal static partial class Helper20240911
|
||||
Dictionary<int, Record> keyValuePairs;
|
||||
foreach (KeyValuePair<int, WorkItem> keyValuePair in workItems)
|
||||
{
|
||||
// if (keyValuePair.Key != 119185)
|
||||
// continue;
|
||||
keyValuePairs = GetKeyValuePairs(workItems, keyValuePair.Value);
|
||||
results.Add(keyValuePair.Key, new(keyValuePair.Value, new(keyValuePairs)));
|
||||
}
|
||||
@ -157,29 +155,42 @@ internal static partial class Helper20240911
|
||||
private static void AppendLines(List<char> spaces, List<string> lines, ReadOnlyDictionary<int, Record> workItemAndChildren, string workItemType)
|
||||
{
|
||||
WorkItem workItem;
|
||||
string? maxIterationPath;
|
||||
List<string> distinct = [];
|
||||
foreach (KeyValuePair<int, Record> keyValuePair in workItemAndChildren)
|
||||
{
|
||||
workItem = keyValuePair.Value.WorkItem;
|
||||
// if (keyValuePair.Key != 109724)
|
||||
// continue;
|
||||
if (workItem.WorkItemType != workItemType)
|
||||
continue;
|
||||
lines.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}");
|
||||
lines.Add(string.Empty);
|
||||
lines.Add($"- [{workItem.Id}](https://tfs.intra.infineon.com/tfs/FactoryIntegration/ART%20SPS/_workitems/edit/{workItem.Id})");
|
||||
if (keyValuePair.Value.Children.Count == 0)
|
||||
lines.Add(string.Empty);
|
||||
if (keyValuePair.Value.Children.Count > 0)
|
||||
else
|
||||
{
|
||||
AppendLines(spaces, lines, keyValuePair.Value, condensed: true, sprintOnly: false);
|
||||
lines.Add(string.Empty);
|
||||
distinct.Clear();
|
||||
AppendLines(spaces, distinct, keyValuePair.Value, condensed: false, sprintOnly: true);
|
||||
if (distinct.Count > 1)
|
||||
{
|
||||
lines.Add($"## Distinct Iteration Path(s) - {workItem.WorkItemType} - {workItem.AssignedTo} - {workItem.Id} - {workItem.Title} - {workItem.IterationPath}");
|
||||
lines.Add(string.Empty);
|
||||
lines.Add($"- [{workItem.Id}](https://tfs.intra.infineon.com/tfs/FactoryIntegration/ART%20SPS/_workitems/edit/{workItem.Id})");
|
||||
lines.Add(string.Empty);
|
||||
AppendLines(spaces, distinct, keyValuePair.Value, condensed: false, sprintOnly: true);
|
||||
distinct.Sort();
|
||||
lines.AddRange(distinct.Distinct());
|
||||
distinct = (from l in distinct select l.Trim()).Distinct().ToList();
|
||||
lines.AddRange(distinct);
|
||||
lines.Add(string.Empty);
|
||||
maxIterationPath = distinct.Max();
|
||||
if (!string.IsNullOrEmpty(maxIterationPath) && maxIterationPath.Contains("] ") && maxIterationPath.Split(']')[1].Trim() != workItem.IterationPath)
|
||||
{
|
||||
lines.Add($"### Sync to Distinct Max Iteration Path => {maxIterationPath} - {workItem.Id} - {workItem.Title}");
|
||||
lines.Add(string.Empty);
|
||||
}
|
||||
}
|
||||
lines.Add($"## Extended - {workItem.Id} - {workItem.Title}");
|
||||
lines.Add(string.Empty);
|
||||
AppendLines(spaces, lines, keyValuePair.Value, condensed: false, sprintOnly: false);
|
||||
@ -195,10 +206,10 @@ internal static partial class Helper20240911
|
||||
string text;
|
||||
string checkFile;
|
||||
List<char> spaces = [];
|
||||
List<string> lines = [];
|
||||
string searchPattern = args[2];
|
||||
string filterDirectory = args[3];
|
||||
string[] workItemTypes = args[4].Split('|');
|
||||
List<string> lines = ["# WorkItems", string.Empty];
|
||||
string sourceDirectory = Path.GetFullPath(args[0]);
|
||||
string destinationDirectory = Path.GetFullPath(args[5]);
|
||||
if (!Directory.Exists(destinationDirectory))
|
||||
@ -216,6 +227,8 @@ internal static partial class Helper20240911
|
||||
}
|
||||
foreach (string workItemType in workItemTypes)
|
||||
{
|
||||
lines.Clear();
|
||||
lines.AddRange(["# WorkItems", string.Empty]);
|
||||
AppendLines(spaces, lines, workItemAndChildren, workItemType);
|
||||
checkFile = Path.Combine(destinationDirectory, $"{workItemType}.md");
|
||||
text = string.Join(Environment.NewLine, lines);
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Nullable>enable</Nullable>
|
||||
<OutputType>Exe</OutputType>
|
||||
@ -22,6 +22,6 @@
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.4" />
|
||||
<PackageReference Include="TextCopy" Version="6.2.1" />
|
||||
<PackageReference Include="WindowsShortcutFactory" Version="1.2.0" />
|
||||
<PackageReference Include="YamlDotNet" Version="16.0.0" />
|
||||
<PackageReference Include="YamlDotNet" Version="16.1.2" />
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
x
Reference in New Issue
Block a user