logisticsSequenceMemoryDirectory

This commit is contained in:
Mike Phares 2022-03-22 12:54:15 -07:00
parent 8fb5683cbb
commit 5c4d1adda8
2 changed files with 8 additions and 10 deletions

View File

@ -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();

View File

@ -36,30 +36,28 @@ public class ProcessData
return result.ToString();
}
internal static async void PutOpenInsightCommonGatewayInterfaceReactorStatesStatus(IFileRead fileRead, Logistics logistics, HttpClient httpClient, List<jpeg.Description> descriptions)
internal static async void PutOpenInsightCommonGatewayInterfaceReactorStatesStatus(IFileRead fileRead, Logistics logistics, HttpClient httpClient, List<jpeg.Description> 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}");
}
}