MET08DDUPSP1TBI - v2.43.0 - FileInfo added GetMID

This commit is contained in:
2022-06-29 13:03:23 -07:00
parent 44a2e5e67d
commit 48bba76f11
7 changed files with 174 additions and 196 deletions

View File

@ -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

View File

@ -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)
_RDS[rds].Add(new(input.MID, 1));
else
bool rdsCollectionCountIsZero = _RDS[rds].Count == 0;
if (rdsCollectionCountIsZero)
{
if (!string.IsNullOrEmpty(reactor) && !string.IsNullOrEmpty(psn))
_RDS[rds].Add(new(input.MID, 1));
else
{
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)
{
IEnumerable<IGrouping<string, (string MID, int Count)>> grouped = collection.GroupBy(l => l.MID);
orderedMatches.AddRange(from l in grouped orderby l.Count() descending select l);
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)
private static string GetMID(string lsl2SQLConnectionString, int rds)
{
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)
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
{
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) { }
}
}
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;
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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