Dynamic extension for (Day-Helper-2025-07-01)
This commit is contained in:
@ -65,7 +65,7 @@ internal static class Helper20231130
|
||||
return result;
|
||||
}
|
||||
|
||||
private static ReadOnlyCollection<string> GetSystemStateValues(List<string> lines, string[] columns, int keyColumnIndex, ReadOnlyDictionary<string, string> systemStates)
|
||||
private static ReadOnlyCollection<string> GetSystemStateValues(List<string> lines, string[] columns, int keyColumnIndex, ReadOnlyDictionary<string, string> systemStateToNames)
|
||||
{
|
||||
List<string> results = [];
|
||||
string[] values;
|
||||
@ -79,7 +79,7 @@ internal static class Helper20231130
|
||||
keyColumnValue = values[keyColumnIndex];
|
||||
if (string.IsNullOrEmpty(keyColumnValue))
|
||||
continue;
|
||||
if (!systemStates.TryGetValue(keyColumnValue, out systemState))
|
||||
if (!systemStateToNames.TryGetValue(keyColumnValue, out systemState))
|
||||
continue;
|
||||
if (results.Contains(systemState))
|
||||
continue;
|
||||
@ -106,7 +106,7 @@ internal static class Helper20231130
|
||||
string missingKeyDirectory = Path.Combine(sourceDirectory, "Missing-Key");
|
||||
if (!Directory.Exists(missingKeyDirectory))
|
||||
_ = Directory.CreateDirectory(missingKeyDirectory);
|
||||
ReadOnlyDictionary<string, string> systemStates = GetSystemStates();
|
||||
ReadOnlyDictionary<string, string> systemStateToNames = GetSystemStates();
|
||||
ReadOnlyCollection<Record> records = GetRecords(sourceDirectory, timestampFormat);
|
||||
foreach (Record record in records)
|
||||
{
|
||||
@ -132,7 +132,7 @@ internal static class Helper20231130
|
||||
continue;
|
||||
}
|
||||
logger.LogInformation("{timestamp} triggered", record.TimeStamp);
|
||||
systemStateValues = GetSystemStateValues(lines, columns, keyColumnIndex.Value, systemStates);
|
||||
systemStateValues = GetSystemStateValues(lines, columns, keyColumnIndex.Value, systemStateToNames);
|
||||
if (systemStateValues.Count == 0)
|
||||
{
|
||||
File.Move(record.File, Path.Combine(sourceDirectory, missingKeyDirectory, record.FileName));
|
||||
@ -142,7 +142,6 @@ internal static class Helper20231130
|
||||
systemState = string.Join('-', systemStateValues);
|
||||
checkFileName = Path.Combine(Path.GetDirectoryName(record.File) ?? throw new Exception(), $"{record.Equipment}-{record.TimeStamp}-{systemState}.pdsf");
|
||||
File.WriteAllLines(checkFileName, lines);
|
||||
File.Delete(record.File);
|
||||
if (DateTime.TryParseExact(record.TimeStamp, timestampFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))
|
||||
File.SetLastWriteTime(checkFileName, dateTime);
|
||||
}
|
||||
|
Reference in New Issue
Block a user