From 5c4d1adda88c03ad3b41840b8cbf8a3b9307bc7c Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Tue, 22 Mar 2022 12:54:15 -0700 Subject: [PATCH] logisticsSequenceMemoryDirectory --- Adaptation/FileHandlers/DEP08SIASM/FileRead.cs | 2 +- .../FileHandlers/DEP08SIASM/ProcessData.cs | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Adaptation/FileHandlers/DEP08SIASM/FileRead.cs b/Adaptation/FileHandlers/DEP08SIASM/FileRead.cs index b427ab8..9a29ea4 100644 --- a/Adaptation/FileHandlers/DEP08SIASM/FileRead.cs +++ b/Adaptation/FileHandlers/DEP08SIASM/FileRead.cs @@ -212,7 +212,7 @@ public class FileRead : Shared.FileRead, IFileRead if (_HttpClient is null) throw new Exception($"{nameof(_HttpClient)} is null!"); if (!isDummyRun && _IsEAFHosted) - ProcessData.PutOpenInsightCommonGatewayInterfaceReactorStatesStatus(this, _Logistics, _HttpClient, descriptions); + ProcessData.PutOpenInsightCommonGatewayInterfaceReactorStatesStatus(this, _Logistics, _HttpClient, descriptions, logisticsSequenceMemoryDirectory); } else throw new Exception(); diff --git a/Adaptation/FileHandlers/DEP08SIASM/ProcessData.cs b/Adaptation/FileHandlers/DEP08SIASM/ProcessData.cs index 3445bd7..b0f6144 100644 --- a/Adaptation/FileHandlers/DEP08SIASM/ProcessData.cs +++ b/Adaptation/FileHandlers/DEP08SIASM/ProcessData.cs @@ -36,30 +36,28 @@ public class ProcessData return result.ToString(); } - internal static async void PutOpenInsightCommonGatewayInterfaceReactorStatesStatus(IFileRead fileRead, Logistics logistics, HttpClient httpClient, List descriptions) + internal static async void PutOpenInsightCommonGatewayInterfaceReactorStatesStatus(IFileRead fileRead, Logistics logistics, HttpClient httpClient, List descriptions, string logisticsSequenceMemoryDirectory) { - if (fileRead is null) - { } 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"); + string contentFile = Path.Combine(logisticsSequenceMemoryDirectory, $"{logistics.DateTimeFromSequence.Ticks}.txt"); 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) + if (httpResponseMessage.StatusCode is not System.Net.HttpStatusCode.OK) + File.WriteAllText(contentFile, "Failed!"); + else { string content = await httpResponseMessage.Content.ReadAsStringAsync(); - if (string.IsNullOrEmpty(content)) - { } + File.WriteAllText(contentFile, content); } } catch (Exception ex) { - status = ex.Message; - if (string.IsNullOrEmpty(status)) - { } + File.WriteAllText(contentFile, $"{ex.Message}{Environment.NewLine}{ex.StackTrace}{Environment.NewLine}{fileRead.CellInstanceConnectionName}"); } }