Refactor QS408M and PDSF File Handlers

- Updated Detail class to include JsonSourceGenerationOptions and JsonSerializable attributes for source generation.
- Modified ProcessData class to utilize source generation context for Description deserialization.
- Renamed RowSourceGenerationContext to QS408MRowSourceGenerationContext for clarity.
- Updated Run class to use QS408MRunSourceGenerationContext for serialization.
- Enhanced Description class with source generation attributes.
- Refactored FileRead class to use source generation context for Description deserialization.
- Added new methods in ProcessDataStandardFormat for JSON element array extraction.
- Introduced new PDSF file handler classes: Body, Constant, FileRead, Footer, Header, Row, Run, and Site.
- Implemented logic for parsing and handling PDSF data structures.
- Added unit tests for PDSF processing to ensure functionality.
This commit is contained in:
2025-09-15 11:37:05 -07:00
parent 515df7ec37
commit d07755c3a0
29 changed files with 869 additions and 204 deletions

View File

@ -654,6 +654,17 @@ internal class ProcessDataStandardFormat
return results;
}
internal static JsonElement[] GetArray(string reportFullPath, string[] lines, ProcessDataStandardFormat processDataStandardFormat)
{
JsonElement[] results;
string? json = GetRecordsJson(reportFullPath, lines);
if (string.IsNullOrEmpty(json))
results = GetArray(processDataStandardFormat);
else
results = JsonSerializer.Deserialize(json, JsonElementCollectionSourceGenerationContext.Default.JsonElementArray) ?? throw new Exception();
return results;
}
internal static string GetPDSFText(IFileRead fileRead, Logistics logistics, JsonElement[] jsonElements, string logisticsText)
{
string result;
@ -956,6 +967,26 @@ internal class ProcessDataStandardFormat
return result;
}
private static string? GetRecordsJson(string reportFullPath, string[] lines)
{
string? result;
bool foundRecords = false;
List<string> results = new();
lines ??= File.ReadAllLines(reportFullPath);
foreach (string line in lines)
{
if (line.StartsWith("\"Records\""))
foundRecords = true;
if (!foundRecords)
continue;
if (line == "],")
break;
results.Add(line);
}
result = results.Count == 0 ? null : $"{string.Join(Environment.NewLine, results.Skip(1))}{Environment.NewLine}]";
return result;
}
}
[JsonSourceGenerationOptions(WriteIndented = true)]