72 lines
2.2 KiB
C#
72 lines
2.2 KiB
C#
using Adaptation.Shared;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Adaptation.FileHandlers.Stratus;
|
|
|
|
#nullable enable
|
|
|
|
internal class Complete
|
|
{
|
|
|
|
public Complete(Header header, Wafer[] wafers, Footer footer)
|
|
{
|
|
Header = header;
|
|
Wafers = wafers;
|
|
Footer = footer;
|
|
}
|
|
|
|
public Header Header { get; }
|
|
public Wafer[] Wafers { get; }
|
|
public Footer Footer { get; }
|
|
|
|
internal static Complete? Get(Logistics logistics, List<FileInfo> fileInfoCollection)
|
|
{
|
|
Complete? result;
|
|
Constant constant = new();
|
|
int[] i = new int[] { 0 };
|
|
string text = File.ReadAllText(logistics.ReportFullPath);
|
|
Header? header = Header.Get(text, constant, i);
|
|
if (header is null)
|
|
result = null;
|
|
else
|
|
{
|
|
ReadOnlyCollection<string> groups = Wafer.GetGroups(text, constant, i);
|
|
if (groups.Count == 0)
|
|
result = null;
|
|
else
|
|
{
|
|
ReadOnlyCollection<Wafer> wafers = Wafer.Get(constant, groups);
|
|
if (wafers.Count == 0)
|
|
result = null;
|
|
else
|
|
{
|
|
Footer? footer = Footer.Get(constant, groups);
|
|
if (footer is null)
|
|
result = null;
|
|
else
|
|
{
|
|
result = new(header, wafers.ToArray(), footer);
|
|
FileInfo fileInfo = new($"{logistics.ReportFullPath}.json");
|
|
string json = JsonSerializer.Serialize(result, CompleteSourceGenerationContext.Default.Complete);
|
|
File.WriteAllText(fileInfo.FullName, json);
|
|
File.SetLastWriteTime(fileInfo.FullName, logistics.DateTimeFromSequence);
|
|
fileInfoCollection.Add(fileInfo);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Complete))]
|
|
internal partial class CompleteSourceGenerationContext : JsonSerializerContext
|
|
{
|
|
} |