2022-03-22 12:55:42 -07:00

65 lines
3.0 KiB
C#

using Adaptation.Shared;
using Adaptation.Shared.Properties;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Text;
namespace Adaptation.FileHandlers.DEP08SIASM;
public class ProcessData
{
internal static List<Tuple<int, Enum, string>> HyphenTuples => new()
{
new Tuple<int, Enum, string>(0, Hyphen.IsNaEDA, @"\EC_EDA\Staging\Traces\~\Source"),
new Tuple<int, Enum, string>(15, Hyphen.IsXToOpenInsightMetrologyViewer, @"\EC_EAFLog\TracesMES\~\Source"),
new Tuple<int, Enum, string>(-361, Hyphen.IsXToIQSSi, @"\EC_SPC_Si\Traces\~\PollPath"),
new Tuple<int, Enum, string>(362, Hyphen.IsXToOpenInsight, @"\\messa01ec.ec.local\APPS\Metrology\~\Source"),
new Tuple<int, Enum, string>(-363, Hyphen.IsXToOpenInsightMetrologyViewerAttachments, @"\EC_Characterization_Si\In Process\~\Source"),
new Tuple<int, Enum, string>(-3604, Hyphen.IsXToAPC, @"\EC_APC\Staging\Traces\~\PollPath"),
new Tuple<int, Enum, string>(-365, Hyphen.IsXToSPaCe, @"\EC_SPC_Si\Traces\~\Source"),
new Tuple<int, Enum, string>(1806, Hyphen.IsXToArchive, @"\EC_EAFLog\TracesArchive\~\Source"),
new Tuple<int, Enum, string>(367, Hyphen.IsArchive, @"\EC_Characterization_Si\Processed")
// new Tuple<int, Enum, string>(1808, Hyphen.IsDummy
};
internal static string GetLines(IFileRead fileRead, Logistics logistics, List<jpeg.Description> descriptions)
{
StringBuilder result = new();
if (fileRead is null)
{ }
if (logistics is null)
{ }
if (descriptions is null)
{ }
return result.ToString();
}
internal static async void PutOpenInsightCommonGatewayInterfaceReactorStatesStatus(IFileRead fileRead, Logistics logistics, HttpClient httpClient, List<jpeg.Description> descriptions, string logisticsSequenceMemoryDirectory)
{
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 not System.Net.HttpStatusCode.OK)
File.WriteAllText(contentFile, "Failed!");
else
{
string content = await httpResponseMessage.Content.ReadAsStringAsync();
File.WriteAllText(contentFile, content);
}
}
catch (Exception ex)
{
File.WriteAllText(contentFile, $"{ex.Message}{Environment.NewLine}{ex.StackTrace}{Environment.NewLine}{fileRead.CellInstanceConnectionName}");
}
}
}