From ef74d7a85a46bf5af4ab452ac083ac1ed46e629a Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Tue, 22 Mar 2022 12:08:11 -0700 Subject: [PATCH] Put OpenInsightCommonGatewayInterfaceReactorStatesStatus --- Adaptation/.vscode/settings.json | 2 + .../FileHandlers/DEP08SIASM/FileRead.cs | 14 +++-- .../FileHandlers/DEP08SIASM/ProcessData.cs | 53 ++++++++----------- Adaptation/package.json | 1 + DEP08SIASM.csproj | 7 ++- 5 files changed, 42 insertions(+), 35 deletions(-) diff --git a/Adaptation/.vscode/settings.json b/Adaptation/.vscode/settings.json index 8ab3838..bbb2c04 100644 --- a/Adaptation/.vscode/settings.json +++ b/Adaptation/.vscode/settings.json @@ -29,11 +29,13 @@ "pdsfc", "PPID", "pptst", + "reactno", "RPMPL", "RPMXY", "rtsp", "RUNMO", "SIASM", + "statusdtm", "stddev", "Stks", "SUMMO", diff --git a/Adaptation/FileHandlers/DEP08SIASM/FileRead.cs b/Adaptation/FileHandlers/DEP08SIASM/FileRead.cs index 29d3ae7..8c2ef36 100644 --- a/Adaptation/FileHandlers/DEP08SIASM/FileRead.cs +++ b/Adaptation/FileHandlers/DEP08SIASM/FileRead.cs @@ -10,6 +10,7 @@ using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; +using System.Net; using System.Reflection; using System.Text.Json; using System.Text.Json.Serialization; @@ -23,11 +24,11 @@ public class FileRead : Shared.FileRead, IFileRead private readonly bool _IsXToAPC; private readonly bool _IsXToIQSSi; private readonly string _MemoryPath; + private readonly HttpClient _HttpClient; private readonly bool _IsXToOpenInsight; private readonly bool _IsXToOpenInsightMetrologyViewer; private readonly Dictionary _CellNames; private readonly bool _IsXToOpenInsightMetrologyViewerAttachments; - private readonly string _OpenInsightCommonGatewayInterfaceContacts; public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted) : base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted) @@ -49,9 +50,14 @@ public class FileRead : Shared.FileRead, IFileRead _MemoryPath = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "Path.Memory"); _IsXToOpenInsightMetrologyViewerAttachments = _Hyphens == (int)Hyphen.IsXToOpenInsightMetrologyViewerAttachments; ModelObjectParameterDefinition[] cellInstanceCollection = GetProperties(cellInstanceConnectionName, modelObjectParameters, "CellInstance.", ".Path"); - _OpenInsightCommonGatewayInterfaceContacts = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.CommonGatewayInterface.Contacts"); foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in cellInstanceCollection) _CellNames.Add(modelObjectParameterDefinition.Name.Split('.')[1], modelObjectParameterDefinition.Value); + if (_IsXToOpenInsight) + { + _HttpClient = new(); + string openInsightCommonGatewayInterfaceReactorStatesStatus = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.CommonGatewayInterface.ReactorStates.Status"); + _HttpClient.BaseAddress = new(openInsightCommonGatewayInterfaceReactorStatesStatus); + } } void IFileRead.Move(Tuple> extractResults, Exception exception) => Move(extractResults, exception); @@ -202,8 +208,10 @@ public class FileRead : Shared.FileRead, IFileRead throw new Exception($"Only {nameof(_IsXToOpenInsight)} is codded!"); else if (_IsXToOpenInsight) { + if (_HttpClient is null) + throw new Exception($"{nameof(_HttpClient)} is null!"); if (!isDummyRun && _IsEAFHosted) - ProcessData.PostOpenInsightCommonGatewayInterfaceContacts(this, _Logistics, _OpenInsightCommonGatewayInterfaceContacts, dateTime, logisticsSequenceMemoryDirectory, descriptions); + ProcessData.PutOpenInsightCommonGatewayInterfaceReactorStatesStatus(this, _Logistics, _HttpClient, descriptions); } else throw new Exception(); diff --git a/Adaptation/FileHandlers/DEP08SIASM/ProcessData.cs b/Adaptation/FileHandlers/DEP08SIASM/ProcessData.cs index 1de97e4..56a187f 100644 --- a/Adaptation/FileHandlers/DEP08SIASM/ProcessData.cs +++ b/Adaptation/FileHandlers/DEP08SIASM/ProcessData.cs @@ -35,40 +35,31 @@ public class ProcessData return result.ToString(); } - internal static void PostOpenInsightMetrologyViewerAttachments(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, DateTime dateTime, string logisticsSequenceMemoryDirectory, List descriptions, string matchDirectory) + internal static async void PutOpenInsightCommonGatewayInterfaceReactorStatesStatus(IFileRead fileRead, Logistics logistics, HttpClient httpClient, List descriptions) { if (fileRead is null) { } - if (logistics is null) - { } - if (openInsightMetrologyViewerAPI is null) - { } - if (dateTime == DateTime.MinValue) - { } - if (logisticsSequenceMemoryDirectory is null) - { } - if (descriptions is null) - { } - if (matchDirectory is null) - { } - //Not used - } - - internal static void PostOpenInsightCommonGatewayInterfaceContacts(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, DateTime dateTime, string logisticsSequenceMemoryDirectory, List descriptions) - { - if (fileRead is null) - { } - if (logistics is null) - { } - if (openInsightMetrologyViewerAPI is null) - { } - if (dateTime == DateTime.MinValue) - { } - if (logisticsSequenceMemoryDirectory is null) - { } - if (descriptions is null) - { } - //Not used + HttpContent httpContent = null; + string status = descriptions[0].MID; + string reactorNumber = logistics.MesEntity.Substring(1); + string statusDateTime = logistics.DateTimeFromSequence.ToString("MM-dd-yyyy HH:mm:ss"); + Uri uri = new($"{httpClient.BaseAddress.OriginalString}reactno={reactorNumber}&status={status}&statusdtm={statusDateTime}"); + try + { + HttpResponseMessage httpResponseMessage = await httpClient.PutAsync(uri, httpContent); + if (httpResponseMessage.StatusCode is System.Net.HttpStatusCode.OK) + { + string content = await httpResponseMessage.Content.ReadAsStringAsync(); + if (string.IsNullOrEmpty(content)) + { } + } + } + catch (Exception ex) + { + status = ex.Message; + if (string.IsNullOrEmpty(status)) + { } + } } } \ No newline at end of file diff --git a/Adaptation/package.json b/Adaptation/package.json index b0c9739..38df114 100644 --- a/Adaptation/package.json +++ b/Adaptation/package.json @@ -2,6 +2,7 @@ "scripts": { "Alpha": "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "build": "dotnet build --runtime win-x64 --self-contained", + "build-All-Sources": "dotnet build --runtime win-x64 --self-contained --source https://api.nuget.org/v3/index.json --source https://packagemanagement.eu.infineon.com:4430/api/v2/ --source https://tfs.intra.infineon.com/tfs/ManufacturingIT/_packaging/eaf/nuget/v3/index.json --source http://192.168.0.73:5002/v3/index.json", "dotnet-format": "dotnet format --report .vscode --verbosity detailed --severity warn", "pull": "git pull", "garbage-collect": "git gc", diff --git a/DEP08SIASM.csproj b/DEP08SIASM.csproj index c1e251e..66da68d 100644 --- a/DEP08SIASM.csproj +++ b/DEP08SIASM.csproj @@ -14,7 +14,12 @@ win-x86 win-x86 512 - true + + + SAK + SAK + SAK + SAK true