diff --git a/Adaptation/FileHandlers/TIBCO/FileRead.cs b/Adaptation/FileHandlers/TIBCO/FileRead.cs index 5311a44..118d655 100644 --- a/Adaptation/FileHandlers/TIBCO/FileRead.cs +++ b/Adaptation/FileHandlers/TIBCO/FileRead.cs @@ -19,6 +19,7 @@ public class FileRead : Shared.FileRead, IFileRead public const string BarcodeHostFileShare = @"\\mesfs.infineon.com\EC_Metrology_Si\BarcodeHost\API"; public const string MetrologyFileShare = @"\\mesfs.infineon.com\EC_Metrology_Si\WorkMaterialOut\API"; public const string OpenInsightApplicationProgrammingInterface = @"http://oi-metrology-viewer-api.mes.infineon.com:8080/api/oiWizard"; + public const string IQSConnectionString = @"Data Source=messqlec1.infineon.com\PROD1,53959;Initial Catalog=IRMNSPC;Integrated Security=True"; public const string LSL2SQLConnectionString = @"Data Source=messqlec1.infineon.com\PROD1,53959;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;"; private long? _TickOffset; @@ -38,6 +39,9 @@ public class FileRead : Shared.FileRead, IFileRead string barcodeHostFileShare = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "Barcode.Host.FileShare"); if (barcodeHostFileShare != BarcodeHostFileShare) throw new NotSupportedException($"Update configuration for [{nameof(BarcodeHostFileShare)}]"); + string iqsConnectionString = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "IQS.ConnectionString"); + if (iqsConnectionString != IQSConnectionString) + throw new NotSupportedException($"Update configuration for [{nameof(IQSConnectionString)}]"); string lsl2SQLConnectionString = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "ConnectionString.LSL2SQL"); if (lsl2SQLConnectionString != LSL2SQLConnectionString) throw new NotSupportedException($"Update configuration for [{nameof(LSL2SQLConnectionString)}]"); @@ -53,14 +57,14 @@ public class FileRead : Shared.FileRead, IFileRead string tibcoParameterSubjectPrefix = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_SUBJECT_PREFIX"); string tibcoParameterConfigurationLocation = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_CONFIGURATION_LOCATION"); string tibcoParameterConfigurationLocationCopy = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_CONFIGURATION_LOCATION_LOCAL_COPY"); - if (!Directory.Exists(MetrologyFileShare)) + if (!Directory.Exists(metrologyFileShare)) throw new Exception($"Unable to access file-share <{MetrologyFileShare}>"); - if (!Directory.Exists(BarcodeHostFileShare)) + if (!Directory.Exists(barcodeHostFileShare)) throw new Exception($"Unable to access file-share <{BarcodeHostFileShare}>"); if (_IsEAFHosted) { - HttpClient httpClient = new() { BaseAddress = new(OpenInsightApplicationProgrammingInterface) }; - Transport.Main.Initialize(smtp, cellInstanceName, fileConnectorConfiguration, LSL2SQLConnectionString, MetrologyFileShare, BarcodeHostFileShare, httpClient); + HttpClient httpClient = new() { BaseAddress = new(openInsightApplicationProgrammingInterface) }; + Transport.Main.Initialize(smtp, cellInstanceName, fileConnectorConfiguration, iqsConnectionString, lsl2SQLConnectionString, metrologyFileShare, barcodeHostFileShare, httpClient); if (!string.IsNullOrEmpty(fileConnectorConfiguration.SourceFileLocation)) _ = Transport.Main.Setup(useSleep: true, setIfxTransport: true, tibcoParameterChannel, tibcoParameterSubjectPrefix, tibcoParameterConfigurationLocation, tibcoParameterConfigurationLocationCopy, tibcoParameterSubject); else diff --git a/Adaptation/FileHandlers/TIBCO/Transport/Job.cs b/Adaptation/FileHandlers/TIBCO/Transport/Job.cs index 7af641d..823462d 100644 --- a/Adaptation/FileHandlers/TIBCO/Transport/Job.cs +++ b/Adaptation/FileHandlers/TIBCO/Transport/Job.cs @@ -41,7 +41,7 @@ public partial class Job public DateTime DateTime { get; } public List Items { get; } - public Job(string lsl2SQLConnectionString, string metrologyFileShare, string barcodeHostFileShare, HttpClient httpClient, string mid, DateTime enteredDateTimeFilter, DateTime loadSignatureDateTimeFilter) + public Job(string iqsSQLConnectionString, string lsl2SQLConnectionString, string metrologyFileShare, string barcodeHostFileShare, HttpClient httpClient, string mid, DateTime enteredDateTimeFilter, DateTime loadSignatureDateTimeFilter) { const int zero = 0; Items = new List(); @@ -108,6 +108,20 @@ public partial class Job catch (Exception) { runDataSheetRoot = null; } } + string? basicType; + string? jobNames = GetJobNames(input); + if (string.IsNullOrEmpty(jobNames) || commonB.RDSNumber is null || commonB.ReactorNumber is null || string.IsNullOrEmpty(commonB.PSN)) + basicType = hyphen; + else + { + int? runCount; + string commandText = GetCommandText(commonB, jobNames); + try + { runCount = GetScalar(iqsSQLConnectionString, commandText); } + catch (Exception) + { runCount = null; } + basicType = runCount is null ? hyphen : runCount.ToString(); + } Qty = "1"; Status = hyphen; // INFO CreationUser = hyphen; // ? @@ -116,10 +130,10 @@ public partial class Job PackageName = hyphen; // WAFER_ID Qty2 = input.Sequence; // SEQUENCE RecipeName = input.Recipe; // PPID + BasicType = basicType; // BASIC_TYPE IsAreaSi = input.Area == "Si"; // N/A StateModel = input.EquipmentType; // ? JobName = DateTime.Ticks.ToString(); // ? - BasicType = GetComment(hyphen, runDataSheetRoot, commonB); // BASIC_TYPE AutomationMode = string.Concat(DateTime.Ticks, ".", input.MesEntity); // ? SpecName = !string.IsNullOrEmpty(commonB.Layer) ? commonB.Layer : hyphen; // LAYER ProductName = !string.IsNullOrEmpty(commonB.PSN) ? commonB.PSN : hyphen; // PRODUCT @@ -131,27 +145,6 @@ public partial class Job } } - private static string GetComment(string hyphen, RunDataSheetRoot? runDataSheetRoot, CommonB commonB) - { - string result; - string? loadLockSide = commonB.LoadLockSide; - if (string.IsNullOrEmpty(loadLockSide) && commonB.RDSNumber is not null) - loadLockSide = runDataSheetRoot?.RunDataSheet?.LoadLockSide; - if (string.IsNullOrEmpty(loadLockSide) || string.IsNullOrEmpty(commonB.ReactorType)) - result = hyphen; - else - { - string loadLockSideFull = loadLockSide switch - { - "L" => "Left", - "R" => "Right", - _ => loadLockSide, - }; - result = $"{loadLockSideFull} - {commonB.ReactorType}"; - } - return result; - } - private static int? GetReactorNumber(Input input) { int? result; @@ -564,12 +557,12 @@ public partial class Job return result; } - private static string GetRunJson(string lsl2SQLConnectionString, string commandText) + private static string GetRunJson(string connectionString, string commandText) { StringBuilder result = new(); try { - using SqlConnection sqlConnection = new(lsl2SQLConnectionString); + using SqlConnection sqlConnection = new(connectionString); sqlConnection.Open(); using SqlCommand sqlCommand = new(commandText, sqlConnection); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(CommandBehavior.SequentialAccess); @@ -788,4 +781,62 @@ public partial class Job zone: zone); } + private static string? GetJobNames(Input input) => + input.EquipmentType switch + { + "MET08ANLYSDIFAAST230" => "'SPV01'", + "MET08DDUPSFS6420" => "'TENCOR1','TENCOR2','TENCOR3'", + "MET08DDUPSP1TBI" => "'SP101'", + "MET08RESIHGCV" => "'HGCV1','HGCV2','HGCV3'", + "MET08RESIMAPCDE" => "'CDE1','CDE2','CDE3','CDE4','CDE5','CDE6'", + "MET08RESISRP2100" => "'SRP'", + "MET08THFTIRQS408M" => "'BIORAD2','BIORAD3','BIORAD4','BIORAD5'", + "MET08THFTIRSTRATUS" => "'BIORAD4','BIORAD5'", + _ => null, + }; + + private static string GetCommandText(CommonB commonB, string jobNames) + { // cSpell:disable + List results = new(); + results.Add(" select count(distinct(se.f_sgrp)) count_se_sgrp "); + results.Add(" from [spcepiworld].[dbo].[sgrp_ext] se "); + results.Add(" join [spcepiworld].[dbo].[prcs_dat] pr "); + results.Add(" on se.f_prcs = pr.f_prcs "); + results.Add(" join [spcepiworld].[dbo].[job_dat] jd "); + results.Add(" on se.f_job = jd.f_job "); + results.Add(" join [spcepiworld].[dbo].[part_lot] pl "); + results.Add(" on se.f_lot = pl.f_lot "); + results.Add(" join [spcepiworld].[dbo].[part_dat] pd "); + results.Add(" on se.f_part = pd.f_part "); + results.Add(" join [spcepiworld].[dbo].[test_dat] td "); + results.Add(" on se.f_test = td.f_test "); + results.Add(" where se.f_flag = 0 "); + results.Add($" and pl.f_name = '{commonB.RDSNumber}' "); + results.Add($" and pr.f_name = '{commonB.ReactorNumber}' "); + results.Add($" and pd.f_name = '{commonB.PSN}' "); + results.Add($" and jd.f_name in ({jobNames}) "); + return string.Join(Environment.NewLine, results); + } // cSpell:restore + + private static int? GetScalar(string connectionString, string commandText) + { + int? result; + try + { + using SqlConnection sqlConnection = new(connectionString); + sqlConnection.Open(); + using SqlCommand sqlCommand = new(commandText, sqlConnection); + object scalar = sqlCommand.ExecuteScalar(); + if (scalar is null || !int.TryParse(scalar.ToString(), out int value)) + result = null; + else + result = value; + } + catch (Exception) + { + result = null; + } + return result; + } + } \ No newline at end of file diff --git a/Adaptation/FileHandlers/TIBCO/Transport/Main.cs b/Adaptation/FileHandlers/TIBCO/Transport/Main.cs index d1e5f2e..accb9ec 100644 --- a/Adaptation/FileHandlers/TIBCO/Transport/Main.cs +++ b/Adaptation/FileHandlers/TIBCO/Transport/Main.cs @@ -17,19 +17,21 @@ internal partial class Main private static object _IfxTransport; private static string _CellInstanceName; private static string _MetrologyFileShare; + private static string _IQSConnectionString; private static string _BarcodeHostFileShare; private static string _LSL2SQLConnectionString; private static string _TibcoParameterSubjectPrefix; private static HttpClient _HttpClient; private static FileConnectorConfiguration _FileConnectorConfiguration; - internal static void Initialize(ISMTP smtp, string cellInstanceName, FileConnectorConfiguration fileConnectorConfiguration, string lsl2SQLConnectionString, string metrologyFileShare, string barcodeHostFileShare, HttpClient httpClient) + internal static void Initialize(ISMTP smtp, string cellInstanceName, FileConnectorConfiguration fileConnectorConfiguration, string iqsConnectionString, string lsl2SQLConnectionString, string metrologyFileShare, string barcodeHostFileShare, HttpClient httpClient) { _SMTP = smtp; _IfxTransport = null; _HttpClient = httpClient; _CellInstanceName = cellInstanceName; _MetrologyFileShare = metrologyFileShare; + _IQSConnectionString = iqsConnectionString; _TibcoParameterSubjectPrefix = string.Empty; _BarcodeHostFileShare = barcodeHostFileShare; _LSL2SQLConnectionString = lsl2SQLConnectionString; @@ -190,7 +192,7 @@ internal partial class Main string mid = GetJobsMID(envelopeDocument); DateTime enteredDateTimeFilter = dateTime.AddDays(-356); DateTime loadSignatureDateTimeFilter = dateTime.AddDays(-4); - Job job = new(_LSL2SQLConnectionString, _MetrologyFileShare, _BarcodeHostFileShare, _HttpClient, mid, enteredDateTimeFilter, loadSignatureDateTimeFilter); + Job job = new(_IQSConnectionString, _LSL2SQLConnectionString, _MetrologyFileShare, _BarcodeHostFileShare, _HttpClient, mid, enteredDateTimeFilter, loadSignatureDateTimeFilter); if (job.IsAreaSi) { IfxDoc sendReply = GetJobsReply(job); diff --git a/Adaptation/FileHandlers/TIBCO/Transport/RunDataSheet.cs b/Adaptation/FileHandlers/TIBCO/Transport/RunDataSheet.cs index 481bc17..98ced06 100644 --- a/Adaptation/FileHandlers/TIBCO/Transport/RunDataSheet.cs +++ b/Adaptation/FileHandlers/TIBCO/Transport/RunDataSheet.cs @@ -6,15 +6,17 @@ public class RunDataSheet { [JsonConstructor] - public RunDataSheet(string loadLockSide, int psn, int reactor) + public RunDataSheet(string loadLockSide, int psn, int reactor, string reactorType) { PSN = psn; LoadLockSide = loadLockSide; Reactor = reactor; + ReactorType = reactorType; } [JsonPropertyName("loadLockSide")] public string LoadLockSide { get; } // { init; get; } [JsonPropertyName("PSN")] public int PSN { get; } // { init; get; } [JsonPropertyName("reactor")] public int Reactor { get; } // { init; get; } + [JsonPropertyName("reactorType")] public string ReactorType { get; } // { init; get; } } \ No newline at end of file