Ready to test
This commit is contained in:
@ -6,6 +6,7 @@ using Adaptation.Shared.Methods;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Adaptation.FileHandlers.TIBCO;
|
||||
@ -17,6 +18,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-prod-ec-api.mes.infineon.com/api/oiWizard";
|
||||
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;
|
||||
@ -42,6 +44,9 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
string metrologyFileShare = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "Metrology.FileShare");
|
||||
if (metrologyFileShare != MetrologyFileShare)
|
||||
throw new NotSupportedException($"Update configuration for [{nameof(MetrologyFileShare)}]");
|
||||
string openInsightApplicationProgrammingInterface = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.Application.Programming.Interface");
|
||||
if (openInsightApplicationProgrammingInterface != OpenInsightApplicationProgrammingInterface)
|
||||
throw new NotSupportedException($"Update configuration for [{nameof(OpenInsightApplicationProgrammingInterface)}]");
|
||||
ModelObjectParameterDefinition[] tibcoParameters = GetProperties(cellInstanceConnectionName, modelObjectParameters, "TIBCO.");
|
||||
string tibcoParameterChannel = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_CHANNEL");
|
||||
string tibcoParameterSubject = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_SUBJECT");
|
||||
@ -54,7 +59,8 @@ public class FileRead : Shared.FileRead, IFileRead
|
||||
throw new Exception($"Unable to access file-share <{BarcodeHostFileShare}>");
|
||||
if (_IsEAFHosted)
|
||||
{
|
||||
Transport.Main.Initialize(smtp, cellInstanceName, fileConnectorConfiguration, LSL2SQLConnectionString, MetrologyFileShare, BarcodeHostFileShare);
|
||||
HttpClient httpClient = new() { BaseAddress = new(OpenInsightApplicationProgrammingInterface) };
|
||||
Transport.Main.Initialize(smtp, cellInstanceName, fileConnectorConfiguration, LSL2SQLConnectionString, MetrologyFileShare, BarcodeHostFileShare, httpClient);
|
||||
if (!string.IsNullOrEmpty(fileConnectorConfiguration.SourceFileLocation))
|
||||
_ = Transport.Main.Setup(useSleep: true, setIfxTransport: true, tibcoParameterChannel, tibcoParameterSubjectPrefix, tibcoParameterConfigurationLocation, tibcoParameterConfigurationLocationCopy, tibcoParameterSubject);
|
||||
else
|
||||
|
@ -5,9 +5,11 @@ using System.Data.SqlClient;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Adaptation.FileHandlers.TIBCO.Transport;
|
||||
|
||||
@ -37,7 +39,7 @@ public partial class Job
|
||||
public DateTime DateTime { get; }
|
||||
public List<Item> Items { get; }
|
||||
|
||||
public Job(string lsl2SQLConnectionString, string metrologyFileShare, string barcodeHostFileShare, string mid)
|
||||
public Job(string lsl2SQLConnectionString, string metrologyFileShare, string barcodeHostFileShare, HttpClient httpClient, string mid)
|
||||
{
|
||||
const int zero = 0;
|
||||
Items = new List<Item>();
|
||||
@ -59,7 +61,10 @@ public partial class Job
|
||||
DateTime = DateTime.Now;
|
||||
else
|
||||
DateTime = new DateTime(sequence);
|
||||
if (!string.IsNullOrEmpty(input.MID) && !string.IsNullOrEmpty(input.MesEntity) && Regex.IsMatch(input.MID, reactorNumberPattern) && input.MesEntity is bioRad2 or bioRad3)
|
||||
const string dep08CEPIEPSILON = "DEP08CEPIEPSILON";
|
||||
if (input.EquipmentType == dep08CEPIEPSILON)
|
||||
(common, workOrder) = Get(input, httpClient);
|
||||
else if (!string.IsNullOrEmpty(input.MID) && !string.IsNullOrEmpty(input.MesEntity) && Regex.IsMatch(input.MID, reactorNumberPattern) && input.MesEntity is bioRad2 or bioRad3)
|
||||
(common, workOrder) = Get(input, barcodeHostFileShare);
|
||||
else
|
||||
{
|
||||
@ -348,6 +353,63 @@ public partial class Job
|
||||
return result;
|
||||
}
|
||||
|
||||
private static (Common common, WorkOrder workOrder) Get(Input input, HttpClient httpClient)
|
||||
{
|
||||
int? rds;
|
||||
string psn;
|
||||
Common common;
|
||||
WorkOrder workOrder;
|
||||
Task<Stream> streamTask;
|
||||
string zone = string.Empty;
|
||||
string layer = string.Empty;
|
||||
Task<HttpResponseMessage> httpResponseMessageTask;
|
||||
JsonSerializerOptions jsonSerializerOptions = new() { PropertyNameCaseInsensitive = true };
|
||||
int? reactor = !int.TryParse(input.MID.Substring(0, 2), out int reactorNumber) ? null : reactorNumber;
|
||||
httpResponseMessageTask = httpClient.GetAsync($"{httpClient.BaseAddress}/reactors/{reactor}");
|
||||
httpResponseMessageTask.Wait();
|
||||
if (httpResponseMessageTask.Result.StatusCode != System.Net.HttpStatusCode.OK)
|
||||
throw new Exception($"Unable to OI <{httpResponseMessageTask.Result.StatusCode}>");
|
||||
streamTask = httpResponseMessageTask.Result.Content.ReadAsStreamAsync();
|
||||
streamTask.Wait();
|
||||
if (!streamTask.Result.CanRead)
|
||||
throw new NullReferenceException(nameof(streamTask));
|
||||
ReactorRoot? reactorRoot = JsonSerializer.Deserialize<ReactorRoot>(streamTask.Result, jsonSerializerOptions);
|
||||
streamTask.Result.Dispose();
|
||||
if (reactorRoot is null || reactor != reactorRoot.Reactor.ReactorNo || reactorRoot.Reactor.LoadedRDS is null || reactorRoot.Reactor.LoadedRDS.Length < 1)
|
||||
{
|
||||
rds = null;
|
||||
psn = string.Empty;
|
||||
workOrder = new(null, null, null, null, false);
|
||||
common = new(layer, psn, rds, reactor, zone);
|
||||
}
|
||||
else
|
||||
{
|
||||
rds = reactorRoot.Reactor.LoadedRDS[0];
|
||||
workOrder = new(null, null, null, null, false);
|
||||
httpResponseMessageTask = httpClient.GetAsync($"{httpClient.BaseAddress}/materials/rds/{rds}");
|
||||
httpResponseMessageTask.Wait();
|
||||
if (httpResponseMessageTask.Result.StatusCode != System.Net.HttpStatusCode.OK)
|
||||
throw new Exception($"Unable to OI <{httpResponseMessageTask.Result.StatusCode}>");
|
||||
streamTask = httpResponseMessageTask.Result.Content.ReadAsStreamAsync();
|
||||
streamTask.Wait();
|
||||
if (!streamTask.Result.CanRead)
|
||||
throw new NullReferenceException(nameof(streamTask));
|
||||
RunDataSheetRoot? runDataSheetRoot = JsonSerializer.Deserialize<RunDataSheetRoot>(streamTask.Result, jsonSerializerOptions);
|
||||
streamTask.Result.Dispose();
|
||||
if (runDataSheetRoot is null || reactor != runDataSheetRoot.RunDataSheet.Reactor)
|
||||
{
|
||||
psn = string.Empty;
|
||||
common = new(layer, psn, rds, reactor, zone);
|
||||
}
|
||||
else
|
||||
{
|
||||
psn = runDataSheetRoot.RunDataSheet.PSN.ToString();
|
||||
common = new(layer, psn, rds, reactor, zone);
|
||||
}
|
||||
}
|
||||
return new(common, workOrder);
|
||||
}
|
||||
|
||||
private static (Common common, WorkOrder workOrder) Get(Input input, string barcodeHostFileShare)
|
||||
{
|
||||
if (string.IsNullOrEmpty(barcodeHostFileShare) || !Directory.Exists(barcodeHostFileShare))
|
||||
|
@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
|
||||
namespace Adaptation.FileHandlers.TIBCO.Transport;
|
||||
@ -19,12 +20,14 @@ internal partial class Main
|
||||
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)
|
||||
internal static void Initialize(ISMTP smtp, string cellInstanceName, FileConnectorConfiguration fileConnectorConfiguration, string lsl2SQLConnectionString, string metrologyFileShare, string barcodeHostFileShare, HttpClient httpClient)
|
||||
{
|
||||
_SMTP = smtp;
|
||||
_IfxTransport = null;
|
||||
_HttpClient = httpClient;
|
||||
_CellInstanceName = cellInstanceName;
|
||||
_MetrologyFileShare = metrologyFileShare;
|
||||
_TibcoParameterSubjectPrefix = string.Empty;
|
||||
@ -186,7 +189,7 @@ internal partial class Main
|
||||
if (!subject.Contains(_TibcoParameterSubjectPrefix))
|
||||
throw new Exception("Invalid Subject");
|
||||
mid = GetJobsMID(envelopeDocument);
|
||||
Job job = new(_LSL2SQLConnectionString, _MetrologyFileShare, _BarcodeHostFileShare, mid);
|
||||
Job job = new(_LSL2SQLConnectionString, _MetrologyFileShare, _BarcodeHostFileShare, _HttpClient, mid);
|
||||
if (job.IsAreaSi)
|
||||
{
|
||||
IfxDoc sendReply = GetJobsReply(job);
|
||||
|
18
Adaptation/FileHandlers/TIBCO/Transport/Reactor.cs
Normal file
18
Adaptation/FileHandlers/TIBCO/Transport/Reactor.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Adaptation.FileHandlers.TIBCO.Transport;
|
||||
|
||||
public class Reactor
|
||||
{
|
||||
|
||||
[JsonConstructor]
|
||||
public Reactor(int reactorNo, int[] loadedRDS)
|
||||
{
|
||||
ReactorNo = reactorNo;
|
||||
LoadedRDS = loadedRDS;
|
||||
}
|
||||
|
||||
[JsonPropertyName("reactorNo")] public int ReactorNo { get; } // { init; get; }
|
||||
[JsonPropertyName("loadedRDS")] public int[] LoadedRDS { get; } // { init; get; }
|
||||
|
||||
}
|
14
Adaptation/FileHandlers/TIBCO/Transport/ReactorRoot.cs
Normal file
14
Adaptation/FileHandlers/TIBCO/Transport/ReactorRoot.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Adaptation.FileHandlers.TIBCO.Transport;
|
||||
|
||||
public class ReactorRoot
|
||||
{
|
||||
|
||||
[JsonConstructor]
|
||||
public ReactorRoot(Reactor reactor) =>
|
||||
Reactor = reactor;
|
||||
|
||||
[JsonPropertyName("reactor")] public Reactor Reactor { get; } // { init; get; }
|
||||
|
||||
}
|
18
Adaptation/FileHandlers/TIBCO/Transport/RunDataSheet.cs
Normal file
18
Adaptation/FileHandlers/TIBCO/Transport/RunDataSheet.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Adaptation.FileHandlers.TIBCO.Transport;
|
||||
|
||||
public class RunDataSheet
|
||||
{
|
||||
|
||||
[JsonConstructor]
|
||||
public RunDataSheet(int psn, int reactor)
|
||||
{
|
||||
PSN = psn;
|
||||
Reactor = reactor;
|
||||
}
|
||||
|
||||
[JsonPropertyName("PSN")] public int PSN { get; } // { init; get; }
|
||||
[JsonPropertyName("reactor")] public int Reactor { get; } // { init; get; }
|
||||
|
||||
}
|
14
Adaptation/FileHandlers/TIBCO/Transport/RunDataSheetRoot.cs
Normal file
14
Adaptation/FileHandlers/TIBCO/Transport/RunDataSheetRoot.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Adaptation.FileHandlers.TIBCO.Transport;
|
||||
|
||||
public class RunDataSheetRoot
|
||||
{
|
||||
|
||||
[JsonConstructor]
|
||||
public RunDataSheetRoot(RunDataSheet runDataSheet) =>
|
||||
RunDataSheet = runDataSheet;
|
||||
|
||||
[JsonPropertyName("rds")] public RunDataSheet RunDataSheet { get; } // { init; get; }
|
||||
|
||||
}
|
Reference in New Issue
Block a user