Match TFS Changeset 303331
This commit is contained in:
324
Adaptation/FileHandlers/FileRead.cs
Normal file
324
Adaptation/FileHandlers/FileRead.cs
Normal file
@ -0,0 +1,324 @@
|
||||
using Adaptation.Helpers;
|
||||
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
|
||||
using Adaptation.Shared;
|
||||
using Adaptation.Shared.Metrology;
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
|
||||
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 override bool Extract(string reportFullPath, string eventName)
|
||||
{
|
||||
MethodBase methodBase = new StackFrame().GetMethod();
|
||||
_Log.Debug(string.Concat(methodBase.Name, " - Entry - {", reportFullPath, "}"));
|
||||
Tuple<string, JsonElement?, List<FileInfo>> extractResults = null;
|
||||
try
|
||||
{
|
||||
extractResults = GetExtractResult(reportFullPath, eventName);
|
||||
int count = extractResults.Item2.Value.GetArrayLength();
|
||||
if (count > 0 && _ConfigData.EafHosted && (_ConfigData.IsDatabaseExportToIPDSF || !_ConfigData.IsSourceTimer))
|
||||
Shared1140(extractResults.Item2.Value);
|
||||
Shared0704(reportFullPath, extractResults, count);
|
||||
Move(reportFullPath, extractResults);
|
||||
Shared0406(reportFullPath);
|
||||
_Log.Debug(string.Concat(methodBase.Name, " - Try - Exit"));
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_Log.Error(string.Concat(methodBase.Name, " - Catch - Entry {", ex.Message, "}", Environment.NewLine, Environment.NewLine, ex.StackTrace));
|
||||
Move(reportFullPath, extractResults, exception: ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//public void SetColumns(string equipmentElementName, EquipmentType? equipmentType, string reportFullPath, Exception ex) //GaN
|
||||
//{
|
||||
// if (equipmentConnection is null)
|
||||
// throw new Exception(string.Concat("Unable to cast EquipmentElementName {", equipmentElementName, "}!"));
|
||||
// int breakAfterSeconds;
|
||||
// if (_Configuration is null)
|
||||
// breakAfterSeconds = 360;
|
||||
// else
|
||||
// {
|
||||
// if (_Configuration.FileScanningOption == FileConnectorConfiguration.FileScanningOptionEnum.TimeBased)
|
||||
// breakAfterSeconds = 360;
|
||||
// else
|
||||
// breakAfterSeconds = Math.Abs(_Configuration.FileScanningIntervalInSeconds);
|
||||
// }
|
||||
// ExtractResult = new ExtractResult(breakAfterSeconds, enumColumns: null, pairedColumns: null);
|
||||
// switch (equipmentConnection.Value)
|
||||
// {
|
||||
// case EquipmentConnection.MET08DDUPSFS6420:
|
||||
// ExtractResult.HeadersAddRange(Column.Process);
|
||||
// ExtractResult.DetailsAddRange();
|
||||
// ExtractResult.ParametersAddRange();
|
||||
// ExtractResult.DatabaseHeadersAddRange();
|
||||
// ExtractResult.DatabaseDetailsAddRange();
|
||||
// break;
|
||||
// case EquipmentConnection.MET08DDUPSP1TBI:
|
||||
// ExtractResult.HeadersAddRange(Column.Process);
|
||||
// ExtractResult.DetailsAddRange();
|
||||
// ExtractResult.ParametersAddRange();
|
||||
// ExtractResult.DatabaseHeadersAddRange();
|
||||
// ExtractResult.DatabaseDetailsAddRange();
|
||||
// break;
|
||||
// case EquipmentConnection.MET08RESIHGCV:
|
||||
// ExtractResult.HeadersAddRange(Column.Process);
|
||||
// ExtractResult.DetailsAddRange();
|
||||
// ExtractResult.ParametersAddRange();
|
||||
// ExtractResult.DatabaseHeadersAddRange();
|
||||
// ExtractResult.DatabaseDetailsAddRange();
|
||||
// break;
|
||||
// case EquipmentConnection.MET08THFTIRQS408M:
|
||||
// ExtractResult.HeadersAddRange(Column.Process);
|
||||
// ExtractResult.DetailsAddRange();
|
||||
// ExtractResult.ParametersAddRange();
|
||||
// ExtractResult.DatabaseHeadersAddRange();
|
||||
// ExtractResult.DatabaseDetailsAddRange();
|
||||
// break;
|
||||
// case EquipmentConnection.MET08THFTIRSTRATUS:
|
||||
// ExtractResult.HeadersAddRange(Column.Process);
|
||||
// ExtractResult.DetailsAddRange();
|
||||
// ExtractResult.ParametersAddRange();
|
||||
// ExtractResult.DatabaseHeadersAddRange();
|
||||
// ExtractResult.DatabaseDetailsAddRange();
|
||||
// break;
|
||||
// default:
|
||||
// throw new Exception(string.Concat("Else {", equipmentElementName, "}!"));
|
||||
// }
|
||||
// if (!string.IsNullOrEmpty(reportFullPath) && !(ex is null))
|
||||
// {
|
||||
// if (!(_Configuration is null) && _ConfigData.IsDuplicator)
|
||||
// try { File.WriteAllLines(string.Concat(_Configuration.ErrorTargetFileLocation, @"\", Path.GetFileNameWithoutExtension(reportFullPath), ".err"), new string[] { Logistics.Sequence.ToString(), ex.Message, string.Empty, string.Empty, ex.StackTrace }); } catch (Exception) { }
|
||||
// if (!_ConfigData.IsSourceTimer && !_ConfigData.IsDatabaseExportToIPDSF)
|
||||
// {
|
||||
// string fileName = string.Concat(reportFullPath, ".IO");
|
||||
// if (!(Configuration is null) && Configuration.PostProcessingMode == FileConnectorConfiguration.PostProcessingModeEnum.Copy)
|
||||
// try { File.WriteAllLines(fileName, new string[] { Configuration.TargetFileName, Logistics.Sequence.ToString(), ex.Message, string.Empty, string.Empty, ex.StackTrace }); } catch (Exception) { }
|
||||
// }
|
||||
// if (_ConfigData.EquipmentConnection.HasValue && _ConfigData.EquipmentConnection.Value != _ConfigData.EquipmentType)
|
||||
// {
|
||||
// if (!reportFullPath.EndsWith(".pdsf") && !reportFullPath.EndsWith(".ipdsf"))
|
||||
// {
|
||||
// string fileName = string.Concat(reportFullPath, ".IO");
|
||||
// try { File.WriteAllLines(fileName, new string[] { "Configuration.TargetFileName", Logistics.Sequence.ToString(), ex.Message, string.Empty, string.Empty, ex.StackTrace }); } catch (Exception) { }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// List<string> debug = new List<string> { "//Exception:" };
|
||||
// if (!(Logistics is null) && !(Logistics.Tags is null))
|
||||
// debug.AddRange(Logistics.Tags);
|
||||
// debug.Add(ex.Message);
|
||||
// debug.Add(ex.StackTrace);
|
||||
// try { File.AppendAllLines(reportFullPath, debug); } catch (Exception) { }
|
||||
// if (!(Logistics is null) && Logistics.DateTimeFromSequence != DateTime.MinValue && Logistics.TotalSecondsSinceLastWriteTimeFromSequence > 600)
|
||||
// {
|
||||
// try { File.SetLastWriteTime(reportFullPath, Logistics.DateTimeFromSequence); } catch (Exception) { }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
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 if (!_ConfigData.IsSourceIPDSF && reportFullPath.EndsWith(".ipdsf"))
|
||||
{
|
||||
results = new Tuple<string, JsonElement?, List<FileInfo>>(string.Empty, null, new List<FileInfo>());
|
||||
NewMethod1(reportFullPath);
|
||||
}
|
||||
else if (reportFullPath.EndsWith(".pdsf"))
|
||||
{
|
||||
results = new Tuple<string, JsonElement?, List<FileInfo>>(string.Empty, null, new List<FileInfo>());
|
||||
NewMethod2(reportFullPath, results);
|
||||
}
|
||||
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 void NewMethod2(string reportFullPath, Tuple<string, JsonElement?, List<FileInfo>> results)
|
||||
{
|
||||
FileInfo fileInfo = new FileInfo(reportFullPath);
|
||||
Logistics = new Logistics(ConfigData.NullData, _ConfigData.CellNames, _ConfigData.MesEntities, fileInfo, useSplitForMID: false);
|
||||
ProcessData processData = new ProcessData(this, _ConfigData, results.Item3, string.Empty, string.Empty);
|
||||
if (!processData.Details.Any())
|
||||
throw new Exception();
|
||||
else
|
||||
{
|
||||
//foreach (var item in result.Details)
|
||||
//{
|
||||
// ExtractResult.RowColumns[Description.RowColumn.Test].Add((int)Shared.Metrology.MET08ANLYSDIFAAST230.Test.DiffusionLength);
|
||||
// ExtractResult.Headers[Column.Process].Add(item.Reactor);
|
||||
// ExtractResult.Headers[Column.Employee].Add(item.Employee);
|
||||
// ExtractResult.Headers[Column.Wafer_ID].Add(item.Slot);
|
||||
// ExtractResult.Headers[Column.Recipe].Add(item.Recipe);
|
||||
// ExtractResult.Parameters[Column.Wafer_Region].Add(item.DiffusionLength);
|
||||
// ExtractResult.Parameters[Column.Wafer_Scribe].Add(item.DiffusionLengthStandardDeviation);
|
||||
//}
|
||||
System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
|
||||
stringBuilder.Append(nameof(ProcessData.DiffusionLengthDetail.Reactor)).Append(";");
|
||||
stringBuilder.Append("Date").Append(";");
|
||||
stringBuilder.Append(nameof(ProcessData.DiffusionLengthDetail.Employee)).Append(";");
|
||||
stringBuilder.Append(nameof(ProcessData.DiffusionLengthDetail.Slot)).Append(";");
|
||||
stringBuilder.Append(nameof(ProcessData.DiffusionLengthDetail.Recipe)).Append(";");
|
||||
stringBuilder.Append(nameof(ProcessData.DiffusionLengthDetail.DiffusionLength)).Append(";");
|
||||
stringBuilder.Append(nameof(ProcessData.DiffusionLengthDetail.DiffusionLengthStandardDeviation)).Append(";");
|
||||
stringBuilder.AppendLine();
|
||||
foreach (var item in processData.Details)
|
||||
{
|
||||
stringBuilder.Append("!");
|
||||
stringBuilder.Append(item.Reactor).Append(";");
|
||||
stringBuilder.Append(Logistics.DateTimeFromSequence.ToString("MM/dd/yyyy HH:mm:ss")).Append(";");
|
||||
stringBuilder.Append(item.Employee).Append(";");
|
||||
stringBuilder.Append(item.Slot).Append(";");
|
||||
stringBuilder.Append(item.Recipe).Append(";");
|
||||
stringBuilder.Append(item.DiffusionLength).Append(";");
|
||||
stringBuilder.Append(item.DiffusionLengthStandardDeviation);
|
||||
stringBuilder.AppendLine();
|
||||
}
|
||||
string copyFile = string.Concat(_ConfigData.IqsTempPath, @"\", _ConfigData.IqsFile, ".txt");
|
||||
File.WriteAllText(copyFile, stringBuilder.ToString());
|
||||
File.Copy(copyFile, string.Concat(_ConfigData.IqsPath, @"\", _ConfigData.IqsFile, ".txt"));
|
||||
}
|
||||
}
|
||||
|
||||
private void NewMethod1(string reportFullPath)
|
||||
{
|
||||
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
|
||||
Logistics = new Logistics(reportFullPath, pdsf.Item1);
|
||||
SetFileParameterLotIDToLogisticsMID();
|
||||
SetFileParameterSystemDateTimeToLogisticsSequence();
|
||||
var data = ProcessDataStandardFormat.GetTestDictionary(pdsf);
|
||||
ExtractResult.SetCollections(Logistics, data.Item2);
|
||||
}
|
||||
|
||||
private void NewMethod(string reportFullPath)
|
||||
{
|
||||
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
|
||||
Logistics = new Logistics(reportFullPath, pdsf.Item1);
|
||||
SetFileParameterLotIDToLogisticsMID();
|
||||
SetFileParameterSystemDateTimeToLogisticsSequence();
|
||||
bool hardSkip = _Configuration.FileScanningOption == FileConnectorConfiguration.FileScanningOptionEnum.TimeBased; //false;
|
||||
if (!hardSkip && _Configuration.FileScanningIntervalInSeconds > 0 && !_ConfigData.IsArchive)
|
||||
{
|
||||
string successDirectory;
|
||||
string duplicateDirectory;
|
||||
if (!_ConfigData.IsXToAPC)
|
||||
successDirectory = string.Empty;
|
||||
else
|
||||
{
|
||||
successDirectory = string.Concat(Path.GetDirectoryName(_Configuration.TargetFileLocation), @"\ViewerPath");
|
||||
if (!Directory.Exists(successDirectory))
|
||||
Directory.CreateDirectory(successDirectory);
|
||||
}
|
||||
if (_ConfigData.IsXToSPaCe || _ConfigData.IsXToSPaCeVillach)
|
||||
duplicateDirectory = _Configuration.TargetFileLocation;
|
||||
else
|
||||
duplicateDirectory = string.Concat(_Configuration.TargetFileLocation, @"\", Logistics.JobID);
|
||||
if (!Directory.Exists(duplicateDirectory))
|
||||
Directory.CreateDirectory(duplicateDirectory);
|
||||
string logisticsSequence = Logistics.Sequence.ToString();
|
||||
List<Tuple<IScopeInfo, string>> tuples = new List<Tuple<IScopeInfo, string>>();
|
||||
string duplicateFile = string.Concat(duplicateDirectory, @"\", Path.GetFileName(reportFullPath));
|
||||
if (!_ConfigData.IsXToArchive && !_ConfigData.IsXToIQS)
|
||||
File.Copy(reportFullPath, duplicateFile, overwrite: true);
|
||||
else
|
||||
{
|
||||
//Enum[] enumColumns = new Enum[] { ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Move(string reportFullPath, Tuple<string, JsonElement?, List<FileInfo>> extractResults, Exception exception = null)
|
||||
{
|
||||
bool isErrorFile = !(exception is null);
|
||||
object filePathGeneratorInfo = GetFilePathGeneratorInfo(reportFullPath, isErrorFile);
|
||||
if (filePathGeneratorInfo is null || !(filePathGeneratorInfo is FilePathGeneratorInfo filePathGenerator))
|
||||
OISiViewer.WebClientDownloadString(_Description, reportFullPath, isErrorFile, string.Empty);
|
||||
else
|
||||
{
|
||||
FilePathGeneratorInfo info = (FilePathGeneratorInfo)filePathGeneratorInfo;
|
||||
OISiViewer.WebClientDownloadString(_Description, reportFullPath, isErrorFile, filePathGenerator.To);
|
||||
if (isErrorFile)
|
||||
{
|
||||
string[] exceptionLines = new string[] { Logistics.Sequence.ToString(), filePathGenerator.ReportFullPath, filePathGenerator.From, filePathGenerator.ResolvedFileLocation, filePathGenerator.To, string.Empty, string.Empty, exception.Message, string.Empty, string.Empty, exception.StackTrace };
|
||||
if (_ConfigData.IsDuplicator)
|
||||
CreateProgressDirectory(_ConfigData.ProgressPath, Logistics, level, exceptionLines);
|
||||
else
|
||||
{
|
||||
string fileName = string.Concat(filePathGenerator.To, @"\readme.txt");
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(filePathGenerator.To))
|
||||
Directory.CreateDirectory(filePathGenerator.To);
|
||||
File.WriteAllLines(fileName, exceptionLines);
|
||||
}
|
||||
catch (Exception ex) { _Log.Error(ex.Message); }
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isErrorFile && _ConfigData.IsDuplicator)
|
||||
{
|
||||
if (_ConfigData.IsXToArchive)
|
||||
Shared0192(reportFullPath);
|
||||
else if (_ConfigData.IsArchive)
|
||||
{
|
||||
//Archive
|
||||
}
|
||||
if (_ConfigData.EafHosted && !string.IsNullOrEmpty(_ConfigData.ProgressPath))
|
||||
CreateProgressDirectory(_ConfigData.ProgressPath, Logistics, level, exceptionLines: null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
1016
Adaptation/FileHandlers/FileReadShared.cs
Normal file
1016
Adaptation/FileHandlers/FileReadShared.cs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user