json in process-data-standard-format
This commit is contained in:
		| @ -22,17 +22,21 @@ public class FileRead : Shared.FileRead, IFileRead | ||||
|     internal class PreWith | ||||
|     { | ||||
|  | ||||
|         internal string MatchingFile { get; private set; } | ||||
|         internal string CheckFile { get; private set; } | ||||
|         internal string ErrFile { get; private set; } | ||||
|         internal string CheckFile { get; private set; } | ||||
|         internal string MatchingFile { get; private set; } | ||||
|         internal string CheckDirectory { get; private set; } | ||||
|         internal string NoWaitDirectory { get; private set; } | ||||
|  | ||||
|         internal PreWith(string matchingFile, string checkFile, string errFile, string checkDirectory, string noWaitDirectory) | ||||
|         internal PreWith(string checkDirectory, | ||||
|                          string checkFile, | ||||
|                          string errFile, | ||||
|                          string matchingFile, | ||||
|                          string noWaitDirectory) | ||||
|         { | ||||
|             MatchingFile = matchingFile; | ||||
|             CheckFile = checkFile; | ||||
|             ErrFile = errFile; | ||||
|             CheckFile = checkFile; | ||||
|             MatchingFile = matchingFile; | ||||
|             CheckDirectory = checkDirectory; | ||||
|             NoWaitDirectory = noWaitDirectory; | ||||
|         } | ||||
| @ -221,7 +225,11 @@ public class FileRead : Shared.FileRead, IFileRead | ||||
|             if (!Directory.Exists(checkDirectory)) | ||||
|                 _ = Directory.CreateDirectory(checkDirectory); | ||||
|             noWaitDirectory = Path.Combine(checkDirectory, "NoWaitDirectory"); | ||||
|             preWith = new(pre.MatchingFile, pre.CheckFile, errFile, checkDirectory, noWaitDirectory); | ||||
|             preWith = new(checkDirectory: checkDirectory, | ||||
|                           checkFile: pre.CheckFile, | ||||
|                           errFile: errFile, | ||||
|                           matchingFile: pre.MatchingFile, | ||||
|                           noWaitDirectory: noWaitDirectory); | ||||
|             results.Add(preWith); | ||||
|         } | ||||
|         return results.AsReadOnly(); | ||||
| @ -260,7 +268,7 @@ public class FileRead : Shared.FileRead, IFileRead | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private static ReadOnlyCollection<Pre> GetPreCollection(int numberLength, string parentDirectory, ReadOnlyCollection<string> matchingFiles) | ||||
|     private static ReadOnlyCollection<Pre> GetPreCollection(int numberLength, string parentDirectory, ReadOnlyCollection<string> matchingFiles, bool _) | ||||
|     { | ||||
|         List<Pre> results = new(); | ||||
|         Pre pre; | ||||
| @ -275,7 +283,7 @@ public class FileRead : Shared.FileRead, IFileRead | ||||
|         return results.AsReadOnly(); | ||||
|     } | ||||
|  | ||||
|     private void MoveCollection(DateTime dateTime, ProcessDataStandardFormat? processDataStandardFormat, ReadOnlyCollection<PreWith> preWithCollection) | ||||
|     private void MoveCollection(DateTime dateTime, ProcessDataStandardFormat processDataStandardFormat, ReadOnlyCollection<PreWith> preWithCollection) | ||||
|     { | ||||
|         ReadOnlyCollection<Post> postCollection = GetPostCollection(dateTime, processDataStandardFormat, preWithCollection); | ||||
|         if (postCollection.Count != 0) | ||||
| @ -294,7 +302,7 @@ public class FileRead : Shared.FileRead, IFileRead | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private ReadOnlyCollection<Post> GetPostCollection(DateTime dateTime, ProcessDataStandardFormat? processDataStandardFormat, ReadOnlyCollection<PreWith> preWithCollection) | ||||
|     private ReadOnlyCollection<Post> GetPostCollection(DateTime dateTime, ProcessDataStandardFormat processDataStandardFormat, ReadOnlyCollection<PreWith> preWithCollection) | ||||
|     { | ||||
|         List<Post> results = new(); | ||||
|         Post post; | ||||
| @ -303,15 +311,10 @@ public class FileRead : Shared.FileRead, IFileRead | ||||
|         { | ||||
|             if (!_IsEAFHosted) | ||||
|                 continue; | ||||
|             if (processDataStandardFormat is null) | ||||
|                 File.Move(preWith.MatchingFile, preWith.CheckFile); | ||||
|             else | ||||
|             { | ||||
|                 if (!_StaticRuns.TryGetValue(_Logistics.Sequence, out List<Shared.Metrology.WS.Results>? wsResults)) | ||||
|                     wsResults = null; | ||||
|                 ProcessDataStandardFormat.Write(preWith.CheckFile, processDataStandardFormat, wsResults); | ||||
|                 File.Delete(preWith.MatchingFile); | ||||
|             } | ||||
|             if (!_StaticRuns.TryGetValue(_Logistics.Sequence, out List<Shared.Metrology.WS.Results>? wsResults)) | ||||
|                 wsResults = null; | ||||
|             ProcessDataStandardFormat.Write(preWith.CheckFile, processDataStandardFormat, wsResults); | ||||
|             File.Delete(preWith.MatchingFile); | ||||
|             if (Directory.Exists(preWith.NoWaitDirectory)) | ||||
|             { | ||||
|                 post = new(preWith.CheckFile, preWith.ErrFile); | ||||
| @ -345,17 +348,10 @@ 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 = new(string.Empty, Array.Empty<Test>(), Array.Empty<JsonElement>(), new List<FileInfo>()); | ||||
|         ProcessDataStandardFormat? processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath, _ProcessDataStandardFormatMapping); | ||||
|         if (processDataStandardFormat is not null) | ||||
|             _Logistics = new Logistics(reportFullPath, processDataStandardFormat); | ||||
|         else | ||||
|         { | ||||
|             processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath); | ||||
|             _Logistics = new Logistics(reportFullPath, processDataStandardFormat); | ||||
|             processDataStandardFormat = null; | ||||
|         } | ||||
|         if (!_IsEAFHosted && processDataStandardFormat is not null) | ||||
|             ProcessDataStandardFormat.Write(".pdsf", processDataStandardFormat, wsResults: null); | ||||
|         ProcessDataStandardFormat processDataStandardFormat = ProcessDataStandardFormat.GetProcessDataStandardFormat(reportFullPath, _ProcessDataStandardFormatMapping); | ||||
|         _Logistics = new Logistics(reportFullPath, processDataStandardFormat); | ||||
|         if (!_IsEAFHosted) | ||||
|             ProcessDataStandardFormat.Write("../../.pdsf", processDataStandardFormat, wsResults: null); | ||||
|         SetFileParameterLotIDToLogisticsMID(); | ||||
|         int numberLength = 2; | ||||
|         long ticks = dateTime.Ticks; | ||||
| @ -364,10 +360,16 @@ public class FileRead : Shared.FileRead, IFileRead | ||||
|         ReadOnlyCollection<string> matchingFiles = GetMatchingFiles(ticks, reportFullPath, searchDirectories); | ||||
|         if (matchingFiles.Count != searchDirectories.Count) | ||||
|             throw new Exception($"Didn't find all files after {_BreakAfterSeconds} second(s)!"); | ||||
|         try | ||||
|         { CreatePointerFile(numberLength, parentParentDirectory, matchingFiles); } | ||||
|         catch (Exception) { } | ||||
|         ReadOnlyCollection<Pre> preCollection = GetPreCollection(numberLength, parentParentDirectory, matchingFiles); | ||||
|         if (_IsEAFHosted) | ||||
|         { | ||||
|             try | ||||
|             { CreatePointerFile(numberLength, parentParentDirectory, matchingFiles); } | ||||
|             catch (Exception) { } | ||||
|         } | ||||
|         JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processDataStandardFormat); | ||||
|         List<pcl.Description> descriptions = pcl.ProcessData.GetDescriptions(jsonElements); | ||||
|         bool mesEntityMatchesProcess = descriptions.Count > 0 && descriptions[0].MesEntity == descriptions[0].Reactor; | ||||
|         ReadOnlyCollection<Pre> preCollection = GetPreCollection(numberLength, parentParentDirectory, matchingFiles, mesEntityMatchesProcess); | ||||
|         ReadOnlyCollection<PreWith> preWithCollection = GetPreWithCollection(preCollection); | ||||
|         MoveCollection(dateTime, processDataStandardFormat, preWithCollection); | ||||
|         return results; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user