Update to 2025-02-18 and 2025-02-19
This commit is contained in:
@ -7,14 +7,28 @@ namespace File_Folder_Helper.ADO2025.PI5;
|
||||
internal static partial class Helper20250218 {
|
||||
|
||||
internal static void MoveToArchive(ILogger<Worker> logger, List<string> args) {
|
||||
string searchMES = args[3];
|
||||
string searchPattern = args[2];
|
||||
string searchSequence = args[4];
|
||||
string destinationRoot = args[5];
|
||||
string checkDirectory;
|
||||
string searchMES = args[4];
|
||||
string searchPattern = args[3];
|
||||
string searchSequence = args[5];
|
||||
string destinationRoot = args[6];
|
||||
string checkDirectoryName = args[2];
|
||||
string sourceDirectory = Path.GetFullPath(args[0]);
|
||||
string[] files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.AllDirectories);
|
||||
logger.LogInformation("<{files}>(s)", files.Length);
|
||||
MoveToArchive(logger, searchMES, searchSequence, destinationRoot, files);
|
||||
string[] directories = Directory.GetDirectories(sourceDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
foreach (string directory in directories) {
|
||||
checkDirectory = Path.Combine(directory, checkDirectoryName);
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
continue;
|
||||
MoveToArchive(logger, searchPattern, searchMES, searchSequence, destinationRoot, checkDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
private static void MoveToArchive(ILogger<Worker> logger, string searchPattern, string searchMES, string searchSequence, string destinationRoot, string checkDirectory) {
|
||||
string[] files = Directory.GetFiles(checkDirectory, searchPattern, SearchOption.AllDirectories);
|
||||
if (files.Length == 0)
|
||||
logger.LogInformation("<{files}>(s)", files.Length);
|
||||
else
|
||||
MoveToArchive(logger, searchMES, searchSequence, destinationRoot, files);
|
||||
}
|
||||
|
||||
private static void MoveToArchive(ILogger<Worker> logger, string searchMES, string searchSequence, string destinationRoot, string[] files) {
|
||||
@ -66,4 +80,4 @@ internal static partial class Helper20250218 {
|
||||
|
||||
}
|
||||
|
||||
// L:\DevOps\MESA_FI\file-folder-helper\bin\Debug\net8.0\win-x64>dotnet File-Folder-Helper.dll X D:/Tmp Day-Helper-2025-02-18 *.pdsf A_MES_ENTITY= B_SEQUENCE= \\mesfs.infineon.com\EC_Characterization_Si\Archive
|
||||
// L:\DevOps\MESA_FI\file-folder-helper\bin\Debug\net8.0\win-x64>dotnet File-Folder-Helper.dll X \\mesfs.infineon.com\EC_EDA\Production\Traces Day-Helper-2025-02-18 Source *.pdsf A_MES_ENTITY= B_SEQUENCE= \\mesfs.infineon.com\EC_Characterization_Si\Archive
|
@ -19,13 +19,13 @@ internal static partial class Helper20250219 {
|
||||
private partial class JsonElementCollectionSourceGenerationContext : JsonSerializerContext {
|
||||
}
|
||||
|
||||
private record Input(ReadOnlyCollection<string> Backfill,
|
||||
ReadOnlyCollection<int> ColumnIndices,
|
||||
ReadOnlyCollection<string> Ignore,
|
||||
ReadOnlyCollection<string> IndexOnly,
|
||||
ReadOnlyDictionary<string, string> KeyValuePairs,
|
||||
ReadOnlyCollection<string> NewColumnNames,
|
||||
ReadOnlyCollection<string> OldColumnNames);
|
||||
private record ProcessDataStandardFormatMapping(ReadOnlyCollection<string> BackfillColumns,
|
||||
ReadOnlyCollection<int> ColumnIndices,
|
||||
ReadOnlyCollection<string> IgnoreColumns,
|
||||
ReadOnlyCollection<string> IndexOnlyColumns,
|
||||
ReadOnlyDictionary<string, string> KeyValuePairs,
|
||||
ReadOnlyCollection<string> NewColumnNames,
|
||||
ReadOnlyCollection<string> OldColumnNames);
|
||||
|
||||
internal static void Compare(ILogger<Worker> logger, List<string> args) {
|
||||
string[] segmentsB;
|
||||
@ -49,20 +49,20 @@ internal static partial class Helper20250219 {
|
||||
distinct.Add(segmentsB[0]);
|
||||
keyValuePairs.Add(segmentsB[0], segmentsB[1]);
|
||||
}
|
||||
Input input = new(Backfill: backfill,
|
||||
ColumnIndices: columnIndices,
|
||||
NewColumnNames: newColumnNames,
|
||||
Ignore: ignore,
|
||||
IndexOnly: indexOnly,
|
||||
KeyValuePairs: keyValuePairs.AsReadOnly(),
|
||||
OldColumnNames: oldColumnNames);
|
||||
ProcessDataStandardFormatMapping processDataStandardFormatMapping = new(BackfillColumns: backfill,
|
||||
ColumnIndices: columnIndices,
|
||||
NewColumnNames: newColumnNames,
|
||||
IgnoreColumns: ignore,
|
||||
IndexOnlyColumns: indexOnly,
|
||||
KeyValuePairs: keyValuePairs.AsReadOnly(),
|
||||
OldColumnNames: oldColumnNames);
|
||||
string sourceDirectory = Path.GetFullPath(args[0]);
|
||||
string[] files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.AllDirectories);
|
||||
logger.LogInformation("<{files}>(s)", files.Length);
|
||||
Compare(logger, sourceDirectory.Length, searchPatternB, input, files);
|
||||
Compare(logger, sourceDirectory.Length, searchPatternB, processDataStandardFormatMapping, files);
|
||||
}
|
||||
|
||||
private static void Compare(ILogger<Worker> logger, int sourceDirectoryLength, string searchPattern, Input input, string[] files) {
|
||||
private static void Compare(ILogger<Worker> logger, int sourceDirectoryLength, string searchPattern, ProcessDataStandardFormatMapping pdsfMapping, string[] files) {
|
||||
bool compare;
|
||||
string directory;
|
||||
string[] matches;
|
||||
@ -80,22 +80,22 @@ internal static partial class Helper20250219 {
|
||||
if (matches.Length < 1)
|
||||
continue;
|
||||
directorySegment = directory[sourceDirectoryLength..];
|
||||
processDataStandardFormat = GetProcessDataStandardFormat(logger, fileInfo.LastWriteTime, input.NewColumnNames.Count, columnsLine, fileInfo.FullName, lines: null);
|
||||
jsonElementsNew = GetArray(logger, input.NewColumnNames.Count, processDataStandardFormat, lookForNumbers: false);
|
||||
processDataStandardFormat = GetProcessDataStandardFormat(logger, fileInfo.LastWriteTime, pdsfMapping.NewColumnNames.Count, columnsLine, fileInfo.FullName, lines: null);
|
||||
jsonElementsNew = GetArray(logger, pdsfMapping.NewColumnNames.Count, processDataStandardFormat, lookForNumbers: false);
|
||||
if (jsonElementsNew is null)
|
||||
continue;
|
||||
if (input.OldColumnNames.Count == input.ColumnIndices.Count) {
|
||||
processDataStandardFormat = Get(logger, input, jsonElementsNew, processDataStandardFormat);
|
||||
if (pdsfMapping.OldColumnNames.Count == pdsfMapping.ColumnIndices.Count) {
|
||||
processDataStandardFormat = GetProcessDataStandardFormat(logger, pdsfMapping, jsonElementsNew, processDataStandardFormat);
|
||||
Write(logger, fileInfo, processDataStandardFormat);
|
||||
}
|
||||
foreach (string match in matches) {
|
||||
processDataStandardFormat = GetProcessDataStandardFormat(logger, fileInfo.LastWriteTime, input.OldColumnNames.Count, columnsLine, match, lines: null);
|
||||
jsonElementsOld = GetArray(logger, input.OldColumnNames.Count, processDataStandardFormat, lookForNumbers: false);
|
||||
processDataStandardFormat = GetProcessDataStandardFormat(logger, fileInfo.LastWriteTime, pdsfMapping.OldColumnNames.Count, columnsLine, match, lines: null);
|
||||
jsonElementsOld = GetArray(logger, pdsfMapping.OldColumnNames.Count, processDataStandardFormat, lookForNumbers: false);
|
||||
if (jsonElementsOld is null || jsonElementsOld.Length != jsonElementsNew.Length) {
|
||||
logger.LogWarning("! <{match}> (jsonElementsOld.Length:{jsonElementsOld} != jsonElementsNew.Length:{jsonElementsNew})", match, jsonElementsOld?.Length, jsonElementsNew.Length);
|
||||
continue;
|
||||
}
|
||||
compare = Compare(logger, input, directorySegment, jsonElementsNew, jsonElementsOld);
|
||||
compare = Compare(logger, pdsfMapping, directorySegment, jsonElementsNew, jsonElementsOld);
|
||||
if (!compare) {
|
||||
logger.LogWarning("! <{match}>", match);
|
||||
continue;
|
||||
@ -105,7 +105,7 @@ internal static partial class Helper20250219 {
|
||||
}
|
||||
}
|
||||
|
||||
private static bool Compare(ILogger<Worker> logger, Input input, string directory, JsonElement[] jsonElementsNew, JsonElement[] jsonElementsOld) {
|
||||
private static bool Compare(ILogger<Worker> logger, ProcessDataStandardFormatMapping processDataStandardFormatMapping, string directory, JsonElement[] jsonElementsNew, JsonElement[] jsonElementsOld) {
|
||||
bool result;
|
||||
int? q;
|
||||
string valueNew;
|
||||
@ -129,7 +129,7 @@ internal static partial class Helper20250219 {
|
||||
for (int p = 0; p < jsonPropertiesOld.Length; p++) {
|
||||
jsonPropertyOld = jsonPropertiesOld[p];
|
||||
valueOld = jsonPropertyOld.Value.ToString();
|
||||
if (input.KeyValuePairs.TryGetValue(jsonPropertyOld.Name, out string? name) && !string.IsNullOrEmpty(name)) {
|
||||
if (processDataStandardFormatMapping.KeyValuePairs.TryGetValue(jsonPropertyOld.Name, out string? name) && !string.IsNullOrEmpty(name)) {
|
||||
q = TryGetPropertyIndex(jsonPropertiesNew, name);
|
||||
if (q is null && i == 0)
|
||||
unknownColumns.Add($"{jsonPropertyOld.Name}|{name}");
|
||||
@ -141,7 +141,7 @@ internal static partial class Helper20250219 {
|
||||
}
|
||||
}
|
||||
if (q is null) {
|
||||
if (input.Ignore.Contains(jsonPropertyOld.Name)) {
|
||||
if (processDataStandardFormatMapping.IgnoreColumns.Contains(jsonPropertyOld.Name)) {
|
||||
if (i == last) {
|
||||
columns.Add("-1");
|
||||
logger.LogDebug("{p} )) {jsonPropertyOld.Name} **", p, jsonPropertyOld.Name);
|
||||
@ -164,9 +164,9 @@ internal static partial class Helper20250219 {
|
||||
if (valueNew.Length >= 2 && valueNew.Split(' ')[0] == valueOld)
|
||||
sameAfterSpaceSplitColumns.Add(jsonPropertyOld.Name);
|
||||
else {
|
||||
if (input.Backfill.Contains(jsonPropertyOld.Name) && i != last)
|
||||
if (processDataStandardFormatMapping.BackfillColumns.Contains(jsonPropertyOld.Name) && i != last)
|
||||
continue;
|
||||
if (input.IndexOnly.Contains(jsonPropertyOld.Name) && int.TryParse(jsonPropertyOld.Name[^2..], out int index) && i != index - 1)
|
||||
if (processDataStandardFormatMapping.IndexOnlyColumns.Contains(jsonPropertyOld.Name) && int.TryParse(jsonPropertyOld.Name[^2..], out int index) && i != index - 1)
|
||||
continue;
|
||||
logger.LogWarning("For [{jsonProperty.Name}] <{directory}> doesn't match (valueNew:{valueNew} != valueOld:{valueOld})!", jsonPropertyOld.Name, directory, valueNew, valueOld);
|
||||
differentColumns.Add(jsonPropertyOld.Name);
|
||||
@ -294,7 +294,7 @@ internal static partial class Helper20250219 {
|
||||
return results;
|
||||
}
|
||||
|
||||
private static ProcessDataStandardFormat Get(ILogger<Worker> logger, Input input, JsonElement[] jsonElements, ProcessDataStandardFormat processDataStandardFormat) {
|
||||
private static ProcessDataStandardFormat GetProcessDataStandardFormat(ILogger<Worker> logger, ProcessDataStandardFormatMapping processDataStandardFormatMapping, JsonElement[] jsonElements, ProcessDataStandardFormat processDataStandardFormat) {
|
||||
ProcessDataStandardFormat result;
|
||||
int column;
|
||||
string value;
|
||||
@ -310,14 +310,14 @@ internal static partial class Helper20250219 {
|
||||
break;
|
||||
}
|
||||
jsonProperties = jsonElements[i].EnumerateObject().ToArray();
|
||||
if (jsonProperties.Length != input.NewColumnNames.Count) {
|
||||
logger.LogWarning("{jsonProperties} != {NewColumnNames}", jsonProperties.Length, input.NewColumnNames.Count);
|
||||
if (jsonProperties.Length != processDataStandardFormatMapping.NewColumnNames.Count) {
|
||||
logger.LogWarning("{jsonProperties} != {NewColumnNames}", jsonProperties.Length, processDataStandardFormatMapping.NewColumnNames.Count);
|
||||
continue;
|
||||
}
|
||||
for (int c = 0; c < input.ColumnIndices.Count; c++) {
|
||||
column = input.ColumnIndices[c];
|
||||
for (int c = 0; c < processDataStandardFormatMapping.ColumnIndices.Count; c++) {
|
||||
column = processDataStandardFormatMapping.ColumnIndices[c];
|
||||
if (column == -1)
|
||||
value = input.OldColumnNames[c];
|
||||
value = processDataStandardFormatMapping.OldColumnNames[c];
|
||||
else {
|
||||
jsonProperty = jsonProperties[column];
|
||||
value = jsonProperty.Value.ToString();
|
||||
@ -327,7 +327,7 @@ internal static partial class Helper20250219 {
|
||||
results.Add(string.Join('\t', values));
|
||||
}
|
||||
result = new(Body: new(results),
|
||||
Columns: processDataStandardFormat.Columns,
|
||||
Columns: processDataStandardFormatMapping.OldColumnNames,
|
||||
Logistics: processDataStandardFormat.Logistics,
|
||||
Sequence: processDataStandardFormat.Sequence);
|
||||
return result;
|
||||
@ -348,7 +348,7 @@ internal static partial class Helper20250219 {
|
||||
results.Add($"HEADER_OFFSET\t{headerOffset}");
|
||||
results.Add($"DATA_OFFSET\t{dataOffset}");
|
||||
results.Add($"END_OFFSET\t{endOffset}");
|
||||
results.Add($"\"{string.Join("\",\t\"", processDataStandardFormat.Columns)}\"");
|
||||
results.Add($"\"{string.Join("\"\t\"", processDataStandardFormat.Columns)}\"");
|
||||
results.AddRange(processDataStandardFormat.Body);
|
||||
results.Add($"NUM_DATA_ROWS\t{processDataStandardFormat.Body.Count.ToString().PadLeft(9, '0')}");
|
||||
results.Add($"NUM_DATA_COLUMNS\t{processDataStandardFormat.Columns.Count.ToString().PadLeft(9, '0')}");
|
||||
|
@ -98,7 +98,9 @@ internal static partial class Helper20250228 {
|
||||
else
|
||||
keyValuePairs.Add(record.Columns[i], row[i]);
|
||||
}
|
||||
#pragma warning disable IL3050, IL2026
|
||||
json = JsonSerializer.Serialize(keyValuePairs);
|
||||
#pragma warning restore IL3050, IL2026
|
||||
results.Add(json);
|
||||
}
|
||||
text = string.Join($",{Environment.NewLine}", results);
|
||||
|
Reference in New Issue
Block a user