Compare commits
3 Commits
6ce6c28db1
...
master
Author | SHA1 | Date | |
---|---|---|---|
89bb87bd14 | |||
e7c1fd2221 | |||
fc4449f515 |
27
.vscode/launch.json
vendored
27
.vscode/launch.json
vendored
@ -11,6 +11,33 @@
|
|||||||
"preLaunchTask": "build",
|
"preLaunchTask": "build",
|
||||||
"program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Folder-Helper.dll",
|
"program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Folder-Helper.dll",
|
||||||
"args": [
|
"args": [
|
||||||
|
"s",
|
||||||
|
"X",
|
||||||
|
"V:/Tmp/Phares/Pictures/2023 TI2023.6 Fall Samsung",
|
||||||
|
"Day-Helper-2025-07-05",
|
||||||
|
"x-653889110721.jpg~401223300869.jpg",
|
||||||
|
"3648,2736,1~3024,4032,6",
|
||||||
|
"0.341694,0.599963,0.1642,0.279605~0.552357,0.65095,0.195175,0.32383~0.31002,0.42328,0.0379464,0.0459656",
|
||||||
|
"0.259594,0.460161,0.1642,0.279605~0.45477,0.489035,0.195175,0.32383~0.328993,0.446263,0.0379464,0.0459656",
|
||||||
|
"9",
|
||||||
|
"x-825511723~x-444522128~831410304",
|
||||||
|
"s",
|
||||||
|
"X",
|
||||||
|
"\\\\mesfs.infineon.com\\EC_APC\\Production\\Traces\\DEP08CEPIEPSILON\\PollPath",
|
||||||
|
"Day-Helper-2025-07-01",
|
||||||
|
"*.pdsf",
|
||||||
|
"654321",
|
||||||
|
"Time",
|
||||||
|
"id12~CenterTemp,id13~CenterSetpt,id15~FrontTemp,id153~PPSTEPNAME,id154~SystemState,id16~FrontSetpt,id172~LVC1Ratio,id173~LVC1Carrier,id176~TotalWaferCount,i-d-1-7-8~TIME,id18~SideTemp,id183~SCRDrive4,id19~SideSetpt,id193~SCRLOAD4,id21~RearTemp,id22~RearSetpt,id221~LeftDefaultRecipe,id222~RightDefaultRecipe,id223~RecipeCompleteMsg,id25~N2H2Setpt,id26~N2H2Flow,id27~HCLSetpt,id28~HCLFlow,id29~HCLHISetpt,id30~HCLHIFlow,id37~NSRCSetpt,id38~NSRCFlow,id39~NDILSetpt,id40~NDILFlow,id41~NINJSetpt,id42~NINJFlow,id57~LVC1Setpt,id58~LVC1Flow,id61~ROTSetpt,id62~ROTSpeed,id78~LL1State,id79~LL1Init,id80~LL1Lotid,id81~LL1WafersIn,id82~LL1WfrCnt,id83~LL2State,id84~LL2Init,id85~LL2Lotid,id86~LL2WafersIn,id87~LL2WfrCnt,id93~ProcessState",
|
||||||
|
"\\\\mesfs.infineon.com\\EC_APC\\Production\\Traces\\DEP08CEPIEPSILON\\Markdown",
|
||||||
|
"\\\\mesfs.infineon.com\\EC_APC\\Production\\Traces\\DEP08CEPIEPSILON\\KeyValuePairs",
|
||||||
|
"\\\\mesfs.infineon.com\\EC_APC\\Production\\Traces\\DEP08CEPIEPSILON\\JavaScriptObjectNotation",
|
||||||
|
"s",
|
||||||
|
"X",
|
||||||
|
"F:/0-ISO-A",
|
||||||
|
"Day-Helper-2025-06-28",
|
||||||
|
"*.iso",
|
||||||
|
"F",
|
||||||
"s",
|
"s",
|
||||||
"X",
|
"X",
|
||||||
"D:/5-Other-Small",
|
"D:/5-Other-Small",
|
||||||
|
@ -277,12 +277,12 @@ internal static partial class Helper20250219 {
|
|||||||
}
|
}
|
||||||
if (!lookForNumbers) {
|
if (!lookForNumbers) {
|
||||||
for (int c = 0; c < segments.Length; c++) {
|
for (int c = 0; c < segments.Length; c++) {
|
||||||
value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\");
|
value = segments[c].Replace("\\", "\\\\").Replace("\"", "\\\"");
|
||||||
_ = stringBuilder.Append('"').Append(processDataStandardFormat.Columns[c]).Append("\":\"").Append(value).Append("\",");
|
_ = stringBuilder.Append('"').Append(processDataStandardFormat.Columns[c]).Append("\":\"").Append(value).Append("\",");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int c = 0; c < segments.Length; c++) {
|
for (int c = 0; c < segments.Length; c++) {
|
||||||
value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\");
|
value = segments[c].Replace("\\", "\\\\").Replace("\"", "\\\"");
|
||||||
if (string.IsNullOrEmpty(value))
|
if (string.IsNullOrEmpty(value))
|
||||||
_ = stringBuilder.Append('"').Append(processDataStandardFormat.Columns[c]).Append("\":").Append(value).Append("null,");
|
_ = stringBuilder.Append('"').Append(processDataStandardFormat.Columns[c]).Append("\":").Append(value).Append("null,");
|
||||||
else if (value.All(char.IsDigit))
|
else if (value.All(char.IsDigit))
|
||||||
|
@ -71,7 +71,7 @@ internal static partial class Helper20250306 {
|
|||||||
if (segments.Length != columnsLength)
|
if (segments.Length != columnsLength)
|
||||||
continue;
|
continue;
|
||||||
for (int c = 1; c < segments.Length; c++) {
|
for (int c = 1; c < segments.Length; c++) {
|
||||||
value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\");
|
value = segments[c].Replace("\\", "\\\\").Replace("\"", "\\\"");
|
||||||
line += '"' + columns[c].Trim('"') + '"' + ':' + '"' + value + '"' + ',';
|
line += '"' + columns[c].Trim('"') + '"' + ':' + '"' + value + '"' + ',';
|
||||||
}
|
}
|
||||||
line = line.Substring(0, line.Length - 1) + '}' + ',' + '\n';
|
line = line.Substring(0, line.Length - 1) + '}' + ',' + '\n';
|
||||||
|
89
ADO2025/PI6/Helper-2025-06-28.cs
Normal file
89
ADO2025/PI6/Helper-2025-06-28.cs
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
|
using DiscUtils.Iso9660;
|
||||||
|
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace File_Folder_Helper.ADO2025.PI6;
|
||||||
|
|
||||||
|
internal static partial class Helper20250628 {
|
||||||
|
|
||||||
|
private record Record(string Path,
|
||||||
|
long Size,
|
||||||
|
long Ticks);
|
||||||
|
|
||||||
|
internal static void LogIsoInformation(ILogger<Worker> logger, List<string> args) {
|
||||||
|
logger.LogInformation(args[0]);
|
||||||
|
logger.LogInformation(args[1]);
|
||||||
|
logger.LogInformation(args[2]);
|
||||||
|
string searchPattern = args[2];
|
||||||
|
string sourceDirectory = Path.GetFullPath(args[0].Split('~')[0]);
|
||||||
|
string[] searchPatternFiles = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.AllDirectories);
|
||||||
|
ReadOnlyCollection<Record> records = GetRecords(searchPatternFiles);
|
||||||
|
LogIsoInformation(logger, records, args[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ReadOnlyCollection<Record> GetRecords(string[] searchPatternFiles) {
|
||||||
|
List<Record> results = [];
|
||||||
|
Record record;
|
||||||
|
string[] files;
|
||||||
|
FileInfo fileInfo;
|
||||||
|
foreach (string searchPatternFile in searchPatternFiles) {
|
||||||
|
fileInfo = new(searchPatternFile);
|
||||||
|
record = new(searchPatternFile, fileInfo.Length, fileInfo.LastWriteTime.Ticks);
|
||||||
|
results.Add(record);
|
||||||
|
}
|
||||||
|
return results.AsReadOnly();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetSizeWithSuffix(long value) {
|
||||||
|
string result;
|
||||||
|
int i = 0;
|
||||||
|
string[] SizeSuffixes = ["bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
||||||
|
if (value < 0) {
|
||||||
|
result = "-" + GetSizeWithSuffix(-value);
|
||||||
|
} else {
|
||||||
|
while (Math.Round(value / 1024f) >= 1) {
|
||||||
|
value /= 1024;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
result = string.Format("{0:n1} {1}", value, SizeSuffixes[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void LogIsoInformation(ILogger<Worker> logger, ReadOnlyCollection<Record> records, string letter) {
|
||||||
|
string size;
|
||||||
|
string[] files;
|
||||||
|
List<string> messages = [];
|
||||||
|
Record[] sorted = records.OrderBy(l => l.Ticks).ToArray();
|
||||||
|
string directory = Path.Combine(Environment.CurrentDirectory, ".vscode", "helper");
|
||||||
|
foreach (Record record in sorted) {
|
||||||
|
if (string.IsNullOrEmpty(record.Path)) {
|
||||||
|
using FileStream fileStream = File.OpenRead(record.Path);
|
||||||
|
CDReader reader = new(fileStream, true);
|
||||||
|
files = reader.GetFiles("", "*");
|
||||||
|
foreach (string _ in files) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
size = GetSizeWithSuffix(record.Size);
|
||||||
|
messages.Add($"#; {size}");
|
||||||
|
messages.Add($"#; {new DateTime(record.Ticks):yyyy-MM-dd HH:mm:ss.fff}");
|
||||||
|
messages.Add($"$driveLetter = \"{letter}:\"");
|
||||||
|
messages.Add($"$isoImg = \"{record.Path}\"");
|
||||||
|
messages.Add("$diskImg = Mount-DiskImage -ImagePath $isoImg -NoDriveLetter");
|
||||||
|
messages.Add("$volInfo = $diskImg | Get-Volume");
|
||||||
|
messages.Add("mountvol $driveLetter $volInfo.UniqueId");
|
||||||
|
messages.Add(string.Empty);
|
||||||
|
}
|
||||||
|
if (Directory.Exists(directory)) {
|
||||||
|
File.WriteAllText(Path.Combine(directory, ".lsv"), string.Join(Environment.NewLine, messages));
|
||||||
|
} else {
|
||||||
|
messages.Reverse();
|
||||||
|
foreach (string message in messages) {
|
||||||
|
logger.LogInformation(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
313
ADO2025/PI6/Helper-2025-07-01.cs
Normal file
313
ADO2025/PI6/Helper-2025-07-01.cs
Normal file
@ -0,0 +1,313 @@
|
|||||||
|
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace File_Folder_Helper.ADO2025.PI6;
|
||||||
|
|
||||||
|
internal static partial class Helper20250701 {
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
|
||||||
|
[JsonSerializable(typeof(JsonElement))]
|
||||||
|
internal partial class JsonElementSourceGenerationContext : JsonSerializerContext {
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void ProcessDataStandardFormatTo(ILogger<Worker> logger, List<string> args) {
|
||||||
|
logger.LogInformation(args[0]);
|
||||||
|
logger.LogInformation(args[1]);
|
||||||
|
logger.LogInformation(args[2]);
|
||||||
|
logger.LogInformation(args[3]);
|
||||||
|
logger.LogInformation(args[4]);
|
||||||
|
logger.LogInformation(args[5]);
|
||||||
|
logger.LogInformation(args[6]);
|
||||||
|
string[] segments;
|
||||||
|
string timeColumn = args[4];
|
||||||
|
string searchPattern = args[2];
|
||||||
|
int sizeFilter = int.Parse(args[3]);
|
||||||
|
string[] columns = args[5].Split(',');
|
||||||
|
Dictionary<string, string> columnMapping = [];
|
||||||
|
string sourceDirectory = Path.GetFullPath(args[0].Split('~')[0]);
|
||||||
|
string destinationDirectory = Path.GetFullPath(args[6].Split('~')[0]);
|
||||||
|
foreach (string column in columns) {
|
||||||
|
segments = column.Split('~');
|
||||||
|
columnMapping.Add(segments[0], segments[1]);
|
||||||
|
}
|
||||||
|
string[] directories = Directory.GetDirectories(sourceDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||||
|
ProcessDataStandardFormatTo(logger, sourceDirectory, searchPattern, sizeFilter, timeColumn, columnMapping, destinationDirectory, directories);
|
||||||
|
Helpers.HelperDeleteEmptyDirectories.DeleteEmptyDirectories(logger, sourceDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ProcessDataStandardFormatTo(ILogger<Worker> logger, string sourceDirectory, string searchPattern, int sizeFilter, string timeColumn, Dictionary<string, string> columnMapping, string destinationDirectory, string[] directories) {
|
||||||
|
string? json;
|
||||||
|
string[] files;
|
||||||
|
string markdown;
|
||||||
|
string checkFile;
|
||||||
|
string[] matches;
|
||||||
|
FileInfo fileInfo;
|
||||||
|
string? pipeTable;
|
||||||
|
string? collections;
|
||||||
|
string directoryName;
|
||||||
|
string checkDirectory;
|
||||||
|
foreach (string directory in directories) {
|
||||||
|
if (Path.GetFileName(directory).Contains('-')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
files = Directory.GetFiles(directory, searchPattern, SearchOption.TopDirectoryOnly);
|
||||||
|
foreach (string file in files) {
|
||||||
|
fileInfo = new(file);
|
||||||
|
if (fileInfo.LastWriteTime > DateTime.Now.AddSeconds(-5)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
directoryName = Path.GetFileName(fileInfo.DirectoryName);
|
||||||
|
if (fileInfo.Length > sizeFilter && !directoryName.StartsWith('Z')) {
|
||||||
|
checkDirectory = Path.Combine(sourceDirectory, $"Z{directoryName}");
|
||||||
|
if (!Directory.Exists(checkDirectory)) {
|
||||||
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
|
}
|
||||||
|
checkFile = Path.Combine(checkDirectory, fileInfo.Name);
|
||||||
|
if (File.Exists(checkFile)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
File.Move(file, checkFile);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
checkDirectory = Path.Combine(destinationDirectory, directoryName);
|
||||||
|
if (!Directory.Exists(checkDirectory)) {
|
||||||
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
|
}
|
||||||
|
checkFile = Path.Combine(checkDirectory, $"{fileInfo.Name}.md");
|
||||||
|
if (File.Exists(checkFile)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
collections = GetMarkdown(logger, timeColumn, columnMapping, file, fileInfo.Name);
|
||||||
|
if (string.IsNullOrEmpty(collections)) {
|
||||||
|
logger.LogWarning("collections is null");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
File.WriteAllText(checkFile, collections);
|
||||||
|
File.SetLastWriteTime(checkFile, fileInfo.LastAccessTime);
|
||||||
|
if (!string.IsNullOrEmpty(destinationDirectory)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
json = GetJavaScriptObjectNotation(logger, file);
|
||||||
|
if (string.IsNullOrEmpty(json)) {
|
||||||
|
logger.LogWarning("json is null");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
File.WriteAllText($"{checkFile}.md", json);
|
||||||
|
File.SetLastWriteTime($"{checkFile}.md", fileInfo.LastAccessTime);
|
||||||
|
pipeTable = GetPipeTable(logger, json);
|
||||||
|
if (string.IsNullOrEmpty(pipeTable)) {
|
||||||
|
logger.LogWarning("pipeTable is null");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
markdown = $"# {fileInfo.Name}{Environment.NewLine}{Environment.NewLine}{pipeTable}{Environment.NewLine}";
|
||||||
|
File.WriteAllText($"{checkFile}.md", markdown);
|
||||||
|
File.SetLastWriteTime($"{checkFile}.md", fileInfo.LastAccessTime);
|
||||||
|
logger.LogInformation("<{checkFile}> was written", checkFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string? GetMarkdown(ILogger<Worker> logger, string timeColumn, Dictionary<string, string> columnMapping, string file, string name) {
|
||||||
|
string? result = null;
|
||||||
|
string[] lines = File.ReadAllLines(file);
|
||||||
|
int? columnTitlesLine = GetProcessDataStandardFormatColumnTitlesLine(lines);
|
||||||
|
if (columnTitlesLine is null) {
|
||||||
|
logger.LogWarning("<{columnTitlesLine}> is null", nameof(columnTitlesLine));
|
||||||
|
} else {
|
||||||
|
if (lines.Length < columnTitlesLine.Value + 1) {
|
||||||
|
logger.LogWarning("<{lines}>(s)", lines.Length);
|
||||||
|
} else {
|
||||||
|
result = GetMarkdown(timeColumn, columnMapping, name, lines, columnTitlesLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int? GetProcessDataStandardFormatColumnTitlesLine(string[] lines) {
|
||||||
|
int? result = null;
|
||||||
|
for (int i = 0; i < lines.Length; i++) {
|
||||||
|
if (lines[i].StartsWith("END_OFFSET") && i + 3 < lines.Length) {
|
||||||
|
result = i + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ReadOnlyDictionary<string, ReadOnlyCollection<string>> GetKeyValuePairs(int columnTitlesLine, string[] lines) {
|
||||||
|
Dictionary<string, ReadOnlyCollection<string>> results = [];
|
||||||
|
string value;
|
||||||
|
string[] segments;
|
||||||
|
List<List<string>> collections = [];
|
||||||
|
string[] columns = lines[columnTitlesLine].Split('\t');
|
||||||
|
foreach (string column in columns) {
|
||||||
|
collections.Add([]);
|
||||||
|
}
|
||||||
|
for (int i = columnTitlesLine + 1; i < lines.Length; i++) {
|
||||||
|
if (lines[i].StartsWith("NUM_DATA_ROWS")) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
segments = lines[i].Split('\t');
|
||||||
|
if (segments.Length > columns.Length) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (int c = 0; c < segments.Length; c++) {
|
||||||
|
collections[c].Add(segments[c]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < collections.Count; i++) {
|
||||||
|
if (collections[i].Count > 1) {
|
||||||
|
if (string.IsNullOrEmpty(collections[i][0])) {
|
||||||
|
collections[i][0] = collections[i][1];
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(collections[i][^1])) {
|
||||||
|
collections[i][^1] = collections[i][^2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
results.Add(columns[i].Trim('"'), collections[i].AsReadOnly());
|
||||||
|
}
|
||||||
|
return results.AsReadOnly();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string? GetMarkdown(string timeColumn, Dictionary<string, string> columnMapping, string name, string[] lines, int? columnTitlesLine) {
|
||||||
|
string? result;
|
||||||
|
List<string> charts = [];
|
||||||
|
List<string> results = [];
|
||||||
|
ReadOnlyDictionary<string, ReadOnlyCollection<string>> keyValuePairs = GetKeyValuePairs(columnTitlesLine.Value, lines);
|
||||||
|
string[] columns = keyValuePairs.Keys.OrderBy(l => l).ToArray();
|
||||||
|
if (!columns.Contains(timeColumn)) {
|
||||||
|
result = null;
|
||||||
|
} else {
|
||||||
|
string? alias;
|
||||||
|
string[] mappedColumns = columnMapping.Keys.ToArray();
|
||||||
|
string labels = string.Join(',', keyValuePairs[timeColumn].Select(l => l.Replace(',', '_')));
|
||||||
|
foreach (string column in columns) {
|
||||||
|
if (column == timeColumn) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!columnMapping.TryGetValue(column, out alias) || keyValuePairs[column].Count == 0 || string.IsNullOrEmpty(keyValuePairs[column][0])) {
|
||||||
|
results.Add(string.Concat("## ", column, Environment.NewLine, Environment.NewLine,
|
||||||
|
"- ", string.Join(',', keyValuePairs[column].Select(l => l.Replace(',', '_'))), Environment.NewLine
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
charts.Add(string.Concat(
|
||||||
|
"## ", column, " - ", alias, Environment.NewLine, Environment.NewLine,
|
||||||
|
"```chart", Environment.NewLine,
|
||||||
|
"{\"type\": \"line\", \"data\": {\"datasets\": [{", Environment.NewLine,
|
||||||
|
"\"label\": \"", column, " - ", alias, "\",", Environment.NewLine,
|
||||||
|
"\"data\": [", string.Join(',', keyValuePairs[column].Select(l => l.Replace(',', '_'))), "],", Environment.NewLine,
|
||||||
|
"\"borderColor\": \"rgb(75, 192, 192)\"", Environment.NewLine,
|
||||||
|
"}],", Environment.NewLine,
|
||||||
|
"\"labels\": [", labels, "]", Environment.NewLine,
|
||||||
|
"}}", Environment.NewLine,
|
||||||
|
"```", Environment.NewLine
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (results.Count == 0 && charts.Count == 0) {
|
||||||
|
result = null;
|
||||||
|
} else {
|
||||||
|
string[] segments;
|
||||||
|
results.Add($"## Footer{Environment.NewLine}");
|
||||||
|
results.Insert(0, $"# {name}{Environment.NewLine}");
|
||||||
|
for (int i = columnTitlesLine.Value + 1; i < lines.Length; i++) {
|
||||||
|
if (lines[i].StartsWith("NUM_DATA_ROWS")) {
|
||||||
|
for (int j = i; j < lines.Length; j++) {
|
||||||
|
results.Add($"- {lines[j]}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
results.Add(string.Empty);
|
||||||
|
results.Add(string.Empty);
|
||||||
|
result = $"{string.Join(Environment.NewLine, results)}{string.Join(Environment.NewLine, charts)}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string? GetJavaScriptObjectNotation(ILogger<Worker> logger, string file) {
|
||||||
|
string? result = null;
|
||||||
|
string[] lines = File.ReadAllLines(file);
|
||||||
|
int? columnTitlesLine = GetProcessDataStandardFormatColumnTitlesLine(lines);
|
||||||
|
if (columnTitlesLine is null) {
|
||||||
|
logger.LogWarning("<{columnTitlesLine}> is null", nameof(columnTitlesLine));
|
||||||
|
} else {
|
||||||
|
if (lines.Length < columnTitlesLine.Value + 1) {
|
||||||
|
logger.LogWarning("<{lines}>(s)", lines.Length);
|
||||||
|
} else {
|
||||||
|
result = GetJavaScriptObjectNotation(columnTitlesLine.Value, [], lines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetJavaScriptObjectNotation(int columnTitlesLine, string[] columns, string[] lines) {
|
||||||
|
#pragma warning disable CA1845, IDE0057
|
||||||
|
string result = "[\n";
|
||||||
|
string line;
|
||||||
|
string value;
|
||||||
|
string[] segments;
|
||||||
|
if (columns.Length == 0) {
|
||||||
|
columns = lines[columnTitlesLine].Split('\t');
|
||||||
|
}
|
||||||
|
for (int i = columnTitlesLine + 1; i < lines.Length; i++) {
|
||||||
|
if (lines[i].StartsWith("NUM_DATA_ROWS")) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
line = "{";
|
||||||
|
segments = lines[i].Split('\t');
|
||||||
|
if (segments.Length > columns.Length) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (int c = 0; c < segments.Length; c++) {
|
||||||
|
value = segments[c].Replace("\\", "\\\\").Replace("\"", "\\\"");
|
||||||
|
line += '"' + columns[c].Trim('"') + '"' + ':' + '"' + value + '"' + ',';
|
||||||
|
}
|
||||||
|
line = line.Substring(0, line.Length - 1) + '}' + ',' + '\n';
|
||||||
|
result += line;
|
||||||
|
}
|
||||||
|
result = result.Substring(0, result.Length - 2) + ']';
|
||||||
|
return result;
|
||||||
|
#pragma warning restore CA1845, IDE0057
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string? GetPipeTable(ILogger<Worker> logger, string json) {
|
||||||
|
string? result = null;
|
||||||
|
string? value;
|
||||||
|
string[]? columns = null;
|
||||||
|
List<string> values = [];
|
||||||
|
List<string> results = [];
|
||||||
|
Dictionary<string, string> keyValuePairs = [];
|
||||||
|
JsonElement jsonElement = JsonSerializer.Deserialize(json, JsonElementSourceGenerationContext.Default.JsonElement);
|
||||||
|
JsonElement[] jsonElements = jsonElement.EnumerateArray().ToArray();
|
||||||
|
foreach (JsonElement j in jsonElements) {
|
||||||
|
values.Clear();
|
||||||
|
keyValuePairs.Clear();
|
||||||
|
foreach (JsonProperty jsonProperty in j.EnumerateObject().ToArray()) {
|
||||||
|
if (columns is null) {
|
||||||
|
JsonProperty[] jsonProperties = j.EnumerateObject().OrderBy(l => l.Name).ToArray();
|
||||||
|
columns = jsonProperties.Select(l => l.Name).ToArray();
|
||||||
|
results.Add($"|{string.Join('|', columns)}|");
|
||||||
|
results.Add($"|{string.Join('|', columns.Select(l => '-'))}|");
|
||||||
|
}
|
||||||
|
keyValuePairs.Add(jsonProperty.Name, jsonProperty.Value.ToString());
|
||||||
|
}
|
||||||
|
foreach (string column in columns) {
|
||||||
|
if (!keyValuePairs.TryGetValue(column, out value)) {
|
||||||
|
values.Add(new string(' ', column.Length));
|
||||||
|
} else {
|
||||||
|
values.Add(value.PadLeft(column.Length, ' '));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
results.Add($"|{string.Join('|', values)}|");
|
||||||
|
}
|
||||||
|
if (results.Count > 0) {
|
||||||
|
result = string.Join(Environment.NewLine, results);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
112
ADO2025/PI6/Helper-2025-07-05.cs
Normal file
112
ADO2025/PI6/Helper-2025-07-05.cs
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace File_Folder_Helper.ADO2025.PI6;
|
||||||
|
|
||||||
|
internal static partial class Helper20250705 {
|
||||||
|
|
||||||
|
internal static void ExportFaces(ILogger<Worker> logger, List<string> args) {
|
||||||
|
string checkFile;
|
||||||
|
logger.LogInformation(args[0]);
|
||||||
|
logger.LogInformation(args[1]);
|
||||||
|
logger.LogInformation(args[2]);
|
||||||
|
logger.LogInformation(args[3]);
|
||||||
|
logger.LogInformation(args[4]);
|
||||||
|
logger.LogInformation(args[5]);
|
||||||
|
logger.LogInformation(args[6]);
|
||||||
|
logger.LogInformation(args[7]);
|
||||||
|
string locationDigits = args[6];
|
||||||
|
string[] mp = args[4].Split('~');
|
||||||
|
string[] mwg = args[5].Split('~');
|
||||||
|
string[] xyz = args[3].Split(',');
|
||||||
|
string[] fileNames = args[2].Split('~');
|
||||||
|
string[] wholePercentages = args[7].Split('~');
|
||||||
|
string sourceDirectory = Path.GetFullPath(args[0].Split('~')[0]);
|
||||||
|
if (mp.Length != mwg.Length || mp.Length != wholePercentages.Length) {
|
||||||
|
logger.LogWarning("Lengths don't match!");
|
||||||
|
} else {
|
||||||
|
foreach (string fileName in fileNames) {
|
||||||
|
checkFile = Path.Combine(sourceDirectory, fileName);
|
||||||
|
if (!File.Exists(checkFile)) {
|
||||||
|
logger.LogWarning("<{file}> doesn't exist!", args[2]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < mp.Length; i++) {
|
||||||
|
if (wholePercentages[i].StartsWith("x-")) {
|
||||||
|
logger.LogWarning("Skipping {wholePercentages}", wholePercentages[i]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Ext(checkFile, xyz, i, mp[i], mwg[i], locationDigits, wholePercentages[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Ext(string checkFile, string[] xyz, int i, string mp, string mwg, string locationDigits, string wholePercentages) {
|
||||||
|
int width = int.Parse(xyz[0]);
|
||||||
|
int height = int.Parse(xyz[1]);
|
||||||
|
string[] mpValues = mp.Split(',');
|
||||||
|
string[] mwgValues = mwg.Split(',');
|
||||||
|
float mpWidth = float.Parse(mpValues[2]) * width;
|
||||||
|
float mpHeight = float.Parse(mpValues[3]) * height;
|
||||||
|
double mpLeft = (float.Parse(mpValues[0]) * width) - (mpWidth * .5);
|
||||||
|
double mpTop = (float.Parse(mpValues[1]) * height) - (mpHeight * .5);
|
||||||
|
Extract(file: checkFile,
|
||||||
|
width: mpWidth,
|
||||||
|
height: mpHeight,
|
||||||
|
left: mpLeft,
|
||||||
|
top: mpTop,
|
||||||
|
suffix: $"-{i}mp.jpg");
|
||||||
|
float mwgWidth = float.Parse(mwgValues[2]) * width;
|
||||||
|
float mwgHeight = float.Parse(mwgValues[3]) * height;
|
||||||
|
double mwgLeft = double.Parse(mwgValues[0]) * width;
|
||||||
|
double mwgTop = double.Parse(mwgValues[1]) * height;
|
||||||
|
Extract(file: checkFile,
|
||||||
|
width: mwgWidth,
|
||||||
|
height: mwgHeight,
|
||||||
|
left: mwgLeft,
|
||||||
|
top: mwgTop,
|
||||||
|
suffix: $"-{i}mwg.jpg");
|
||||||
|
int length = (int.Parse(locationDigits) - 1) / 4;
|
||||||
|
string[] segments =
|
||||||
|
[
|
||||||
|
wholePercentages[..1],
|
||||||
|
wholePercentages.Substring(1, length),
|
||||||
|
wholePercentages.Substring(3, length),
|
||||||
|
wholePercentages.Substring(5, length),
|
||||||
|
wholePercentages.Substring(7, length)
|
||||||
|
];
|
||||||
|
if (string.Join(string.Empty, segments) == wholePercentages) {
|
||||||
|
if (int.TryParse(segments[1], out int xWholePercent)
|
||||||
|
&& int.TryParse(segments[2], out int yWholePercent)
|
||||||
|
&& int.TryParse(segments[3], out int wWholePercent)
|
||||||
|
&& int.TryParse(segments[4], out int hWholePercent)) {
|
||||||
|
float factor = 100;
|
||||||
|
RectangleF rectangleF = new(xWholePercent / factor, yWholePercent / factor, wWholePercent / factor, hWholePercent / factor);
|
||||||
|
float rectangleFWidth = rectangleF.Width * width;
|
||||||
|
float rectangleFHeight = rectangleF.Height * height;
|
||||||
|
double rectangleFLeft = rectangleF.Left * width;
|
||||||
|
double rectangleFTop = rectangleF.Top * height;
|
||||||
|
Extract(file: checkFile,
|
||||||
|
width: rectangleFWidth,
|
||||||
|
height: rectangleFHeight,
|
||||||
|
left: rectangleFLeft,
|
||||||
|
top: rectangleFTop,
|
||||||
|
suffix: $"-{i}whole-percentages.jpg");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Extract(string file, float width, float height, double left, double top, string suffix) {
|
||||||
|
RectangleF rectangle = new((float)left, (float)top, width, height);
|
||||||
|
using (Bitmap source = new(file)) {
|
||||||
|
using (Bitmap bitmap = new((int)width, (int)height)) {
|
||||||
|
using (Graphics graphics = Graphics.FromImage(bitmap))
|
||||||
|
graphics.DrawImage(source, new RectangleF(0, 0, width, height), rectangle, GraphicsUnit.Pixel);
|
||||||
|
bitmap.Save($"{file}{suffix}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -171,6 +171,12 @@ internal static class HelperDay
|
|||||||
ADO2025.PI6.Helper20250602.EquipmentAutomationFrameworkCellInstanceStateImageVerbIf(logger, args);
|
ADO2025.PI6.Helper20250602.EquipmentAutomationFrameworkCellInstanceStateImageVerbIf(logger, args);
|
||||||
else if (args[1] == "Day-Helper-2025-06-18")
|
else if (args[1] == "Day-Helper-2025-06-18")
|
||||||
ADO2025.PI6.Helper20250618.MoveAllButXOfEach(logger, args);
|
ADO2025.PI6.Helper20250618.MoveAllButXOfEach(logger, args);
|
||||||
|
else if (args[1] == "Day-Helper-2025-06-28")
|
||||||
|
ADO2025.PI6.Helper20250628.LogIsoInformation(logger, args);
|
||||||
|
else if (args[1] == "Day-Helper-2025-07-01")
|
||||||
|
ADO2025.PI6.Helper20250701.ProcessDataStandardFormatTo(logger, args);
|
||||||
|
else if (args[1] == "Day-Helper-2025-07-05")
|
||||||
|
ADO2025.PI6.Helper20250705.ExportFaces(logger, args);
|
||||||
else
|
else
|
||||||
throw new Exception(appSettings.Company);
|
throw new Exception(appSettings.Company);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
|
||||||
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="8.0.17" />
|
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="8.0.17" />
|
||||||
|
<PackageReference Include="System.Drawing.Common" Version="8.0.10" />
|
||||||
<PackageReference Include="System.Text.Json" Version="9.0.5" />
|
<PackageReference Include="System.Text.Json" Version="9.0.5" />
|
||||||
<PackageReference Include="TextCopy" Version="6.2.1" />
|
<PackageReference Include="TextCopy" Version="6.2.1" />
|
||||||
<PackageReference Include="WindowsShortcutFactory" Version="1.2.0" />
|
<PackageReference Include="WindowsShortcutFactory" Version="1.2.0" />
|
||||||
|
Reference in New Issue
Block a user