FlagDuplicates

CA1510
Complete
This commit is contained in:
2024-11-18 16:58:26 -07:00
parent aaefffd3d2
commit 8ff877156d
20 changed files with 726 additions and 100 deletions

View File

@ -232,7 +232,8 @@ public class ProcessData : IProcessData
return GetBefore("\n", false);
}
private string GetToText(string text) => _Data.Substring(_I, _Data.IndexOf(text, _I) - _I).Trim();
private string GetToText(string text) =>
_Data.Substring(_I, _Data.IndexOf(text, _I) - _I).Trim();
private string GetToken()
{
@ -412,10 +413,10 @@ public class ProcessData : IProcessData
UniqueId = string.Format("{0}_{1}_{2}", logistics.JobID, lot, Path.GetFileNameWithoutExtension(logistics.ReportFullPath));
}
#pragma warning disable IDE0060
private void ParseLotSummary(IFileRead fileRead, ILogistics logistics, string headerFileName, Dictionary<string, string> pages, Dictionary<string, List<Detail>> slots)
#pragma warning restore IDE0060
{
if (fileRead is null)
throw new ArgumentNullException(nameof(fileRead));
_I = 0;
ParseErrorText = string.Empty;
if (!pages.TryGetValue(headerFileName, out string value))
@ -601,6 +602,16 @@ public class ProcessData : IProcessData
return result;
}
#nullable enable
private static Complete? GetComplete(string headerFileName, Dictionary<string, string> pages, Dictionary<string, List<Detail>> slots)
{
Complete? result;
Constant constant = new();
result = Complete.Get(headerFileName, pages, slots, constant);
return result;
}
private void Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string ghostPCLFileName)
{
object item;
@ -611,9 +622,9 @@ public class ProcessData : IProcessData
List<string> missingSlots = new();
Dictionary<string, string> pages = new();
Dictionary<string, List<Detail>> slots = new();
string sourcePath = Path.GetDirectoryName(logistics.ReportFullPath);
string sourceFileNamePdf = ConvertSourceFileToPdf(ghostPCLFileName, logistics);
sourceFiles.Add(sourceFileNamePdf);
string sourcePath = Path.GetDirectoryName(logistics.ReportFullPath) ?? throw new Exception();
string sourceFileNameWithoutExtension = Path.GetFileNameWithoutExtension(logistics.ReportFullPath);
string[] txtFiles = Directory.GetFiles(sourcePath, $"{sourceFileNameWithoutExtension}_*.txt", SearchOption.TopDirectoryOnly);
if (txtFiles.Length != 0)
@ -676,7 +687,6 @@ public class ProcessData : IProcessData
}
pdDocument.close();
}
// parse lot summary
_Log.Debug($"****ParseData - Parsing lot summary");
List<Tuple<string, string>> pageMapping = new();
string headerFileName = string.Concat(sourcePath, @"\", sourceFileNameWithoutExtension, "_", pages.Count, ".pdf");
@ -764,6 +774,23 @@ public class ProcessData : IProcessData
foreach (string sourceFile in sourceFiles)
fileInfoCollection.Add(new FileInfo(sourceFile));
fileInfoCollection.Add(logistics.FileInfo);
try
{
Complete? complete = GetComplete(headerFileName, pages, slots);
if (complete is null)
_Log.Warn($"Could not get Complete from {sourceFileNameWithoutExtension}");
else
{
FileInfo fileInfo = new($"{sourceFileNameWithoutExtension}.json");
string json = JsonSerializer.Serialize(complete, CompleteSourceGenerationContext.Default.Complete);
File.WriteAllText(fileInfo.FullName, json);
fileInfoCollection.Add(fileInfo);
}
}
catch (Exception ex)
{
_Log.Error($"Error in {nameof(GetComplete)}", ex);
}
}
#nullable enable