diff --git a/Adaptation/.vscode/settings.json b/Adaptation/.vscode/settings.json index 10ac5ce..d5513a1 100644 --- a/Adaptation/.vscode/settings.json +++ b/Adaptation/.vscode/settings.json @@ -17,6 +17,7 @@ "lsid", "messa", "messv", + "NETFRAMEWORK", "NOPAUSE", "PDFC", "PDSF", diff --git a/Adaptation/FileHandlers/MoveAllFiles/ApiController/BarcodeController.cs b/Adaptation/FileHandlers/MoveAllFiles/ApiController/BarcodeController.cs index efd26a6..152fada 100644 --- a/Adaptation/FileHandlers/MoveAllFiles/ApiController/BarcodeController.cs +++ b/Adaptation/FileHandlers/MoveAllFiles/ApiController/BarcodeController.cs @@ -1,10 +1,7 @@ -#if SelfHost -using System; -using System.Globalization; -using System.IO; -using System.Text.Json; -using System.Threading.Tasks; +#if NETFRAMEWORK && NET48 +using Adaptation.FileHandlers.TIBCO.Transport; using System.Web.Http; +using System.Web.Http.Results; namespace Adaptation.FileHandlers.MoveAllFiles.ApiController; @@ -15,50 +12,20 @@ public class BarcodeController : System.Web.Http.ApiController #nullable enable #pragma warning disable CA1822 - public string Get() + public OkNegotiatedContentResult Get() #pragma warning restore CA1822 { - string results = "record"; - return results; - } - - private static string? GetJson(System.Net.Http.HttpContent? httpContent) - { - string? result; - if (httpContent is null) - result = null; - else - { - Task task = httpContent.ReadAsStringAsync(); - task.Wait(); - result = task.Result; - } - return result; - } - - private static void Write(string barcodeHostFileShare, string cellInstanceConnectionName, Notification notification) - { - DateTime dateTime = DateTime.Now; - Calendar calendar = new CultureInfo("en-US").Calendar; - string weekOfYear = $"{dateTime:yyyy}_Week_{calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday):00}"; - string directory = Path.Combine(barcodeHostFileShare, weekOfYear, dateTime.ToString("yyyy-MM-dd_HH")); - if (!Directory.Exists(directory)) - _ = Directory.CreateDirectory(directory); - File.WriteAllText(Path.Combine(directory, $"{cellInstanceConnectionName}.csv"), notification.LastScanServiceResultValue); + string result = "record"; + return Ok(result); } [Route("{id}")] #pragma warning disable CA1822 - public void Post(string id) + public JsonResult Post(string id) #pragma warning restore CA1822 { - string? json = GetJson(Request.Content); - if (json is not null) - { - Notification? notification = JsonSerializer.Deserialize(json); - if (notification is not null) - Write(FileRead.BarcodeHostFileShare, id, notification.Value); - } + PostReplay? postReplay = BarcodeHelper.Post(id, Request.Content); + return Json(postReplay); } } diff --git a/Adaptation/FileHandlers/MoveAllFiles/ApiController/BarcodeHelper.cs b/Adaptation/FileHandlers/MoveAllFiles/ApiController/BarcodeHelper.cs new file mode 100644 index 0000000..a6a8230 --- /dev/null +++ b/Adaptation/FileHandlers/MoveAllFiles/ApiController/BarcodeHelper.cs @@ -0,0 +1,77 @@ +using Adaptation.FileHandlers.TIBCO.Transport; +using System; +using System.Globalization; +using System.IO; +using System.Text.Json; +using System.Threading.Tasks; + +namespace Adaptation.FileHandlers.MoveAllFiles.ApiController; + +public class BarcodeHelper +{ + +#nullable enable + + private static string? GetJson(System.Net.Http.HttpContent? httpContent) + { + string? result; + if (httpContent is null) + result = null; + else + { + Task task = httpContent.ReadAsStringAsync(); + task.Wait(); + result = task.Result; + } + return result; + } + + private static void Write(string barcodeHostFileShare, string cellInstanceConnectionName, Notification notification) + { + DateTime dateTime = DateTime.Now; + Calendar calendar = new CultureInfo("en-US").Calendar; + string weekOfYear = $"{dateTime:yyyy}_Week_{calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday):00}"; + string directory = Path.Combine(barcodeHostFileShare, weekOfYear, dateTime.ToString("yyyy-MM-dd_HH")); + if (!Directory.Exists(directory)) + _ = Directory.CreateDirectory(directory); + File.WriteAllText(Path.Combine(directory, $"{cellInstanceConnectionName}.csv"), notification.LastScanServiceResultValue); + } + + private static Job GetJob(string lsl2SQLConnectionString, string metrologyFileShare, string barcodeHostFileShare, string id, Notification notification) + { + Job result; + string lastScan = notification.LastScanServiceResultValue.Length < 3 || notification.LastScanServiceResultValue[1] is not 't' and not 'T' || notification.LastScanServiceResultValue[0] != '1' ? notification.LastScanServiceResultValue : notification.LastScanServiceResultValue.Substring(2); + string json = string.Concat("{\"Area\": \"Si\", \"EquipmentType\": \"MET08THFTIRQS408M\", \"MesEntity\": \"", id, "\", \"Sequence\": \"", notification.KeyPressEvent.DateTime.Ticks, "\", \"MID\": \"-", lastScan, "-\", \"Recipe\": \"Recipe\"}"); + result = new(lsl2SQLConnectionString, metrologyFileShare, barcodeHostFileShare, json); + return result; + } + + internal static PostReplay? Post(string id, System.Net.Http.HttpContent? httpContent) + { + PostReplay? result; + string? json = GetJson(httpContent); + if (json is null) + result = null; + else + { + Notification? notification = JsonSerializer.Deserialize(json); + if (notification is null) + result = null; + else + { + const string hyphen = "-"; + Write(TIBCO.FileRead.BarcodeHostFileShare, id, notification.Value); + Job job = GetJob(TIBCO.FileRead.LSL2SQLConnectionString, TIBCO.FileRead.MetrologyFileShare, TIBCO.FileRead.BarcodeHostFileShare, id, notification.Value); + string mid = job.SpecName == hyphen || job.ProcessSpecName == hyphen ? $"{job.ProcessType}" : $"{job.ProcessType}.{job.SpecName}.{job.ProcessSpecName}"; + try + { + // https://oi-prod-ec-api.mes.infineon.com/api/oiWizard/materials/rds/ + } + catch (Exception) { } + result = new(job, mid, job.RecipeName); + } + } + return result; + } + +} \ No newline at end of file diff --git a/Adaptation/FileHandlers/MoveAllFiles/ApiController/Notification.cs b/Adaptation/FileHandlers/MoveAllFiles/ApiController/Notification.cs index f82ea54..7db86e6 100644 --- a/Adaptation/FileHandlers/MoveAllFiles/ApiController/Notification.cs +++ b/Adaptation/FileHandlers/MoveAllFiles/ApiController/Notification.cs @@ -2,6 +2,7 @@ namespace Adaptation.FileHandlers.MoveAllFiles.ApiController; public readonly struct Notification { + public KeyPressEvent KeyPressEvent { get; } public string LastScanServiceResultValue { get; } diff --git a/Adaptation/FileHandlers/MoveAllFiles/ApiController/PostReplay.cs b/Adaptation/FileHandlers/MoveAllFiles/ApiController/PostReplay.cs new file mode 100644 index 0000000..bcb1f58 --- /dev/null +++ b/Adaptation/FileHandlers/MoveAllFiles/ApiController/PostReplay.cs @@ -0,0 +1,20 @@ +using Adaptation.FileHandlers.TIBCO.Transport; + +namespace Adaptation.FileHandlers.MoveAllFiles.ApiController; + +public class PostReplay +{ + + public Job Job { get; } + public string MId { get; } + public string Recipe { get; } + + [System.Text.Json.Serialization.JsonConstructor] + public PostReplay(Job job, string mid, string recipe) + { + Job = job; + MId = mid; + Recipe = recipe; + } + +} \ No newline at end of file diff --git a/Adaptation/FileHandlers/MoveAllFiles/FileRead.cs b/Adaptation/FileHandlers/MoveAllFiles/FileRead.cs index 7dd98f1..0f24843 100644 --- a/Adaptation/FileHandlers/MoveAllFiles/FileRead.cs +++ b/Adaptation/FileHandlers/MoveAllFiles/FileRead.cs @@ -7,7 +7,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Text.Json; -#if SelfHost +#if NETFRAMEWORK && NET48 using System.Web.Http; using System.Web.Http.SelfHost; #endif @@ -20,12 +20,10 @@ public class FileRead : Shared.FileRead, IFileRead #nullable enable private long? _TickOffset; -#if SelfHost +#if NETFRAMEWORK && NET48 private readonly HttpSelfHostServer? _HttpSelfHostServer; #endif - public const string BarcodeHostFileShare = @"\\messv02ecc1.ec.local\EC_Metrology_Si\BarcodeHost\API"; // GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "BarcodeHost.FileShare"); - public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) { @@ -38,7 +36,7 @@ public class FileRead : Shared.FileRead, IFileRead throw new Exception(cellInstanceConnectionName); if (_IsDuplicator) throw new Exception(cellInstanceConnectionName); -#if SelfHost +#if NETFRAMEWORK && NET48 if (!_IsEAFHosted) _HttpSelfHostServer = null; else @@ -127,7 +125,6 @@ public class FileRead : Shared.FileRead, IFileRead _TickOffset ??= new FileInfo(reportFullPath).LastWriteTime.Ticks - dateTime.Ticks; _Logistics = new Logistics(this, _TickOffset.Value, reportFullPath, useSplitForMID: true); SetFileParameterLotIDToLogisticsMID(); - return results; } diff --git a/Adaptation/FileHandlers/TIBCO/FileRead.cs b/Adaptation/FileHandlers/TIBCO/FileRead.cs index 25b2d92..a5ffc99 100644 --- a/Adaptation/FileHandlers/TIBCO/FileRead.cs +++ b/Adaptation/FileHandlers/TIBCO/FileRead.cs @@ -15,8 +15,11 @@ public class FileRead : Shared.FileRead, IFileRead #nullable enable + public const string BarcodeHostFileShare = @"\\messv02ecc1.ec.local\EC_Metrology_Si\BarcodeHost\API"; + public const string MetrologyFileShare = @"\\messv02ecc1.ec.local\EC_Metrology_Si\WorkMaterialOut\API"; + public const string LSL2SQLConnectionString = @"Data Source=10.95.128.28\\PROD1,53959;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;"; + private long? _TickOffset; - private readonly string _BarcodeHostFileShare; public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, Dictionary> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) @@ -31,21 +34,27 @@ public class FileRead : Shared.FileRead, IFileRead if (!_IsDuplicator) throw new Exception(cellInstanceConnectionName); string metrologyFileShare = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "Metrology.FileShare"); - _BarcodeHostFileShare = @"\\messv02ecc1.ec.local\EC_Metrology_Si\BarcodeHost\API"; // GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "BarcodeHost.FileShare"); + if (metrologyFileShare != MetrologyFileShare) + throw new NotSupportedException($"Update configuration for [{nameof(MetrologyFileShare)}]"); + string barcodeHostFileShare = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "BarcodeHost.FileShare"); + if (barcodeHostFileShare != BarcodeHostFileShare) + throw new NotSupportedException($"Update configuration for [{nameof(BarcodeHostFileShare)}]"); string lsl2SQLConnectionString = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "ConnectionString.LSL2SQL"); + if (lsl2SQLConnectionString != LSL2SQLConnectionString) + throw new NotSupportedException($"Update configuration for [{nameof(LSL2SQLConnectionString)}]"); ModelObjectParameterDefinition[] tibcoParameters = GetProperties(cellInstanceConnectionName, modelObjectParameters, "TIBCO."); string tibcoParameterChannel = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_CHANNEL"); string tibcoParameterSubject = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_SUBJECT"); 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)) - throw new Exception($"Unable to access file-share <{metrologyFileShare}>"); - if (!Directory.Exists(_BarcodeHostFileShare)) - throw new Exception($"Unable to access file-share <{_BarcodeHostFileShare}>"); + if (!Directory.Exists(MetrologyFileShare)) + throw new Exception($"Unable to access file-share <{MetrologyFileShare}>"); + if (!Directory.Exists(BarcodeHostFileShare)) + throw new Exception($"Unable to access file-share <{BarcodeHostFileShare}>"); if (_IsEAFHosted) { - Transport.Main.Initialize(smtp, cellInstanceName, fileConnectorConfiguration, lsl2SQLConnectionString, metrologyFileShare, _BarcodeHostFileShare); + Transport.Main.Initialize(smtp, cellInstanceName, fileConnectorConfiguration, LSL2SQLConnectionString, MetrologyFileShare, BarcodeHostFileShare); if (!string.IsNullOrEmpty(fileConnectorConfiguration.SourceFileLocation)) _ = Transport.Main.Setup(useSleep: true, setIfxTransport: true, tibcoParameterChannel, tibcoParameterSubjectPrefix, tibcoParameterConfigurationLocation, tibcoParameterConfigurationLocationCopy, tibcoParameterSubject); else diff --git a/Adaptation/MET08DDUPSP1TBI.Tests.csproj b/Adaptation/MET08DDUPSP1TBI.Tests.csproj index 9c9a2a3..eadfa41 100644 --- a/Adaptation/MET08DDUPSP1TBI.Tests.csproj +++ b/Adaptation/MET08DDUPSP1TBI.Tests.csproj @@ -43,7 +43,6 @@ NU1701 NU1701 - diff --git a/MET08DDUPSP1TBI.csproj b/MET08DDUPSP1TBI.csproj index 03e3af4..40e2cae 100644 --- a/MET08DDUPSP1TBI.csproj +++ b/MET08DDUPSP1TBI.csproj @@ -48,6 +48,9 @@ prompt MinimumRecommendedRules.ruleset + + NETFRAMEWORK;NET20;NET35;NET40;NET45;NET451;NET452;NET46;NET461;NET462;NET47;NET471;NET472;NET48;$(DefineConstants) + @@ -103,10 +106,12 @@ + + @@ -179,6 +184,12 @@ 2.49.2 + + 5.2.7 + + + 5.2.7 + 6.0.3