Ready to test
This commit is contained in:
141
Adaptation/FileHandlers/Archive/FileRead.cs
Normal file
141
Adaptation/FileHandlers/Archive/FileRead.cs
Normal file
@ -0,0 +1,141 @@
|
||||
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
|
||||
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Duplicator;
|
||||
using Adaptation.Shared.Methods;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Adaptation.FileHandlers.Archive;
|
||||
|
||||
public class FileRead : Shared.FileRead, IFileRead
|
||||
{
|
||||
|
||||
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted) :
|
||||
base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
|
||||
{
|
||||
_MinFileLength = 10;
|
||||
_NullData = string.Empty;
|
||||
_Logistics = new Logistics(this);
|
||||
if (_FileParameter is null)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (_ModelObjectParameterDefinitions is null)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (!_IsDuplicator)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
}
|
||||
|
||||
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) => Move(extractResults, exception);
|
||||
|
||||
void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
|
||||
|
||||
string IFileRead.GetEventDescription()
|
||||
{
|
||||
string result = _Description.GetEventDescription();
|
||||
return result;
|
||||
}
|
||||
|
||||
List<string> IFileRead.GetHeaderNames()
|
||||
{
|
||||
List<string> results = _Description.GetHeaderNames();
|
||||
return results;
|
||||
}
|
||||
|
||||
string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
|
||||
{
|
||||
string[] results = Move(extractResults, to, from, resolvedFileLocation, exception);
|
||||
return results;
|
||||
}
|
||||
|
||||
JsonProperty[] IFileRead.GetDefault()
|
||||
{
|
||||
JsonProperty[] results = _Description.GetDefault(this, _Logistics);
|
||||
return results;
|
||||
}
|
||||
|
||||
Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement()
|
||||
{
|
||||
Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this);
|
||||
return results;
|
||||
}
|
||||
|
||||
List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData)
|
||||
{
|
||||
List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
|
||||
return results;
|
||||
}
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.GetExtractResult(string reportFullPath, string eventName)
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
if (string.IsNullOrEmpty(eventName))
|
||||
throw new Exception();
|
||||
_ReportFullPath = reportFullPath;
|
||||
DateTime dateTime = DateTime.Now;
|
||||
results = GetExtractResult(reportFullPath, dateTime);
|
||||
if (results.Item3 is null)
|
||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(results.Item1, Array.Empty<Test>(), JsonSerializer.Deserialize<JsonElement[]>("[]"), results.Item4);
|
||||
if (results.Item3.Length > 0 && _IsEAFHosted)
|
||||
WritePDSF(this, results.Item3);
|
||||
UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks);
|
||||
return results;
|
||||
}
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.ReExtract()
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
List<string> headerNames = _Description.GetHeaderNames();
|
||||
Dictionary<string, string> keyValuePairs = _Description.GetDisplayNamesJsonElement(this);
|
||||
results = ReExtract(this, headerNames, keyValuePairs);
|
||||
return results;
|
||||
}
|
||||
|
||||
void IFileRead.CheckTests(Test[] tests, bool extra)
|
||||
{
|
||||
if (_Description is not Description)
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
void IFileRead.Callback(object state) => throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
|
||||
|
||||
private void MoveArchive(DateTime dateTime)
|
||||
{
|
||||
if (dateTime == DateTime.MinValue)
|
||||
{ }
|
||||
string logisticsSequence = _Logistics.Sequence.ToString();
|
||||
string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
string weekDirectory = string.Concat(_Logistics.DateTimeFromSequence.ToString("yyyy"), "_Week_", weekOfYear, @"\", _Logistics.DateTimeFromSequence.ToString("yyyy-MM-dd"));
|
||||
string jobIdDirectory = string.Concat(_FileConnectorConfiguration.TargetFileLocation, @"\", _Logistics.JobID);
|
||||
if (!Directory.Exists(jobIdDirectory))
|
||||
_ = Directory.CreateDirectory(jobIdDirectory);
|
||||
//string destinationArchiveDirectory = string.Concat(jobIdDirectory, @"\!Archive\", weekDirectory);
|
||||
string destinationArchiveDirectory = string.Concat(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation), @"\Archive\", _Logistics.JobID, @"\", weekDirectory);
|
||||
if (!Directory.Exists(destinationArchiveDirectory))
|
||||
_ = Directory.CreateDirectory(destinationArchiveDirectory);
|
||||
string[] matchDirectories = new string[] { GetDirectoriesRecursively(jobIdDirectory, logisticsSequence).FirstOrDefault() };
|
||||
if ((matchDirectories is null) || matchDirectories.Length != 1)
|
||||
throw new Exception("Didn't find directory by logistics sequence");
|
||||
string sourceDirectory = Path.GetDirectoryName(matchDirectories[0]);
|
||||
destinationArchiveDirectory = string.Concat(destinationArchiveDirectory, @"\", Path.GetFileName(sourceDirectory));
|
||||
Directory.Move(sourceDirectory, destinationArchiveDirectory);
|
||||
}
|
||||
|
||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
|
||||
_Logistics = new Logistics(reportFullPath, pdsf.Item1);
|
||||
SetFileParameterLotIDToLogisticsMID();
|
||||
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf);
|
||||
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
|
||||
Tuple<Test[], Dictionary<Test, List<Shared.Properties.IDescription>>> tuple = GetTuple(this, descriptions, extra: false);
|
||||
MoveArchive(dateTime);
|
||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tuple.Item1, jsonElements, new List<FileInfo>());
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
39
Adaptation/FileHandlers/CellInstanceConnectionName.cs
Normal file
39
Adaptation/FileHandlers/CellInstanceConnectionName.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
|
||||
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
|
||||
using Adaptation.Shared.Methods;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Adaptation.FileHandlers;
|
||||
|
||||
public class CellInstanceConnectionName
|
||||
{
|
||||
|
||||
internal static IFileRead Get(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted)
|
||||
{
|
||||
IFileRead result;
|
||||
bool isDuplicator = cellInstanceConnectionName.StartsWith(cellInstanceName);
|
||||
if (isDuplicator)
|
||||
{
|
||||
string cellInstanceConnectionNameBase = cellInstanceConnectionName.Replace("-", string.Empty);
|
||||
int hyphens = cellInstanceConnectionName.Length - cellInstanceConnectionNameBase.Length;
|
||||
result = hyphens switch
|
||||
{
|
||||
(int)MET08RESIHGCV.Hyphen.IsArchive => new Archive.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted),
|
||||
(int)MET08RESIHGCV.Hyphen.IsDummy => new Dummy.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted),
|
||||
(int)MET08RESIHGCV.Hyphen.IsXToArchive => new ToArchive.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted),
|
||||
_ => new MET08RESIHGCV.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
result = cellInstanceConnectionName switch
|
||||
{
|
||||
nameof(pcl) => new pcl.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted),
|
||||
_ => throw new Exception(),
|
||||
};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
308
Adaptation/FileHandlers/Dummy/FileRead.cs
Normal file
308
Adaptation/FileHandlers/Dummy/FileRead.cs
Normal file
@ -0,0 +1,308 @@
|
||||
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
|
||||
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Duplicator;
|
||||
using Adaptation.Shared.Methods;
|
||||
using Infineon.Monitoring.MonA;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
|
||||
namespace Adaptation.FileHandlers.Dummy;
|
||||
|
||||
public class FileRead : Shared.FileRead, IFileRead
|
||||
{
|
||||
|
||||
private readonly Timer _Timer;
|
||||
private int _LastDummyRunIndex;
|
||||
private readonly string[] _CellNames;
|
||||
|
||||
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted) :
|
||||
base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
|
||||
{
|
||||
_MinFileLength = 10;
|
||||
_NullData = string.Empty;
|
||||
_Logistics = new Logistics(this);
|
||||
if (_FileParameter is null)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (_ModelObjectParameterDefinitions is null)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (!_IsDuplicator)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
_LastDummyRunIndex = -1;
|
||||
List<string> cellNames = new();
|
||||
_Timer = new Timer(Callback, null, Timeout.Infinite, Timeout.Infinite);
|
||||
ModelObjectParameterDefinition[] cellInstanceCollection = GetProperties(cellInstanceConnectionName, modelObjectParameters, "CellInstance.", ".Alias");
|
||||
foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in cellInstanceCollection)
|
||||
cellNames.Add(modelObjectParameterDefinition.Name.Split('.')[1]);
|
||||
_CellNames = cellNames.ToArray();
|
||||
if (Debugger.IsAttached || fileConnectorConfiguration.PreProcessingMode == FileConnectorConfiguration.PreProcessingModeEnum.Process)
|
||||
Callback(null);
|
||||
else
|
||||
{
|
||||
TimeSpan timeSpan = new(DateTime.Now.AddSeconds(_FileConnectorConfiguration.FileScanningIntervalInSeconds.Value).Ticks - DateTime.Now.Ticks);
|
||||
_ = _Timer.Change((long)timeSpan.TotalMilliseconds, Timeout.Infinite);
|
||||
}
|
||||
}
|
||||
|
||||
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) => Move(extractResults, exception);
|
||||
|
||||
void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
|
||||
|
||||
string IFileRead.GetEventDescription()
|
||||
{
|
||||
string result = _Description.GetEventDescription();
|
||||
return result;
|
||||
}
|
||||
|
||||
List<string> IFileRead.GetHeaderNames()
|
||||
{
|
||||
List<string> results = _Description.GetHeaderNames();
|
||||
return results;
|
||||
}
|
||||
|
||||
string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
|
||||
{
|
||||
string[] results = Move(extractResults, to, from, resolvedFileLocation, exception);
|
||||
return results;
|
||||
}
|
||||
|
||||
JsonProperty[] IFileRead.GetDefault()
|
||||
{
|
||||
JsonProperty[] results = _Description.GetDefault(this, _Logistics);
|
||||
return results;
|
||||
}
|
||||
|
||||
Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement()
|
||||
{
|
||||
Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this);
|
||||
return results;
|
||||
}
|
||||
|
||||
List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData)
|
||||
{
|
||||
List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
|
||||
return results;
|
||||
}
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.GetExtractResult(string reportFullPath, string eventName) => throw new Exception(string.Concat("See ", nameof(CallbackFileExists)));
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.ReExtract() => throw new Exception(string.Concat("See ", nameof(CallbackFileExists)));
|
||||
|
||||
void IFileRead.CheckTests(Test[] tests, bool extra)
|
||||
{
|
||||
if (_Description is not Description)
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
void IFileRead.Callback(object state) => Callback(state);
|
||||
|
||||
private void CallbackInProcessCleared(string sourceArchiveFile, string traceDummyFile, string targetFileLocation, string monARessource, string inProcessDirectory, long sequence, bool warning)
|
||||
{
|
||||
const string site = "sjc";
|
||||
string stateName = string.Concat("Dummy_", _EventName);
|
||||
const string monInURL = "http://moninhttp.sjc.infineon.com/input/text";
|
||||
MonIn monIn = MonIn.GetInstance(monInURL);
|
||||
try
|
||||
{
|
||||
if (warning)
|
||||
{
|
||||
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Warning.ToString() });
|
||||
_ = monIn.SendStatus(site, monARessource, stateName, State.Warning);
|
||||
for (int i = 1; i < 12; i++)
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
ZipFile.ExtractToDirectory(sourceArchiveFile, inProcessDirectory);
|
||||
string[] files = Directory.GetFiles(inProcessDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
if (files.Length > 250)
|
||||
throw new Exception("Safety net!");
|
||||
foreach (string file in files)
|
||||
File.SetLastWriteTime(file, new DateTime(sequence));
|
||||
if (!_FileConnectorConfiguration.IncludeSubDirectories.Value)
|
||||
{
|
||||
foreach (string file in files)
|
||||
File.Move(file, Path.Combine(targetFileLocation, Path.GetFileName(file)));
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] directories = Directory.GetDirectories(inProcessDirectory, "*", SearchOption.AllDirectories);
|
||||
foreach (string directory in directories)
|
||||
_ = Directory.CreateDirectory(string.Concat(targetFileLocation, directory.Substring(inProcessDirectory.Length)));
|
||||
foreach (string file in files)
|
||||
File.Move(file, string.Concat(targetFileLocation, file.Substring(inProcessDirectory.Length)));
|
||||
}
|
||||
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Ok.ToString() });
|
||||
_ = monIn.SendStatus(site, monARessource, stateName, State.Ok);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
||||
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
||||
try
|
||||
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
|
||||
catch (Exception) { }
|
||||
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Critical.ToString(), exception.Message, exception.StackTrace });
|
||||
_ = monIn.SendStatus(site, monARessource, stateName, State.Critical);
|
||||
}
|
||||
}
|
||||
|
||||
private void CallbackFileExists(string sourceArchiveFile, string traceDummyFile, string targetFileLocation, string monARessource, long sequence)
|
||||
{
|
||||
string[] files;
|
||||
bool warning = false;
|
||||
if (!_DummyRuns.ContainsKey(monARessource))
|
||||
_DummyRuns.Add(monARessource, new List<long>());
|
||||
if (!_DummyRuns[monARessource].Contains(sequence))
|
||||
_DummyRuns[monARessource].Add(sequence);
|
||||
File.AppendAllLines(traceDummyFile, new string[] { sourceArchiveFile });
|
||||
string inProcessDirectory = Path.Combine(_ProgressPath, "Dummy In-Process", sequence.ToString());
|
||||
if (!Directory.Exists(inProcessDirectory))
|
||||
_ = Directory.CreateDirectory(inProcessDirectory);
|
||||
files = Directory.GetFiles(inProcessDirectory, "*", SearchOption.AllDirectories);
|
||||
if (files.Any())
|
||||
{
|
||||
if (files.Length > 250)
|
||||
throw new Exception("Safety net!");
|
||||
try
|
||||
{
|
||||
foreach (string file in files)
|
||||
File.Delete(file);
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
if (_FileConnectorConfiguration.IncludeSubDirectories.Value)
|
||||
files = Directory.GetFiles(targetFileLocation, "*", SearchOption.AllDirectories);
|
||||
else
|
||||
files = Directory.GetFiles(targetFileLocation, "*", SearchOption.TopDirectoryOnly);
|
||||
foreach (string file in files)
|
||||
{
|
||||
if (new FileInfo(file).LastWriteTime.Ticks == sequence)
|
||||
{
|
||||
warning = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CallbackInProcessCleared(sourceArchiveFile, traceDummyFile, targetFileLocation, monARessource, inProcessDirectory, sequence, warning);
|
||||
}
|
||||
|
||||
private string GetCellName(string pathSegment)
|
||||
{
|
||||
string result = string.Empty;
|
||||
foreach (string cellName in _CellNames)
|
||||
{
|
||||
if (pathSegment.ToLower().Contains(cellName.ToLower()))
|
||||
{
|
||||
result = cellName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(result))
|
||||
{
|
||||
int count;
|
||||
List<(string CellName, int Count)> cellNames = new();
|
||||
foreach (string cellName in _CellNames)
|
||||
{
|
||||
count = 0;
|
||||
foreach (char @char in cellName.ToLower())
|
||||
count += pathSegment.Length - pathSegment.ToLower().Replace(@char.ToString(), string.Empty).Length;
|
||||
cellNames.Add(new(cellName, count));
|
||||
}
|
||||
result = (from l in cellNames orderby l.CellName.Length, l.Count descending select l.CellName).First();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void Callback(object state)
|
||||
{
|
||||
try
|
||||
{
|
||||
string pathSegment;
|
||||
string monARessource;
|
||||
DateTime dateTime = DateTime.Now;
|
||||
if (!_FileConnectorConfiguration.TargetFileLocation.Contains(_FileConnectorConfiguration.SourceFileLocation))
|
||||
throw new Exception("Target must start with source");
|
||||
bool check = dateTime.Hour > 7 && dateTime.Hour < 18 && dateTime.DayOfWeek != DayOfWeek.Sunday && dateTime.DayOfWeek != DayOfWeek.Saturday;
|
||||
if (!_IsEAFHosted || check)
|
||||
{
|
||||
string checkSegment;
|
||||
string checkDirectory;
|
||||
string sourceFileFilter;
|
||||
string sourceArchiveFile;
|
||||
string sourceFileLocation;
|
||||
string weekOfYear = _Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
string traceDummyDirectory = Path.Combine(Path.GetPathRoot(_TracePath), "TracesDummy", _CellInstanceName, "Source", $"{dateTime:yyyy}___Week_{weekOfYear}");
|
||||
if (!Directory.Exists(traceDummyDirectory))
|
||||
_ = Directory.CreateDirectory(traceDummyDirectory);
|
||||
string traceDummyFile = Path.Combine(traceDummyDirectory, $"{dateTime.Ticks} - {_CellInstanceName}.txt");
|
||||
File.AppendAllText(traceDummyFile, string.Empty);
|
||||
if (_FileConnectorConfiguration.SourceFileLocation.EndsWith("\\"))
|
||||
sourceFileLocation = _FileConnectorConfiguration.SourceFileLocation;
|
||||
else
|
||||
sourceFileLocation = string.Concat(_FileConnectorConfiguration.SourceFileLocation, '\\');
|
||||
for (int i = 0; i < _FileConnectorConfiguration.SourceFileFilters.Count; i++)
|
||||
{
|
||||
_LastDummyRunIndex += 1;
|
||||
if (_LastDummyRunIndex >= _FileConnectorConfiguration.SourceFileFilters.Count)
|
||||
_LastDummyRunIndex = 0;
|
||||
sourceFileFilter = _FileConnectorConfiguration.SourceFileFilters[_LastDummyRunIndex];
|
||||
sourceArchiveFile = Path.GetFullPath(string.Concat(sourceFileLocation, sourceFileFilter));
|
||||
if (File.Exists(sourceArchiveFile))
|
||||
{
|
||||
checkSegment = _FileConnectorConfiguration.TargetFileLocation.Substring(sourceFileLocation.Length);
|
||||
checkDirectory = Path.GetDirectoryName(sourceArchiveFile);
|
||||
for (int z = 0; z < int.MaxValue; z++)
|
||||
{
|
||||
if (checkDirectory.Length < sourceFileLocation.Length || !checkDirectory.StartsWith(sourceFileLocation))
|
||||
break;
|
||||
checkDirectory = Path.GetDirectoryName(checkDirectory);
|
||||
if (Directory.Exists(Path.Combine(checkDirectory, checkSegment)))
|
||||
{
|
||||
checkDirectory = Path.Combine(checkDirectory, checkSegment);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!checkDirectory.EndsWith(checkSegment))
|
||||
throw new Exception("Could not determine dummy target directory for extract!");
|
||||
if (!long.TryParse(Path.GetFileNameWithoutExtension(sourceArchiveFile).Replace("x", string.Empty), out long sequence))
|
||||
throw new Exception("Invalid file name for source archive file!");
|
||||
pathSegment = checkDirectory.Substring(sourceFileLocation.Length);
|
||||
monARessource = GetCellName(pathSegment);
|
||||
if (string.IsNullOrEmpty(monARessource))
|
||||
throw new Exception("Could not determine which cell archive file is associated with!");
|
||||
if (_IsEAFHosted)
|
||||
CallbackFileExists(sourceArchiveFile, traceDummyFile, checkDirectory, monARessource, sequence);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
||||
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
||||
try
|
||||
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
try
|
||||
{
|
||||
TimeSpan timeSpan = new(DateTime.Now.AddSeconds(_FileConnectorConfiguration.FileScanningIntervalInSeconds.Value).Ticks - DateTime.Now.Ticks);
|
||||
_ = _Timer.Change((long)timeSpan.TotalMilliseconds, Timeout.Infinite);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
||||
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
||||
try
|
||||
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,280 +0,0 @@
|
||||
//using Adaptation.Helpers;
|
||||
//using Adaptation.Shared;
|
||||
//using Adaptation.Shared.Metrology;
|
||||
//using log4net;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Globalization;
|
||||
//using System.IO;
|
||||
//using System.Linq;
|
||||
//using System.Text.Json;
|
||||
//using System.Text.RegularExpressions;
|
||||
|
||||
//namespace Adaptation.FileHandlers
|
||||
//{
|
||||
|
||||
// public partial class FileRead : ILogic
|
||||
// {
|
||||
|
||||
// private ConfigData _ConfigData;
|
||||
|
||||
// public FileRead()
|
||||
// {
|
||||
// Logistics = new Logistics();
|
||||
// _Log = LogManager.GetLogger(typeof(FileRead));
|
||||
// }
|
||||
|
||||
// public ILogic ShallowCopy()
|
||||
// {
|
||||
// return (ILogic)MemberwiseClone();
|
||||
// }
|
||||
|
||||
// public void WaitForThread()
|
||||
// {
|
||||
// WaitForThread(thread: null, threadExceptions: null);
|
||||
// }
|
||||
|
||||
// public Tuple<string, ConfigDataBase> GetOpenInsightTuple()
|
||||
// {
|
||||
// Tuple<string, ConfigDataBase> restuls = new Tuple<string, ConfigDataBase>(_ConfigData.OpenInsightSiViewer, _ConfigData);
|
||||
// return restuls;
|
||||
// }
|
||||
|
||||
// public Tuple<string, JsonElement?, List<FileInfo>> GetExtractResult(string reportFullPath, string eventName)
|
||||
// {
|
||||
// Tuple<string, JsonElement?, List<FileInfo>> results;
|
||||
// _FileParameter.Clear();
|
||||
// DateTime dateTime = DateTime.Now;
|
||||
// if (_ConfigData.IsEvent && _ConfigData.Duplicator is null)
|
||||
// results = GetExtractResult(reportFullPath);
|
||||
// else if (_ConfigData.Duplicator.HasValue)
|
||||
// results = GetDuplicatorExtractResult(reportFullPath, dateTime);
|
||||
// else
|
||||
// throw new Exception();
|
||||
// if (results.Item2 is null)
|
||||
// results = new Tuple<string, JsonElement?, List<FileInfo>>(results.Item1, JsonSerializer.Deserialize<JsonElement>("[]"), results.Item3);
|
||||
// int count = results.Item2.Value.GetArrayLength();
|
||||
// if (count > 0 && _ConfigData.EafHosted)
|
||||
// WritePDSF(results.Item2.Value);
|
||||
// UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks);
|
||||
// return results;
|
||||
// }
|
||||
|
||||
// private Tuple<string, JsonElement?, List<FileInfo>> GetExtractResult(string reportFullPath)
|
||||
// {
|
||||
// Tuple<string, JsonElement?, List<FileInfo>> results = new Tuple<string, JsonElement?, List<FileInfo>>(string.Empty, null, new List<FileInfo>());
|
||||
// FileInfo fileInfo = new FileInfo(reportFullPath);
|
||||
// Logistics = new Logistics(ConfigData.NullData, _ConfigData.CellNames, _ConfigData.MesEntities, fileInfo, useSplitForMID: false);
|
||||
// SetFileParameterLotID(Logistics.MID);
|
||||
// if (fileInfo.Length < ConfigData.MinFileLength)
|
||||
// results.Item3.Add(fileInfo);
|
||||
// else
|
||||
// {
|
||||
// ProcessData processData = new ProcessData(this, _ConfigData, results.Item3);
|
||||
// if (!(processData.Header is null))
|
||||
// {
|
||||
// string mid = string.Concat(processData.Header.Reactor, "-", processData.Header.RDS, "-", processData.Header.PSN);
|
||||
// mid = Regex.Replace(mid, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
|
||||
// Logistics.MID = mid;
|
||||
// SetFileParameterLotID(mid);
|
||||
// Logistics.ProcessJobID = processData.Header.Reactor;
|
||||
// }
|
||||
// if (processData.Header is null || !processData.Details.Any())
|
||||
// throw new Exception();
|
||||
// results = processData.GetResults(this, _ConfigData, results.Item3);
|
||||
// }
|
||||
// return results;
|
||||
// }
|
||||
|
||||
// private Tuple<string, JsonElement?, List<FileInfo>> GetDuplicatorExtractResult(string reportFullPath, DateTime dateTime)
|
||||
// {
|
||||
// Tuple<string, JsonElement?, List<FileInfo>> results;
|
||||
// Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
|
||||
// Logistics = new Logistics(reportFullPath, pdsf.Item1);
|
||||
// SetFileParameterLotIDToLogisticsMID();
|
||||
// JsonElement pdsdBodyValues = ProcessDataStandardFormat.GetArray(pdsf);
|
||||
// results = new Tuple<string, JsonElement?, List<FileInfo>>(pdsf.Item1, pdsdBodyValues, new List<FileInfo>());
|
||||
// List<Duplicator.Description> processDataDescriptions = _ConfigData.GetProcessDataDescriptions(pdsdBodyValues);
|
||||
// Dictionary<Test, List<Duplicator.Description>> keyValuePairs = ProcessData.GetKeyValuePairs(_ConfigData, pdsdBodyValues, processDataDescriptions, extra: false);
|
||||
// bool isNotUsedInsightMetrologyViewerAttachments = (!(_Configuration.FileScanningIntervalInSeconds > 0) && _ConfigData.Duplicator.Value == ConfigData.Level.IsXToOpenInsightMetrologyViewerAttachments);
|
||||
// bool isDummyRun = (ConfigData.DummyRuns.Any() && ConfigData.DummyRuns.ContainsKey(Logistics.JobID) && ConfigData.DummyRuns[Logistics.JobID].Any() && (from l in ConfigData.DummyRuns[Logistics.JobID] where l == Logistics.Sequence select 1).Any());
|
||||
// if (isDummyRun)
|
||||
// {
|
||||
// try { File.SetLastWriteTime(reportFullPath, dateTime); } catch (Exception) { }
|
||||
// }
|
||||
// string duplicateDirectory;
|
||||
// string[] segments = Path.GetFileNameWithoutExtension(reportFullPath).Split('_');
|
||||
// if (_ConfigData.Duplicator.Value != ConfigData.Level.IsXToOpenInsight)
|
||||
// duplicateDirectory = string.Concat(_Configuration.TargetFileLocation, @"\", segments[0]);
|
||||
// else
|
||||
// duplicateDirectory = string.Concat(Path.GetDirectoryName(Path.GetDirectoryName(_Configuration.TargetFileLocation)), @"\Data");
|
||||
// if (segments.Length > 2)
|
||||
// duplicateDirectory = string.Concat(duplicateDirectory, @"-", segments[2]);
|
||||
// if (!Directory.Exists(duplicateDirectory))
|
||||
// Directory.CreateDirectory(duplicateDirectory);
|
||||
// if ((isDummyRun || isNotUsedInsightMetrologyViewerAttachments || _Configuration.FileScanningIntervalInSeconds > 0) && _ConfigData.Duplicator.Value != ConfigData.Level.IsXToArchive && _ConfigData.Duplicator.Value != ConfigData.Level.IsArchive)
|
||||
// {
|
||||
// string successDirectory;
|
||||
// if (_ConfigData.Duplicator.Value != ConfigData.Level.IsXToAPC)
|
||||
// successDirectory = string.Empty;
|
||||
// else
|
||||
// {
|
||||
// successDirectory = string.Concat(Path.GetDirectoryName(_Configuration.TargetFileLocation), @"\ViewerPath");
|
||||
// if (!Directory.Exists(successDirectory))
|
||||
// Directory.CreateDirectory(successDirectory);
|
||||
// }
|
||||
// CultureInfo cultureInfo = new CultureInfo("en-US");
|
||||
// Calendar calendar = cultureInfo.Calendar;
|
||||
// List<Tuple<IScopeInfo, string>> tuples = new List<Tuple<IScopeInfo, string>>();
|
||||
// string duplicateFile = string.Concat(duplicateDirectory, @"\", Path.GetFileName(reportFullPath));
|
||||
// string weekOfYear = calendar.GetWeekOfYear(Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
// string weekDirectory = string.Concat(Logistics.DateTimeFromSequence.ToString("yyyy"), "_Week_", weekOfYear, @"\", Logistics.DateTimeFromSequence.ToString("yyyy-MM-dd"));
|
||||
// string logisticsSequenceMemoryDirectory = string.Concat(_ConfigData.MemoryPath, @"\", _ConfigData.GetEquipmentType(), @"\Source\", weekDirectory, @"\", Logistics.Sequence);
|
||||
// if (!Directory.Exists(logisticsSequenceMemoryDirectory))
|
||||
// Directory.CreateDirectory(logisticsSequenceMemoryDirectory);
|
||||
// if (_ConfigData.Duplicator.Value == ConfigData.Level.IsXToAPC)
|
||||
// {
|
||||
// if (!isDummyRun && _ConfigData.EafHosted)
|
||||
// File.Copy(reportFullPath, duplicateFile, overwrite: true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (_ConfigData.Duplicator.Value == ConfigData.Level.IsXToOpenInsightMetrologyViewer)
|
||||
// {
|
||||
// List<ProcessData.FileRead.Description> fileReadDescriptions = ProcessData.GetProcessDataFileReadDescriptions(_ConfigData, pdsdBodyValues);
|
||||
// ProcessData.WSRequest wsRequest = new ProcessData.WSRequest(this, fileReadDescriptions);
|
||||
// if (!isDummyRun && _ConfigData.EafHosted)
|
||||
// {
|
||||
// Tuple<string, WS.Results> wsResults = WS.SendData(_ConfigData.OpenInsightMetrologyViewerAPI, wsRequest);
|
||||
// if (!wsResults.Item2.Success)
|
||||
// throw new Exception(wsResults.ToString());
|
||||
// _Log.Debug(wsResults.Item2.HeaderID);
|
||||
// File.WriteAllText(string.Concat(logisticsSequenceMemoryDirectory, @"\", nameof(WS.Results), ".json"), wsResults.Item1);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Test test;
|
||||
// string lines;
|
||||
// IScopeInfo scopeInfo;
|
||||
// foreach (KeyValuePair<Test, List<Duplicator.Description>> keyValuePair in keyValuePairs)
|
||||
// {
|
||||
// test = keyValuePair.Key;
|
||||
// //scopeInfo = new ScopeInfo(this, _ConfigData, test);
|
||||
// if (_ConfigData.Duplicator.Value != ConfigData.Level.IsXToOpenInsight)
|
||||
// scopeInfo = new ScopeInfo(this, _ConfigData, test, _ConfigData.IqsFile, _ConfigData.IqsQueryFilter);
|
||||
// else
|
||||
// scopeInfo = new ScopeInfo(this, _ConfigData, test, _ConfigData.OpenInsightFilePattern, _ConfigData.IqsQueryFilter);
|
||||
// //lines = ProcessDataStandardFormat.GetLines(Logistics, scopeInfo, names, values, dateFormat: "M/d/yyyy hh:mm:ss tt", timeFormat: string.Empty, pairedColumns: ExtractResultPairedColumns);
|
||||
// List<ProcessData.FileRead.Description> fileReadDescriptions = ProcessData.GetProcessDataFileReadDescriptions(_ConfigData, pdsdBodyValues);
|
||||
// lines = ProcessData.GetLines(this, fileReadDescriptions);
|
||||
// tuples.Add(new Tuple<IScopeInfo, string>(scopeInfo, lines));
|
||||
// }
|
||||
// }
|
||||
// if (_ConfigData.Duplicator.Value == ConfigData.Level.IsXToOpenInsightMetrologyViewerAttachments)
|
||||
// {
|
||||
// string[] matchDirectories = Shared1567(reportFullPath, tuples);
|
||||
// if (!isDummyRun && _ConfigData.EafHosted && !isNotUsedInsightMetrologyViewerAttachments)
|
||||
// {
|
||||
// List<ProcessData.FileRead.Description> fileReadDescriptions = ProcessData.GetProcessDataFileReadDescriptions(_ConfigData, pdsdBodyValues);
|
||||
// ProcessData.PostOpenInsightMetrologyViewerAttachments(_Log, _ConfigData, Logistics, dateTime, logisticsSequenceMemoryDirectory, fileReadDescriptions, matchDirectories[0]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (_ConfigData.Duplicator.Value != ConfigData.Level.IsXToOpenInsightMetrologyViewer && _ConfigData.Duplicator.Value != ConfigData.Level.IsXToOpenInsightMetrologyViewerAttachments)
|
||||
// Shared0413(dateTime, isDummyRun, successDirectory, duplicateDirectory, tuples, duplicateFile);
|
||||
// }
|
||||
// if (_ConfigData.Duplicator.Value == ConfigData.Level.IsXToOpenInsightMetrologyViewerAttachments)
|
||||
// {
|
||||
// string destinationDirectory;
|
||||
// //string destinationDirectory = WriteScopeInfo(_ConfigData.ProgressPath, Logistics, dateTime, duplicateDirectory, tuples);
|
||||
// FileInfo fileInfo = new FileInfo(reportFullPath);
|
||||
// string logisticsSequence = Logistics.Sequence.ToString();
|
||||
// if (fileInfo.Exists && fileInfo.LastWriteTime < fileInfo.CreationTime)
|
||||
// File.SetLastWriteTime(reportFullPath, fileInfo.CreationTime);
|
||||
// string jobIdDirectory = string.Concat(Path.GetDirectoryName(Path.GetDirectoryName(_ConfigData.FileConnectorConfiguration.TargetFileLocation)), @"\", Logistics.JobID);
|
||||
// if (!Directory.Exists(jobIdDirectory))
|
||||
// Directory.CreateDirectory(jobIdDirectory);
|
||||
// string[] matchDirectories;
|
||||
// if (!_ConfigData.EafHosted)
|
||||
// matchDirectories = new string[] { Path.GetDirectoryName(Path.GetDirectoryName(reportFullPath)) };
|
||||
// else
|
||||
// matchDirectories = Directory.GetDirectories(jobIdDirectory, string.Concat(Logistics.MID, '*', logisticsSequence, '*'), SearchOption.TopDirectoryOnly);
|
||||
// if ((matchDirectories is null) || matchDirectories.Length != 1)
|
||||
// throw new Exception("Didn't find directory by logistics sequence");
|
||||
// destinationDirectory = matchDirectories[0];
|
||||
// if (isDummyRun)
|
||||
// Shared0607(reportFullPath, duplicateDirectory, logisticsSequence, destinationDirectory);
|
||||
// else
|
||||
// {
|
||||
// List<ProcessData.FileRead.Description> fileReadDescriptions = ProcessData.GetProcessDataFileReadDescriptions(_ConfigData, pdsdBodyValues);
|
||||
// ProcessData.WSRequest wsRequest = new ProcessData.WSRequest(this, fileReadDescriptions);
|
||||
// JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
|
||||
// string json = JsonSerializer.Serialize(wsRequest, wsRequest.GetType(), jsonSerializerOptions);
|
||||
// if (_ConfigData.EafHosted)
|
||||
// Shared1277(reportFullPath, destinationDirectory, logisticsSequence, jobIdDirectory, json);
|
||||
// else
|
||||
// {
|
||||
// string jsonFileName = Path.ChangeExtension(reportFullPath, ".json");
|
||||
// string historicalText = File.ReadAllText(jsonFileName);
|
||||
// if (json != historicalText)
|
||||
// throw new Exception("File doesn't match historical!");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return results;
|
||||
// }
|
||||
|
||||
// private void MoveArchive()
|
||||
// {
|
||||
// CultureInfo cultureInfo = new CultureInfo("en-US");
|
||||
// Calendar calendar = cultureInfo.Calendar;
|
||||
// string logisticsSequence = Logistics.Sequence.ToString();
|
||||
// string weekOfYear = calendar.GetWeekOfYear(Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
// string weekDirectory = string.Concat(Logistics.DateTimeFromSequence.ToString("yyyy"), "_Week_", weekOfYear, @"\", Logistics.DateTimeFromSequence.ToString("yyyy-MM-dd"));
|
||||
// string jobIdDirectory = string.Concat(_ConfigData.FileConnectorConfiguration.TargetFileLocation, @"\", Logistics.JobID);
|
||||
// if (!Directory.Exists(jobIdDirectory))
|
||||
// Directory.CreateDirectory(jobIdDirectory);
|
||||
// //string destinationArchiveDirectory = string.Concat(jobIdDirectory, @"\!Archive\", weekDirectory);
|
||||
// string destinationArchiveDirectory = string.Concat(Path.GetDirectoryName(_ConfigData.FileConnectorConfiguration.TargetFileLocation), @"\Archive\", Logistics.JobID, @"\", weekDirectory);
|
||||
// if (!Directory.Exists(destinationArchiveDirectory))
|
||||
// Directory.CreateDirectory(destinationArchiveDirectory);
|
||||
// string[] matchDirectories = new string[] { GetDirectoriesRecursively(jobIdDirectory, logisticsSequence).FirstOrDefault() };
|
||||
// if ((matchDirectories is null) || matchDirectories.Length != 1)
|
||||
// throw new Exception("Didn't find directory by logistics sequence");
|
||||
// string sourceDirectory = Path.GetDirectoryName(matchDirectories[0]);
|
||||
// destinationArchiveDirectory = string.Concat(destinationArchiveDirectory, @"\", Path.GetFileName(sourceDirectory));
|
||||
// Directory.Move(sourceDirectory, destinationArchiveDirectory);
|
||||
// }
|
||||
|
||||
// public void Move(string reportFullPath, Tuple<string, JsonElement?, List<FileInfo>> extractResults, Exception exception = null)
|
||||
// {
|
||||
// Shared1872(reportFullPath, exception);
|
||||
// bool isErrorFile = !(exception is null);
|
||||
// if (!isErrorFile && _ConfigData.Duplicator.HasValue)
|
||||
// {
|
||||
// if (_ConfigData.Duplicator.Value == ConfigData.Level.IsXToArchive)
|
||||
// Shared0192(reportFullPath);
|
||||
// else if (_ConfigData.EafHosted && _ConfigData.Duplicator.Value == ConfigData.Level.IsArchive)
|
||||
// MoveArchive();
|
||||
// if (_ConfigData.EafHosted && !string.IsNullOrEmpty(_ConfigData.ProgressPath))
|
||||
// CreateProgressDirectory(_ConfigData.ProgressPath, Logistics, (int?)_ConfigData.Duplicator, exceptionLines: null);
|
||||
// }
|
||||
// if (!isErrorFile && _ConfigData.Duplicator is null)
|
||||
// WriteIO(reportFullPath);
|
||||
// if (!_ConfigData.EafHosted)
|
||||
// {
|
||||
// object @object = GetFilePathGeneratorInfo(reportFullPath, isErrorFile: false);
|
||||
// if (!(@object is null) && @object is string to)
|
||||
// {
|
||||
// if (to.Contains("%"))
|
||||
// _Log.Debug("Can't debug without EAF Hosting");
|
||||
// else
|
||||
// Shared1124(reportFullPath, extractResults, to, _Configuration.SourceFileLocation, resolvedFileLocation: string.Empty, exception: null);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
//}
|
507
Adaptation/FileHandlers/MET08RESIHGCV/FileRead.cs
Normal file
507
Adaptation/FileHandlers/MET08RESIHGCV/FileRead.cs
Normal file
@ -0,0 +1,507 @@
|
||||
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
|
||||
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Duplicator;
|
||||
using Adaptation.Shared.Methods;
|
||||
using Adaptation.Shared.Metrology;
|
||||
using Infineon.Monitoring.MonA;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading;
|
||||
|
||||
namespace Adaptation.FileHandlers.MET08RESIHGCV;
|
||||
|
||||
public class FileRead : Shared.FileRead, IFileRead
|
||||
{
|
||||
|
||||
private readonly Timer _Timer;
|
||||
private int _LastDummyRunIndex;
|
||||
private readonly bool _IsDummy;
|
||||
private readonly bool _IsNaEDA;
|
||||
private readonly bool _IsXToAPC;
|
||||
private readonly string _IqsFile;
|
||||
private readonly bool _IsXToIQSSi;
|
||||
private readonly bool _IsXToSPaCe;
|
||||
private readonly string _MemoryPath;
|
||||
private readonly bool _IsXToOpenInsight;
|
||||
private readonly string _LincPDFCFileName;
|
||||
private readonly string _OpenInsightFilePattern;
|
||||
private readonly bool _IsXToOpenInsightMetrologyViewer;
|
||||
private readonly Dictionary<string, string> _CellNames;
|
||||
private readonly string _OpenInsightMetrologyViewerAPI;
|
||||
private readonly bool _IsXToOpenInsightMetrologyViewerAttachments;
|
||||
|
||||
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted) :
|
||||
base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
|
||||
{
|
||||
_MinFileLength = 10;
|
||||
_NullData = string.Empty;
|
||||
_Logistics = new Logistics(this);
|
||||
if (_FileParameter is null)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (_ModelObjectParameterDefinitions is null)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (!_IsDuplicator)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
_LastDummyRunIndex = -1;
|
||||
_IsDummy = _Hyphens == (int)Hyphen.IsDummy;
|
||||
_IsNaEDA = _Hyphens == (int)Hyphen.IsNaEDA;
|
||||
_IsXToAPC = _Hyphens == (int)Hyphen.IsXToAPC;
|
||||
_CellNames = new Dictionary<string, string>();
|
||||
_IsXToIQSSi = _Hyphens == (int)Hyphen.IsXToIQSSi;
|
||||
_IsXToSPaCe = _Hyphens == (int)Hyphen.IsXToSPaCe;
|
||||
_IsXToOpenInsight = _Hyphens == (int)Hyphen.IsXToOpenInsight;
|
||||
_IsXToOpenInsightMetrologyViewer = _Hyphens == (int)Hyphen.IsXToOpenInsightMetrologyViewer;
|
||||
_IqsFile = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "IQS.File");
|
||||
_MemoryPath = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "Path.Memory");
|
||||
_IsXToOpenInsightMetrologyViewerAttachments = _Hyphens == (int)Hyphen.IsXToOpenInsightMetrologyViewerAttachments;
|
||||
_OpenInsightFilePattern = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.FilePattern");
|
||||
_OpenInsightMetrologyViewerAPI = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.MetrologyViewerAPI");
|
||||
ModelObjectParameterDefinition[] cellInstanceCollection = GetProperties(cellInstanceConnectionName, modelObjectParameters, "CellInstance.", ".Path");
|
||||
foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in cellInstanceCollection)
|
||||
_CellNames.Add(modelObjectParameterDefinition.Name.Split('.')[1], modelObjectParameterDefinition.Value);
|
||||
_LincPDFCFileName = string.Concat(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), @"\LincPDFC.exe");
|
||||
if (_IsEAFHosted && _IsXToOpenInsightMetrologyViewerAttachments && !File.Exists(_LincPDFCFileName))
|
||||
throw new Exception("LincPDFC FileName doesn't Exist!");
|
||||
if (_IsDummy)
|
||||
{
|
||||
if (Debugger.IsAttached || fileConnectorConfiguration.PreProcessingMode == FileConnectorConfiguration.PreProcessingModeEnum.Process)
|
||||
{
|
||||
_Timer = new Timer(Callback, null, Timeout.Infinite, Timeout.Infinite);
|
||||
Callback(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
int milliSeconds;
|
||||
milliSeconds = (int)(fileConnectorConfiguration.FileScanningIntervalInSeconds * 1000 / 2);
|
||||
_Timer = new Timer(Callback, null, milliSeconds, Timeout.Infinite);
|
||||
milliSeconds += 2000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) => Move(extractResults, exception);
|
||||
|
||||
void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
|
||||
|
||||
string IFileRead.GetEventDescription()
|
||||
{
|
||||
string result = _Description.GetEventDescription();
|
||||
return result;
|
||||
}
|
||||
|
||||
List<string> IFileRead.GetHeaderNames()
|
||||
{
|
||||
List<string> results = _Description.GetHeaderNames();
|
||||
return results;
|
||||
}
|
||||
|
||||
string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
|
||||
{
|
||||
string[] results = Move(extractResults, to, from, resolvedFileLocation, exception);
|
||||
return results;
|
||||
}
|
||||
|
||||
JsonProperty[] IFileRead.GetDefault()
|
||||
{
|
||||
JsonProperty[] results = _Description.GetDefault(this, _Logistics);
|
||||
return results;
|
||||
}
|
||||
|
||||
Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement()
|
||||
{
|
||||
Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this);
|
||||
return results;
|
||||
}
|
||||
|
||||
List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData)
|
||||
{
|
||||
List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
|
||||
return results;
|
||||
}
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.GetExtractResult(string reportFullPath, string eventName)
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
if (string.IsNullOrEmpty(eventName))
|
||||
throw new Exception();
|
||||
_ReportFullPath = reportFullPath;
|
||||
DateTime dateTime = DateTime.Now;
|
||||
results = GetExtractResult(reportFullPath, dateTime);
|
||||
if (results.Item3 is null)
|
||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(results.Item1, Array.Empty<Test>(), JsonSerializer.Deserialize<JsonElement[]>("[]"), results.Item4);
|
||||
if (results.Item3.Length > 0 && _IsEAFHosted)
|
||||
WritePDSF(this, results.Item3);
|
||||
UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks);
|
||||
return results;
|
||||
}
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.ReExtract()
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
List<string> headerNames = _Description.GetHeaderNames();
|
||||
Dictionary<string, string> keyValuePairs = _Description.GetDisplayNamesJsonElement(this);
|
||||
results = ReExtract(this, headerNames, keyValuePairs);
|
||||
return results;
|
||||
}
|
||||
|
||||
void IFileRead.CheckTests(Test[] tests, bool extra)
|
||||
{
|
||||
if (_Description is not Description)
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
void IFileRead.Callback(object state) => Callback(state);
|
||||
|
||||
protected static List<pcl.Description> GetDescriptions(JsonElement[] jsonElements)
|
||||
{
|
||||
List<pcl.Description> results = new();
|
||||
pcl.Description description;
|
||||
JsonSerializerOptions jsonSerializerOptions = new() { NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString };
|
||||
foreach (JsonElement jsonElement in jsonElements)
|
||||
{
|
||||
if (jsonElement.ValueKind != JsonValueKind.Object)
|
||||
throw new Exception();
|
||||
description = JsonSerializer.Deserialize<pcl.Description>(jsonElement.ToString(), jsonSerializerOptions);
|
||||
results.Add(description);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
string duplicateDirectory;
|
||||
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
|
||||
_Logistics = new Logistics(reportFullPath, pdsf.Item1);
|
||||
SetFileParameterLotIDToLogisticsMID();
|
||||
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf);
|
||||
List<pcl.Description> descriptions = GetDescriptions(jsonElements);
|
||||
Tuple<Test[], Dictionary<Test, List<Shared.Properties.IDescription>>> tuple = GetTuple(this, from l in descriptions select (Shared.Properties.IDescription)l, extra: false);
|
||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tuple.Item1, jsonElements, new List<FileInfo>());
|
||||
bool isNotUsedInsightMetrologyViewerAttachments = !(_FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) && _IsXToOpenInsightMetrologyViewerAttachments;
|
||||
bool isDummyRun = _DummyRuns.Any() && _DummyRuns.ContainsKey(_Logistics.JobID) && _DummyRuns[_Logistics.JobID].Any() && (from l in _DummyRuns[_Logistics.JobID] where l == _Logistics.Sequence select 1).Any();
|
||||
if (isDummyRun)
|
||||
{
|
||||
try
|
||||
{ File.SetLastWriteTime(reportFullPath, dateTime); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
string[] segments = Path.GetFileNameWithoutExtension(reportFullPath).Split('_');
|
||||
if (_IsXToIQSSi)
|
||||
duplicateDirectory = string.Concat(_FileConnectorConfiguration.TargetFileLocation, @"\All");
|
||||
else if (!_IsXToOpenInsight)
|
||||
duplicateDirectory = string.Concat(_FileConnectorConfiguration.TargetFileLocation, @"\", segments[0]);
|
||||
else
|
||||
duplicateDirectory = string.Concat(Path.GetDirectoryName(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation)), @"\Data");
|
||||
if (segments.Length > 2)
|
||||
duplicateDirectory = string.Concat(duplicateDirectory, @"-", segments[2]);
|
||||
if (!Directory.Exists(duplicateDirectory))
|
||||
_ = Directory.CreateDirectory(duplicateDirectory);
|
||||
if (isDummyRun || isNotUsedInsightMetrologyViewerAttachments || _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
|
||||
{
|
||||
if (!Directory.Exists(duplicateDirectory))
|
||||
_ = Directory.CreateDirectory(duplicateDirectory);
|
||||
string successDirectory;
|
||||
if (!_IsXToAPC)
|
||||
successDirectory = string.Empty;
|
||||
else
|
||||
{
|
||||
successDirectory = string.Concat(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation), @"\ViewerPath");
|
||||
if (!Directory.Exists(successDirectory))
|
||||
_ = Directory.CreateDirectory(successDirectory);
|
||||
}
|
||||
List<Tuple<Shared.Properties.IScopeInfo, string>> tuples = new();
|
||||
string duplicateFile = string.Concat(duplicateDirectory, @"\", Path.GetFileName(reportFullPath));
|
||||
string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
string weekDirectory = string.Concat(_Logistics.DateTimeFromSequence.ToString("yyyy"), "_Week_", weekOfYear, @"\", _Logistics.DateTimeFromSequence.ToString("yyyy-MM-dd"));
|
||||
string logisticsSequenceMemoryDirectory = string.Concat(_MemoryPath, @"\", _EquipmentType, @"\Source\", weekDirectory, @"\", _Logistics.Sequence);
|
||||
if (!Directory.Exists(logisticsSequenceMemoryDirectory))
|
||||
_ = Directory.CreateDirectory(logisticsSequenceMemoryDirectory);
|
||||
if (_IsXToAPC)
|
||||
{
|
||||
if (!isDummyRun && _IsEAFHosted)
|
||||
File.Copy(reportFullPath, duplicateFile, overwrite: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_IsXToOpenInsightMetrologyViewer)
|
||||
{
|
||||
WSRequest wsRequest = new(this, _Logistics, descriptions);
|
||||
if (!isDummyRun && _IsEAFHosted)
|
||||
{
|
||||
Tuple<string, WS.Results> wsResults = WS.SendData(_OpenInsightMetrologyViewerAPI, wsRequest);
|
||||
if (!wsResults.Item2.Success)
|
||||
throw new Exception(wsResults.ToString());
|
||||
_Log.Debug(wsResults.Item2.HeaderID);
|
||||
File.WriteAllText(string.Concat(logisticsSequenceMemoryDirectory, @"\", nameof(WS.Results), ".json"), wsResults.Item1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Test test;
|
||||
string lines;
|
||||
Shared.Properties.IScopeInfo scopeInfo;
|
||||
foreach (KeyValuePair<Test, List<Shared.Properties.IDescription>> keyValuePair in tuple.Item2)
|
||||
{
|
||||
test = keyValuePair.Key;
|
||||
//scopeInfo = new ScopeInfo(test);
|
||||
if (!_IsXToOpenInsight)
|
||||
scopeInfo = new ScopeInfo(test, _IqsFile);
|
||||
else
|
||||
scopeInfo = new ScopeInfo(test, _OpenInsightFilePattern);
|
||||
lines = ProcessData.GetLines(this, _Logistics, descriptions);
|
||||
tuples.Add(new Tuple<Shared.Properties.IScopeInfo, string>(scopeInfo, lines));
|
||||
}
|
||||
}
|
||||
if (_IsXToOpenInsightMetrologyViewerAttachments)
|
||||
{
|
||||
string[] matchDirectories = Shared1567(reportFullPath, tuples);
|
||||
if (!isDummyRun && _IsEAFHosted && !isNotUsedInsightMetrologyViewerAttachments)
|
||||
ProcessData.PostOpenInsightMetrologyViewerAttachments(this, _Logistics, _OpenInsightMetrologyViewerAPI, _LincPDFCFileName, dateTime, logisticsSequenceMemoryDirectory, descriptions, matchDirectories[0]);
|
||||
}
|
||||
}
|
||||
if (!_IsXToOpenInsightMetrologyViewer && !_IsXToOpenInsightMetrologyViewerAttachments)
|
||||
Shared0413(dateTime, isDummyRun, successDirectory, duplicateDirectory, tuples, duplicateFile);
|
||||
}
|
||||
if (_IsXToOpenInsightMetrologyViewerAttachments)
|
||||
{
|
||||
string destinationDirectory;
|
||||
//string destinationDirectory = WriteScopeInfo(_ProgressPath, _Logistics, dateTime, duplicateDirectory, tuples);
|
||||
FileInfo fileInfo = new(reportFullPath);
|
||||
string logisticsSequence = _Logistics.Sequence.ToString();
|
||||
if (fileInfo.Exists && fileInfo.LastWriteTime < fileInfo.CreationTime)
|
||||
File.SetLastWriteTime(reportFullPath, fileInfo.CreationTime);
|
||||
string jobIdDirectory = string.Concat(Path.GetDirectoryName(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation)), @"\", _Logistics.JobID);
|
||||
if (!Directory.Exists(jobIdDirectory))
|
||||
_ = Directory.CreateDirectory(jobIdDirectory);
|
||||
string[] matchDirectories;
|
||||
if (!_IsEAFHosted)
|
||||
matchDirectories = new string[] { Path.GetDirectoryName(Path.GetDirectoryName(reportFullPath)) };
|
||||
else
|
||||
matchDirectories = Directory.GetDirectories(jobIdDirectory, string.Concat(_Logistics.MID, '*', logisticsSequence, '*'), SearchOption.TopDirectoryOnly);
|
||||
if ((matchDirectories is null) || matchDirectories.Length != 1)
|
||||
throw new Exception("Didn't find directory by logistics sequence");
|
||||
destinationDirectory = matchDirectories[0];
|
||||
if (isDummyRun)
|
||||
Shared0607(reportFullPath, duplicateDirectory, logisticsSequence, destinationDirectory);
|
||||
else
|
||||
{
|
||||
WSRequest wsRequest = new(this, _Logistics, descriptions);
|
||||
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
|
||||
string json = JsonSerializer.Serialize(wsRequest, wsRequest.GetType(), jsonSerializerOptions);
|
||||
if (_IsEAFHosted)
|
||||
Shared1277(reportFullPath, destinationDirectory, logisticsSequence, jobIdDirectory, json);
|
||||
else
|
||||
{
|
||||
string jsonFileName = Path.ChangeExtension(reportFullPath, ".json");
|
||||
string historicalText = File.ReadAllText(jsonFileName);
|
||||
if (json != historicalText)
|
||||
throw new Exception("File doesn't match historical!");
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private void CallbackIsDummy(string traceDummyFile, List<Tuple<string, string, string, string, int>> tuples, bool fileConnectorConfigurationIncludeSubDirectories, bool includeSubDirectoriesExtra)
|
||||
{
|
||||
int fileCount;
|
||||
string[] files;
|
||||
string monARessource;
|
||||
string checkDirectory;
|
||||
string sourceArchiveFile;
|
||||
string inProcessDirectory;
|
||||
const string site = "sjc";
|
||||
string stateName = string.Concat("Dummy_", _EventName);
|
||||
const string monInURL = "http://moninhttp.sjc.infineon.com/input/text";
|
||||
MonIn monIn = MonIn.GetInstance(monInURL);
|
||||
foreach (Tuple<string, string, string, string, int> item in tuples)
|
||||
{
|
||||
monARessource = item.Item1;
|
||||
sourceArchiveFile = item.Item2;
|
||||
inProcessDirectory = item.Item3;
|
||||
checkDirectory = item.Item4;
|
||||
fileCount = item.Item5;
|
||||
try
|
||||
{
|
||||
if (fileCount > 0 || string.IsNullOrEmpty(checkDirectory))
|
||||
{
|
||||
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Warning.ToString() });
|
||||
_ = monIn.SendStatus(site, monARessource, stateName, State.Warning);
|
||||
for (int i = 1; i < 12; i++)
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
else if (inProcessDirectory == checkDirectory)
|
||||
continue;
|
||||
if (!_IsEAFHosted)
|
||||
continue;
|
||||
if (!File.Exists(sourceArchiveFile))
|
||||
continue;
|
||||
if (!long.TryParse(Path.GetFileNameWithoutExtension(sourceArchiveFile).Replace("x", string.Empty), out long sequence))
|
||||
continue;
|
||||
ZipFile.ExtractToDirectory(sourceArchiveFile, inProcessDirectory);
|
||||
if (fileConnectorConfigurationIncludeSubDirectories && includeSubDirectoriesExtra)
|
||||
checkDirectory = string.Concat(checkDirectory, @"\", sequence);
|
||||
if (fileConnectorConfigurationIncludeSubDirectories)
|
||||
files = Directory.GetFiles(inProcessDirectory, "*", SearchOption.AllDirectories);
|
||||
else
|
||||
files = Directory.GetFiles(inProcessDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
if (files.Length > 250)
|
||||
throw new Exception("Safety net!");
|
||||
foreach (string file in files)
|
||||
File.SetLastWriteTime(file, new DateTime(sequence));
|
||||
if (!fileConnectorConfigurationIncludeSubDirectories)
|
||||
{
|
||||
foreach (string file in files)
|
||||
File.Move(file, string.Concat(checkDirectory, @"\", Path.GetFileName(file)));
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] directories = Directory.GetDirectories(inProcessDirectory, "*", SearchOption.AllDirectories);
|
||||
foreach (string directory in directories)
|
||||
_ = Directory.CreateDirectory(string.Concat(checkDirectory, directory.Substring(inProcessDirectory.Length)));
|
||||
foreach (string file in files)
|
||||
File.Move(file, string.Concat(checkDirectory, file.Substring(inProcessDirectory.Length)));
|
||||
}
|
||||
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Ok.ToString() });
|
||||
_ = monIn.SendStatus(site, monARessource, stateName, State.Ok);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
||||
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
||||
try
|
||||
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
|
||||
catch (Exception) { }
|
||||
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Critical.ToString(), exception.Message, exception.StackTrace });
|
||||
_ = monIn.SendStatus(site, monARessource, stateName, State.Critical);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Callback(object state)
|
||||
{
|
||||
if (!_IsDummy)
|
||||
throw new Exception();
|
||||
try
|
||||
{
|
||||
DateTime dateTime = DateTime.Now;
|
||||
bool check = dateTime.Hour > 7 && dateTime.Hour < 18 && dateTime.DayOfWeek != DayOfWeek.Sunday && dateTime.DayOfWeek != DayOfWeek.Saturday;
|
||||
if (check)
|
||||
{
|
||||
int fileCount;
|
||||
string[] files;
|
||||
string monARessource;
|
||||
string checkDirectory;
|
||||
string sourceArchiveFile;
|
||||
string sourceFileLocation;
|
||||
string inProcessDirectory;
|
||||
string weekOfYear = _Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
string traceDummyDirectory = string.Concat(Path.GetPathRoot(_TracePath), @"\TracesDummy\", _CellInstanceName, @"\Source\", dateTime.ToString("yyyy"), "___Week_", weekOfYear);
|
||||
if (!Directory.Exists(traceDummyDirectory))
|
||||
_ = Directory.CreateDirectory(traceDummyDirectory);
|
||||
string traceDummyFile = string.Concat(traceDummyDirectory, @"\", dateTime.Ticks, " - ", _CellInstanceName, ".txt");
|
||||
File.AppendAllText(traceDummyFile, string.Empty);
|
||||
List<Tuple<string, string, string, string, int>> tuples = new();
|
||||
string progressDirectory = Path.GetFullPath(string.Concat(_FileConnectorConfiguration.SourceFileLocation, @"\_ Progress"));
|
||||
if (progressDirectory != _ProgressPath || !Directory.Exists(progressDirectory))
|
||||
throw new Exception("Invalid progress path");
|
||||
foreach (KeyValuePair<string, string> keyValuePair in _CellNames)
|
||||
{
|
||||
monARessource = keyValuePair.Key;
|
||||
if (!keyValuePair.Value.Contains('\\'))
|
||||
continue;
|
||||
foreach (string sourceFileFilter in _FileConnectorConfiguration.SourceFileFilter.Split('|'))
|
||||
{
|
||||
if (sourceFileFilter.ToLower().StartsWith(keyValuePair.Value.Replace(@"\", string.Empty)))
|
||||
sourceFileLocation = Path.GetFullPath(_FileConnectorConfiguration.SourceFileLocation);
|
||||
else if (_FileConnectorConfiguration.SourceFileLocation.ToLower().EndsWith(keyValuePair.Value))
|
||||
sourceFileLocation = Path.GetFullPath(_FileConnectorConfiguration.SourceFileLocation);
|
||||
else
|
||||
sourceFileLocation = Path.GetFullPath(string.Concat(_FileConnectorConfiguration.SourceFileLocation, @"\", keyValuePair.Value));
|
||||
sourceArchiveFile = Path.GetFullPath(string.Concat(sourceFileLocation, @"\", sourceFileFilter));
|
||||
if (!File.Exists(sourceArchiveFile))
|
||||
continue;
|
||||
if (!_DummyRuns.ContainsKey(monARessource))
|
||||
_DummyRuns.Add(monARessource, new List<long>());
|
||||
tuples.Add(new Tuple<string, string, string, string, int>(monARessource, sourceFileFilter, sourceFileLocation, sourceArchiveFile, 0));
|
||||
}
|
||||
}
|
||||
File.AppendAllLines(traceDummyFile, from l in tuples select l.Item4);
|
||||
if (tuples.Any())
|
||||
{
|
||||
_LastDummyRunIndex += 1;
|
||||
if (_LastDummyRunIndex >= tuples.Count)
|
||||
_LastDummyRunIndex = 0;
|
||||
monARessource = tuples[_LastDummyRunIndex].Item1;
|
||||
string sourceFileFilter = tuples[_LastDummyRunIndex].Item2;
|
||||
sourceFileLocation = tuples[_LastDummyRunIndex].Item3;
|
||||
sourceArchiveFile = tuples[_LastDummyRunIndex].Item4;
|
||||
//fileCount = tuples[_LastDummyRunIndex].Item5;
|
||||
tuples.Clear();
|
||||
if (long.TryParse(Path.GetFileNameWithoutExtension(sourceArchiveFile).Replace("x", string.Empty), out long sequence))
|
||||
{
|
||||
if (!_DummyRuns[monARessource].Contains(sequence))
|
||||
_DummyRuns[monARessource].Add(sequence);
|
||||
inProcessDirectory = string.Concat(progressDirectory, @"\Dummy_in process\", sequence);
|
||||
checkDirectory = inProcessDirectory;
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
_ = Directory.CreateDirectory(checkDirectory);
|
||||
files = Directory.GetFiles(checkDirectory, "*", SearchOption.AllDirectories);
|
||||
fileCount = files.Length;
|
||||
if (files.Any())
|
||||
{
|
||||
if (files.Length > 250)
|
||||
throw new Exception("Safety net!");
|
||||
try
|
||||
{
|
||||
foreach (string file in files)
|
||||
File.Delete(file);
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
tuples.Add(new Tuple<string, string, string, string, int>(monARessource, sourceArchiveFile, inProcessDirectory, checkDirectory, fileCount));
|
||||
checkDirectory = sourceFileLocation;
|
||||
files = Directory.GetFiles(checkDirectory, string.Concat("*", sequence, "*"), SearchOption.TopDirectoryOnly);
|
||||
fileCount = files.Length;
|
||||
tuples.Add(new Tuple<string, string, string, string, int>(monARessource, sourceArchiveFile, inProcessDirectory, checkDirectory, fileCount));
|
||||
}
|
||||
}
|
||||
if (tuples.Any())
|
||||
//CallbackIsDummy(traceDummyFile, tuples, FileConnectorConfiguration.IncludeSubDirectories.Value, includeSubDirectoriesExtra: false);
|
||||
CallbackIsDummy(traceDummyFile, tuples, fileConnectorConfigurationIncludeSubDirectories: true, includeSubDirectoriesExtra: true);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
||||
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
||||
try
|
||||
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
try
|
||||
{
|
||||
TimeSpan timeSpan = new(DateTime.Now.AddSeconds(_FileConnectorConfiguration.FileScanningIntervalInSeconds.Value).Ticks - DateTime.Now.Ticks);
|
||||
_ = _Timer.Change((long)timeSpan.TotalMilliseconds, Timeout.Infinite);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
|
||||
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
|
||||
try
|
||||
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
15
Adaptation/FileHandlers/MET08RESIHGCV/Hyphen.cs
Normal file
15
Adaptation/FileHandlers/MET08RESIHGCV/Hyphen.cs
Normal file
@ -0,0 +1,15 @@
|
||||
namespace Adaptation.FileHandlers.MET08RESIHGCV;
|
||||
|
||||
public enum Hyphen
|
||||
{
|
||||
IsXToOpenInsightMetrologyViewer, //MetrologyWS.SendData(file, string.Concat("http://", serverName, "/api/inbound/MercuryProbe"), headerAttachments);
|
||||
IsXToIQSSi, //NA <d7p1:FileScanningIntervalInSeconds>-361</d7p1:FileScanningIntervalInSeconds>
|
||||
IsXToOpenInsight, //NA <d7p1:FileScanningIntervalInSeconds>-363</d7p1:FileScanningIntervalInSeconds>
|
||||
IsXToOpenInsightMetrologyViewerAttachments, //Site-One
|
||||
IsXToAPC,
|
||||
IsXToSPaCe,
|
||||
IsXToArchive,
|
||||
IsArchive,
|
||||
IsDummy,
|
||||
IsNaEDA
|
||||
}
|
103
Adaptation/FileHandlers/MET08RESIHGCV/ProcessData.cs
Normal file
103
Adaptation/FileHandlers/MET08RESIHGCV/ProcessData.cs
Normal file
@ -0,0 +1,103 @@
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Metrology;
|
||||
using Adaptation.Shared.Properties;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Adaptation.FileHandlers.MET08RESIHGCV;
|
||||
|
||||
public class ProcessData
|
||||
{
|
||||
|
||||
internal static List<Tuple<int, Enum, string>> HyphenTuples => new()
|
||||
{
|
||||
new Tuple<int, Enum, string>(0, Hyphen.IsNaEDA, @"\EC_EDA\Staging\Traces\~\Source"),
|
||||
new Tuple<int, Enum, string>(15, Hyphen.IsXToOpenInsightMetrologyViewer, @"\EC_EAFLog\TracesMES\~\Source"),
|
||||
new Tuple<int, Enum, string>(-36, Hyphen.IsXToIQSSi, @"\EC_SPC_Si\Traces\~\PollPath"),
|
||||
new Tuple<int, Enum, string>(-36, Hyphen.IsXToOpenInsight, @"\\messa01ec.ec.local\APPS\Metrology\~\Source"),
|
||||
new Tuple<int, Enum, string>(36, Hyphen.IsXToOpenInsightMetrologyViewerAttachments, @"\EC_Characterization_Si\In Process\~\Source"),
|
||||
new Tuple<int, Enum, string>(360, Hyphen.IsXToAPC, @"\EC_APC\Staging\Traces\~\PollPath"),
|
||||
new Tuple<int, Enum, string>(-36, Hyphen.IsXToSPaCe, @"\EC_SPC_Si\Traces\~\Source"),
|
||||
new Tuple<int, Enum, string>(180, Hyphen.IsXToArchive, @"\EC_EAFLog\TracesArchive\~\Source"),
|
||||
new Tuple<int, Enum, string>(36, Hyphen.IsArchive, @"\EC_Characterization_Si\Processed")
|
||||
//new Tuple<int, Enum, string>("IsDummy"
|
||||
};
|
||||
|
||||
internal static string GetLines(IFileRead fileRead, Logistics logistics, List<pcl.Description> descriptions)
|
||||
{
|
||||
StringBuilder result = new();
|
||||
if (fileRead is null)
|
||||
{ }
|
||||
if (logistics is null)
|
||||
{ }
|
||||
if (descriptions is null)
|
||||
{ }
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
/// <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 ConvertSourceFileToPdfWithChartData(string lincPDFCFileName, string sourceFile)
|
||||
{
|
||||
string result = Path.ChangeExtension(sourceFile, ".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 \"", sourceFile, "\"");
|
||||
Process process = Process.Start(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;
|
||||
}
|
||||
|
||||
internal static void PostOpenInsightMetrologyViewerAttachments(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, string lincPDFCFileName, DateTime dateTime, string logisticsSequenceMemoryDirectory, List<pcl.Description> descriptions, string matchDirectory)
|
||||
{
|
||||
if (fileRead is null)
|
||||
{ }
|
||||
if (dateTime == DateTime.MinValue)
|
||||
{ }
|
||||
if (logisticsSequenceMemoryDirectory is null)
|
||||
{ }
|
||||
if (descriptions is null)
|
||||
{ }
|
||||
if (matchDirectory is null)
|
||||
{ }
|
||||
string[] pclFiles = Directory.GetFiles(matchDirectory, "*.pcl", SearchOption.TopDirectoryOnly);
|
||||
if (pclFiles.Length != 1)
|
||||
throw new Exception("Invalid source file count!");
|
||||
string wsResultsMemoryFile = string.Concat(logisticsSequenceMemoryDirectory, @"\", nameof(WS.Results), ".json");
|
||||
if (!File.Exists(wsResultsMemoryFile))
|
||||
throw new Exception(string.Concat("Memory file <", wsResultsMemoryFile, "> doesn't exist!"));
|
||||
string json = File.ReadAllText(wsResultsMemoryFile);
|
||||
WS.Results metrologyWSRequest = JsonSerializer.Deserialize<WS.Results>(json);
|
||||
long wsResultsHeaderID = metrologyWSRequest.HeaderID;
|
||||
List<string> pdfFiles = new();
|
||||
pdfFiles.AddRange(Directory.GetFiles(matchDirectory, "*.pdf_old", SearchOption.TopDirectoryOnly));
|
||||
foreach (string pdfFile in pdfFiles)
|
||||
File.Delete(pdfFile);
|
||||
pdfFiles.Clear();
|
||||
pdfFiles.AddRange(Directory.GetFiles(matchDirectory, "*.pdf", SearchOption.TopDirectoryOnly));
|
||||
foreach (string pdfFile in pdfFiles)
|
||||
File.Move(pdfFile, Path.ChangeExtension(pdfFile, ".pdf_old"));
|
||||
pdfFiles.Clear();
|
||||
foreach (string pclFile in pclFiles.OrderBy(l => l))
|
||||
pdfFiles.Add(ConvertSourceFileToPdfWithChartData(lincPDFCFileName, pclFile));
|
||||
if (pdfFiles.Count == 0)
|
||||
throw new Exception("Invalid *.pdf file count!");
|
||||
List<WS.Attachment> headerAttachments = new()
|
||||
{ new WS.Attachment(descriptions[0].HeaderUniqueId, "Data.pdf", pdfFiles[0]) };
|
||||
WS.AttachFiles(openInsightMetrologyViewerAPI, wsResultsHeaderID, headerAttachments, dataAttachments: null);
|
||||
}
|
||||
|
||||
}
|
158
Adaptation/FileHandlers/MET08RESIHGCV/WSRequest.cs
Normal file
158
Adaptation/FileHandlers/MET08RESIHGCV/WSRequest.cs
Normal file
@ -0,0 +1,158 @@
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Properties;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Adaptation.FileHandlers.MET08RESIHGCV;
|
||||
|
||||
public class WSRequest
|
||||
{
|
||||
public bool SentToMetrology { get; set; }
|
||||
public bool SentToSPC { get; set; }
|
||||
//
|
||||
|
||||
public string Area { get; set; }
|
||||
public string Ccomp { get; set; }
|
||||
public string CellName { get; set; }
|
||||
public string CondType { get; set; }
|
||||
public string Date { get; set; }
|
||||
public string FlatZMean { get; set; }
|
||||
public string FlatZRadialGradient { get; set; }
|
||||
public string FlatZStdDev { get; set; }
|
||||
public string Folder { get; set; }
|
||||
public string GLimit { get; set; }
|
||||
public string GradeMean { get; set; }
|
||||
public string GradeRadialGradient { get; set; }
|
||||
public string GradeStdDev { get; set; }
|
||||
public string Id { get; set; }
|
||||
public string Layer { get; set; }
|
||||
public string Lot { get; set; }
|
||||
public string Model { get; set; }
|
||||
public string NAvgMean { get; set; }
|
||||
public string NAvgRadialGradient { get; set; }
|
||||
public string NAvgStdDev { get; set; }
|
||||
public string NslMean { get; set; }
|
||||
public string NslRadialGradient { get; set; }
|
||||
public string NslStdDev { get; set; }
|
||||
public string Operator { get; set; }
|
||||
public string PSN { get; set; }
|
||||
public string Pattern { get; set; }
|
||||
public string PhaseMean { get; set; }
|
||||
public string PhaseRadialGradient { get; set; }
|
||||
public string PhaseStdDev { get; set; }
|
||||
public string Plan { get; set; }
|
||||
public string RDS { get; set; }
|
||||
public string RampRate { get; set; }
|
||||
public string Reactor { get; set; }
|
||||
public string RhoAvgMean { get; set; }
|
||||
public string RhoAvgRadialGradient { get; set; }
|
||||
public string RhoAvgStdDev { get; set; }
|
||||
public string RhoMethod { get; set; }
|
||||
public string RhoslMean { get; set; }
|
||||
public string RhoslRadialGradient { get; set; }
|
||||
public string RhoslStdDev { get; set; }
|
||||
public string RsMean { get; set; }
|
||||
public string RsRadialGradient { get; set; }
|
||||
public string RsStdDev { get; set; }
|
||||
public string SetupFile { get; set; }
|
||||
public string StartVoltage { get; set; }
|
||||
public string StopVoltage { get; set; }
|
||||
public string UniqueId { get; set; }
|
||||
public string VdMean { get; set; }
|
||||
public string VdRadialGradient { get; set; }
|
||||
public string VdStdDev { get; set; }
|
||||
public string Wafer { get; set; }
|
||||
public string WaferSize { get; set; }
|
||||
public string Zone { get; set; }
|
||||
public List<pcl.Detail> Details { get; protected set; }
|
||||
|
||||
[Obsolete("For json")] public WSRequest() { }
|
||||
|
||||
internal WSRequest(IFileRead fileRead, Logistics logistics, List<pcl.Description> descriptions)
|
||||
{
|
||||
if (fileRead is null)
|
||||
{ }
|
||||
Id = string.Empty;
|
||||
Details = new List<pcl.Detail>();
|
||||
CellName = logistics.MesEntity;
|
||||
pcl.Description x = descriptions[0];
|
||||
//Header
|
||||
{
|
||||
Area = x.Area;
|
||||
Ccomp = x.Ccomp;
|
||||
CondType = x.CondType;
|
||||
Date = x.Date;
|
||||
FlatZMean = x.FlatZMean;
|
||||
FlatZRadialGradient = x.FlatZRadialGradient;
|
||||
FlatZStdDev = x.FlatZStdDev;
|
||||
Folder = x.Folder;
|
||||
GLimit = x.GLimit;
|
||||
GradeMean = x.GradeMean;
|
||||
GradeRadialGradient = x.GradeRadialGradient;
|
||||
GradeStdDev = x.GradeStdDev;
|
||||
Operator = x.Employee;
|
||||
Layer = x.Layer;
|
||||
Lot = x.Lot;
|
||||
Model = x.Model;
|
||||
NAvgMean = x.NAvgMean;
|
||||
NAvgRadialGradient = x.NAvgRadialGradient;
|
||||
NAvgStdDev = x.NAvgStdDev;
|
||||
NslMean = x.NslMean;
|
||||
NslRadialGradient = x.NslRadialGradient;
|
||||
NslStdDev = x.NslStdDev;
|
||||
PSN = x.PSN;
|
||||
Pattern = x.Pattern;
|
||||
PhaseMean = x.PhaseMean;
|
||||
PhaseRadialGradient = x.PhaseRadialGradient;
|
||||
PhaseStdDev = x.PhaseStdDev;
|
||||
Plan = x.Plan;
|
||||
RDS = x.RDS;
|
||||
RampRate = x.RampRate;
|
||||
Reactor = x.Reactor;
|
||||
RhoAvgMean = x.RhoAvgMean;
|
||||
RhoAvgRadialGradient = x.RhoAvgRadialGradient;
|
||||
RhoAvgStdDev = x.RhoAvgStdDev;
|
||||
RhoMethod = x.RhoMethod;
|
||||
RhoslMean = x.RhoslMean;
|
||||
RhoslRadialGradient = x.RhoslRadialGradient;
|
||||
RhoslStdDev = x.RhoslStdDev;
|
||||
RsMean = x.RsMean;
|
||||
RsRadialGradient = x.RsRadialGradient;
|
||||
RsStdDev = x.RsStdDev;
|
||||
SetupFile = x.SetupFile;
|
||||
StartVoltage = x.StartVoltage;
|
||||
StopVoltage = x.StopVoltage;
|
||||
UniqueId = x.UniqueId;
|
||||
VdMean = x.VdMean;
|
||||
VdRadialGradient = x.VdRadialGradient;
|
||||
VdStdDev = x.VdStdDev;
|
||||
Wafer = x.Wafer;
|
||||
WaferSize = x.WaferSize;
|
||||
Zone = x.Zone;
|
||||
}
|
||||
pcl.Detail detail;
|
||||
foreach (pcl.Description description in descriptions)
|
||||
{
|
||||
detail = new pcl.Detail
|
||||
{
|
||||
FlatZ = description.FlatZ,
|
||||
Grade = description.Grade,
|
||||
HeaderUniqueId = description.HeaderUniqueId,
|
||||
NAvg = description.NAvg,
|
||||
Nsl = description.Nsl,
|
||||
Phase = description.Phase,
|
||||
RhoAvg = description.RhoAvg,
|
||||
Rhosl = description.Rhosl,
|
||||
UniqueId = description.UniqueId,
|
||||
Vd = description.Vd
|
||||
};
|
||||
Details.Add(detail);
|
||||
}
|
||||
if (Date is null)
|
||||
Date = logistics.DateTimeFromSequence.ToString();
|
||||
if (UniqueId is null && Details.Any())
|
||||
UniqueId = Details[0].HeaderUniqueId;
|
||||
}
|
||||
|
||||
}
|
140
Adaptation/FileHandlers/ToArchive/FileRead.cs
Normal file
140
Adaptation/FileHandlers/ToArchive/FileRead.cs
Normal file
@ -0,0 +1,140 @@
|
||||
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
|
||||
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Duplicator;
|
||||
using Adaptation.Shared.Methods;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Adaptation.FileHandlers.ToArchive;
|
||||
|
||||
public class FileRead : Shared.FileRead, IFileRead
|
||||
{
|
||||
|
||||
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted) :
|
||||
base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
|
||||
{
|
||||
_MinFileLength = 10;
|
||||
_NullData = string.Empty;
|
||||
_Logistics = new Logistics(this);
|
||||
if (_FileParameter is null)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (_ModelObjectParameterDefinitions is null)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (!_IsDuplicator)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
}
|
||||
|
||||
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception)
|
||||
{
|
||||
bool isErrorFile = exception is not null;
|
||||
if (!isErrorFile && !string.IsNullOrEmpty(_Logistics.ReportFullPath))
|
||||
{
|
||||
FileInfo fileInfo = new(_Logistics.ReportFullPath);
|
||||
if (fileInfo.Exists && fileInfo.LastWriteTime < fileInfo.CreationTime)
|
||||
File.SetLastWriteTime(_Logistics.ReportFullPath, fileInfo.CreationTime);
|
||||
}
|
||||
Move(extractResults, exception);
|
||||
}
|
||||
|
||||
void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
|
||||
|
||||
string IFileRead.GetEventDescription()
|
||||
{
|
||||
string result = _Description.GetEventDescription();
|
||||
return result;
|
||||
}
|
||||
|
||||
List<string> IFileRead.GetHeaderNames()
|
||||
{
|
||||
List<string> results = _Description.GetHeaderNames();
|
||||
return results;
|
||||
}
|
||||
|
||||
string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
|
||||
{
|
||||
string[] results = Move(extractResults, to, from, resolvedFileLocation, exception);
|
||||
return results;
|
||||
}
|
||||
|
||||
JsonProperty[] IFileRead.GetDefault()
|
||||
{
|
||||
JsonProperty[] results = _Description.GetDefault(this, _Logistics);
|
||||
return results;
|
||||
}
|
||||
|
||||
Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement()
|
||||
{
|
||||
Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this);
|
||||
return results;
|
||||
}
|
||||
|
||||
List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData)
|
||||
{
|
||||
List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
|
||||
return results;
|
||||
}
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.GetExtractResult(string reportFullPath, string eventName)
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
if (string.IsNullOrEmpty(eventName))
|
||||
throw new Exception();
|
||||
_ReportFullPath = reportFullPath;
|
||||
DateTime dateTime = DateTime.Now;
|
||||
results = GetExtractResult(reportFullPath, dateTime);
|
||||
if (results.Item3 is null)
|
||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(results.Item1, Array.Empty<Test>(), JsonSerializer.Deserialize<JsonElement[]>("[]"), results.Item4);
|
||||
if (results.Item3.Length > 0 && _IsEAFHosted)
|
||||
WritePDSF(this, results.Item3);
|
||||
UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks);
|
||||
return results;
|
||||
}
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.ReExtract()
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
List<string> headerNames = _Description.GetHeaderNames();
|
||||
Dictionary<string, string> keyValuePairs = _Description.GetDisplayNamesJsonElement(this);
|
||||
results = ReExtract(this, headerNames, keyValuePairs);
|
||||
return results;
|
||||
}
|
||||
|
||||
void IFileRead.CheckTests(Test[] tests, bool extra)
|
||||
{
|
||||
if (_Description is not Description)
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
void IFileRead.Callback(object state) => throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
|
||||
|
||||
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
|
||||
{
|
||||
if (dateTime == DateTime.MinValue)
|
||||
{ }
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>());
|
||||
_Logistics = new Logistics(this, reportFullPath, useSplitForMID: true);
|
||||
SetFileParameterLotIDToLogisticsMID();
|
||||
|
||||
string[] segments = Path.GetFileNameWithoutExtension(reportFullPath).Split('_');
|
||||
string duplicateDirectory = string.Concat(_FileConnectorConfiguration.TargetFileLocation, @"\", segments[0]);
|
||||
if (segments.Length > 2)
|
||||
duplicateDirectory = string.Concat(duplicateDirectory, @"-", segments[2]);
|
||||
if (!Directory.Exists(duplicateDirectory))
|
||||
_ = Directory.CreateDirectory(duplicateDirectory);
|
||||
|
||||
string logisticsSequence = _Logistics.Sequence.ToString();
|
||||
bool isDummyRun = _DummyRuns.Any() && _DummyRuns.ContainsKey(_Logistics.JobID) && _DummyRuns[_Logistics.JobID].Any() && (from l in _DummyRuns[_Logistics.JobID] where l == _Logistics.Sequence select 1).Any();
|
||||
|
||||
List<Tuple<Shared.Properties.IScopeInfo, string>> tuples = new();
|
||||
|
||||
string destinationDirectory = WriteScopeInfo(_ProgressPath, _Logistics, dateTime, duplicateDirectory, tuples);
|
||||
if (isDummyRun)
|
||||
Shared0607(reportFullPath, duplicateDirectory, logisticsSequence, destinationDirectory);
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
437
Adaptation/FileHandlers/pcl/Description.cs
Normal file
437
Adaptation/FileHandlers/pcl/Description.cs
Normal file
@ -0,0 +1,437 @@
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Methods;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Adaptation.FileHandlers.pcl;
|
||||
|
||||
public class Description : IDescription, Shared.Properties.IDescription
|
||||
{
|
||||
|
||||
public int Test { get; set; }
|
||||
public int Count { get; set; }
|
||||
public int Index { get; set; }
|
||||
//
|
||||
public string EventName { get; set; }
|
||||
public string NullData { get; set; }
|
||||
public string JobID { get; set; }
|
||||
public string Sequence { get; set; }
|
||||
public string MesEntity { get; set; }
|
||||
public string ReportFullPath { get; set; }
|
||||
public string ProcessJobID { get; set; }
|
||||
public string MID { get; set; }
|
||||
//
|
||||
public string Date { get; set; }
|
||||
public string Employee { get; set; }
|
||||
public string Lot { get; set; }
|
||||
public string PSN { get; set; }
|
||||
public string Reactor { get; set; }
|
||||
public string Recipe { get; set; }
|
||||
//
|
||||
public string Area { get; set; }
|
||||
public string Folder { get; set; }
|
||||
public string HeaderUniqueId { get; set; }
|
||||
public string Id { get; set; }
|
||||
public string Layer { get; set; }
|
||||
public string Model { get; set; }
|
||||
public string Pattern { get; set; }
|
||||
public string Phase { get; set; }
|
||||
public string Plan { get; set; }
|
||||
public string RampRate { get; set; }
|
||||
public string RDS { get; set; }
|
||||
public string SetupFile { get; set; }
|
||||
public string StartVoltage { get; set; }
|
||||
public string StopVoltage { get; set; }
|
||||
public string UniqueId { get; set; }
|
||||
public string Wafer { get; set; }
|
||||
public string WaferSize { get; set; }
|
||||
public string Zone { get; set; }
|
||||
//
|
||||
public string Ccomp { get; set; }
|
||||
public string CondType { get; set; }
|
||||
public string FlatZ { get; set; }
|
||||
public string FlatZMean { get; set; }
|
||||
public string FlatZRadialGradient { get; set; }
|
||||
public string FlatZStdDev { get; set; }
|
||||
public string GLimit { get; set; }
|
||||
public string Grade { get; set; }
|
||||
public string GradeMean { get; set; }
|
||||
public string GradeRadialGradient { get; set; }
|
||||
public string GradeStdDev { get; set; }
|
||||
public string NAvg { get; set; }
|
||||
public string NAvgMean { get; set; }
|
||||
public string NAvgRadialGradient { get; set; }
|
||||
public string NAvgStdDev { get; set; }
|
||||
public string Nsl { get; set; }
|
||||
public string NslMean { get; set; }
|
||||
public string NslRadialGradient { get; set; }
|
||||
public string NslStdDev { get; set; }
|
||||
public string PhaseMean { get; set; }
|
||||
public string PhaseRadialGradient { get; set; }
|
||||
public string PhaseStdDev { get; set; }
|
||||
public string RhoAvg { get; set; }
|
||||
public string RhoAvgMean { get; set; }
|
||||
public string RhoAvgRadialGradient { get; set; }
|
||||
public string RhoAvgStdDev { get; set; }
|
||||
public string RhoMethod { get; set; }
|
||||
public string Rhosl { get; set; }
|
||||
public string RhoslMean { get; set; }
|
||||
public string RhoslRadialGradient { get; set; }
|
||||
public string RhoslStdDev { get; set; }
|
||||
public string RsMean { get; set; }
|
||||
public string RsRadialGradient { get; set; }
|
||||
public string RsStdDev { get; set; }
|
||||
public string Vd { get; set; }
|
||||
public string VdMean { get; set; }
|
||||
public string VdRadialGradient { get; set; }
|
||||
public string VdStdDev { get; set; }
|
||||
|
||||
string IDescription.GetEventDescription() => "File Has been read and parsed";
|
||||
|
||||
List<string> IDescription.GetNames(IFileRead fileRead, Logistics logistics)
|
||||
{
|
||||
List<string> results = new();
|
||||
IDescription description = GetDefault(fileRead, logistics);
|
||||
string json = JsonSerializer.Serialize(description, description.GetType());
|
||||
object @object = JsonSerializer.Deserialize<object>(json);
|
||||
if (@object is not JsonElement jsonElement)
|
||||
throw new Exception();
|
||||
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
|
||||
results.Add(jsonProperty.Name);
|
||||
return results;
|
||||
}
|
||||
|
||||
List<string> IDescription.GetDetailNames()
|
||||
{
|
||||
List<string> results = new()
|
||||
{
|
||||
nameof(Area),
|
||||
nameof(Folder),
|
||||
nameof(HeaderUniqueId),
|
||||
nameof(Id),
|
||||
nameof(Layer),
|
||||
nameof(Model),
|
||||
nameof(Pattern),
|
||||
nameof(Phase),
|
||||
nameof(Plan),
|
||||
nameof(RampRate),
|
||||
nameof(RDS),
|
||||
nameof(SetupFile),
|
||||
nameof(StartVoltage),
|
||||
nameof(StopVoltage),
|
||||
nameof(UniqueId),
|
||||
nameof(Wafer),
|
||||
nameof(WaferSize),
|
||||
nameof(Zone)
|
||||
};
|
||||
return results;
|
||||
}
|
||||
|
||||
List<string> IDescription.GetHeaderNames()
|
||||
{
|
||||
List<string> results = new()
|
||||
{
|
||||
nameof(Date),
|
||||
nameof(Employee),
|
||||
nameof(Lot),
|
||||
nameof(PSN),
|
||||
nameof(Reactor),
|
||||
nameof(Recipe)
|
||||
};
|
||||
return results;
|
||||
}
|
||||
|
||||
IDescription IDescription.GetDisplayNames()
|
||||
{
|
||||
Description result = GetDisplayNames();
|
||||
return result;
|
||||
}
|
||||
|
||||
List<string> IDescription.GetParameterNames()
|
||||
{
|
||||
List<string> results = new()
|
||||
{
|
||||
nameof(Ccomp),
|
||||
nameof(CondType),
|
||||
nameof(FlatZ),
|
||||
nameof(FlatZMean),
|
||||
nameof(FlatZRadialGradient),
|
||||
nameof(FlatZStdDev),
|
||||
nameof(GLimit),
|
||||
nameof(Grade),
|
||||
nameof(GradeMean),
|
||||
nameof(GradeRadialGradient),
|
||||
nameof(GradeStdDev),
|
||||
nameof(NAvg),
|
||||
nameof(NAvgMean),
|
||||
nameof(NAvgRadialGradient),
|
||||
nameof(NAvgStdDev),
|
||||
nameof(Nsl),
|
||||
nameof(NslMean),
|
||||
nameof(NslRadialGradient),
|
||||
nameof(NslStdDev),
|
||||
nameof(PhaseMean),
|
||||
nameof(PhaseRadialGradient),
|
||||
nameof(PhaseStdDev),
|
||||
nameof(RhoAvg),
|
||||
nameof(RhoAvgMean),
|
||||
nameof(RhoAvgRadialGradient),
|
||||
nameof(RhoAvgStdDev),
|
||||
nameof(RhoMethod),
|
||||
nameof(Rhosl),
|
||||
nameof(RhoslMean),
|
||||
nameof(RhoslRadialGradient),
|
||||
nameof(RhoslStdDev),
|
||||
nameof(RsMean),
|
||||
nameof(RsRadialGradient),
|
||||
nameof(RsStdDev),
|
||||
nameof(Vd),
|
||||
nameof(VdMean),
|
||||
nameof(VdRadialGradient),
|
||||
nameof(VdStdDev)
|
||||
};
|
||||
return results;
|
||||
}
|
||||
|
||||
JsonProperty[] IDescription.GetDefault(IFileRead fileRead, Logistics logistics)
|
||||
{
|
||||
JsonProperty[] results;
|
||||
IDescription description = GetDefault(fileRead, logistics);
|
||||
string json = JsonSerializer.Serialize(description, description.GetType());
|
||||
object @object = JsonSerializer.Deserialize<object>(json);
|
||||
results = ((JsonElement)@object).EnumerateObject().ToArray();
|
||||
return results;
|
||||
}
|
||||
|
||||
List<string> IDescription.GetPairedParameterNames()
|
||||
{
|
||||
List<string> results = new();
|
||||
return results;
|
||||
}
|
||||
|
||||
List<string> IDescription.GetIgnoreParameterNames(Test test)
|
||||
{
|
||||
List<string> results = new();
|
||||
return results;
|
||||
}
|
||||
|
||||
IDescription IDescription.GetDefaultDescription(IFileRead fileRead, Logistics logistics)
|
||||
{
|
||||
Description result = GetDefault(fileRead, logistics);
|
||||
return result;
|
||||
}
|
||||
|
||||
Dictionary<string, string> IDescription.GetDisplayNamesJsonElement(IFileRead fileRead)
|
||||
{
|
||||
Dictionary<string, string> results = new();
|
||||
IDescription description = GetDisplayNames();
|
||||
string json = JsonSerializer.Serialize(description, description.GetType());
|
||||
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
|
||||
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
|
||||
{
|
||||
if (!results.ContainsKey(jsonProperty.Name))
|
||||
results.Add(jsonProperty.Name, string.Empty);
|
||||
if (jsonProperty.Value is JsonElement jsonPropertyValue)
|
||||
results[jsonProperty.Name] = jsonPropertyValue.ToString();
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
List<IDescription> IDescription.GetDescriptions(IFileRead fileRead, Logistics logistics, List<Test> tests, IProcessData iProcessData)
|
||||
{
|
||||
List<IDescription> results = new();
|
||||
if (iProcessData is null || !iProcessData.Details.Any() || iProcessData is not ProcessData processData)
|
||||
results.Add(GetDefault(fileRead, logistics));
|
||||
else
|
||||
{
|
||||
string nullData;
|
||||
Description description;
|
||||
object configDataNullData = fileRead.NullData;
|
||||
if (configDataNullData is null)
|
||||
nullData = string.Empty;
|
||||
else
|
||||
nullData = configDataNullData.ToString();
|
||||
for (int i = 0; i < iProcessData.Details.Count; i++)
|
||||
{
|
||||
if (iProcessData.Details[i] is not Detail detail)
|
||||
continue;
|
||||
description = new Description
|
||||
{
|
||||
Test = (int)tests[i],
|
||||
Count = tests.Count,
|
||||
Index = i,
|
||||
//
|
||||
EventName = fileRead.EventName,
|
||||
NullData = nullData,
|
||||
JobID = fileRead.CellInstanceName,
|
||||
Sequence = logistics.Sequence.ToString(),
|
||||
MesEntity = logistics.MesEntity,
|
||||
ReportFullPath = logistics.ReportFullPath,
|
||||
ProcessJobID = logistics.ProcessJobID,
|
||||
MID = logistics.MID,
|
||||
//
|
||||
Date = processData.Date,
|
||||
Employee = processData.Employee,
|
||||
Lot = processData.Lot,
|
||||
PSN = processData.PSN,
|
||||
Reactor = processData.Reactor,
|
||||
Recipe = string.Empty,
|
||||
//
|
||||
Area = processData.Area,
|
||||
Folder = processData.Folder,
|
||||
HeaderUniqueId = detail.UniqueId,
|
||||
Id = string.Empty,
|
||||
Layer = processData.Layer,
|
||||
Model = processData.Model,
|
||||
Pattern = processData.Pattern,
|
||||
Phase = detail.Phase,
|
||||
Plan = processData.Plan,
|
||||
RampRate = processData.RampRate,
|
||||
RDS = processData.RDS,
|
||||
SetupFile = processData.SetupFile,
|
||||
StartVoltage = processData.StartVoltage,
|
||||
StopVoltage = processData.StopVoltage,
|
||||
UniqueId = detail.UniqueId,
|
||||
Wafer = processData.Wafer,
|
||||
WaferSize = processData.WaferSize,
|
||||
Zone = processData.Zone,
|
||||
//
|
||||
Ccomp = processData.Ccomp,
|
||||
CondType = processData.CondType,
|
||||
FlatZ = detail.FlatZ,
|
||||
FlatZMean = processData.FlatZMean,
|
||||
FlatZRadialGradient = processData.FlatZRadialGradient,
|
||||
FlatZStdDev = processData.FlatZStdDev,
|
||||
GLimit = processData.GLimit,
|
||||
Grade = detail.Grade,
|
||||
GradeMean = processData.GradeMean,
|
||||
GradeRadialGradient = processData.GradeRadialGradient,
|
||||
GradeStdDev = processData.GradeStdDev,
|
||||
NAvg = detail.NAvg,
|
||||
NAvgMean = processData.NAvgMean,
|
||||
NAvgRadialGradient = processData.NAvgRadialGradient,
|
||||
NAvgStdDev = processData.NAvgStdDev,
|
||||
Nsl = detail.Nsl,
|
||||
NslMean = processData.NslMean,
|
||||
NslRadialGradient = processData.NslRadialGradient,
|
||||
NslStdDev = processData.NslStdDev,
|
||||
PhaseMean = processData.PhaseMean,
|
||||
PhaseRadialGradient = processData.PhaseRadialGradient,
|
||||
PhaseStdDev = processData.PhaseStdDev,
|
||||
RhoAvg = detail.RhoAvg,
|
||||
RhoAvgMean = processData.RhoAvgMean,
|
||||
RhoAvgRadialGradient = processData.RhoAvgRadialGradient,
|
||||
RhoAvgStdDev = processData.RhoAvgStdDev,
|
||||
RhoMethod = processData.RhoMethod,
|
||||
Rhosl = detail.Rhosl,
|
||||
RhoslMean = processData.RhoslMean,
|
||||
RhoslRadialGradient = processData.RhoslRadialGradient,
|
||||
RhoslStdDev = processData.RhoslStdDev,
|
||||
RsMean = processData.RsMean,
|
||||
RsRadialGradient = processData.RsRadialGradient,
|
||||
RsStdDev = processData.RsStdDev,
|
||||
Vd = detail.Vd,
|
||||
VdMean = processData.VdMean,
|
||||
VdRadialGradient = processData.VdRadialGradient,
|
||||
VdStdDev = processData.VdStdDev
|
||||
};
|
||||
results.Add(description);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private static Description GetDisplayNames()
|
||||
{
|
||||
Description result = new();
|
||||
return result;
|
||||
}
|
||||
|
||||
private Description GetDefault(IFileRead fileRead, Logistics logistics)
|
||||
{
|
||||
Description result = new()
|
||||
{
|
||||
Test = -1,
|
||||
Count = 0,
|
||||
Index = -1,
|
||||
//
|
||||
EventName = fileRead.EventName,
|
||||
NullData = fileRead.NullData,
|
||||
JobID = fileRead.CellInstanceName,
|
||||
Sequence = logistics.Sequence.ToString(),
|
||||
MesEntity = fileRead.MesEntity,
|
||||
ReportFullPath = logistics.ReportFullPath,
|
||||
ProcessJobID = logistics.ProcessJobID,
|
||||
MID = logistics.MID,
|
||||
//
|
||||
Date = nameof(Date),
|
||||
Employee = nameof(Employee),
|
||||
Lot = nameof(Lot),
|
||||
PSN = nameof(PSN),
|
||||
Reactor = nameof(Reactor),
|
||||
Recipe = nameof(Recipe),
|
||||
//
|
||||
Area = nameof(Area),
|
||||
Folder = nameof(Folder),
|
||||
HeaderUniqueId = nameof(HeaderUniqueId),
|
||||
Id = nameof(Id),
|
||||
Layer = nameof(Layer),
|
||||
Model = nameof(Model),
|
||||
Pattern = nameof(Pattern),
|
||||
Phase = nameof(Phase),
|
||||
Plan = nameof(Plan),
|
||||
RampRate = nameof(RampRate),
|
||||
RDS = nameof(RDS),
|
||||
SetupFile = nameof(SetupFile),
|
||||
StartVoltage = nameof(StartVoltage),
|
||||
StopVoltage = nameof(StopVoltage),
|
||||
UniqueId = nameof(UniqueId),
|
||||
Wafer = nameof(Wafer),
|
||||
WaferSize = nameof(WaferSize),
|
||||
Zone = nameof(Zone),
|
||||
//
|
||||
Ccomp = nameof(Ccomp),
|
||||
CondType = nameof(CondType),
|
||||
FlatZ = nameof(FlatZ),
|
||||
FlatZMean = nameof(FlatZMean),
|
||||
FlatZRadialGradient = nameof(FlatZRadialGradient),
|
||||
FlatZStdDev = nameof(FlatZStdDev),
|
||||
GLimit = nameof(GLimit),
|
||||
Grade = nameof(Grade),
|
||||
GradeMean = nameof(GradeMean),
|
||||
GradeRadialGradient = nameof(GradeRadialGradient),
|
||||
GradeStdDev = nameof(GradeStdDev),
|
||||
NAvg = nameof(NAvg),
|
||||
NAvgMean = nameof(NAvgMean),
|
||||
NAvgRadialGradient = nameof(NAvgRadialGradient),
|
||||
NAvgStdDev = nameof(NAvgStdDev),
|
||||
Nsl = nameof(Nsl),
|
||||
NslMean = nameof(NslMean),
|
||||
NslRadialGradient = nameof(NslRadialGradient),
|
||||
NslStdDev = nameof(NslStdDev),
|
||||
PhaseMean = nameof(PhaseMean),
|
||||
PhaseRadialGradient = nameof(PhaseRadialGradient),
|
||||
PhaseStdDev = nameof(PhaseStdDev),
|
||||
RhoAvg = nameof(RhoAvg),
|
||||
RhoAvgMean = nameof(RhoAvgMean),
|
||||
RhoAvgRadialGradient = nameof(RhoAvgRadialGradient),
|
||||
RhoAvgStdDev = nameof(RhoAvgStdDev),
|
||||
RhoMethod = nameof(RhoMethod),
|
||||
Rhosl = nameof(Rhosl),
|
||||
RhoslMean = nameof(RhoslMean),
|
||||
RhoslRadialGradient = nameof(RhoslRadialGradient),
|
||||
RhoslStdDev = nameof(RhoslStdDev),
|
||||
RsMean = nameof(RsMean),
|
||||
RsRadialGradient = nameof(RsRadialGradient),
|
||||
RsStdDev = nameof(RsStdDev),
|
||||
Vd = nameof(Vd),
|
||||
VdMean = nameof(VdMean),
|
||||
VdRadialGradient = nameof(VdRadialGradient),
|
||||
VdStdDev = nameof(VdStdDev),
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
19
Adaptation/FileHandlers/pcl/Detail.cs
Normal file
19
Adaptation/FileHandlers/pcl/Detail.cs
Normal file
@ -0,0 +1,19 @@
|
||||
namespace Adaptation.FileHandlers.pcl;
|
||||
|
||||
public class Detail
|
||||
{
|
||||
|
||||
public string FlatZ { get; set; }
|
||||
public string Grade { get; set; }
|
||||
public string HeaderUniqueId { get; set; }
|
||||
public string NAvg { get; set; }
|
||||
public string Nsl { get; set; }
|
||||
public string Phase { get; set; }
|
||||
public string RhoAvg { get; set; }
|
||||
public string Rhosl { get; set; }
|
||||
public string UniqueId { get; set; }
|
||||
public string Vd { get; set; }
|
||||
|
||||
public override string ToString() => string.Concat(FlatZ, ";", Grade);
|
||||
|
||||
}
|
131
Adaptation/FileHandlers/pcl/FileRead.cs
Normal file
131
Adaptation/FileHandlers/pcl/FileRead.cs
Normal file
@ -0,0 +1,131 @@
|
||||
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
|
||||
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Methods;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Adaptation.FileHandlers.pcl;
|
||||
|
||||
public class FileRead : Shared.FileRead, IFileRead
|
||||
{
|
||||
|
||||
private readonly string _GhostPCLFileName;
|
||||
|
||||
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted) :
|
||||
base(new Description(), true, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
|
||||
{
|
||||
_MinFileLength = 10;
|
||||
_NullData = string.Empty;
|
||||
_Logistics = new Logistics(this);
|
||||
if (_FileParameter is null)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (_ModelObjectParameterDefinitions is null)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (_IsDuplicator)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
_GhostPCLFileName = string.Concat(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), @"\gpcl6win64.exe");
|
||||
if (_IsEAFHosted && !File.Exists(_GhostPCLFileName))
|
||||
throw new Exception("Ghost PCL FileName doesn't Exist!");
|
||||
}
|
||||
|
||||
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) => Move(extractResults, exception);
|
||||
|
||||
void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
|
||||
|
||||
string IFileRead.GetEventDescription()
|
||||
{
|
||||
string result = _Description.GetEventDescription();
|
||||
return result;
|
||||
}
|
||||
|
||||
List<string> IFileRead.GetHeaderNames()
|
||||
{
|
||||
List<string> results = _Description.GetHeaderNames();
|
||||
return results;
|
||||
}
|
||||
|
||||
string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
|
||||
{
|
||||
string[] results = Move(extractResults, to, from, resolvedFileLocation, exception);
|
||||
return results;
|
||||
}
|
||||
|
||||
JsonProperty[] IFileRead.GetDefault()
|
||||
{
|
||||
JsonProperty[] results = _Description.GetDefault(this, _Logistics);
|
||||
return results;
|
||||
}
|
||||
|
||||
Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement()
|
||||
{
|
||||
Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this);
|
||||
return results;
|
||||
}
|
||||
|
||||
List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData)
|
||||
{
|
||||
List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
|
||||
return results;
|
||||
}
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.GetExtractResult(string reportFullPath, string eventName)
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
if (string.IsNullOrEmpty(eventName))
|
||||
throw new Exception();
|
||||
_ReportFullPath = reportFullPath;
|
||||
DateTime dateTime = DateTime.Now;
|
||||
results = GetExtractResult(reportFullPath, dateTime);
|
||||
if (results.Item3 is null)
|
||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(results.Item1, Array.Empty<Test>(), JsonSerializer.Deserialize<JsonElement[]>("[]"), results.Item4);
|
||||
if (results.Item3.Length > 0 && _IsEAFHosted)
|
||||
WritePDSF(this, results.Item3);
|
||||
UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks);
|
||||
return results;
|
||||
}
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.ReExtract()
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
List<string> headerNames = _Description.GetHeaderNames();
|
||||
Dictionary<string, string> keyValuePairs = _Description.GetDisplayNamesJsonElement(this);
|
||||
results = ReExtract(this, headerNames, keyValuePairs);
|
||||
return results;
|
||||
}
|
||||
|
||||
void IFileRead.CheckTests(Test[] tests, bool extra) => throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
|
||||
|
||||
void IFileRead.Callback(object state) => throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
|
||||
|
||||
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>());
|
||||
_Logistics = new Logistics(this, reportFullPath, useSplitForMID: true);
|
||||
SetFileParameterLotIDToLogisticsMID();
|
||||
if (reportFullPath.Length < _MinFileLength)
|
||||
results.Item4.Add(new FileInfo(reportFullPath));
|
||||
else
|
||||
{
|
||||
IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, _GhostPCLFileName);
|
||||
if (iProcessData is ProcessData processData)
|
||||
{
|
||||
string mid = string.Concat(processData.Reactor, "-", processData.RDS, "-", processData.PSN);
|
||||
mid = Regex.Replace(mid, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
|
||||
_Logistics.MID = mid;
|
||||
SetFileParameterLotID(mid);
|
||||
_Logistics.ProcessJobID = processData.Reactor;
|
||||
}
|
||||
if (!iProcessData.Details.Any())
|
||||
throw new Exception(string.Concat("No Data - ", dateTime.Ticks));
|
||||
results = iProcessData.GetResults(this, _Logistics, results.Item4);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
404
Adaptation/FileHandlers/pcl/ProcessData.cs
Normal file
404
Adaptation/FileHandlers/pcl/ProcessData.cs
Normal file
@ -0,0 +1,404 @@
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Methods;
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Adaptation.FileHandlers.pcl;
|
||||
|
||||
public class ProcessData : IProcessData
|
||||
{
|
||||
|
||||
private int _I;
|
||||
private string _Data;
|
||||
|
||||
private readonly ILog _Log;
|
||||
private readonly List<object> _Details;
|
||||
|
||||
public string JobID { get; set; }
|
||||
public string MesEntity { get; set; }
|
||||
public string Area { get; set; }
|
||||
public string Ccomp { get; set; }
|
||||
public string CondType { get; set; }
|
||||
public string Date { get; set; }
|
||||
public string Employee { get; set; }
|
||||
public string FlatZMean { get; set; }
|
||||
public string FlatZRadialGradient { get; set; }
|
||||
public string FlatZStdDev { get; set; }
|
||||
public string Folder { get; set; }
|
||||
public string GLimit { get; set; }
|
||||
public string GradeMean { get; set; }
|
||||
public string GradeRadialGradient { get; set; }
|
||||
public string GradeStdDev { get; set; }
|
||||
public string Layer { get; set; }
|
||||
public string Lot { get; set; }
|
||||
public string Model { get; set; }
|
||||
public string NAvgMean { get; set; }
|
||||
public string NAvgRadialGradient { get; set; }
|
||||
public string NAvgStdDev { get; set; }
|
||||
public string NslMean { get; set; }
|
||||
public string NslRadialGradient { get; set; }
|
||||
public string NslStdDev { get; set; }
|
||||
public string PSN { get; set; }
|
||||
public string Pattern { get; set; }
|
||||
public string PhaseMean { get; set; }
|
||||
public string PhaseRadialGradient { get; set; }
|
||||
public string PhaseStdDev { get; set; }
|
||||
public string Plan { get; set; }
|
||||
public string RDS { get; set; }
|
||||
public string RampRate { get; set; }
|
||||
public string Reactor { get; set; }
|
||||
public string RhoAvgMean { get; set; }
|
||||
public string RhoAvgRadialGradient { get; set; }
|
||||
public string RhoAvgStdDev { get; set; }
|
||||
public string RhoMethod { get; set; }
|
||||
public string RhoslMean { get; set; }
|
||||
public string RhoslRadialGradient { get; set; }
|
||||
public string RhoslStdDev { get; set; }
|
||||
public string RsMean { get; set; }
|
||||
public string RsRadialGradient { get; set; }
|
||||
public string RsStdDev { get; set; }
|
||||
public string SetupFile { get; set; }
|
||||
public string StartVoltage { get; set; }
|
||||
public string StopVoltage { get; set; }
|
||||
public string UniqueId { get; set; }
|
||||
public string VdMean { get; set; }
|
||||
public string VdRadialGradient { get; set; }
|
||||
public string VdStdDev { get; set; }
|
||||
public string Wafer { get; set; }
|
||||
public string WaferSize { get; set; }
|
||||
public string Zone { get; set; }
|
||||
|
||||
List<object> Shared.Properties.IProcessData.Details => _Details;
|
||||
|
||||
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string ghostPCLFileName)
|
||||
{
|
||||
fileInfoCollection.Clear();
|
||||
_Details = new List<object>();
|
||||
_I = 0;
|
||||
_Data = string.Empty;
|
||||
JobID = logistics.JobID;
|
||||
MesEntity = logistics.MesEntity;
|
||||
_Log = LogManager.GetLogger(typeof(ProcessData));
|
||||
Date = DateTime.Now.ToString();
|
||||
Parse(fileRead, logistics, fileInfoCollection, ghostPCLFileName);
|
||||
}
|
||||
|
||||
string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) => throw new Exception(string.Concat("See ", nameof(Parse)));
|
||||
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
|
||||
{
|
||||
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
|
||||
List<Test> tests = new();
|
||||
foreach (object item in _Details)
|
||||
tests.Add(Test.HGCV);
|
||||
List<IDescription> descriptions = fileRead.GetDescriptions(fileRead, tests, this);
|
||||
if (tests.Count != descriptions.Count)
|
||||
throw new Exception();
|
||||
for (int i = 0; i < tests.Count; i++)
|
||||
{
|
||||
if (descriptions[i] is not Description description)
|
||||
throw new Exception();
|
||||
if (description.Test != (int)tests[i])
|
||||
throw new Exception();
|
||||
}
|
||||
List<Description> fileReadDescriptions = (from l in descriptions select (Description)l).ToList();
|
||||
string json = JsonSerializer.Serialize(fileReadDescriptions, fileReadDescriptions.GetType());
|
||||
JsonElement[] jsonElements = JsonSerializer.Deserialize<JsonElement[]>(json);
|
||||
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(logistics.Logistics1[0], tests.ToArray(), jsonElements, fileInfoCollection);
|
||||
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)
|
||||
{
|
||||
int num = _Data.IndexOf(text, _I);
|
||||
if (num > -1)
|
||||
{
|
||||
_I = num + text.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
_I = _Data.Length;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetBefore(string text)
|
||||
{
|
||||
int num = _Data.IndexOf(text, _I);
|
||||
string text2;
|
||||
if (num > -1)
|
||||
{
|
||||
text2 = _Data.Substring(_I, num - _I);
|
||||
_I = num + text.Length;
|
||||
return text2.Trim();
|
||||
}
|
||||
text2 = _Data.Substring(_I);
|
||||
_I = _Data.Length;
|
||||
return text2.Trim();
|
||||
}
|
||||
|
||||
private static bool IsNullOrWhiteSpace(string text)
|
||||
{
|
||||
for (int i = 0; i < text.Length; i++)
|
||||
{
|
||||
if (!char.IsWhiteSpace(text[i]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool IsBlankLine()
|
||||
{
|
||||
int num = _Data.IndexOf("\n", _I);
|
||||
return IsNullOrWhiteSpace((num > -1) ? _Data.Substring(_I, num - _I) : _Data.Substring(_I));
|
||||
}
|
||||
|
||||
private string GetToEOL() => GetBefore("\n");
|
||||
|
||||
private string GetToken()
|
||||
{
|
||||
while (_I < _Data.Length && IsNullOrWhiteSpace(_Data.Substring(_I, 1)))
|
||||
{
|
||||
_I++;
|
||||
}
|
||||
int j;
|
||||
for (j = _I; j < _Data.Length && !IsNullOrWhiteSpace(_Data.Substring(j, 1)); j++)
|
||||
{
|
||||
}
|
||||
string text = _Data.Substring(_I, j - _I);
|
||||
_I = j;
|
||||
return text.Trim();
|
||||
}
|
||||
|
||||
private void Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string ghostPCLFileName)
|
||||
{
|
||||
if (fileRead is null)
|
||||
{ }
|
||||
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
|
||||
{
|
||||
//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));
|
||||
}
|
||||
if (headerText.Contains("G A T E V O L T A G E"))
|
||||
throw new Exception("Ignore: GATEVOLTAGE runs are not parsed.");
|
||||
if (!string.IsNullOrEmpty(headerText))
|
||||
{
|
||||
headerText = headerText.Replace("box", "");
|
||||
headerText = headerText.Replace("bar", "");
|
||||
headerText = headerText.Replace("horiz", "");
|
||||
headerText = headerText.Replace("center", "");
|
||||
headerText = headerText.Replace("upper", "");
|
||||
headerText = headerText.Replace("lower", "");
|
||||
headerText = headerText.Replace("right", "");
|
||||
headerText = headerText.Replace("left", "");
|
||||
headerText = headerText.Replace("thin", "");
|
||||
headerText = headerText.Replace("vertical", "");
|
||||
headerText = headerText.Replace("line", "");
|
||||
headerText = headerText.Replace("middle", "");
|
||||
headerText = headerText.Replace("side", "");
|
||||
headerText = headerText.Replace("top", ""); // This will change "Stop Voltage" to "S Voltage"
|
||||
headerText = headerText.Replace("corner", "");
|
||||
headerText = headerText.Replace("bottom", "");
|
||||
headerText = headerText.Replace("ruleunder", "_");
|
||||
headerText = headerText.Replace("@", "");
|
||||
headerText = headerText.Replace("*", "");
|
||||
_I = 0;
|
||||
_Data = headerText;
|
||||
_Log.Debug($"****MERCURY-DATA [002]= {headerText}");
|
||||
ScanPast("Operator:");
|
||||
Employee = GetBefore("Start Voltage:");
|
||||
StartVoltage = GetBefore("V");
|
||||
ScanPast("Wafer :");
|
||||
Wafer = GetBefore("S Voltage :"); // This is actually "Stop Voltage"
|
||||
StopVoltage = GetBefore("V");
|
||||
ScanPast("Lot :");
|
||||
if (headerText.Contains("Ramp Rate :"))
|
||||
Lot = GetBefore("Ramp Rate :");
|
||||
else if (headerText.Contains("Forward Rate :"))
|
||||
Lot = GetBefore("Forward Rate :");
|
||||
else if (headerText.Contains("Conduct Type:"))
|
||||
Lot = GetBefore("Conduct Type:");
|
||||
else
|
||||
Lot = string.Empty;
|
||||
// Remove illegal characters \/:*?"<>| found in the Lot.
|
||||
Lot = Regex.Replace(Lot, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
|
||||
RampRate = GetBefore("mV/sec");
|
||||
ScanPast("Plan :");
|
||||
Plan = GetBefore("G limit :");
|
||||
//GLimit = GetBefore("S ");
|
||||
GLimit = GetBefore("S");
|
||||
Date = DateTime.Now.ToString();
|
||||
ScanPast("Setup File:");
|
||||
//SetupFile = GetBefore("O O");
|
||||
SetupFile = GetBefore("O O");
|
||||
ScanPast("Wafer size :");
|
||||
WaferSize = GetBefore("mm");
|
||||
ScanPast("Folder :");
|
||||
//Folder = GetBefore("N N");
|
||||
Folder = GetBefore("N N");
|
||||
ScanPast("Ccomp : ");
|
||||
Ccomp = GetBefore("pF");
|
||||
ScanPast("Pattern :");
|
||||
//Pattern = GetBefore("C C");
|
||||
Pattern = GetBefore("C C");
|
||||
ScanPast("Area:");
|
||||
Area = GetBefore("cm2");
|
||||
ScanPast("Cond Type :");
|
||||
CondType = GetBefore("Rho Method:");
|
||||
//RhoMethod = GetBefore("N N");
|
||||
RhoMethod = GetBefore("N N");
|
||||
ScanPast("Model :");
|
||||
//Model = GetBefore("T T");
|
||||
Model = GetBefore("T T");
|
||||
ScanPast("Navg :");
|
||||
NAvgMean = GetToken();
|
||||
NAvgStdDev = GetToken();
|
||||
NAvgRadialGradient = GetToken();
|
||||
ScanPast("Nsl :");
|
||||
NslMean = GetToken();
|
||||
NslStdDev = GetToken();
|
||||
NslRadialGradient = GetToken();
|
||||
ScanPast("Vd :");
|
||||
VdMean = GetToken();
|
||||
VdStdDev = GetToken();
|
||||
VdRadialGradient = GetToken();
|
||||
ScanPast("Flat Z:");
|
||||
FlatZMean = GetToken();
|
||||
FlatZStdDev = GetToken();
|
||||
FlatZRadialGradient = GetToken();
|
||||
ScanPast("Rhoavg:");
|
||||
RhoAvgMean = GetToken();
|
||||
RhoAvgStdDev = GetToken();
|
||||
RhoAvgRadialGradient = GetToken();
|
||||
ScanPast("Rhosl :");
|
||||
RhoslMean = GetToken();
|
||||
RhoslStdDev = GetToken();
|
||||
RhoslRadialGradient = GetToken();
|
||||
ScanPast("Phase :");
|
||||
PhaseMean = GetToken();
|
||||
PhaseStdDev = GetToken();
|
||||
PhaseRadialGradient = GetToken();
|
||||
ScanPast("Grade :");
|
||||
GradeMean = GetToken();
|
||||
GradeStdDev = GetToken();
|
||||
GradeRadialGradient = GetToken();
|
||||
ScanPast("Rs :");
|
||||
RsMean = GetToken();
|
||||
RsStdDev = GetToken();
|
||||
RsRadialGradient = GetToken();
|
||||
|
||||
string lot = Lot;
|
||||
string[] segments = lot.Split('-');
|
||||
|
||||
if (segments.Length >= 1)
|
||||
Reactor = segments[0];
|
||||
|
||||
if (segments.Length >= 2)
|
||||
RDS = segments[1];
|
||||
|
||||
if (segments.Length >= 3)
|
||||
{
|
||||
string str = segments[2];
|
||||
string[] segmentsB = str.Split('.');
|
||||
if (segmentsB.Length >= 1)
|
||||
PSN = segmentsB[0];
|
||||
if (segmentsB.Length >= 2)
|
||||
Layer = segmentsB[1];
|
||||
}
|
||||
if (segments.Length >= 4)
|
||||
Zone = segments[3];
|
||||
|
||||
//ScanPast("Flat Z: Grade : % Flat Z: Grade : % Flat Z: Grade : %");
|
||||
ScanPast("Flat Z: Grade : % Flat Z: Grade : % Flat Z: Grade : %");
|
||||
string token = GetToken();
|
||||
while (!string.IsNullOrEmpty(token))
|
||||
{
|
||||
Detail hgProbeDetail = new()
|
||||
{ NAvg = token };
|
||||
_ = GetToEOL();
|
||||
hgProbeDetail.Nsl = GetToken();
|
||||
_ = GetToEOL();
|
||||
hgProbeDetail.Vd = GetToken();
|
||||
_ = GetToEOL();
|
||||
hgProbeDetail.FlatZ = GetToken();
|
||||
_ = GetToEOL();
|
||||
hgProbeDetail.RhoAvg = GetToken();
|
||||
_ = GetToEOL();
|
||||
hgProbeDetail.Rhosl = GetToken();
|
||||
_ = GetToEOL();
|
||||
hgProbeDetail.Phase = GetToken();
|
||||
_ = GetToEOL();
|
||||
hgProbeDetail.Grade = GetToken();
|
||||
hgProbeDetail.UniqueId = string.Concat("_Point-", _Details.Count + 1);
|
||||
_Details.Add(hgProbeDetail);
|
||||
_ = GetToken();
|
||||
_ = GetToken();
|
||||
_ = GetToken();
|
||||
_ = GetToken();
|
||||
token = GetToken();
|
||||
//if (token.Contains("LincPDF") || token.Contains("MULTIPLE"))
|
||||
if (token.Contains("MULTIPLE"))
|
||||
{
|
||||
//ScanPast("Flat Z: Grade : % Flat Z: Grade : % Flat Z: Grade : %");
|
||||
//ScanPast("Flat Z: Grade : % Flat Z: Grade : % Flat Z: Grade : %");
|
||||
ScanPast("Flat Z: Grade : % Flat Z: Grade : % Flat Z: Grade : %");
|
||||
ScanPast("Flat Z: Grade : % Flat Z: Grade : % Flat Z: Grade : %");
|
||||
token = GetToken();
|
||||
}
|
||||
}
|
||||
}
|
||||
UniqueId = string.Format("{0}_{1}_{2}", logistics.JobID, Lot, Path.GetFileNameWithoutExtension(logistics.ReportFullPath));
|
||||
foreach (Detail detail in _Details)
|
||||
{
|
||||
detail.HeaderUniqueId = UniqueId;
|
||||
detail.UniqueId = string.Concat(detail, detail.UniqueId);
|
||||
}
|
||||
fileInfoCollection.Add(new FileInfo(logistics.ReportFullPath));
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user