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}"); } }