Require Complete
IDE0060
This commit is contained in:
parent
8ae8386b30
commit
66f5acc6fa
@ -115,10 +115,10 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE0060
|
|
||||||
private void MoveArchive(string reportFullPath, DateTime dateTime)
|
private void MoveArchive(string reportFullPath, DateTime dateTime)
|
||||||
#pragma warning restore IDE0060
|
|
||||||
{
|
{
|
||||||
|
if (dateTime == DateTime.MinValue)
|
||||||
|
throw new ArgumentNullException(nameof(dateTime));
|
||||||
string logisticsSequence = _Logistics.Sequence.ToString();
|
string logisticsSequence = _Logistics.Sequence.ToString();
|
||||||
string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||||
string weekDirectory = $"{_Logistics.DateTimeFromSequence:yyyy}_Week_{weekOfYear}{@"\"}{_Logistics.DateTimeFromSequence:yyyy-MM-dd}";
|
string weekDirectory = $"{_Logistics.DateTimeFromSequence:yyyy}_Week_{weekOfYear}{@"\"}{_Logistics.DateTimeFromSequence:yyyy-MM-dd}";
|
||||||
|
@ -167,10 +167,10 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
OpenInsightMetrologyViewer.WSRequest.PostOpenInsightMetrologyViewerAttachments(this, _Logistics, _OpenInsightMetrologyViewerAPI, _LincPDFCFileName, descriptions, matchDirectories[0], subGroupId, headerId, headerIdDirectory);
|
OpenInsightMetrologyViewer.WSRequest.PostOpenInsightMetrologyViewerAttachments(this, _Logistics, _OpenInsightMetrologyViewerAPI, _LincPDFCFileName, descriptions, matchDirectories[0], subGroupId, headerId, headerIdDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE0060
|
|
||||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
|
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
|
||||||
#pragma warning restore IDE0060
|
|
||||||
{
|
{
|
||||||
|
if (dateTime == DateTime.MinValue)
|
||||||
|
throw new ArgumentNullException(nameof(dateTime));
|
||||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||||
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
|
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
|
||||||
_Logistics = new Logistics(reportFullPath, pdsf.Item1);
|
_Logistics = new Logistics(reportFullPath, pdsf.Item1);
|
||||||
|
@ -108,10 +108,10 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE0060
|
|
||||||
private void DirectoryMove(string reportFullPath, DateTime dateTime, List<pcl.Description> descriptions)
|
private void DirectoryMove(string reportFullPath, DateTime dateTime, List<pcl.Description> descriptions)
|
||||||
#pragma warning restore IDE0060
|
|
||||||
{
|
{
|
||||||
|
if (dateTime == DateTime.MinValue)
|
||||||
|
throw new ArgumentNullException(nameof(dateTime));
|
||||||
FileInfo fileInfo = new(reportFullPath);
|
FileInfo fileInfo = new(reportFullPath);
|
||||||
string logisticsSequence = _Logistics.Sequence.ToString();
|
string logisticsSequence = _Logistics.Sequence.ToString();
|
||||||
string jobIdDirectory = Path.Combine(_JobIdParentDirectory, _Logistics.JobID);
|
string jobIdDirectory = Path.Combine(_JobIdParentDirectory, _Logistics.JobID);
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Adaptation.FileHandlers.pcl;
|
namespace Adaptation.FileHandlers.pcl;
|
||||||
@ -20,24 +23,38 @@ internal class Complete
|
|||||||
public Summary Summary { get; }
|
public Summary Summary { get; }
|
||||||
public ReadOnlyCollection<Point> Points { get; }
|
public ReadOnlyCollection<Point> Points { get; }
|
||||||
|
|
||||||
public static Complete? Get(Constant constant, ReadOnlyCollection<string> lines)
|
public static Complete? Get(Shared.Logistics logistics, List<FileInfo> fileInfoCollection, ReadOnlyCollection<string> lines)
|
||||||
{
|
{
|
||||||
Complete? result;
|
Complete? result;
|
||||||
Header? header = Header.Get(constant, lines);
|
Constant constant = new();
|
||||||
if (header is null)
|
ReadOnlyCollection<string> collection = new(lines);
|
||||||
|
if (collection.Count <= constant.Take)
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Summary? summary = SummarySegment.Get(constant, lines);
|
Header? header = Header.Get(constant, collection);
|
||||||
if (summary is null)
|
if (header is null)
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ReadOnlyCollection<Point> points = Point.GetCollection(constant, lines) ?? throw new NullReferenceException(nameof(summary));
|
Summary? summary = SummarySegment.Get(constant, collection);
|
||||||
if (points.Count == 0)
|
if (summary is null)
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
result = new(header, summary, points);
|
{
|
||||||
|
ReadOnlyCollection<Point> points = Point.GetCollection(constant, collection) ?? throw new NullReferenceException(nameof(summary));
|
||||||
|
if (points.Count == 0)
|
||||||
|
result = null;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = new(header, summary, points);
|
||||||
|
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;
|
return result;
|
||||||
|
89
Adaptation/FileHandlers/pcl/Convert.cs
Normal file
89
Adaptation/FileHandlers/pcl/Convert.cs
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
using Adaptation.Shared;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace Adaptation.FileHandlers.pcl;
|
||||||
|
|
||||||
|
internal class Convert
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Convert the raw data file to parsable file format - in this case from PCL to PDF
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sourceFile">source file to be converted to PDF</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static string ConvertSourceFileToPdf(Logistics logistics, string ghostPCLFileName)
|
||||||
|
{
|
||||||
|
string result = Path.ChangeExtension(logistics.ReportFullPath, ".pdf");
|
||||||
|
if (!File.Exists(result))
|
||||||
|
{
|
||||||
|
//string arguments = string.Concat("-i \"", sourceFile, "\" -o \"", result, "\"");
|
||||||
|
string arguments = string.Concat("-dSAFER -dBATCH -dNOPAUSE -dFIXEDMEDIA -dFitPage -dAutoRotatePages=/All -dDEVICEWIDTHPOINTS=792 -dDEVICEHEIGHTPOINTS=612 -sOutputFile=\"", result, "\" -sDEVICE=pdfwrite \"", logistics.ReportFullPath, "\"");
|
||||||
|
//Process process = Process.Start(configData.LincPDFCFileName, arguments);
|
||||||
|
Process process = Process.Start(ghostPCLFileName, arguments);
|
||||||
|
_ = process.WaitForExit(30000);
|
||||||
|
if (!File.Exists(result))
|
||||||
|
throw new Exception("PDF file wasn't created");
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ReadOnlyCollection<string> GetTextFromPDF(string pdfTextStripperFileName, string sourceFileNamePdf, string altHeaderFileName)
|
||||||
|
{
|
||||||
|
string[] result;
|
||||||
|
ProcessStartInfo processStartInfo = new(pdfTextStripperFileName, $"s \"{sourceFileNamePdf}\"")
|
||||||
|
{
|
||||||
|
UseShellExecute = false,
|
||||||
|
RedirectStandardError = true,
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
};
|
||||||
|
Process process = Process.Start(processStartInfo);
|
||||||
|
_ = process.WaitForExit(30000);
|
||||||
|
if (!File.Exists(altHeaderFileName))
|
||||||
|
result = Array.Empty<string>();
|
||||||
|
else
|
||||||
|
result = File.ReadAllLines(altHeaderFileName);
|
||||||
|
return new(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static ReadOnlyCollection<string> PDF(Logistics logistics, string ghostPCLFileName, string pdfTextStripperFileName, List<FileInfo> fileInfoCollection)
|
||||||
|
{
|
||||||
|
ReadOnlyCollection<string> result;
|
||||||
|
string sourceFileNamePdf = ConvertSourceFileToPdf(logistics, ghostPCLFileName);
|
||||||
|
fileInfoCollection.Add(new FileInfo(sourceFileNamePdf));
|
||||||
|
string altHeaderFileName = Path.ChangeExtension(logistics.ReportFullPath, ".txt");
|
||||||
|
if (File.Exists(altHeaderFileName))
|
||||||
|
{
|
||||||
|
result = new(File.ReadAllLines(altHeaderFileName));
|
||||||
|
fileInfoCollection.Add(new FileInfo(altHeaderFileName));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//Pdfbox, IKVM.AWT.WinForms
|
||||||
|
org.apache.pdfbox.pdmodel.PDDocument pdfDocument = org.apache.pdfbox.pdmodel.PDDocument.load(sourceFileNamePdf);
|
||||||
|
org.apache.pdfbox.util.PDFTextStripper stripper = new();
|
||||||
|
string text = stripper.getText(pdfDocument);
|
||||||
|
pdfDocument.close();
|
||||||
|
File.AppendAllText(altHeaderFileName, text);
|
||||||
|
fileInfoCollection.Add(new FileInfo(altHeaderFileName));
|
||||||
|
result = new(text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None));
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
if (!File.Exists(pdfTextStripperFileName))
|
||||||
|
throw;
|
||||||
|
result = GetTextFromPDF(pdfTextStripperFileName, sourceFileNamePdf, altHeaderFileName);
|
||||||
|
if (result.Count == 0)
|
||||||
|
throw;
|
||||||
|
fileInfoCollection.Add(new FileInfo(altHeaderFileName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,7 @@ using Adaptation.Shared;
|
|||||||
using Adaptation.Shared.Methods;
|
using Adaptation.Shared.Methods;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
@ -104,9 +105,11 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
|
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
|
||||||
{
|
{
|
||||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>());
|
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, Array.Empty<Test>(), Array.Empty<JsonElement>(), new List<FileInfo>());
|
||||||
_TickOffset ??= 0; // new FileInfo(reportFullPath).LastWriteTime.Ticks - dateTime.Ticks;
|
_TickOffset ??= 0; // new FileInfo(reportFullPath).LastWriteTime.Ticks - dateTime.Ticks;
|
||||||
_Logistics = new Logistics(this, _TickOffset.Value, reportFullPath, useSplitForMID: true);
|
_Logistics = new Logistics(this, _TickOffset.Value, reportFullPath, useSplitForMID: true);
|
||||||
SetFileParameterLotIDToLogisticsMID();
|
SetFileParameterLotIDToLogisticsMID();
|
||||||
@ -114,9 +117,13 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
results.Item4.Add(_Logistics.FileInfo);
|
results.Item4.Add(_Logistics.FileInfo);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, _GhostPCLFileName, _PDFTextStripperFileName);
|
ReadOnlyCollection<string> lines = Convert.PDF(_Logistics, _GhostPCLFileName, _PDFTextStripperFileName, results.Item4);
|
||||||
if (iProcessData is not ProcessData processData)
|
Complete? complete = Complete.Get(_Logistics, results.Item4, lines);
|
||||||
|
if (complete is null)
|
||||||
throw new Exception(string.Concat("A) No Data - ", dateTime.Ticks));
|
throw new Exception(string.Concat("A) No Data - ", dateTime.Ticks));
|
||||||
|
IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, lines);
|
||||||
|
if (iProcessData is not ProcessData processData)
|
||||||
|
throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks));
|
||||||
string mid;
|
string mid;
|
||||||
if (!string.IsNullOrEmpty(processData.Lot) && string.IsNullOrEmpty(processData.Reactor) && string.IsNullOrEmpty(processData.RDS) && string.IsNullOrEmpty(processData.PSN))
|
if (!string.IsNullOrEmpty(processData.Lot) && string.IsNullOrEmpty(processData.Reactor) && string.IsNullOrEmpty(processData.RDS) && string.IsNullOrEmpty(processData.PSN))
|
||||||
mid = processData.Lot;
|
mid = processData.Lot;
|
||||||
@ -130,7 +137,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
|||||||
SetFileParameterLotID(mid);
|
SetFileParameterLotID(mid);
|
||||||
_Logistics.Update(mid, processData.Reactor);
|
_Logistics.Update(mid, processData.Reactor);
|
||||||
if (iProcessData.Details.Count == 0)
|
if (iProcessData.Details.Count == 0)
|
||||||
throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks));
|
throw new Exception(string.Concat("C) No Data - ", dateTime.Ticks));
|
||||||
results = iProcessData.GetResults(this, _Logistics, results.Item4);
|
results = iProcessData.GetResults(this, _Logistics, results.Item4);
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
|
@ -5,7 +5,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
@ -88,7 +87,7 @@ public class ProcessData : IProcessData
|
|||||||
|
|
||||||
List<object> Shared.Properties.IProcessData.Details => _Details;
|
List<object> Shared.Properties.IProcessData.Details => _Details;
|
||||||
|
|
||||||
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string ghostPCLFileName, string pdfTextStripperFileName)
|
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, ReadOnlyCollection<string> lines)
|
||||||
{
|
{
|
||||||
fileInfoCollection.Clear();
|
fileInfoCollection.Clear();
|
||||||
_Details = new List<object>();
|
_Details = new List<object>();
|
||||||
@ -98,7 +97,7 @@ public class ProcessData : IProcessData
|
|||||||
Date = GetDateTime(logistics);
|
Date = GetDateTime(logistics);
|
||||||
MesEntity = logistics.MesEntity;
|
MesEntity = logistics.MesEntity;
|
||||||
_Log = LogManager.GetLogger(typeof(ProcessData));
|
_Log = LogManager.GetLogger(typeof(ProcessData));
|
||||||
Parse(fileRead, logistics, fileInfoCollection, ghostPCLFileName, pdfTextStripperFileName);
|
Parse(fileRead, logistics, fileInfoCollection, lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DateTime GetDateTime(Logistics logistics) =>
|
private static DateTime GetDateTime(Logistics logistics) =>
|
||||||
@ -129,27 +128,6 @@ public class ProcessData : IProcessData
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Convert the raw data file to parsable file format - in this case from PCL to PDF
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sourceFile">source file to be converted to PDF</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static string ConvertSourceFileToPdf(Logistics logistics, string ghostPCLFileName)
|
|
||||||
{
|
|
||||||
string result = Path.ChangeExtension(logistics.ReportFullPath, ".pdf");
|
|
||||||
if (!File.Exists(result))
|
|
||||||
{
|
|
||||||
//string arguments = string.Concat("-i \"", sourceFile, "\" -o \"", result, "\"");
|
|
||||||
string arguments = string.Concat("-dSAFER -dBATCH -dNOPAUSE -dFIXEDMEDIA -dFitPage -dAutoRotatePages=/All -dDEVICEWIDTHPOINTS=792 -dDEVICEHEIGHTPOINTS=612 -sOutputFile=\"", result, "\" -sDEVICE=pdfwrite \"", logistics.ReportFullPath, "\"");
|
|
||||||
//Process process = Process.Start(configData.LincPDFCFileName, arguments);
|
|
||||||
Process process = Process.Start(ghostPCLFileName, arguments);
|
|
||||||
_ = process.WaitForExit(30000);
|
|
||||||
if (!File.Exists(result))
|
|
||||||
throw new Exception("PDF file wasn't created");
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ScanPast(string text)
|
private void ScanPast(string text)
|
||||||
{
|
{
|
||||||
int num = _Data.IndexOf(text, _I);
|
int num = _Data.IndexOf(text, _I);
|
||||||
@ -213,24 +191,6 @@ public class ProcessData : IProcessData
|
|||||||
return text.Trim();
|
return text.Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetTextFromPDF(string pdfTextStripperFileName, string sourceFileNamePdf, string altHeaderFileName)
|
|
||||||
{
|
|
||||||
string result;
|
|
||||||
ProcessStartInfo processStartInfo = new(pdfTextStripperFileName, $"s \"{sourceFileNamePdf}\"")
|
|
||||||
{
|
|
||||||
UseShellExecute = false,
|
|
||||||
RedirectStandardError = true,
|
|
||||||
RedirectStandardOutput = true,
|
|
||||||
};
|
|
||||||
Process process = Process.Start(processStartInfo);
|
|
||||||
_ = process.WaitForExit(30000);
|
|
||||||
if (!File.Exists(altHeaderFileName))
|
|
||||||
result = string.Empty;
|
|
||||||
else
|
|
||||||
result = File.ReadAllText(altHeaderFileName);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static (string, string) GetReactorAndRDS(string defaultReactor, string defaultRDS, string text, string formattedText, string[] segments)
|
private static (string, string) GetReactorAndRDS(string defaultReactor, string defaultRDS, string text, string formattedText, string[] segments)
|
||||||
{
|
{
|
||||||
string rds;
|
string rds;
|
||||||
@ -533,57 +493,11 @@ public class ProcessData : IProcessData
|
|||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
|
||||||
private Complete? GetComplete(string altHeaderFileName)
|
private void Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, ReadOnlyCollection<string> lines)
|
||||||
{
|
{
|
||||||
Complete? result;
|
if (fileRead is null)
|
||||||
Constant constant = new();
|
throw new ArgumentNullException(nameof(fileRead));
|
||||||
string[] lines = File.ReadAllLines(altHeaderFileName);
|
string headerText = string.Join(Environment.NewLine, lines);
|
||||||
ReadOnlyCollection<string> collection = new(lines);
|
|
||||||
if (collection.Count > constant.Take)
|
|
||||||
result = Complete.Get(constant, collection);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = null;
|
|
||||||
_Log.Warn($"File {altHeaderFileName} has less than {constant.Take} collection");
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma warning disable IDE0060
|
|
||||||
private void Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string ghostPCLFileName, string pdfTextStripperFileName)
|
|
||||||
#pragma warning restore IDE0060
|
|
||||||
{
|
|
||||||
string headerText;
|
|
||||||
string sourceFileNamePdf = ConvertSourceFileToPdf(logistics, ghostPCLFileName);
|
|
||||||
fileInfoCollection.Add(new FileInfo(sourceFileNamePdf));
|
|
||||||
string altHeaderFileName = Path.ChangeExtension(logistics.ReportFullPath, ".txt");
|
|
||||||
if (File.Exists(altHeaderFileName))
|
|
||||||
{
|
|
||||||
headerText = File.ReadAllText(altHeaderFileName);
|
|
||||||
fileInfoCollection.Add(new FileInfo(altHeaderFileName));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//Pdfbox, IKVM.AWT.WinForms
|
|
||||||
org.apache.pdfbox.pdmodel.PDDocument pdfDocument = org.apache.pdfbox.pdmodel.PDDocument.load(sourceFileNamePdf);
|
|
||||||
org.apache.pdfbox.util.PDFTextStripper stripper = new();
|
|
||||||
headerText = stripper.getText(pdfDocument);
|
|
||||||
pdfDocument.close();
|
|
||||||
File.AppendAllText(altHeaderFileName, headerText);
|
|
||||||
fileInfoCollection.Add(new FileInfo(altHeaderFileName));
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
if (!File.Exists(pdfTextStripperFileName))
|
|
||||||
throw;
|
|
||||||
headerText = GetTextFromPDF(pdfTextStripperFileName, sourceFileNamePdf, altHeaderFileName);
|
|
||||||
if (string.IsNullOrEmpty(headerText))
|
|
||||||
throw;
|
|
||||||
fileInfoCollection.Add(new FileInfo(altHeaderFileName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (headerText.Contains("G A T E V O L T A G E"))
|
if (headerText.Contains("G A T E V O L T A G E"))
|
||||||
throw new Exception("Ignore: GATEVOLTAGE runs are not parsed.");
|
throw new Exception("Ignore: GATEVOLTAGE runs are not parsed.");
|
||||||
if (!string.IsNullOrEmpty(headerText))
|
if (!string.IsNullOrEmpty(headerText))
|
||||||
@ -692,23 +606,6 @@ public class ProcessData : IProcessData
|
|||||||
detail.UniqueId = string.Concat(detail, detail.UniqueId);
|
detail.UniqueId = string.Concat(detail, detail.UniqueId);
|
||||||
}
|
}
|
||||||
fileInfoCollection.Add(logistics.FileInfo);
|
fileInfoCollection.Add(logistics.FileInfo);
|
||||||
try
|
|
||||||
{
|
|
||||||
Complete? complete = GetComplete(altHeaderFileName);
|
|
||||||
if (complete is null)
|
|
||||||
_Log.Warn($"Could not get Complete from {altHeaderFileName}");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FileInfo fileInfo = new($"{altHeaderFileName}.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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static List<Description> GetDescriptions(JsonElement[] jsonElements)
|
internal static List<Description> GetDescriptions(JsonElement[] jsonElements)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Adaptation.FileHandlers.pcl;
|
namespace Adaptation.FileHandlers.pcl;
|
||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
@ -17,3 +19,9 @@ internal class Summary
|
|||||||
public SummarySegment? RadialGradient { get; }
|
public SummarySegment? RadialGradient { get; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Summary))]
|
||||||
|
internal partial class SummarySourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
@ -118,6 +118,7 @@
|
|||||||
<Compile Include="Adaptation\FileHandlers\OpenInsightMetrologyViewerAttachments\FileRead.cs" />
|
<Compile Include="Adaptation\FileHandlers\OpenInsightMetrologyViewerAttachments\FileRead.cs" />
|
||||||
<Compile Include="Adaptation\FileHandlers\pcl\Complete.cs" />
|
<Compile Include="Adaptation\FileHandlers\pcl\Complete.cs" />
|
||||||
<Compile Include="Adaptation\FileHandlers\pcl\Constant.cs" />
|
<Compile Include="Adaptation\FileHandlers\pcl\Constant.cs" />
|
||||||
|
<Compile Include="Adaptation\FileHandlers\pcl\Convert.cs" />
|
||||||
<Compile Include="Adaptation\FileHandlers\pcl\Description.cs" />
|
<Compile Include="Adaptation\FileHandlers\pcl\Description.cs" />
|
||||||
<Compile Include="Adaptation\FileHandlers\pcl\Descriptor.cs" />
|
<Compile Include="Adaptation\FileHandlers\pcl\Descriptor.cs" />
|
||||||
<Compile Include="Adaptation\FileHandlers\pcl\Detail.cs" />
|
<Compile Include="Adaptation\FileHandlers\pcl\Detail.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user