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:
@ -110,10 +110,10 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
return results;
|
||||
}
|
||||
|
||||
private void SendData(string reportFullPath, DateTime dateTime, List<Stratus.Description> descriptions)
|
||||
private void SendData(string reportFullPath, DateTime dateTime, JsonElement[] jsonElements, List<Stratus.Description> descriptions)
|
||||
{
|
||||
string checkDirectory;
|
||||
WSRequest wsRequest = new(this, _Logistics, descriptions);
|
||||
WSRequest wsRequest = new(this, _Logistics, jsonElements, descriptions);
|
||||
int weekOfYear = _Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
|
||||
string directory = Path.Combine(_OpenInsightMetrologyViewerFileShare, dateTime.Year.ToString(), $"WW{weekOfYear:00}");
|
||||
checkDirectory = Path.Combine(directory, _Logistics.Sequence.ToString());
|
||||
@ -139,14 +139,15 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath);
|
||||
string[] lines = File.ReadAllLines(reportFullPath);
|
||||
ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath, lines);
|
||||
_Logistics = new Logistics(reportFullPath, processDataStandardFormat);
|
||||
SetFileParameterLotIDToLogisticsMID();
|
||||
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat);
|
||||
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(reportFullPath, lines, processDataStandardFormat);
|
||||
List<Stratus.Description> descriptions = Stratus.ProcessData.GetDescriptions(jsonElements);
|
||||
Test[] tests = (from l in descriptions select (Test)l.Test).ToArray();
|
||||
if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
|
||||
SendData(reportFullPath, dateTime, descriptions);
|
||||
SendData(reportFullPath, dateTime, jsonElements, descriptions);
|
||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(string.Join(Environment.NewLine, processDataStandardFormat.Logistics), tests, jsonElements, new List<FileInfo>());
|
||||
return results;
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user