555 lines
25 KiB
C#
555 lines
25 KiB
C#
using Microsoft.Extensions.Logging;
|
|
#if CDE
|
|
using System.Collections.ObjectModel;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
#endif
|
|
|
|
namespace File_Folder_Helper.ADO2024.PI3;
|
|
|
|
internal static partial class Helper20241031
|
|
{
|
|
|
|
#if CDE
|
|
|
|
private record Complete(Line1 Line1, Line2 Line2, Line3 Line3, Line4 Line4, Line4B Line4B, Line5 Line5, Line6 Line6, Line7 Line7, Line8 Line8, Line9 Line9, Line10 Line10, Line11 Line11, Line12 Line12, Line13 Line13, Point[] Points)
|
|
{
|
|
|
|
internal static ReadOnlyCollection<string> GetCollection(string[] segments)
|
|
{
|
|
List<string> results = [];
|
|
foreach (string segment in segments)
|
|
{
|
|
if (segment[0] == ',')
|
|
break;
|
|
results.Add(segment);
|
|
}
|
|
return new(results);
|
|
}
|
|
|
|
internal static Complete? Get(int take, ReadOnlyCollection<string> lines)
|
|
{
|
|
Complete? result;
|
|
if (lines.Count < take)
|
|
result = null;
|
|
else
|
|
{
|
|
string[] separator = [" ", "\t"];
|
|
// <Title>
|
|
Line1 line1 = Line1.Get(lines[0].Split(separator, StringSplitOptions.RemoveEmptyEntries));
|
|
// <FileName, Proj,Rcpe, LotID,WfrID, Is_TF_DataFile>
|
|
Line2 line2 = Line2.Get(lines[1].Split(separator, StringSplitOptions.RemoveEmptyEntries));
|
|
// <Directory>
|
|
Line3 line3 = Line3.Get(lines[2].Split(separator, StringSplitOptions.RemoveEmptyEntries));
|
|
// <DateTime,Temp,TCR%,N|P>
|
|
Line4 line4 = Line4.Get(lines[3].Split(separator, StringSplitOptions.RemoveEmptyEntries));
|
|
// <Avg,Dev,Min,Max>
|
|
Line4B? line4B = Line4B.Get(lines[3].Split([">"], StringSplitOptions.RemoveEmptyEntries));
|
|
if (line4B is null)
|
|
result = null;
|
|
else
|
|
{
|
|
// <Operator, Epuipment>
|
|
Line5 line5 = Line5.Get(lines[4].Split(separator, StringSplitOptions.RemoveEmptyEntries));
|
|
// <Engineer>
|
|
Line6 line6 = Line6.Get(lines[5].Split(separator, StringSplitOptions.RemoveEmptyEntries));
|
|
// <AreaOrDiamScan, WaferShape, dNBand, TemplateFile, xsize,ysize, CalibFactor, MsmtMode, DataType, DataUnit>
|
|
Line7 line7 = Line7.Get(lines[6].Split(separator, StringSplitOptions.RemoveEmptyEntries));
|
|
// <NumProbePoints, SingleOrDualProbeConfig, #ActPrbPts, Rsens,IdrvMx,VinGain, DataRejectSigma, MeritThreshold, PrbChg#, PrbName>
|
|
Line8 line8 = Line8.Get(lines[7].Split(separator, StringSplitOptions.RemoveEmptyEntries));
|
|
// <WaferSize,EdgeEx, x,yll, x,yur, #x,y, CutCorners>
|
|
Line9 line9 = Line9.Get(lines[8].Split(separator, StringSplitOptions.RemoveEmptyEntries));
|
|
// <Diam: ThScan Start End Step>
|
|
Line10 line10 = Line10.Get(lines[9].Split(separator, StringSplitOptions.RemoveEmptyEntries));
|
|
// <FlatOrNotch FollowMajorFlat AutoOrManualLoad RangeOrIndvdual PauseAfterEveryRun, AutoPrint,Plot, BulkSmplThk & Unit>
|
|
Line11 line11 = Line11.Get(lines[10].Split(separator, StringSplitOptions.RemoveEmptyEntries));
|
|
// <RangeFrom, RangeTo>
|
|
Line12 line12 = Line12.Get(lines[11].Split(separator, StringSplitOptions.RemoveEmptyEntries));
|
|
// <CassSlotSelected>
|
|
Line13 line13 = Line13.Get(lines[12].Split(separator, StringSplitOptions.RemoveEmptyEntries));
|
|
// <R,Th,Data, Rs,RsA,RsB, #Smpl, x,y, Irng,Vrng, ChiSq,merit/GOF, DataIntegrity>
|
|
ReadOnlyCollection<Point> points = Point.Get(take, lines, separator);
|
|
if (points.Count == 0)
|
|
result = null;
|
|
else
|
|
result = new(line1, line2, line3, line4, line4B, line5, line6, line7, line8, line9, line10, line11, line12, line13, points.ToArray());
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Complete))]
|
|
private partial class CompleteSourceGenerationContext : JsonSerializerContext
|
|
{
|
|
}
|
|
|
|
private record Line1([property: JsonPropertyName("Title")] string Title)
|
|
{
|
|
|
|
internal static Line1 Get(string[] segments)
|
|
{
|
|
Line1 result;
|
|
ReadOnlyCollection<string> collection = Complete.GetCollection(segments);
|
|
result = new(collection.Count < 1 ? string.Empty : collection[0]);
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Line1))]
|
|
private partial class Line1SourceGenerationContext : JsonSerializerContext
|
|
{
|
|
}
|
|
|
|
private record Line2([property: JsonPropertyName("FileName")] string FileName,
|
|
[property: JsonPropertyName("Proj")] string Project,
|
|
[property: JsonPropertyName("Rcpe")] string RecipeName,
|
|
[property: JsonPropertyName("LotID")] string LotID,
|
|
[property: JsonPropertyName("WfrID")] string WfrID,
|
|
[property: JsonPropertyName("Is_TF_DataFile")] string Is_TF_DataFile)
|
|
{
|
|
|
|
internal static Line2 Get(string[] segments)
|
|
{
|
|
Line2 result;
|
|
ReadOnlyCollection<string> collection = Complete.GetCollection(segments);
|
|
result = new(collection.Count < 1 ? string.Empty : collection[0],
|
|
collection.Count < 2 ? string.Empty : collection[1],
|
|
collection.Count < 3 ? string.Empty : collection[2],
|
|
collection.Count < 4 ? string.Empty : collection[3],
|
|
collection.Count < 5 ? string.Empty : collection[4],
|
|
collection.Count < 6 ? string.Empty : collection[5]);
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Line2))]
|
|
private partial class Line2SourceGenerationContext : JsonSerializerContext
|
|
{
|
|
}
|
|
|
|
private record Line3([property: JsonPropertyName("Directory")] string Directory)
|
|
{
|
|
|
|
internal static Line3 Get(string[] segments)
|
|
{
|
|
Line3 result;
|
|
ReadOnlyCollection<string> collection = Complete.GetCollection(segments);
|
|
result = new(collection.Count < 1 ? string.Empty : collection[0]);
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Line3))]
|
|
private partial class Line3SourceGenerationContext : JsonSerializerContext
|
|
{
|
|
}
|
|
|
|
private record Line4([property: JsonPropertyName("Time")] string Time,
|
|
[property: JsonPropertyName("Date")] string Date,
|
|
[property: JsonPropertyName("Temp")] string Temp,
|
|
[property: JsonPropertyName("TCR%")] string TCRPercent,
|
|
[property: JsonPropertyName("N|P")] string NOrP)
|
|
{
|
|
|
|
internal static Line4 Get(string[] segments)
|
|
{
|
|
Line4 result;
|
|
ReadOnlyCollection<string> collection = Complete.GetCollection(segments);
|
|
result = new(collection.Count < 1 ? string.Empty : collection[0],
|
|
collection.Count < 2 ? string.Empty : collection[1],
|
|
collection.Count < 3 ? string.Empty : collection[2],
|
|
collection.Count < 4 ? string.Empty : collection[3],
|
|
collection.Count < 5 ? string.Empty : collection[4]);
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Line4))]
|
|
private partial class Line4SourceGenerationContext : JsonSerializerContext
|
|
{
|
|
}
|
|
|
|
private record Line4B([property: JsonPropertyName("Avg")] string Avg,
|
|
[property: JsonPropertyName("Dev")] string Dev,
|
|
[property: JsonPropertyName("Min")] string Min,
|
|
[property: JsonPropertyName("Max")] string Max)
|
|
{
|
|
|
|
internal static Line4B? Get(string[] segments)
|
|
{
|
|
Line4B? result;
|
|
if (segments.Length < 2)
|
|
result = null;
|
|
else
|
|
{
|
|
string[] segmentsB = segments[1].Split([" "], StringSplitOptions.RemoveEmptyEntries);
|
|
result = new(segmentsB.Length < 2 ? string.Empty : segmentsB[1],
|
|
segmentsB.Length < 4 ? string.Empty : segmentsB[3],
|
|
segmentsB.Length < 6 ? string.Empty : segmentsB[5],
|
|
segmentsB.Length < 8 ? string.Empty : segmentsB[7]);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Line4B))]
|
|
private partial class Line4BSourceGenerationContext : JsonSerializerContext
|
|
{
|
|
}
|
|
|
|
private record Line5([property: JsonPropertyName("Operator")] string Operator,
|
|
[property: JsonPropertyName("Epuipment")] string Equipment)
|
|
{
|
|
|
|
internal static Line5 Get(string[] segments)
|
|
{
|
|
Line5 result;
|
|
ReadOnlyCollection<string> collection = Complete.GetCollection(segments);
|
|
result = new(collection.Count < 1 ? string.Empty : collection[0],
|
|
collection.Count < 2 ? string.Empty : collection[1]);
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Line5))]
|
|
private partial class Line5SourceGenerationContext : JsonSerializerContext
|
|
{
|
|
}
|
|
|
|
private record Line6([property: JsonPropertyName("Engineer")] string Engineer)
|
|
{
|
|
|
|
internal static Line6 Get(string[] segments)
|
|
{
|
|
Line6 result;
|
|
ReadOnlyCollection<string> collection = Complete.GetCollection(segments);
|
|
result = new(collection.Count < 1 ? string.Empty : collection[0]);
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Line6))]
|
|
private partial class Line6SourceGenerationContext : JsonSerializerContext
|
|
{
|
|
}
|
|
|
|
private record Line7([property: JsonPropertyName("AreaOrDiamScan")] string AreaOrDiamScan,
|
|
[property: JsonPropertyName("WaferShape")] string WaferShape,
|
|
[property: JsonPropertyName("dNBand")] string BNBand,
|
|
[property: JsonPropertyName("TemplateFile")] string TemplateFile,
|
|
[property: JsonPropertyName("xsize")] string XSize,
|
|
[property: JsonPropertyName("ysize")] string YSize,
|
|
[property: JsonPropertyName("CalibFactor")] string CalibrationFactor,
|
|
[property: JsonPropertyName("MsmtMode")] string MsmtMode,
|
|
[property: JsonPropertyName("DataType")] string DataType,
|
|
[property: JsonPropertyName("DataUnit")] string DataUnit)
|
|
{
|
|
|
|
internal static Line7 Get(string[] segments)
|
|
{
|
|
Line7 result;
|
|
ReadOnlyCollection<string> collection = Complete.GetCollection(segments);
|
|
result = new(collection.Count < 1 ? string.Empty : collection[0],
|
|
collection.Count < 2 ? string.Empty : collection[1],
|
|
collection.Count < 3 ? string.Empty : collection[2],
|
|
collection.Count < 4 ? string.Empty : collection[3],
|
|
collection.Count < 5 ? string.Empty : collection[4],
|
|
collection.Count < 6 ? string.Empty : collection[5],
|
|
collection.Count < 7 ? string.Empty : collection[6],
|
|
collection.Count < 8 ? string.Empty : collection[7],
|
|
collection.Count < 9 ? string.Empty : collection[8],
|
|
collection.Count < 10 ? string.Empty : collection[9]);
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Line7))]
|
|
private partial class Line7SourceGenerationContext : JsonSerializerContext
|
|
{
|
|
}
|
|
|
|
private record Line8([property: JsonPropertyName("NumProbePoints")] string NumProbePoints,
|
|
[property: JsonPropertyName("SingleOrDualProbeConfig")] string SingleOrDualProbeConfig,
|
|
[property: JsonPropertyName("#ActPrbPts")] string NumberActPrbPts,
|
|
[property: JsonPropertyName("Rsens")] string Rsens,
|
|
[property: JsonPropertyName("IdrvMx")] string IdrvMx,
|
|
[property: JsonPropertyName("VinGain")] string VinGain,
|
|
[property: JsonPropertyName("DataRejectSigma")] string DataRejectSigma,
|
|
[property: JsonPropertyName("MeritThreshold")] string MeritThreshold,
|
|
[property: JsonPropertyName("PrbChg#")] string PrbChgNumber,
|
|
[property: JsonPropertyName("PrbName")] string PrbName)
|
|
{
|
|
|
|
internal static Line8 Get(string[] segments)
|
|
{
|
|
Line8 result;
|
|
ReadOnlyCollection<string> collection = Complete.GetCollection(segments);
|
|
result = new(collection.Count < 1 ? string.Empty : collection[0],
|
|
collection.Count < 2 ? string.Empty : collection[1],
|
|
collection.Count < 3 ? string.Empty : collection[2],
|
|
collection.Count < 4 ? string.Empty : collection[3],
|
|
collection.Count < 5 ? string.Empty : collection[4],
|
|
collection.Count < 6 ? string.Empty : collection[5],
|
|
collection.Count < 7 ? string.Empty : collection[6],
|
|
collection.Count < 8 ? string.Empty : collection[7],
|
|
collection.Count < 9 ? string.Empty : collection[8],
|
|
collection.Count < 10 ? string.Empty : collection[9]);
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Line8))]
|
|
private partial class Line8SourceGenerationContext : JsonSerializerContext
|
|
{
|
|
}
|
|
|
|
private record Line9([property: JsonPropertyName("WaferSize")] string WaferSize,
|
|
[property: JsonPropertyName("EdgeEx")] string EdgeEx,
|
|
[property: JsonPropertyName("xll")] string Xll,
|
|
[property: JsonPropertyName("yll")] string Yll,
|
|
[property: JsonPropertyName("xur")] string Xur,
|
|
[property: JsonPropertyName("yur")] string Yur,
|
|
[property: JsonPropertyName("x")] string X,
|
|
[property: JsonPropertyName("y")] string Y,
|
|
[property: JsonPropertyName("CutCorners")] string CutCorners)
|
|
{
|
|
|
|
internal static Line9 Get(string[] segments)
|
|
{
|
|
Line9 result;
|
|
ReadOnlyCollection<string> collection = Complete.GetCollection(segments);
|
|
result = new(collection.Count < 1 ? string.Empty : collection[0],
|
|
collection.Count < 2 ? string.Empty : collection[1],
|
|
collection.Count < 3 ? string.Empty : collection[2],
|
|
collection.Count < 4 ? string.Empty : collection[3],
|
|
collection.Count < 5 ? string.Empty : collection[4],
|
|
collection.Count < 6 ? string.Empty : collection[5],
|
|
collection.Count < 7 ? string.Empty : collection[6],
|
|
collection.Count < 8 ? string.Empty : collection[7],
|
|
collection.Count < 9 ? string.Empty : collection[8]);
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Line9))]
|
|
private partial class Line9SourceGenerationContext : JsonSerializerContext
|
|
{
|
|
}
|
|
|
|
private record Line10([property: JsonPropertyName("Diam ThScan")] string DiamThScan,
|
|
[property: JsonPropertyName("Diam Start")] string DiamStart,
|
|
[property: JsonPropertyName("Diam End")] string DiamEnd,
|
|
[property: JsonPropertyName("Diam Step")] string DiamStep)
|
|
{
|
|
|
|
internal static Line10 Get(string[] segments)
|
|
{
|
|
Line10 result;
|
|
ReadOnlyCollection<string> collection = Complete.GetCollection(segments);
|
|
result = new(collection.Count < 1 ? string.Empty : collection[0],
|
|
collection.Count < 2 ? string.Empty : collection[1],
|
|
collection.Count < 3 ? string.Empty : collection[2],
|
|
collection.Count < 4 ? string.Empty : collection[3]);
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Line10))]
|
|
private partial class Line10SourceGenerationContext : JsonSerializerContext
|
|
{
|
|
}
|
|
|
|
private record Line11([property: JsonPropertyName("FlatOrNotch")] string FlatOrNotch,
|
|
[property: JsonPropertyName("FollowMajorFlat")] string FollowMajorFlat,
|
|
[property: JsonPropertyName("AutoOrManualLoad")] string AutoOrManualLoad,
|
|
[property: JsonPropertyName("RangeOrIndvdual")] string RangeOrIndividual,
|
|
[property: JsonPropertyName("PauseAfterEveryRun")] string PauseAfterEveryRun,
|
|
[property: JsonPropertyName("AutoPrint")] string AutoPrint,
|
|
[property: JsonPropertyName("Plot")] string Plot,
|
|
[property: JsonPropertyName("BulkSmplThk")] string BulkSampleThk,
|
|
[property: JsonPropertyName("Unit")] string Unit)
|
|
{
|
|
|
|
internal static Line11 Get(string[] segments)
|
|
{
|
|
Line11 result;
|
|
ReadOnlyCollection<string> collection = Complete.GetCollection(segments);
|
|
result = new(collection.Count < 1 ? string.Empty : collection[0],
|
|
collection.Count < 2 ? string.Empty : collection[1],
|
|
collection.Count < 3 ? string.Empty : collection[2],
|
|
collection.Count < 4 ? string.Empty : collection[3],
|
|
collection.Count < 5 ? string.Empty : collection[4],
|
|
collection.Count < 6 ? string.Empty : collection[5],
|
|
collection.Count < 7 ? string.Empty : collection[6],
|
|
collection.Count < 8 ? string.Empty : collection[7],
|
|
collection.Count < 9 ? string.Empty : collection[8]);
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Line11))]
|
|
private partial class Line11SourceGenerationContext : JsonSerializerContext
|
|
{
|
|
}
|
|
|
|
private record Line12([property: JsonPropertyName("RangeFrom")] string RangeFrom,
|
|
[property: JsonPropertyName("RangeTo")] string RangeTo)
|
|
{
|
|
|
|
internal static Line12 Get(string[] segments)
|
|
{
|
|
Line12 result;
|
|
ReadOnlyCollection<string> collection = Complete.GetCollection(segments);
|
|
result = new(collection.Count < 1 ? string.Empty : collection[0],
|
|
collection.Count < 2 ? string.Empty : collection[1]);
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Line12))]
|
|
private partial class Line12SourceGenerationContext : JsonSerializerContext
|
|
{
|
|
}
|
|
|
|
private record Line13([property: JsonPropertyName("CassSlotSelected")] string CassetteSlotSelected)
|
|
{
|
|
|
|
internal static Line13 Get(string[] segments)
|
|
{
|
|
Line13 result;
|
|
ReadOnlyCollection<string> collection = Complete.GetCollection(segments);
|
|
result = new(collection.Count < 1 ? string.Empty : collection[0]);
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Line13))]
|
|
private partial class Line13SourceGenerationContext : JsonSerializerContext
|
|
{
|
|
}
|
|
|
|
private record Point([property: JsonPropertyName("R")] string R,
|
|
[property: JsonPropertyName("Th")] string Th,
|
|
[property: JsonPropertyName("Data")] string Data,
|
|
[property: JsonPropertyName("Rs")] string Rs,
|
|
[property: JsonPropertyName("RsA")] string RsA,
|
|
[property: JsonPropertyName("RsB")] string RsB,
|
|
[property: JsonPropertyName("#Smpl")] string NumberSample,
|
|
[property: JsonPropertyName("x")] string X,
|
|
[property: JsonPropertyName("y")] string Y,
|
|
[property: JsonPropertyName("Irng")] string Irng,
|
|
[property: JsonPropertyName("Vrng")] string Vrng,
|
|
[property: JsonPropertyName("ChiSq")] string ChiSq,
|
|
[property: JsonPropertyName("merit/GOF")] string MeritGOF,
|
|
[property: JsonPropertyName("DataIntegrity")] string DataIntegrity)
|
|
{
|
|
|
|
internal static ReadOnlyCollection<Point> Get(int take, ReadOnlyCollection<string> lines, string[] separator)
|
|
{
|
|
List<Point> results = [];
|
|
Point point;
|
|
string[] segments;
|
|
ReadOnlyCollection<string> collection;
|
|
for (int i = take - 1; i < lines.Count; i++)
|
|
{
|
|
if (string.IsNullOrEmpty(lines[i]))
|
|
break;
|
|
segments = lines[i].Split(separator, StringSplitOptions.RemoveEmptyEntries);
|
|
collection = Complete.GetCollection(segments);
|
|
point = new(collection.Count < 1 ? string.Empty : collection[0],
|
|
collection.Count < 2 ? string.Empty : collection[1],
|
|
collection.Count < 3 ? string.Empty : collection[2],
|
|
collection.Count < 4 ? string.Empty : collection[3],
|
|
collection.Count < 5 ? string.Empty : collection[4],
|
|
collection.Count < 6 ? string.Empty : collection[5],
|
|
collection.Count < 7 ? string.Empty : collection[6],
|
|
collection.Count < 8 ? string.Empty : collection[7],
|
|
collection.Count < 9 ? string.Empty : collection[8],
|
|
collection.Count < 10 ? string.Empty : collection[9],
|
|
collection.Count < 11 ? string.Empty : collection[10],
|
|
collection.Count < 12 ? string.Empty : collection[11],
|
|
collection.Count < 13 ? string.Empty : collection[12],
|
|
collection.Count < 14 ? string.Empty : collection[13]);
|
|
results.Add(point);
|
|
}
|
|
return new(results);
|
|
}
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Point))]
|
|
private partial class PointSourceGenerationContext : JsonSerializerContext
|
|
{
|
|
}
|
|
|
|
internal static void GetComplete(ILogger<Worker> logger, List<string> args)
|
|
{
|
|
string searchPattern = args[2];
|
|
string sourceDirectory = Path.GetFullPath(args[0]);
|
|
string[] files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.TopDirectoryOnly);
|
|
if (files.Length != 1)
|
|
logger.LogError("No files found in {sourceDirectory} with search pattern {searchPattern}", sourceDirectory, searchPattern);
|
|
else
|
|
{
|
|
int take = 14;
|
|
string[] lines = File.ReadAllLines(files[0]);
|
|
if (lines.Length < take)
|
|
logger.LogError("File {files[0]} has less than {take} lines", files[0], take);
|
|
else
|
|
{
|
|
ReadOnlyCollection<string> collection = new(lines);
|
|
Complete? complete = Complete.Get(take, collection);
|
|
if (complete is null)
|
|
logger.LogError("Could not get Complete from {files[0]}", files[0]);
|
|
else
|
|
{
|
|
string json = JsonSerializer.Serialize(complete, CompleteSourceGenerationContext.Default.Complete);
|
|
File.WriteAllText($"{files[0]}.json", json);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#else
|
|
|
|
internal static void GetComplete(ILogger<Worker> logger, List<string> args)
|
|
{
|
|
logger.LogError("GetComplete is not available in CDE {args[0]}", args[0]);
|
|
logger.LogError("GetComplete is not available in CDE {args[1]}", args[1]);
|
|
}
|
|
|
|
#endif
|
|
|
|
} |