MET08DDUPSFS6420 - v2.43.0 - Remove unit for IQS
Remove RecordStart Update Mona Logistics update
This commit is contained in:
parent
acbbb75404
commit
b5244f1166
@ -135,7 +135,19 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
if (!Directory.Exists(duplicateDirectory))
|
||||
_ = Directory.CreateDirectory(duplicateDirectory);
|
||||
string duplicateFile = Path.Combine(duplicateDirectory, Path.GetFileName(reportFullPath));
|
||||
File.Copy(reportFullPath, duplicateFile, overwrite: true);
|
||||
string lines = File.ReadAllText(reportFullPath);
|
||||
lines = lines
|
||||
.Replace("ppm\t", "\t")
|
||||
.Replace("mm2\t", "\t")
|
||||
.Replace("um\t", "\t")
|
||||
.Replace("mm\t", "\t")
|
||||
.Replace("nm\t", "\t")
|
||||
.Replace("\t[ ", "\t")
|
||||
.Replace("\t*0", "\t")
|
||||
.Replace("\t*", "\t")
|
||||
.Replace("%\t", "\t")
|
||||
.Replace("]\t", "\t");
|
||||
File.WriteAllText(duplicateFile, lines);
|
||||
WaitForFileConsumption(dateTime, isDummyRun, successDirectory, duplicateDirectory, tuples, duplicateFile);
|
||||
}
|
||||
|
||||
|
@ -103,8 +103,8 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
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));
|
||||
if (_Logistics.FileInfo.Length < _MinFileLength)
|
||||
results.Item4.Add(_Logistics.FileInfo);
|
||||
else
|
||||
{
|
||||
IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, _GhostPCLFileName);
|
||||
@ -112,9 +112,8 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
throw new Exception(string.Concat("A) No Data - ", dateTime.Ticks));
|
||||
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;
|
||||
_Logistics.Update(mid, processData.Reactor);
|
||||
if (!iProcessData.Details.Any())
|
||||
throw new Exception(string.Concat("B) No Data - ", dateTime.Ticks));
|
||||
results = iProcessData.GetResults(this, _Logistics, results.Item4);
|
||||
|
@ -626,7 +626,7 @@ public class ProcessData : IProcessData
|
||||
// dataFiles[i].Date = DateTime.Parse(dataFiles[i].Date).ToString();
|
||||
foreach (string sourceFile in sourceFiles)
|
||||
fileInfoCollection.Add(new FileInfo(sourceFile));
|
||||
fileInfoCollection.Add(new FileInfo(logistics.ReportFullPath));
|
||||
fileInfoCollection.Add(logistics.FileInfo);
|
||||
}
|
||||
|
||||
#nullable enable
|
||||
|
@ -62,7 +62,7 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="FFMpegCore" Version="4.8.0" />
|
||||
<PackageReference Include="Infineon.Monitoring.MonA" Version="2.0.0" />
|
||||
<PackageReference Include="Infineon.Monitoring.MonA" Version="3.0.0" />
|
||||
<PackageReference Include="Infineon.Yoda" Version="5.4.1" />
|
||||
<PackageReference Include="Instances" Version="2.0.0" />
|
||||
<PackageReference Include="RoboSharp" Version="1.2.7" />
|
||||
|
@ -9,34 +9,46 @@ namespace Adaptation.Shared;
|
||||
public class Logistics : ILogistics
|
||||
{
|
||||
|
||||
public object NullData { get; private set; }
|
||||
public string JobID { get; private set; } //CellName
|
||||
public long Sequence { get; private set; } //Ticks
|
||||
public DateTime DateTimeFromSequence { get; private set; }
|
||||
public double TotalSecondsSinceLastWriteTimeFromSequence { get; private set; }
|
||||
public string MesEntity { get; private set; } //SPC
|
||||
public string ReportFullPath { get; private set; } //Extract file
|
||||
public string ProcessJobID { get; set; } //Reactor (duplicate but I want it in the logistics)
|
||||
public string MID { get; set; } //Lot & Pocket || Lot
|
||||
public List<string> Tags { get; set; }
|
||||
public List<string> Logistics1 { get; set; }
|
||||
public List<Logistics2> Logistics2 { get; set; }
|
||||
protected readonly DateTime _DateTimeFromSequence;
|
||||
protected readonly FileInfo _FileInfo;
|
||||
protected readonly string _JobID;
|
||||
protected readonly List<string> _Logistics1;
|
||||
protected readonly List<Logistics2> _Logistics2;
|
||||
protected string _MID;
|
||||
protected readonly string _MesEntity;
|
||||
protected readonly object _NullData;
|
||||
protected string _ProcessJobID;
|
||||
protected readonly string _ReportFullPath;
|
||||
protected readonly long _Sequence;
|
||||
protected readonly double _TotalSecondsSinceLastWriteTimeFromSequence;
|
||||
|
||||
public DateTime DateTimeFromSequence => _DateTimeFromSequence;
|
||||
public FileInfo FileInfo => _FileInfo;
|
||||
public string JobID => _JobID;
|
||||
public List<string> Logistics1 => _Logistics1;
|
||||
public List<Logistics2> Logistics2 => _Logistics2;
|
||||
public string MID => _MID;
|
||||
public string MesEntity => _MesEntity;
|
||||
public object NullData => _NullData;
|
||||
public string ProcessJobID => _ProcessJobID;
|
||||
public string ReportFullPath => _ReportFullPath;
|
||||
public long Sequence => _Sequence;
|
||||
public double TotalSecondsSinceLastWriteTimeFromSequence => _TotalSecondsSinceLastWriteTimeFromSequence;
|
||||
|
||||
public Logistics(IFileRead fileRead)
|
||||
{
|
||||
DateTime dateTime = DateTime.Now;
|
||||
NullData = null;
|
||||
Sequence = dateTime.Ticks;
|
||||
DateTimeFromSequence = dateTime;
|
||||
JobID = fileRead.CellInstanceName;
|
||||
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
|
||||
MesEntity = DefaultMesEntity(dateTime);
|
||||
ReportFullPath = string.Empty;
|
||||
ProcessJobID = nameof(ProcessJobID);
|
||||
MID = nameof(MID);
|
||||
Tags = new List<string>();
|
||||
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
|
||||
Logistics2 = new List<Logistics2>();
|
||||
_NullData = null;
|
||||
_Sequence = dateTime.Ticks;
|
||||
_DateTimeFromSequence = dateTime;
|
||||
_JobID = fileRead.CellInstanceName;
|
||||
_TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
|
||||
_MesEntity = DefaultMesEntity(dateTime);
|
||||
_ReportFullPath = string.Empty;
|
||||
_ProcessJobID = nameof(ProcessJobID);
|
||||
_MID = nameof(MID);
|
||||
_Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
|
||||
_Logistics2 = new List<Logistics2>();
|
||||
}
|
||||
|
||||
public Logistics(IFileRead fileRead, string reportFullPath, bool useSplitForMID, int? fileInfoLength = null)
|
||||
@ -45,19 +57,19 @@ public class Logistics : ILogistics
|
||||
throw new Exception();
|
||||
if (string.IsNullOrEmpty(fileRead.MesEntity))
|
||||
throw new Exception();
|
||||
NullData = fileRead.NullData;
|
||||
FileInfo fileInfo = new(reportFullPath);
|
||||
DateTime dateTime = fileInfo.LastWriteTime;
|
||||
if (fileInfoLength.HasValue && fileInfo.Length < fileInfoLength.Value)
|
||||
_NullData = fileRead.NullData;
|
||||
_FileInfo = new(reportFullPath);
|
||||
DateTime dateTime = _FileInfo.LastWriteTime;
|
||||
if (fileInfoLength.HasValue && _FileInfo.Length < fileInfoLength.Value)
|
||||
dateTime = dateTime.AddTicks(-1);
|
||||
JobID = fileRead.CellInstanceName;
|
||||
Sequence = dateTime.Ticks;
|
||||
DateTimeFromSequence = dateTime;
|
||||
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
|
||||
MesEntity = fileRead.MesEntity;
|
||||
ReportFullPath = fileInfo.FullName;
|
||||
ProcessJobID = nameof(ProcessJobID);
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName);
|
||||
_JobID = fileRead.CellInstanceName;
|
||||
_Sequence = dateTime.Ticks;
|
||||
_DateTimeFromSequence = dateTime;
|
||||
_TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
|
||||
_MesEntity = fileRead.MesEntity;
|
||||
_ReportFullPath = _FileInfo.FullName;
|
||||
_ProcessJobID = nameof(ProcessJobID);
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(_FileInfo.FullName);
|
||||
if (useSplitForMID)
|
||||
{
|
||||
if (fileNameWithoutExtension.IndexOf(".") > -1)
|
||||
@ -67,10 +79,9 @@ public class Logistics : ILogistics
|
||||
if (fileNameWithoutExtension.IndexOf("-") > -1)
|
||||
fileNameWithoutExtension = fileNameWithoutExtension.Split('-')[0].Trim();
|
||||
}
|
||||
MID = string.Concat(fileNameWithoutExtension.Substring(0, 1).ToUpper(), fileNameWithoutExtension.Substring(1).ToLower());
|
||||
Tags = new List<string>();
|
||||
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
|
||||
Logistics2 = new List<Logistics2>();
|
||||
_MID = string.Concat(fileNameWithoutExtension.Substring(0, 1).ToUpper(), fileNameWithoutExtension.Substring(1).ToLower());
|
||||
_Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
|
||||
_Logistics2 = new List<Logistics2>();
|
||||
}
|
||||
|
||||
public Logistics(string reportFullPath, string logistics)
|
||||
@ -78,57 +89,57 @@ public class Logistics : ILogistics
|
||||
string key;
|
||||
DateTime dateTime;
|
||||
string[] segments;
|
||||
Logistics1 = logistics.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
_FileInfo = new(reportFullPath);
|
||||
_Logistics1 = logistics.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
if (!Logistics1.Any() || !Logistics1[0].StartsWith("LOGISTICS_1"))
|
||||
{
|
||||
NullData = null;
|
||||
JobID = "null";
|
||||
dateTime = new FileInfo(reportFullPath).LastWriteTime;
|
||||
Sequence = dateTime.Ticks;
|
||||
DateTimeFromSequence = dateTime;
|
||||
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
|
||||
MesEntity = DefaultMesEntity(dateTime);
|
||||
ReportFullPath = reportFullPath;
|
||||
ProcessJobID = "R##";
|
||||
MID = "null";
|
||||
Tags = new List<string>();
|
||||
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
|
||||
Logistics2 = new List<Logistics2>();
|
||||
_NullData = null;
|
||||
_JobID = "null";
|
||||
dateTime = _FileInfo.LastWriteTime;
|
||||
_Sequence = dateTime.Ticks;
|
||||
_DateTimeFromSequence = dateTime;
|
||||
_TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
|
||||
_MesEntity = DefaultMesEntity(dateTime);
|
||||
_ReportFullPath = reportFullPath;
|
||||
_ProcessJobID = "R##";
|
||||
_MID = "null";
|
||||
_Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
|
||||
_Logistics2 = new List<Logistics2>();
|
||||
}
|
||||
else
|
||||
{
|
||||
string logistics1Line1 = Logistics1[0];
|
||||
key = "NULL_DATA=";
|
||||
if (!logistics1Line1.Contains(key))
|
||||
NullData = null;
|
||||
_NullData = null;
|
||||
else
|
||||
{
|
||||
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
||||
NullData = segments[1].Split(';')[0];
|
||||
_NullData = segments[1].Split(';')[0];
|
||||
}
|
||||
key = "JOBID=";
|
||||
if (!logistics1Line1.Contains(key))
|
||||
JobID = "null";
|
||||
_JobID = "null";
|
||||
else
|
||||
{
|
||||
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
||||
JobID = segments[1].Split(';')[0];
|
||||
_JobID = segments[1].Split(';')[0];
|
||||
}
|
||||
key = "SEQUENCE=";
|
||||
if (!logistics1Line1.Contains(key))
|
||||
dateTime = new FileInfo(reportFullPath).LastWriteTime;
|
||||
dateTime = _FileInfo.LastWriteTime;
|
||||
else
|
||||
{
|
||||
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (!long.TryParse(segments[1].Split(';')[0].Split('.')[0], out long sequence) || sequence < new DateTime(1999, 1, 1).Ticks)
|
||||
dateTime = new FileInfo(reportFullPath).LastWriteTime;
|
||||
dateTime = _FileInfo.LastWriteTime;
|
||||
else
|
||||
dateTime = new DateTime(sequence);
|
||||
}
|
||||
Sequence = dateTime.Ticks;
|
||||
DateTimeFromSequence = dateTime;
|
||||
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
|
||||
DateTime lastWriteTime = new FileInfo(reportFullPath).LastWriteTime;
|
||||
_Sequence = dateTime.Ticks;
|
||||
_DateTimeFromSequence = dateTime;
|
||||
_TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
|
||||
DateTime lastWriteTime = _FileInfo.LastWriteTime;
|
||||
if (TotalSecondsSinceLastWriteTimeFromSequence > 600)
|
||||
{
|
||||
if (lastWriteTime != dateTime)
|
||||
@ -138,33 +149,32 @@ public class Logistics : ILogistics
|
||||
}
|
||||
key = "MES_ENTITY=";
|
||||
if (!logistics1Line1.Contains(key))
|
||||
MesEntity = DefaultMesEntity(dateTime);
|
||||
_MesEntity = DefaultMesEntity(dateTime);
|
||||
else
|
||||
{
|
||||
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
||||
MesEntity = segments[1].Split(';')[0];
|
||||
_MesEntity = segments[1].Split(';')[0];
|
||||
}
|
||||
ReportFullPath = reportFullPath;
|
||||
_ReportFullPath = reportFullPath;
|
||||
key = "PROCESS_JOBID=";
|
||||
if (!logistics1Line1.Contains(key))
|
||||
ProcessJobID = "R##";
|
||||
_ProcessJobID = "R##";
|
||||
else
|
||||
{
|
||||
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
||||
ProcessJobID = segments[1].Split(';')[0];
|
||||
_ProcessJobID = segments[1].Split(';')[0];
|
||||
}
|
||||
key = "MID=";
|
||||
if (!logistics1Line1.Contains(key))
|
||||
MID = "null";
|
||||
_MID = "null";
|
||||
else
|
||||
{
|
||||
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
||||
MID = segments[1].Split(';')[0];
|
||||
_MID = segments[1].Split(';')[0];
|
||||
}
|
||||
}
|
||||
Logistics2 logistics2;
|
||||
Tags = new List<string>();
|
||||
Logistics2 = new List<Logistics2>();
|
||||
_Logistics2 = new List<Logistics2>();
|
||||
for (int i = 1; i < Logistics1.Count; i++)
|
||||
{
|
||||
if (Logistics1[i].StartsWith("LOGISTICS_2"))
|
||||
@ -180,29 +190,12 @@ public class Logistics : ILogistics
|
||||
}
|
||||
}
|
||||
|
||||
public Logistics ShallowCopy() => (Logistics)MemberwiseClone();
|
||||
|
||||
private static string DefaultMesEntity(DateTime dateTime) => string.Concat(dateTime.Ticks, "_MES_ENTITY");
|
||||
|
||||
internal string GetLotViaMostCommonMethod() => MID.Substring(0, MID.Length - 2);
|
||||
|
||||
internal string GetPocketNumberViaMostCommonMethod() => MID.Substring(MID.Length - 2);
|
||||
|
||||
internal void Update(string dateTime, string processJobID, string mid)
|
||||
internal void Update(string mid, string processJobID)
|
||||
{
|
||||
if (!DateTime.TryParse(dateTime, out DateTime dateTimeCasted))
|
||||
dateTimeCasted = DateTime.Now;
|
||||
NullData = null;
|
||||
//JobID = Description.GetCellName();
|
||||
Sequence = dateTimeCasted.Ticks;
|
||||
DateTimeFromSequence = dateTimeCasted;
|
||||
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTimeCasted).TotalSeconds;
|
||||
//MesEntity = DefaultMesEntity(dateTime);
|
||||
//ReportFullPath = string.Empty;
|
||||
ProcessJobID = processJobID;
|
||||
MID = mid;
|
||||
Tags = new List<string>();
|
||||
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
|
||||
Logistics2 = new List<Logistics2>();
|
||||
_MID = mid;
|
||||
_ProcessJobID = processJobID;
|
||||
}
|
||||
|
||||
}
|
@ -12,8 +12,6 @@ namespace Adaptation.Shared;
|
||||
public class ProcessDataStandardFormat
|
||||
{
|
||||
|
||||
public const string RecordStart = "RECORD_START";
|
||||
|
||||
public enum SearchFor
|
||||
{
|
||||
EquipmentIntegration = 1,
|
||||
|
@ -1,22 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Adaptation.Shared.Properties;
|
||||
|
||||
public interface ILogistics
|
||||
{
|
||||
|
||||
public object NullData { get; }
|
||||
public string JobID { get; } //CellName
|
||||
public long Sequence { get; } //Ticks
|
||||
public DateTime DateTimeFromSequence { get; }
|
||||
public FileInfo FileInfo { get; }
|
||||
public string JobID { get; }
|
||||
public List<string> Logistics1 { get; }
|
||||
public List<Logistics2> Logistics2 { get; }
|
||||
public string MID { get; }
|
||||
public string MesEntity { get; }
|
||||
public object NullData { get; }
|
||||
public string ProcessJobID { get; }
|
||||
public string ReportFullPath { get; }
|
||||
public long Sequence { get; }
|
||||
public double TotalSecondsSinceLastWriteTimeFromSequence { get; }
|
||||
public string MesEntity { get; } //SPC
|
||||
public string ReportFullPath { get; } //Extract file
|
||||
public string ProcessJobID { get; set; } //Reactor (duplicate but I want it in the logistics)
|
||||
public string MID { get; set; } //Lot & Pocket || Lot
|
||||
public List<string> Tags { get; set; }
|
||||
public List<string> Logistics1 { get; set; }
|
||||
public List<Logistics2> Logistics2 { get; set; }
|
||||
|
||||
}
|
@ -1,243 +1,201 @@
|
||||
using System;
|
||||
using Adaptation.Shared.Methods;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace Shared
|
||||
namespace Adaptation.Shared;
|
||||
|
||||
public class Logistics : ILogistics
|
||||
{
|
||||
|
||||
public class Logistics
|
||||
protected readonly DateTime _DateTimeFromSequence;
|
||||
protected readonly FileInfo _FileInfo;
|
||||
protected readonly string _JobID;
|
||||
protected readonly List<string> _Logistics1;
|
||||
protected readonly List<Logistics2> _Logistics2;
|
||||
protected string _MID;
|
||||
protected readonly string _MesEntity;
|
||||
protected readonly object _NullData;
|
||||
protected string _ProcessJobID;
|
||||
protected readonly string _ReportFullPath;
|
||||
protected readonly long _Sequence;
|
||||
protected readonly double _TotalSecondsSinceLastWriteTimeFromSequence;
|
||||
|
||||
public DateTime DateTimeFromSequence => _DateTimeFromSequence;
|
||||
public FileInfo FileInfo => _FileInfo;
|
||||
public string JobID => _JobID;
|
||||
public List<string> Logistics1 => _Logistics1;
|
||||
public List<Logistics2> Logistics2 => _Logistics2;
|
||||
public string MID => _MID;
|
||||
public string MesEntity => _MesEntity;
|
||||
public object NullData => _NullData;
|
||||
public string ProcessJobID => _ProcessJobID;
|
||||
public string ReportFullPath => _ReportFullPath;
|
||||
public long Sequence => _Sequence;
|
||||
public double TotalSecondsSinceLastWriteTimeFromSequence => _TotalSecondsSinceLastWriteTimeFromSequence;
|
||||
|
||||
public Logistics(IFileRead fileRead)
|
||||
{
|
||||
DateTime dateTime = DateTime.Now;
|
||||
_NullData = null;
|
||||
_Sequence = dateTime.Ticks;
|
||||
_DateTimeFromSequence = dateTime;
|
||||
_JobID = fileRead.CellInstanceName;
|
||||
_TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
|
||||
_MesEntity = DefaultMesEntity(dateTime);
|
||||
_ReportFullPath = string.Empty;
|
||||
_ProcessJobID = nameof(ProcessJobID);
|
||||
_MID = nameof(MID);
|
||||
_Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
|
||||
_Logistics2 = new List<Logistics2>();
|
||||
}
|
||||
|
||||
public object NullData { get; private set; }
|
||||
public string JobID { get; private set; } //CellName
|
||||
public long Sequence { get; private set; } //Ticks
|
||||
public DateTime DateTimeFromSequence { get; private set; }
|
||||
public double TotalSecondsSinceLastWriteTimeFromSequence { get; private set; }
|
||||
public string MesEntity { get; private set; } //SPC
|
||||
public string ReportFullPath { get; private set; } //Extract file
|
||||
public string ProcessJobID { get; internal set; } //Reactor (duplicate but I want it in the logistics)
|
||||
public string MID { get; internal set; } //Lot & Pocket || Lot
|
||||
public List<string> Tags { get; internal set; }
|
||||
public List<string> Logistics1 { get; internal set; }
|
||||
public List<Logistics2> Logistics2 { get; internal set; }
|
||||
|
||||
public Logistics()
|
||||
public Logistics(IFileRead fileRead, string reportFullPath, bool useSplitForMID, int? fileInfoLength = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fileRead.CellInstanceName))
|
||||
throw new Exception();
|
||||
if (string.IsNullOrEmpty(fileRead.MesEntity))
|
||||
throw new Exception();
|
||||
_NullData = fileRead.NullData;
|
||||
_FileInfo = new(reportFullPath);
|
||||
DateTime dateTime = _FileInfo.LastWriteTime;
|
||||
if (fileInfoLength.HasValue && _FileInfo.Length < fileInfoLength.Value)
|
||||
dateTime = dateTime.AddTicks(-1);
|
||||
_JobID = fileRead.CellInstanceName;
|
||||
_Sequence = dateTime.Ticks;
|
||||
_DateTimeFromSequence = dateTime;
|
||||
_TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
|
||||
_MesEntity = fileRead.MesEntity;
|
||||
_ReportFullPath = _FileInfo.FullName;
|
||||
_ProcessJobID = nameof(ProcessJobID);
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(_FileInfo.FullName);
|
||||
if (useSplitForMID)
|
||||
{
|
||||
DateTime dateTime = DateTime.Now;
|
||||
NullData = null;
|
||||
JobID = Description.GetCellName();
|
||||
Sequence = dateTime.Ticks;
|
||||
DateTimeFromSequence = dateTime;
|
||||
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
|
||||
MesEntity = DefaultMesEntity(dateTime);
|
||||
ReportFullPath = string.Empty;
|
||||
ProcessJobID = nameof(ProcessJobID);
|
||||
MID = nameof(MID);
|
||||
Tags = new List<string>();
|
||||
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
|
||||
Logistics2 = new List<Logistics2>();
|
||||
if (fileNameWithoutExtension.IndexOf(".") > -1)
|
||||
fileNameWithoutExtension = fileNameWithoutExtension.Split('.')[0].Trim();
|
||||
if (fileNameWithoutExtension.IndexOf("_") > -1)
|
||||
fileNameWithoutExtension = fileNameWithoutExtension.Split('_')[0].Trim();
|
||||
if (fileNameWithoutExtension.IndexOf("-") > -1)
|
||||
fileNameWithoutExtension = fileNameWithoutExtension.Split('-')[0].Trim();
|
||||
}
|
||||
_MID = string.Concat(fileNameWithoutExtension.Substring(0, 1).ToUpper(), fileNameWithoutExtension.Substring(1).ToLower());
|
||||
_Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
|
||||
_Logistics2 = new List<Logistics2>();
|
||||
}
|
||||
|
||||
public Logistics(object nullData, Dictionary<string, string> cellNames, Dictionary<string, string> mesEntities, FileInfo fileInfo, bool useSplitForMID, int? fileInfoLength = null)
|
||||
public Logistics(string reportFullPath, string logistics)
|
||||
{
|
||||
string key;
|
||||
DateTime dateTime;
|
||||
string[] segments;
|
||||
_FileInfo = new(reportFullPath);
|
||||
_Logistics1 = logistics.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
if (!Logistics1.Any() || !Logistics1[0].StartsWith("LOGISTICS_1"))
|
||||
{
|
||||
NullData = nullData;
|
||||
string mesEntity = string.Empty;
|
||||
string jobID = Description.GetCellName();
|
||||
DateTime dateTime = fileInfo.LastWriteTime;
|
||||
if (fileInfoLength.HasValue && fileInfo.Length < fileInfoLength.Value)
|
||||
dateTime = dateTime.AddTicks(-1);
|
||||
if (string.IsNullOrEmpty(jobID))
|
||||
{
|
||||
if (cellNames.Count == 1)
|
||||
jobID = cellNames.ElementAt(0).Key;
|
||||
else
|
||||
{
|
||||
string reportFullPathLower = fileInfo.FullName.ToLower();
|
||||
foreach (var element in cellNames)
|
||||
{
|
||||
if (reportFullPathLower.Contains(element.Key) || reportFullPathLower.Contains(element.Value))
|
||||
{
|
||||
jobID = element.Key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(jobID))
|
||||
throw new Exception();
|
||||
if (mesEntities.ContainsKey(jobID))
|
||||
mesEntity = mesEntities[jobID];
|
||||
else if (mesEntities.Count == 1)
|
||||
mesEntity = mesEntities.ElementAt(0).Value;
|
||||
//
|
||||
if (string.IsNullOrEmpty(mesEntity))
|
||||
throw new Exception();
|
||||
JobID = jobID;
|
||||
Sequence = dateTime.Ticks;
|
||||
DateTimeFromSequence = dateTime;
|
||||
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
|
||||
MesEntity = mesEntity;
|
||||
ReportFullPath = fileInfo.FullName;
|
||||
ProcessJobID = nameof(ProcessJobID);
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName);
|
||||
if (useSplitForMID)
|
||||
{
|
||||
if (fileNameWithoutExtension.IndexOf(".") > -1)
|
||||
fileNameWithoutExtension = fileNameWithoutExtension.Split('.')[0].Trim();
|
||||
if (fileNameWithoutExtension.IndexOf("_") > -1)
|
||||
fileNameWithoutExtension = fileNameWithoutExtension.Split('_')[0].Trim();
|
||||
if (fileNameWithoutExtension.IndexOf("-") > -1)
|
||||
fileNameWithoutExtension = fileNameWithoutExtension.Split('-')[0].Trim();
|
||||
}
|
||||
MID = string.Concat(fileNameWithoutExtension.Substring(0, 1).ToUpper(), fileNameWithoutExtension.Substring(1).ToLower());
|
||||
Tags = new List<string>();
|
||||
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
|
||||
Logistics2 = new List<Logistics2>();
|
||||
_NullData = null;
|
||||
_JobID = "null";
|
||||
dateTime = _FileInfo.LastWriteTime;
|
||||
_Sequence = dateTime.Ticks;
|
||||
_DateTimeFromSequence = dateTime;
|
||||
_TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
|
||||
_MesEntity = DefaultMesEntity(dateTime);
|
||||
_ReportFullPath = reportFullPath;
|
||||
_ProcessJobID = "R##";
|
||||
_MID = "null";
|
||||
_Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
|
||||
_Logistics2 = new List<Logistics2>();
|
||||
}
|
||||
|
||||
public Logistics(string reportFullPath, string logistics)
|
||||
else
|
||||
{
|
||||
string key;
|
||||
DateTime dateTime;
|
||||
string[] segments;
|
||||
Logistics1 = logistics.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
if (!Logistics1.Any() || !Logistics1[0].StartsWith("LOGISTICS_1"))
|
||||
{
|
||||
NullData = null;
|
||||
JobID = "null";
|
||||
dateTime = new FileInfo(reportFullPath).LastWriteTime;
|
||||
Sequence = dateTime.Ticks;
|
||||
DateTimeFromSequence = dateTime;
|
||||
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
|
||||
MesEntity = DefaultMesEntity(dateTime);
|
||||
ReportFullPath = reportFullPath;
|
||||
ProcessJobID = "R##";
|
||||
MID = "null";
|
||||
Tags = new List<string>();
|
||||
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
|
||||
Logistics2 = new List<Logistics2>();
|
||||
}
|
||||
string logistics1Line1 = Logistics1[0];
|
||||
key = "NULL_DATA=";
|
||||
if (!logistics1Line1.Contains(key))
|
||||
_NullData = null;
|
||||
else
|
||||
{
|
||||
string logistics1Line1 = Logistics1[0];
|
||||
key = "NULL_DATA=";
|
||||
if (!logistics1Line1.Contains(key))
|
||||
NullData = null;
|
||||
else
|
||||
{
|
||||
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
||||
NullData = segments[1].Split(';')[0];
|
||||
}
|
||||
key = "JOBID=";
|
||||
if (!logistics1Line1.Contains(key))
|
||||
JobID = "null";
|
||||
else
|
||||
{
|
||||
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
||||
JobID = segments[1].Split(';')[0];
|
||||
}
|
||||
key = "SEQUENCE=";
|
||||
if (!logistics1Line1.Contains(key))
|
||||
dateTime = new FileInfo(reportFullPath).LastWriteTime;
|
||||
else
|
||||
{
|
||||
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (!long.TryParse(segments[1].Split(';')[0], out long sequence) || sequence < new DateTime(1999, 1, 1).Ticks)
|
||||
dateTime = new FileInfo(reportFullPath).LastWriteTime;
|
||||
else
|
||||
dateTime = new DateTime(sequence);
|
||||
}
|
||||
Sequence = dateTime.Ticks;
|
||||
DateTimeFromSequence = dateTime;
|
||||
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
|
||||
DateTime lastWriteTime = new FileInfo(reportFullPath).LastWriteTime;
|
||||
if (TotalSecondsSinceLastWriteTimeFromSequence > 600)
|
||||
{
|
||||
if (lastWriteTime != dateTime)
|
||||
try { File.SetLastWriteTime(reportFullPath, dateTime); } catch (Exception) { }
|
||||
}
|
||||
key = "MES_ENTITY=";
|
||||
if (!logistics1Line1.Contains(key))
|
||||
MesEntity = DefaultMesEntity(dateTime);
|
||||
else
|
||||
{
|
||||
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
||||
MesEntity = segments[1].Split(';')[0];
|
||||
}
|
||||
ReportFullPath = reportFullPath;
|
||||
key = "PROCESS_JOBID=";
|
||||
if (!logistics1Line1.Contains(key))
|
||||
ProcessJobID = "R##";
|
||||
else
|
||||
{
|
||||
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
||||
ProcessJobID = segments[1].Split(';')[0];
|
||||
}
|
||||
key = "MID=";
|
||||
if (!logistics1Line1.Contains(key))
|
||||
MID = "null";
|
||||
else
|
||||
{
|
||||
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
||||
MID = segments[1].Split(';')[0];
|
||||
}
|
||||
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
||||
_NullData = segments[1].Split(';')[0];
|
||||
}
|
||||
Logistics2 logistics2;
|
||||
Tags = new List<string>();
|
||||
Logistics2 = new List<Logistics2>();
|
||||
for (int i = 1; i < Logistics1.Count(); i++)
|
||||
key = "JOBID=";
|
||||
if (!logistics1Line1.Contains(key))
|
||||
_JobID = "null";
|
||||
else
|
||||
{
|
||||
if (Logistics1[i].StartsWith("LOGISTICS_2"))
|
||||
{
|
||||
logistics2 = new Logistics2(Logistics1[i]);
|
||||
Logistics2.Add(logistics2);
|
||||
}
|
||||
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
||||
_JobID = segments[1].Split(';')[0];
|
||||
}
|
||||
for (int i = Logistics1.Count() - 1; i >= 0; i--)
|
||||
key = "SEQUENCE=";
|
||||
if (!logistics1Line1.Contains(key))
|
||||
dateTime = _FileInfo.LastWriteTime;
|
||||
else
|
||||
{
|
||||
if (Logistics1[i].StartsWith("LOGISTICS_2"))
|
||||
Logistics1.RemoveAt(i);
|
||||
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (!long.TryParse(segments[1].Split(';')[0].Split('.')[0], out long sequence) || sequence < new DateTime(1999, 1, 1).Ticks)
|
||||
dateTime = _FileInfo.LastWriteTime;
|
||||
else
|
||||
dateTime = new DateTime(sequence);
|
||||
}
|
||||
_Sequence = dateTime.Ticks;
|
||||
_DateTimeFromSequence = dateTime;
|
||||
_TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
|
||||
DateTime lastWriteTime = _FileInfo.LastWriteTime;
|
||||
if (TotalSecondsSinceLastWriteTimeFromSequence > 600)
|
||||
{
|
||||
if (lastWriteTime != dateTime)
|
||||
try
|
||||
{ File.SetLastWriteTime(reportFullPath, dateTime); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
key = "MES_ENTITY=";
|
||||
if (!logistics1Line1.Contains(key))
|
||||
_MesEntity = DefaultMesEntity(dateTime);
|
||||
else
|
||||
{
|
||||
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
||||
_MesEntity = segments[1].Split(';')[0];
|
||||
}
|
||||
_ReportFullPath = reportFullPath;
|
||||
key = "PROCESS_JOBID=";
|
||||
if (!logistics1Line1.Contains(key))
|
||||
_ProcessJobID = "R##";
|
||||
else
|
||||
{
|
||||
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
||||
_ProcessJobID = segments[1].Split(';')[0];
|
||||
}
|
||||
key = "MID=";
|
||||
if (!logistics1Line1.Contains(key))
|
||||
_MID = "null";
|
||||
else
|
||||
{
|
||||
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
|
||||
_MID = segments[1].Split(';')[0];
|
||||
}
|
||||
}
|
||||
|
||||
public Logistics ShallowCopy()
|
||||
Logistics2 logistics2;
|
||||
_Logistics2 = new List<Logistics2>();
|
||||
for (int i = 1; i < Logistics1.Count; i++)
|
||||
{
|
||||
return (Logistics)this.MemberwiseClone();
|
||||
if (Logistics1[i].StartsWith("LOGISTICS_2"))
|
||||
{
|
||||
logistics2 = new Logistics2(Logistics1[i]);
|
||||
Logistics2.Add(logistics2);
|
||||
}
|
||||
}
|
||||
|
||||
private string DefaultMesEntity(DateTime dateTime)
|
||||
for (int i = Logistics1.Count - 1; i > -1; i--)
|
||||
{
|
||||
return string.Concat(dateTime.Ticks, "_MES_ENTITY");
|
||||
}
|
||||
|
||||
internal string GetLotViaMostCommonMethod()
|
||||
{
|
||||
return MID.Substring(0, MID.Length - 2);
|
||||
}
|
||||
|
||||
internal string GetPocketNumberViaMostCommonMethod()
|
||||
{
|
||||
return MID.Substring(MID.Length - 2);
|
||||
}
|
||||
|
||||
internal void Update(string dateTime, string processJobID, string mid)
|
||||
{
|
||||
if (!DateTime.TryParse(dateTime, out DateTime dateTimeCasted))
|
||||
dateTimeCasted = DateTime.Now;
|
||||
NullData = null;
|
||||
//JobID = Description.GetCellName();
|
||||
Sequence = dateTimeCasted.Ticks;
|
||||
DateTimeFromSequence = dateTimeCasted;
|
||||
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTimeCasted).TotalSeconds;
|
||||
//MesEntity = DefaultMesEntity(dateTime);
|
||||
//ReportFullPath = string.Empty;
|
||||
ProcessJobID = processJobID;
|
||||
MID = mid;
|
||||
Tags = new List<string>();
|
||||
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
|
||||
Logistics2 = new List<Logistics2>();
|
||||
if (Logistics1[i].StartsWith("LOGISTICS_2"))
|
||||
Logistics1.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
private static string DefaultMesEntity(DateTime dateTime) => string.Concat(dateTime.Ticks, "_MES_ENTITY");
|
||||
|
||||
internal void Update(string mid, string processJobID)
|
||||
{
|
||||
_MID = mid;
|
||||
_ProcessJobID = processJobID;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user