Add Transmission Control Protocol file handling and update PCL serialization

- Introduced FileRead and Record classes for handling file reading in the Transmission Control Protocol.
- Enhanced Description, Detail, and other related classes with JSON serialization attributes for improved data handling.
- Implemented methods for reading and processing files, including network stream management.
- Updated unit tests to cover new functionality and ensure robust testing.
- Added new PDSF file handling classes and integrated them into the project structure.
- Refactored existing code to utilize source generation for JSON serialization, improving performance and maintainability.
This commit is contained in:
2025-09-15 09:58:00 -07:00
parent 7561a08adc
commit 2bda7012cd
33 changed files with 1569 additions and 193 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;
@ -903,7 +914,7 @@ internal class ProcessDataStandardFormat
}
foreach (KeyValuePair<string, List<string>> keyValuePair in results)
{
if (body.Count < 3)
if (body.Count < 2)
break;
if (keyValuePair.Value.Count != body.Count)
continue;
@ -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)]