MET08DDUPSP1TBI - v2.43.0 - FileInfo added GetMID
This commit is contained in:
parent
44a2e5e67d
commit
48bba76f11
@ -25,10 +25,6 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
if (!_IsDuplicator)
|
||||
throw new Exception(cellInstanceConnectionName);
|
||||
ModelObjectParameterDefinition[] pathParameters = GetProperties(cellInstanceConnectionName, modelObjectParameters, "Path.");
|
||||
string oiContextDataPendingPath = GetPropertyValue(cellInstanceConnectionName, pathParameters, "Path.OIContextDataPending");
|
||||
string oiContextDataResultsPath = GetPropertyValue(cellInstanceConnectionName, pathParameters, "Path.OIContextDataResults");
|
||||
string oiContextDataSearchPath = GetPropertyValue(cellInstanceConnectionName, pathParameters, "Path.OIContextDataSearch");
|
||||
string lsl2SQLConnectionString = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "ConnectionString.LSL2SQL");
|
||||
ModelObjectParameterDefinition[] tibcoParameters = GetProperties(cellInstanceConnectionName, modelObjectParameters, "TIBCO.");
|
||||
string tibcoParameterChannel = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_CHANNEL");
|
||||
@ -38,7 +34,7 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
string tibcoParameterConfigurationLocationCopy = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_CONFIGURATION_LOCATION_LOCAL_COPY");
|
||||
if (_IsEAFHosted)
|
||||
{
|
||||
Transport.Main.Initialize(smtp, cellInstanceName, fileConnectorConfiguration, oiContextDataPendingPath, oiContextDataResultsPath, oiContextDataSearchPath, lsl2SQLConnectionString);
|
||||
Transport.Main.Initialize(smtp, cellInstanceName, fileConnectorConfiguration, lsl2SQLConnectionString);
|
||||
if (!string.IsNullOrEmpty(fileConnectorConfiguration.SourceFileLocation))
|
||||
_ = Transport.Main.Setup(useSleep: true, setIfxTransport: true, tibcoParameterChannel, tibcoParameterSubjectPrefix, tibcoParameterConfigurationLocation, tibcoParameterConfigurationLocationCopy, tibcoParameterSubject);
|
||||
else
|
||||
|
@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
@ -30,10 +28,10 @@ public class Job
|
||||
public DateTime DateTime { get; }
|
||||
public List<Item> Items { get; }
|
||||
|
||||
public Job(string oiContextDataPendingPath, string oiContextDataResultsPath, string oiContextDataSearchPath, string lsl2SQLConnectionString, Dictionary<int, List<(string MID, int Count)>> _RDS, string mid)
|
||||
public Job(string lsl2SQLConnectionString, Dictionary<int, List<(string MID, int Count)>> _RDS, string mid)
|
||||
{
|
||||
Items = new List<Item>();
|
||||
if (mid[0] != '{' || mid[mid.Length - 1] != '}' || !mid.Contains("\"Si\""))
|
||||
if (string.IsNullOrEmpty(mid) || mid[0] != '{' || mid[mid.Length - 1] != '}' || !mid.Contains("\"Si\""))
|
||||
IsAreaSi = false;
|
||||
else
|
||||
{
|
||||
@ -55,32 +53,43 @@ public class Job
|
||||
psn = string.Empty;
|
||||
reactor = string.Empty;
|
||||
}
|
||||
else if (rds > 0)
|
||||
else if (rds is < 100000 or > 100000000)
|
||||
{
|
||||
psn = string.Empty;
|
||||
reactor = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
psn = segments[2];
|
||||
reactor = segments[0];
|
||||
lock (_RDS)
|
||||
{
|
||||
if (!_RDS.ContainsKey(rds))
|
||||
_RDS.Add(rds, new());
|
||||
List<(string MID, int Count)> collection = _RDS[rds];
|
||||
if (collection.Count == 0)
|
||||
bool rdsCollectionCountIsZero = _RDS[rds].Count == 0;
|
||||
if (rdsCollectionCountIsZero)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(reactor) && !string.IsNullOrEmpty(psn))
|
||||
_RDS[rds].Add(new(input.MID, 1));
|
||||
else
|
||||
{
|
||||
IEnumerable<IGrouping<string, (string MID, int Count)>> grouped = collection.GroupBy(l => l.MID);
|
||||
string lsl2SQLMID = GetMID(lsl2SQLConnectionString, rds);
|
||||
if (string.IsNullOrEmpty(lsl2SQLMID))
|
||||
_RDS[rds].Add(new(input.MID, 1));
|
||||
else
|
||||
_RDS[rds].Add(new(lsl2SQLMID, 1));
|
||||
}
|
||||
}
|
||||
IEnumerable<IGrouping<string, (string MID, int Count)>> grouped = _RDS[rds].GroupBy(l => l.MID);
|
||||
orderedMatches.AddRange(from l in grouped orderby l.Count() descending select l);
|
||||
if (!rdsCollectionCountIsZero)
|
||||
{
|
||||
int length = (from l in orderedMatches where l.Key == input.MID select true).Count();
|
||||
_RDS[rds].Add(new(input.MID, length + 1));
|
||||
}
|
||||
if (_RDS.Count > 1000)
|
||||
_ = _RDS.Remove(_RDS.ElementAt(0).Key);
|
||||
}
|
||||
psn = segments[2];
|
||||
reactor = segments[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
psn = string.Empty;
|
||||
reactor = string.Empty;
|
||||
}
|
||||
AutomationMode = string.Concat(DateTime.Ticks, ".", input.MesEntity);
|
||||
Equipment = input.MesEntity;
|
||||
@ -92,7 +101,7 @@ public class Job
|
||||
reactor = segments[0];
|
||||
}
|
||||
const string hyphen = "-";
|
||||
if (rds < 1)
|
||||
if (rds is < 100000 or > 100000000)
|
||||
{
|
||||
BasicType = hyphen;
|
||||
LotName = input.MID;
|
||||
@ -110,11 +119,10 @@ public class Job
|
||||
RecipeName = input.Recipe;
|
||||
StateModel = input.EquipmentType;
|
||||
Items.Add(new Item { Name = "0", Type = "NA", Number = (0 + 1).ToString(), Qty = "1", CarrierName = hyphen });
|
||||
MoveOldFiles(oiContextDataSearchPath, oiContextDataPendingPath, oiContextDataResultsPath);
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetBasicType(string lsl2SQLConnectionString, string hyphen, int rds)
|
||||
private static string GetBasicType(string lsl2SQLConnectionString, string hyphen, int rds)
|
||||
{
|
||||
string result;
|
||||
// string json;
|
||||
@ -181,8 +189,7 @@ public class Job
|
||||
sqlConnection.Close();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
{ }
|
||||
if (scalar is null)
|
||||
result = hyphen;
|
||||
else
|
||||
@ -190,41 +197,29 @@ public class Job
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void MoveOldFiles(string oiContextDataPendingPath, string oiContextDataResultsPath, string oiContextDataSearchPath)
|
||||
{
|
||||
string yearWeek;
|
||||
string[] oldFiles;
|
||||
FileInfo fileInfo;
|
||||
string weekOfYear;
|
||||
string moveDirectory;
|
||||
DateTime daysOld = DateTime.Now.AddDays(-2);
|
||||
CultureInfo cultureInfo = new("en-US");
|
||||
Calendar calendar = cultureInfo.Calendar;
|
||||
string[] directories = new string[] { oiContextDataSearchPath, oiContextDataPendingPath, oiContextDataResultsPath };
|
||||
foreach (string directory in directories)
|
||||
private static string GetMID(string lsl2SQLConnectionString, int rds)
|
||||
{
|
||||
string result;
|
||||
object scalar = null;
|
||||
StringBuilder sql = new();
|
||||
_ = sql.Append(" SELECT CONCAT(REACTOR, '-', RDS_NO, '-', PS_NO) [MID] ").
|
||||
Append(" FROM [LSL2SQL].[dbo].[REACT_RUN] ").
|
||||
Append($" WHERE RDS_NO = '{rds}' ");
|
||||
try
|
||||
{
|
||||
oldFiles = Directory.GetFiles(directory, "*", SearchOption.TopDirectoryOnly);
|
||||
foreach (string oldFile in oldFiles)
|
||||
{
|
||||
fileInfo = new FileInfo(oldFile);
|
||||
if (!fileInfo.Exists || fileInfo.LastWriteTime > daysOld)
|
||||
continue;
|
||||
weekOfYear = calendar.GetWeekOfYear(fileInfo.LastWriteTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
yearWeek = string.Concat(fileInfo.LastWriteTime.ToString("yyyy"), "___Week_", weekOfYear);
|
||||
moveDirectory = Path.Combine(fileInfo.DirectoryName, yearWeek);
|
||||
if (!Directory.Exists(moveDirectory))
|
||||
_ = Directory.CreateDirectory(moveDirectory);
|
||||
try
|
||||
{ File.Move(oldFile, Path.Combine(moveDirectory, fileInfo.Name)); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
using SqlConnection sqlConnection = new(lsl2SQLConnectionString);
|
||||
sqlConnection.Open();
|
||||
using (SqlCommand sqlCommand = new(sql.ToString(), sqlConnection))
|
||||
scalar = sqlCommand.ExecuteScalar();
|
||||
sqlConnection.Close();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
{ }
|
||||
if (scalar is null)
|
||||
result = string.Empty;
|
||||
else
|
||||
result = scalar.ToString();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -16,22 +16,16 @@ internal partial class Main
|
||||
private static object _IfxTransport;
|
||||
private static string _CellInstanceName;
|
||||
private static string _LSL2SQLConnectionString;
|
||||
private static string _OIContextDataSearchPath;
|
||||
private static string _OIContextDataPendingPath;
|
||||
private static string _OIContextDataResultsPath;
|
||||
private static Dictionary<int, List<(string MID, int Count)>> _RDS;
|
||||
private static FileConnectorConfiguration _FileConnectorConfiguration;
|
||||
|
||||
internal static void Initialize(ISMTP smtp, string cellInstanceName, FileConnectorConfiguration fileConnectorConfiguration, string oiContextDataPendingPath, string oiContextDataResultsPath, string oiContextDataSearchPath, string lsl2SQLConnectionString)
|
||||
internal static void Initialize(ISMTP smtp, string cellInstanceName, FileConnectorConfiguration fileConnectorConfiguration, string lsl2SQLConnectionString)
|
||||
{
|
||||
_RDS = new();
|
||||
_SMTP = smtp;
|
||||
_IfxTransport = null;
|
||||
_CellInstanceName = cellInstanceName;
|
||||
_LSL2SQLConnectionString = lsl2SQLConnectionString;
|
||||
_OIContextDataSearchPath = oiContextDataSearchPath;
|
||||
_OIContextDataPendingPath = oiContextDataPendingPath;
|
||||
_OIContextDataResultsPath = oiContextDataResultsPath;
|
||||
_FileConnectorConfiguration = fileConnectorConfiguration;
|
||||
}
|
||||
|
||||
@ -120,36 +114,36 @@ internal partial class Main
|
||||
IfxDoc lotDoc = new();
|
||||
IfxDoc recipeDoc = new();
|
||||
List<IfxDoc> itemDocs = new();
|
||||
jobDoc.Add("AutomationMode", job.AutomationMode);
|
||||
jobDoc.Add(nameof(Job.AutomationMode), job.AutomationMode);
|
||||
jobDoc.Add("CreationTimestamp", job.DateTime);
|
||||
jobDoc.Add("CreationUser", "-");
|
||||
jobDoc.Add("CurrentState", true);
|
||||
jobDoc.Add("Equipment", job.Equipment);
|
||||
jobDoc.Add("JobName", job.JobName);
|
||||
jobDoc.Add(nameof(Job.Equipment), job.Equipment);
|
||||
jobDoc.Add(nameof(Job.JobName), job.JobName);
|
||||
jobDoc.Add("LastUpdateTimestamp", job.DateTime);
|
||||
jobDoc.Add("LastUpdateUser", "-");
|
||||
jobDoc.Add("ProcessType", job.ProcessType);
|
||||
jobDoc.Add("StateModel", job.StateModel);
|
||||
jobDoc.Add(nameof(Job.ProcessType), job.ProcessType); //Key.ProccessJobId
|
||||
jobDoc.Add(nameof(Job.StateModel), job.StateModel);
|
||||
jobDoc.Add("Status", "-");
|
||||
lotDoc.Add("BasicType", job.BasicType);
|
||||
lotDoc.Add(nameof(Job.BasicType), job.BasicType); //Key.BasicType
|
||||
lotDoc.Add("IsActive", true);
|
||||
lotDoc.Add("LotName", job.LotName);
|
||||
lotDoc.Add(nameof(Job.LotName), job.LotName); //Key.MID
|
||||
lotDoc.Add("LotState", "-");
|
||||
lotDoc.Add("PackageName", job.PackageName);
|
||||
lotDoc.Add("ProcessSpecName", job.ProcessSpecName);
|
||||
lotDoc.Add("ProductName", job.ProductName);
|
||||
lotDoc.Add("Qty", job.Qty);
|
||||
lotDoc.Add("Qty2", "-");
|
||||
recipeDoc.Add("RecipeName", job.RecipeName);
|
||||
lotDoc.Add("SpecName", "-");
|
||||
lotDoc.Add(nameof(Job.PackageName), job.PackageName); //Key.WaferId
|
||||
lotDoc.Add(nameof(Job.ProcessSpecName), job.ProcessSpecName); //Key.Chamber
|
||||
lotDoc.Add(nameof(Job.ProductName), job.ProductName); //Key.Product
|
||||
lotDoc.Add(nameof(Job.Qty), job.Qty);
|
||||
lotDoc.Add("Qty2", "-"); //Key.Sequence
|
||||
recipeDoc.Add(nameof(Job.RecipeName), job.RecipeName); //Key.PPID
|
||||
lotDoc.Add("SpecName", "-"); //Key.Info
|
||||
foreach (Item item in job.Items)
|
||||
{
|
||||
itemDoc = new IfxDoc();
|
||||
itemDoc.Add("Name", item.Name);
|
||||
itemDoc.Add("Type", item.Type);
|
||||
itemDoc.Add("Number", item.Number);
|
||||
itemDoc.Add("Qty", item.Qty);
|
||||
itemDoc.Add("CarrierName", item.CarrierName);
|
||||
itemDoc.Add(nameof(Item.Name), item.Name);
|
||||
itemDoc.Add(nameof(Item.Type), item.Type);
|
||||
itemDoc.Add(nameof(Item.Number), item.Number);
|
||||
itemDoc.Add(nameof(Item.Qty), item.Qty);
|
||||
itemDoc.Add(nameof(Item.CarrierName), item.CarrierName);
|
||||
itemDocs.Add(itemDoc);
|
||||
}
|
||||
jobDoc.Add("Recipe", recipeDoc);
|
||||
@ -187,7 +181,7 @@ internal partial class Main
|
||||
if (!subject.EndsWith("GETJOBS"))
|
||||
throw new Exception();
|
||||
mid = GetJobsMID(envelopeDocument);
|
||||
Job job = new(_OIContextDataPendingPath, _OIContextDataResultsPath, _OIContextDataSearchPath, _LSL2SQLConnectionString, _RDS, mid);
|
||||
Job job = new(_LSL2SQLConnectionString, _RDS, mid);
|
||||
if (job.IsAreaSi)
|
||||
{
|
||||
IfxDoc sendReply = GetJobsReply(job);
|
||||
|
@ -98,8 +98,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);
|
||||
@ -107,9 +107,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);
|
||||
|
@ -899,7 +899,7 @@ public class ProcessData : IProcessData
|
||||
dataFile = ParseWaferSummary(i, dcnTotals, dwnTotals, dnnTotals);
|
||||
_Details.Add(dataFile);
|
||||
}
|
||||
fileInfoCollection.Add(new FileInfo(logistics.ReportFullPath));
|
||||
fileInfoCollection.Add(logistics.FileInfo);
|
||||
}
|
||||
|
||||
#nullable enable
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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; }
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user