Refactor OpenInsight file handling to utilize JsonElement for data processing and enhance serialization with JsonSourceGeneration. Updated methods across multiple classes to improve data handling and reduce dependencies on ProcessDataStandardFormat.

This commit is contained in:
2025-09-08 14:33:50 -07:00
parent 7739ff03a2
commit b135095e53
12 changed files with 148 additions and 129 deletions

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
namespace Adaptation.FileHandlers.OpenInsightMetrologyViewer;
@ -31,7 +32,7 @@ public class WSRequest
[Obsolete("For json")] public WSRequest() { }
#pragma warning disable IDE0060
internal WSRequest(IFileRead fileRead, Logistics logistics, List<Stratus.Description> descriptions, string processDataStandardFormat = null)
internal WSRequest(IFileRead fileRead, Logistics logistics, JsonElement[] jsonElements, List<Stratus.Description> descriptions, string processDataStandardFormat = null)
#pragma warning restore IDE0060
{
Id = -1;
@ -42,16 +43,16 @@ public class WSRequest
Details = new List<Stratus.Detail>();
//Header
{
Batch = x.Lot;
Batch = x.Lot; // different name
Cassette = x.Cassette;
Date = x.Date;
MeanThickness = x.MeanThickness;
Operator = x.Employee;
Operator = x.Employee; // different name
PSN = x.PSN;
RDS = x.RDS;
Reactor = x.Reactor;
Recipe = x.Recipe;
StdDev = x.GradeStdDev;
StdDev = x.GradeStdDev; // different name
Title = x.Title;
UniqueId = x.UniqueId;
}
@ -92,14 +93,14 @@ public class WSRequest
}
}
internal static long GetHeaderId(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, string openInsightMetrologyViewerFileShare, int weekOfYear, WS.Results results, List<Stratus.Description> descriptions)
internal static long GetHeaderId(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, string openInsightMetrologyViewerFileShare, int weekOfYear, WS.Results results, JsonElement[] jsonElements, List<Stratus.Description> descriptions)
{
long result;
if (results is not null && results.HeaderId is not null)
result = results.HeaderId.Value;
else
{
WSRequest wsRequest = new(fileRead, logistics, descriptions);
WSRequest wsRequest = new(fileRead, logistics, jsonElements, descriptions);
string directory = Path.Combine(openInsightMetrologyViewerFileShare, logistics.DateTimeFromSequence.Year.ToString(), $"WW{weekOfYear:00}");
(_, WS.Results wsResults) = WS.SendData(openInsightMetrologyViewerAPI, logistics.Sequence, directory, wsRequest);
if (wsResults.Success is null || !wsResults.Success.Value)