Require Complete
IDE0060
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Methods;
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@ -52,27 +51,32 @@ public partial class ProcessData : IProcessData
|
||||
|
||||
List<object> Shared.Properties.IProcessData.Details => _Details;
|
||||
|
||||
private readonly ILog _Log;
|
||||
|
||||
public ProcessData()
|
||||
{
|
||||
}
|
||||
|
||||
#nullable enable
|
||||
|
||||
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string originalDataBioRad, Header[] lastHeader, long tickOffset)
|
||||
internal ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string originalDataBioRad, long tickOffset, Complete? complete)
|
||||
{
|
||||
if (fileRead is null)
|
||||
throw new ArgumentNullException(nameof(fileRead));
|
||||
JobID = logistics.JobID;
|
||||
fileInfoCollection.Clear();
|
||||
_Details = new List<object>();
|
||||
List<string> moveFiles = new();
|
||||
MesEntity = logistics.MesEntity;
|
||||
_Log = LogManager.GetLogger(typeof(ProcessData));
|
||||
Complete? complete = Parse(fileRead, logistics, fileInfoCollection, originalDataBioRad, lastHeader);
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(logistics.ReportFullPath);
|
||||
string directoryName = Path.GetDirectoryName(logistics.ReportFullPath) ?? throw new Exception();
|
||||
moveFiles.AddRange(Directory.GetFiles(directoryName, string.Concat(originalDataBioRad, "*", logistics.Sequence, "*"), SearchOption.TopDirectoryOnly));
|
||||
moveFiles.AddRange(Directory.GetFiles(directoryName, string.Concat(originalDataBioRad, "*", fileNameWithoutExtension.Split('_').Last(), "*"), SearchOption.TopDirectoryOnly));
|
||||
foreach (string moveFile in moveFiles.Distinct())
|
||||
fileInfoCollection.Add(new FileInfo(moveFile));
|
||||
fileInfoCollection.Add(logistics.FileInfo);
|
||||
if (complete is not null)
|
||||
SetValues(logistics, tickOffset, complete);
|
||||
}
|
||||
|
||||
string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) => throw new Exception(string.Concat("See ", nameof(Parse)));
|
||||
string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) => throw new Exception(string.Concat("See ", nameof(ProcessData)));
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
|
||||
{
|
||||
@ -247,34 +251,6 @@ public partial class ProcessData : IProcessData
|
||||
return result;
|
||||
}
|
||||
|
||||
private Complete? Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string originalDataBioRad, Header[] lastHeader)
|
||||
{
|
||||
if (fileRead is null)
|
||||
throw new ArgumentNullException(nameof(fileRead));
|
||||
Complete? result;
|
||||
List<string> moveFiles = new();
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(logistics.ReportFullPath);
|
||||
string directoryName = Path.GetDirectoryName(logistics.ReportFullPath) ?? throw new Exception();
|
||||
moveFiles.AddRange(Directory.GetFiles(directoryName, string.Concat(originalDataBioRad, "*", logistics.Sequence, "*"), SearchOption.TopDirectoryOnly));
|
||||
moveFiles.AddRange(Directory.GetFiles(directoryName, string.Concat(originalDataBioRad, "*", fileNameWithoutExtension.Split('_').Last(), "*"), SearchOption.TopDirectoryOnly));
|
||||
foreach (string moveFile in moveFiles.Distinct())
|
||||
fileInfoCollection.Add(new FileInfo(moveFile));
|
||||
string receivedData = File.ReadAllText(logistics.ReportFullPath);
|
||||
result = Complete.Get(lastHeader[0], receivedData);
|
||||
if (result is null)
|
||||
_Log.Warn($"Could not get Complete from {fileNameWithoutExtension}");
|
||||
else
|
||||
{
|
||||
FileInfo fileInfo = new($"{fileNameWithoutExtension}.json");
|
||||
string json = JsonSerializer.Serialize(result, CompleteSourceGenerationContext.Default.Complete);
|
||||
File.WriteAllText(fileInfo.FullName, json);
|
||||
fileInfoCollection.Add(fileInfo);
|
||||
lastHeader[0] = result.Header;
|
||||
}
|
||||
fileInfoCollection.Add(logistics.FileInfo);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void SetValues(Logistics logistics, long tickOffset, Complete complete)
|
||||
{
|
||||
int slot = 0;
|
||||
|
Reference in New Issue
Block a user