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 15:31:55 -07:00
parent 7739ff03a2
commit 48ad90c0f1
12 changed files with 149 additions and 140 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;
}
@ -64,7 +65,6 @@ public class WSRequest
HeaderUniqueId = description.HeaderUniqueId,
Mean = description.Mean,
PassFail = description.PassFail,
Position = description.Position,
Recipe = description.Recipe,
Slot = description.Slot,
StdDev = description.StdDev,
@ -73,7 +73,7 @@ public class WSRequest
Wafer = description.Wafer,
Points = new()
};
segments = description.Position.Split(',');
segments = description.Slot.Split(',');
foreach (string segment in segments)
detail.Points.Add(new Stratus.Point { HeaderUniqueId = description.HeaderUniqueId, UniqueId = description.UniqueId, Position = segment });
segments = description.Thickness.Split(',');
@ -92,14 +92,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)