Removed not needed properties from api

This commit is contained in:
2023-08-02 15:28:45 -07:00
parent 2614782d58
commit c5e3acc3e4
5 changed files with 132 additions and 118 deletions

View File

@ -6,6 +6,7 @@ using System.Globalization;
using System.IO;
using System.Net.Http;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Adaptation.FileHandlers.MoveAllFiles.ApiController;
@ -49,6 +50,38 @@ public class BarcodeHelper
return result;
}
private static Root? GetRoot(string rds)
{
HttpClient httpClient = new();
string url = $"{FileRead.OpenInsightApplicationProgrammingInterface}/materials/rds/{rds}";
string httpClientResult = httpClient.GetStringAsync(url).Result;
Root? root = JsonSerializer.Deserialize<Root>(httpClientResult);
httpClient.Dispose();
return root;
}
private static void SetQaMetTests(string toolClass, Root root, Dictionary<string, List<QaMetTest>> qaMetTests)
{
List<QaMetTest>? collection;
foreach (PrsStage prsStage in root.Rds.ProdSpec.PrsStages)
{
if (prsStage.QaMetTests is null)
continue;
foreach (QaMetTest qaMetTest in prsStage.QaMetTests)
{
if (qaMetTest.ToolClass != toolClass)
continue;
if (!qaMetTests.TryGetValue(prsStage.Stage, out collection))
{
qaMetTests.Add(prsStage.Stage, new());
if (!qaMetTests.TryGetValue(prsStage.Stage, out collection))
throw new Exception();
}
collection.Add(qaMetTest);
}
}
}
internal static PostReplay? Post(string id, HttpContent? httpContent)
{
PostReplay? result;
@ -64,42 +97,20 @@ public class BarcodeHelper
{
Job? job;
string? mid;
List<QaMetTest>? collection;
Dictionary<string, List<QaMetTest>> qaMetTests = new();
Write(TIBCO.FileRead.BarcodeHostFileShare, id, notification.Value);
try
{
const string hyphen = "-";
HttpClient httpClient = new();
job = GetJob(TIBCO.FileRead.LSL2SQLConnectionString, TIBCO.FileRead.MetrologyFileShare, TIBCO.FileRead.BarcodeHostFileShare, id, notification.Value);
mid = job.SpecName == hyphen || job.ProcessSpecName == hyphen ? $"{job.ProcessType}" : $"{job.ProcessType}.{job.SpecName}.{job.ProcessSpecName}";
string httpClientResult = httpClient.GetStringAsync($"{FileRead.OpenInsightApplicationProgrammingInterface}/materials/rds/{job.LotName}").Result;
Root? root = JsonSerializer.Deserialize<Root>(httpClientResult);
httpClient.Dispose();
Root? root = GetRoot(job.LotName);
if (root is not null)
{
foreach (PrsStage prsStage in root.Rds.ProdSpec.PrsStages)
{
if (prsStage.QaMetTests is null)
continue;
foreach (QaMetTest qaMetTest in prsStage.QaMetTests)
{
if (qaMetTest.ToolClass != notification.Value.ToolClass)
continue;
if (!qaMetTests.TryGetValue(prsStage.Stage, out collection))
{
qaMetTests.Add(prsStage.Stage, new());
if (!qaMetTests.TryGetValue(prsStage.Stage, out collection))
throw new Exception();
}
collection.Add(qaMetTest);
}
}
}
SetQaMetTests(notification.Value.ToolClass, root, qaMetTests);
}
catch (Exception)
catch (Exception ex)
{
mid = null;
mid = string.Concat(ex.Message, Environment.NewLine, ex.StackTrace);
}
result = new(mid, qaMetTests); // .ProdSpec.PrsStages[0].QaMetTests[0].Recipe);
}