oi-metrology/Server/Repositories/InfinityQSV3Repository.cs
Mike Phares 127634f5ab Delete self contained Thunder Tests
Back to .net8.0
api/v4/InfinityQS
ApiExplorerSettings
Wafer Counter
Color Sorting
2024-03-13 13:15:56 -07:00

565 lines
29 KiB
C#

using OI.Metrology.Server.Models;
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models;
using OI.Metrology.Shared.Models.Stateless;
using OI.Metrology.Shared.Repositories;
using System.Collections.ObjectModel;
using System.Data;
using System.Data.Common;
using System.Text;
using System.Text.Json;
namespace OI.Metrology.Server.Repository;
public class InfinityQSV3Repository : IInfinityQSV3Repository
{
private readonly string _MockRoot;
private readonly string _RepositoryName;
private readonly IHttpClientFactory _HttpClientFactory;
private readonly IDbConnectionFactory _DBConnectionFactory;
private readonly string _OpenInsightApplicationProgrammingInterface;
public InfinityQSV3Repository(AppSettings appSettings, IDbConnectionFactory dbConnectionFactory, IHttpClientFactory httpClientFactory)
{
_MockRoot = appSettings.MockRoot;
_HttpClientFactory = httpClientFactory;
_DBConnectionFactory = dbConnectionFactory;
_RepositoryName = nameof(InfinityQSV3Repository)[..^10];
_OpenInsightApplicationProgrammingInterface = appSettings.OpenInsightApplicationProgrammingInterface;
}
string IInfinityQSV3Repository.GetCommandText(string subGroupId)
{ // cSpell:disable
StringBuilder result = new();
if (string.IsNullOrEmpty(subGroupId))
throw new ArgumentException(null, nameof(subGroupId));
_ = result
.AppendLine(" select ")
.AppendLine(" sd.f_sgrp sd_sgrp, ")
.AppendLine(" sd.f_tsno sd_tsno, ")
.AppendLine(" dd.f_dsgp dd_dsgp, ")
.AppendLine(" dg.f_name gd_name, ")
.AppendLine(" dd.f_name dd_name ")
.AppendLine(" from [SPCEPIWORLD].[dbo].[SGRP_DSC] sd ")
.AppendLine(" join [SPCEPIWORLD].[dbo].[DESC_DAT] dd ")
.AppendLine(" on sd.f_dsgp = dd.f_dsgp ")
.AppendLine(" and sd.f_desc = dd.f_desc ")
.AppendLine(" join [SPCEPIWORLD].[dbo].[DESC_GRP] dg ")
.AppendLine(" on dd.f_dsgp = dg.f_dsgp ");
_ = result.Append(" where sd.f_sgrp = ").Append(subGroupId).AppendLine(" ");
_ = result.AppendLine(" for json path ");
return result.ToString();
} // cSpell:enable
string IInfinityQSV3Repository.GetCommandText(string? subGroupId, string? process, string? job, string? part, string? lot, string? dateTime)
{ // cSpell:disable
StringBuilder result = new();
const string dateTimeFormat = "yyyy-MM-dd HH:mm:ss";
if (!string.IsNullOrEmpty(dateTime) && (dateTime.Contains('-') || dateTime.Contains(' ') || dateTime.Contains(':')) && dateTime.Length != dateTimeFormat.Length)
throw new ArgumentException(null, nameof(dateTime));
_ = result
.AppendLine(" select case when iq.sl_loos is null then 0 else iq.sl_loos end + ")
.AppendLine(" case when iq.sl_uoos is null then 0 else iq.sl_uoos end + ")
.AppendLine(" iq.ev_count as iq_sum, ")
.AppendLine(" iq.sl_aflag, ")
.AppendLine(" iq.sl_loos, ")
.AppendLine(" iq.sl_uoos, ")
.AppendLine(" iq.se_sgrp, ")
.AppendLine(" iq.se_sgtm, ")
.AppendLine(" iq.se_tsno, ")
.AppendLine(" iq.td_test, ")
.AppendLine(" iq.pr_name, ")
.AppendLine(" iq.jd_name, ")
.AppendLine(" iq.pl_name, ")
.AppendLine(" iq.pd_name, ")
.AppendLine(" iq.td_name, ")
.AppendLine(" iq.se_val, ")
.AppendLine(" iq.sl_eflag, ")
.AppendLine(" iq.sl_scal, ")
.AppendLine(" iq.sl_sls, ")
.AppendLine(" iq.sl_usl ")
.AppendLine(" from ( ")
.AppendLine(" select ")
.AppendLine(" se.f_sgrp se_sgrp, ")
.AppendLine(" se.f_sgtm se_sgtm, ")
.AppendLine(" se.f_tsno se_tsno, ")
.AppendLine(" se.f_val se_val, ")
.AppendLine(" pr.f_name pr_name, ")
.AppendLine(" jd.f_name jd_name, ")
.AppendLine(" pl.f_name pl_name, ")
.AppendLine(" pd.f_name pd_name, ")
.AppendLine(" td.f_test td_test, ")
.AppendLine(" td.f_name td_name, ")
.AppendLine(" sl.f_eflag sl_eflag, ")
.AppendLine(" sl.f_aflag sl_aflag, ")
.AppendLine(" sl.f_scal sl_scal, ")
.AppendLine(" sl.f_lsl sl_sls, ")
.AppendLine(" sl.f_usl sl_usl, ")
.AppendLine(" case when sl.f_aflag is null or sl.f_aflag = 0 then null else ")
.AppendLine(" case when round(se.f_val, sl.F_scal, 1) < sl.f_lsl then 1 else 0 end ")
.AppendLine(" end as sl_loos, ")
.AppendLine(" case when sl.f_aflag is null or sl.f_aflag = 0 then null else ")
.AppendLine(" case when round(se.f_val, sl.F_scal, 1) > sl.f_usl then 1 else 0 end ")
.AppendLine(" end as sl_uoos, ")
.AppendLine(" (select count(ev.f_evnt) ")
.AppendLine(" from [spcepiworld].[dbo].[evnt_inf] ev ")
.AppendLine(" where ev.f_prcs = pr.f_prcs ")
.AppendLine(" and ev.f_part = pd.f_part ")
.AppendLine(" and ev.f_sgtm = se.f_sgtm ")
.AppendLine(" ) ev_count ")
.AppendLine(" from [spcepiworld].[dbo].[sgrp_ext] se ")
.AppendLine(" join [spcepiworld].[dbo].[prcs_dat] pr ")
.AppendLine(" on se.f_prcs = pr.f_prcs ")
.AppendLine(" join [spcepiworld].[dbo].[job_dat] jd ")
.AppendLine(" on se.f_job = jd.f_job ")
.AppendLine(" join [spcepiworld].[dbo].[part_lot] pl ")
.AppendLine(" on se.f_lot = pl.f_lot ")
.AppendLine(" join [spcepiworld].[dbo].[part_dat] pd ")
.AppendLine(" on se.f_part = pd.f_part ")
.AppendLine(" join [spcepiworld].[dbo].[test_dat] td ")
.AppendLine(" on se.f_test = td.f_test ")
.AppendLine(" left join [spcepiworld].[dbo].[spec_lim] sl ")
.AppendLine(" on se.f_part = sl.f_part ")
.AppendLine(" and se.f_test = sl.f_test ")
.AppendLine(" where se.f_flag = 0 ")
.AppendLine(" and (sl.f_prcs is null or se.f_prcs = sl.f_prcs or sl.f_prcs = 0) ");
if (!string.IsNullOrEmpty(subGroupId))
_ = result.Append(" and se.f_sgrp = ").Append(subGroupId.Split(" ")[0]).AppendLine(" ");
if (!string.IsNullOrEmpty(process))
_ = result.Append(" and pr.f_name = '").Append(process).AppendLine("' ");
if (!string.IsNullOrEmpty(part))
_ = result.Append(" and pd.f_name = '").Append(part).AppendLine("' ");
if (!string.IsNullOrEmpty(job))
_ = result.Append(" and jd.f_name = '").Append(job).AppendLine("' ");
if (!string.IsNullOrEmpty(lot))
_ = result.Append(" and pl.f_name = '").Append(lot).AppendLine("' ");
if (!string.IsNullOrEmpty(dateTime) && (dateTime.Contains('-') || dateTime.Contains(' ') || dateTime.Contains(':')))
_ = result.Append(" and dateadd(HH, -7, (dateadd(SS, convert(bigint, se.f_sgtm), '19700101'))) = '").Append(dateTime).AppendLine("' ");
_ = result.AppendLine(" ) as iq ")
.AppendLine(" order by iq.sl_loos + iq.sl_uoos + iq.ev_count desc, ")
.AppendLine(" iq.sl_aflag desc, ")
.AppendLine(" iq.se_sgrp, ")
.AppendLine(" iq.se_tsno, ")
.AppendLine(" iq.td_test ")
.AppendLine(" for json path ");
return result.ToString();
} // cSpell:enable
private static StringBuilder GetForJsonPath(IDbConnectionFactory dbConnectionFactory, string commandText)
{
StringBuilder stringBuilder = new();
using DbConnection dbConnection = dbConnectionFactory.GetDbConnection();
DbCommand dbCommand = dbConnection.CreateCommand();
dbCommand.CommandText = commandText;
DbDataReader dbDataReader = dbCommand.ExecuteReader(CommandBehavior.SequentialAccess);
while (dbDataReader.Read())
_ = stringBuilder.Append(dbDataReader.GetString(0));
return stringBuilder;
}
private static InfinityQSV3 GetInfinityQSV3(IDbConnectionFactory dbConnectionFactory, IInfinityQSV3Repository infinityQSV3Repository, string subGroupId)
{
InfinityQSV3 result;
string commandText = infinityQSV3Repository.GetCommandText(subGroupId, process: string.Empty, job: string.Empty, part: string.Empty, lot: string.Empty, dateTime: string.Empty);
StringBuilder stringBuilder = GetForJsonPath(dbConnectionFactory, commandText);
InfinityQSV3[]? results = stringBuilder.Length == 0 ? Array.Empty<InfinityQSV3>() : JsonSerializer.Deserialize(stringBuilder.ToString(), ResultInfinityQSV3SourceGenerationContext.Default.InfinityQSV3Array); // , new JsonSerializerOptions { PropertyNameCaseInsensitive = true }
if (results is null)
throw new NullReferenceException(nameof(results));
result = results.First();
return result;
}
Result<InfinityQSV3[]> IInfinityQSV3Repository.GetData(string subGroupId)
{
Result<InfinityQSV3[]>? result;
if (!string.IsNullOrEmpty(_MockRoot))
{
string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IInfinityQSV3Repository.GetData)}.json"));
result = JsonSerializer.Deserialize(json, ResultInfinityQSV3SourceGenerationContext.Default.ResultInfinityQSV3Array);
if (result is null)
throw new NullReferenceException(nameof(result));
}
else
{
IInfinityQSV3Repository infinityQSV3Repository = this;
InfinityQSV3 infinityQSV3 = GetInfinityQSV3(_DBConnectionFactory, infinityQSV3Repository, subGroupId);
string commandText = infinityQSV3Repository.GetCommandText(subGroupId, process: infinityQSV3.Process, job: infinityQSV3.Job, part: infinityQSV3.Part, lot: infinityQSV3.Lot, dateTime: string.Concat(infinityQSV3.SubGroupDateTime));
StringBuilder stringBuilder = GetForJsonPath(_DBConnectionFactory, commandText);
InfinityQSV3[]? results = stringBuilder.Length == 0 ? Array.Empty<InfinityQSV3>() : JsonSerializer.Deserialize(stringBuilder.ToString(), ResultInfinityQSV3SourceGenerationContext.Default.InfinityQSV3Array); // , new JsonSerializerOptions { PropertyNameCaseInsensitive = true }
if (results is null)
throw new NullReferenceException(nameof(results));
result = new()
{
Results = results,
TotalRows = results.Length,
};
}
return result;
}
Result<InfinityQSDescriptorV3[]> IInfinityQSV3Repository.GetDescriptors(string subGroupId)
{
Result<InfinityQSDescriptorV3[]>? result;
if (!string.IsNullOrEmpty(_MockRoot))
{
string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IInfinityQSV3Repository.GetDescriptors)}.json"));
result = JsonSerializer.Deserialize(json, ResultInfinityQSDescriptorV3SourceGenerationContext.Default.ResultInfinityQSDescriptorV3Array);
if (result is null)
throw new NullReferenceException(nameof(result));
}
else
{
IInfinityQSV3Repository infinityQSV3Repository = this;
string commandText = infinityQSV3Repository.GetCommandText(subGroupId);
StringBuilder stringBuilder = GetForJsonPath(_DBConnectionFactory, commandText);
InfinityQSDescriptorV3[]? results = stringBuilder.Length == 0 ? Array.Empty<InfinityQSDescriptorV3>() : JsonSerializer.Deserialize(stringBuilder.ToString(), ResultInfinityQSDescriptorV3SourceGenerationContext.Default.InfinityQSDescriptorV3Array); // , new JsonSerializerOptions { PropertyNameCaseInsensitive = true }
if (results is null)
throw new NullReferenceException(nameof(results));
result = new()
{
Results = results,
TotalRows = results.Length,
};
}
return result;
}
string IInfinityQSV3Repository.GetCommandText(InfinityQSV3 infinityQSV3)
{ // cSpell:disable
StringBuilder result = new();
if (string.IsNullOrEmpty(infinityQSV3.Process))
throw new ArgumentException(nameof(infinityQSV3.Process));
if (string.IsNullOrEmpty(infinityQSV3.Part))
throw new ArgumentException(nameof(infinityQSV3.Part));
_ = result
.AppendLine(" select ")
.AppendLine(" ev.f_evnt [ev_evnt], ")
.AppendLine(" ev.f_sgtm [ev_sgtm], ")
.AppendLine(" dateadd(HH, -7, (dateadd(SS, convert(bigint, ev.f_sgtm), '19700101'))) [ev_utc7], ")
.AppendLine(" pr.f_name [pr_name], ")
.AppendLine(" pd.f_name [pd_name], ")
.AppendLine(" td.f_test [td_test], ")
.AppendLine(" td.f_name [td_name], ")
.AppendLine(" ev.f_name [ev_name] ")
.AppendLine(" from [spcepiworld].[dbo].[evnt_inf] ev ")
.AppendLine(" join [spcepiworld].[dbo].[prcs_dat] pr ")
.AppendLine(" on ev.f_prcs = pr.f_prcs ")
.AppendLine(" join [spcepiworld].[dbo].[part_dat] pd ")
.AppendLine(" on ev.f_part = pd.f_part ")
.AppendLine(" join [spcepiworld].[dbo].[test_dat] td ")
.AppendLine(" on ev.f_test = td.f_test ")
.Append(" where pr.f_name = '").Append(infinityQSV3.Process).AppendLine("' ")
.Append(" and pd.f_name = '").Append(infinityQSV3.Part).AppendLine("' ")
.Append(" and ev.f_sgtm = ").Append(infinityQSV3.SubGroupDateTime).AppendLine(" ")
.AppendLine(" for json path ");
return result.ToString();
} // cSpell:enable
Result<InfinityQSV3[]> IInfinityQSV3Repository.GetHeader(string subGroupId)
{
Result<InfinityQSV3[]>? result;
if (!string.IsNullOrEmpty(_MockRoot))
{
string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IInfinityQSV3Repository.GetHeader)}.json"));
result = JsonSerializer.Deserialize(json, ResultInfinityQSV3SourceGenerationContext.Default.ResultInfinityQSV3Array);
if (result is null)
throw new NullReferenceException(nameof(result));
}
else
{
IInfinityQSV3Repository infinityQSV3Repository = this;
InfinityQSV3 infinityQSV3 = GetInfinityQSV3(_DBConnectionFactory, infinityQSV3Repository, subGroupId);
InfinityQSV3[] results = new InfinityQSV3[] { infinityQSV3 };
result = new()
{
Results = results,
TotalRows = results.Length,
};
}
return result;
}
string IInfinityQSV3Repository.GetCommandText(string process, string? part)
{ // cSpell:disable
StringBuilder result = new();
if (string.IsNullOrEmpty(process))
throw new ArgumentException(null, nameof(process));
if (string.IsNullOrEmpty(part))
throw new ArgumentException(null, nameof(part));
_ = result
.AppendLine(" select [f_mean] as ProcessMean, ")
.AppendLine(" [f_sp] as ProcessSigma ")
.AppendLine(" from [spcepiworld].[dbo].[test_dat] test ")
.AppendLine(" join [spcepiworld].[dbo].[ctrl_lim] ctrl ")
.AppendLine(" on test.f_test = ctrl.f_test ")
.AppendLine(" and test.f_tsgp = 1104848523 /* Product Data */ ")
.AppendLine(" join [spcepiworld].[dbo].[part_dat] part ")
.AppendLine(" on part.f_part = ctrl.f_part ")
.AppendLine(" and ctrl.f_test = 1125073605 /* Average Sum of Defects */ ")
.AppendLine(" join [spcepiworld].[dbo].[prcs_dat] process ")
.AppendLine(" on process.f_prcs = ctrl.f_prcs ")
.AppendLine(" where test.f_name = 'Average Sum of Defects' ")
.Append(" and process.f_name = '").Append(process).AppendLine("' ")
.Append(" and part.f_name = '").Append(part).AppendLine("' ")
.AppendLine(" for json path; ");
return result.ToString();
} // cSpell:enable
string IInfinityQSV3Repository.GetProductDataAverageSumOfDefectsProcessMeanProcessSigma(string process, string? recipe)
{
StringBuilder result;
if (!string.IsNullOrEmpty(_MockRoot))
{
string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IInfinityQSV3Repository.GetProductDataAverageSumOfDefectsProcessMeanProcessSigma)}.json"));
result = new(json);
}
else
{
IInfinityQSV3Repository infinityQSV3Repository = this;
string commandText = infinityQSV3Repository.GetCommandText(process, recipe);
result = GetForJsonPath(_DBConnectionFactory, commandText);
if (result.Length == 0)
result = new("{}");
}
return result.ToString();
}
private JsonElement[] GetAllReactorsAsJsonElementElement()
{
JsonElement[]? results;
HttpClient httpClient = _HttpClientFactory.CreateClient();
Task<string> task = httpClient.GetStringAsync($"{_OpenInsightApplicationProgrammingInterface}/reactors");
task.Wait();
JsonElement? jsonElement = JsonSerializer.Deserialize<JsonElement>(task.Result);
if (jsonElement is null)
throw new NullReferenceException(nameof(jsonElement));
string json = jsonElement.Value.EnumerateObject().First().Value.ToString();
results = JsonSerializer.Deserialize<JsonElement[]>(json);
if (results is null)
throw new NullReferenceException(nameof(results));
return results;
}
private ReadOnlyDictionary<int, Reactor> GetReactorsMatchingType(string? reactTypeFilter)
{
Dictionary<int, Reactor> results = new();
string json;
Reactor? reactor;
JsonElement[]? jsonElements = GetAllReactorsAsJsonElementElement();
foreach (JsonElement jsonElement in jsonElements)
{
json = jsonElement.EnumerateObject().First().Value.ToString();
if (reactTypeFilter is not null && !json.Contains(reactTypeFilter))
continue;
try
{ reactor = JsonSerializer.Deserialize(json, ReactorSourceGenerationContext.Default.Reactor); }
catch (Exception) { reactor = null; }
if (reactor is null || reactor.ReactType != reactTypeFilter)
continue;
results.Add(reactor.ReactorNo, reactor);
}
return new(results);
}
string IInfinityQSV3Repository.GetCommandText(List<string> eppReactorNumbers)
{ // cSpell:disable
StringBuilder result = new();
_ = result
.AppendLine(" select se.f_sgrp, ")
.AppendLine(" dateadd(HH, -7, (dateadd(SS, convert(bigint, se.f_sgrp), '19700101'))) date_time, ")
.AppendLine(" iq.pr_name, ")
.AppendLine(" iq.pd_name, ")
.AppendLine(" max(case ")
.AppendLine(" when td.f_test = 1104769646 ")
.AppendLine(" then se.f_val ")
.AppendLine(" else null ")
.AppendLine(" end) as iq_value, ")
.AppendLine(" max(case ")
.AppendLine(" when td.f_test = 1312288843 ")
.AppendLine(" then se.f_val else null ")
.AppendLine(" end) as iq_temp_offset_percent ")
.AppendLine(" from ( ")
.AppendLine(" select ")
.AppendLine(" max(se.f_sgrp) se_max_sgrp, ")
.AppendLine(" se.f_test se_test, ")
.AppendLine(" pr.f_name pr_name, ")
.AppendLine(" pd.f_name pd_name ")
.AppendLine(" from [spcepiworld].[dbo].[sgrp_ext] se ")
.AppendLine(" join [spcepiworld].[dbo].[prcs_dat] pr ")
.AppendLine(" on se.f_prcs = pr.f_prcs ")
.AppendLine(" join [spcepiworld].[dbo].[part_dat] pd ")
.AppendLine(" on se.f_part = pd.f_part ")
.AppendLine(" where se.f_flag = 0 ")
.Append(" and pr.f_name in (").Append(string.Join(',', eppReactorNumbers)).AppendLine(") ")
.AppendLine(" and pd.f_name = '1090 - Full Load' ")
.AppendLine(" and se.f_test in (1104769646, 1312288843) ")
.AppendLine(" group by se.f_test, ")
.AppendLine(" pr.f_name, ")
.AppendLine(" pd.f_name ")
.AppendLine(" ) as iq ")
.AppendLine(" join [spcepiworld].[dbo].[sgrp_ext] se ")
.AppendLine(" on iq.se_max_sgrp = se.f_sgrp ")
.AppendLine(" join [spcepiworld].[dbo].[test_dat] td ")
.AppendLine(" on iq.se_test = td.f_test ")
.AppendLine(" and se.f_test = td.f_test ")
.AppendLine(" where se.f_flag = 0 ")
.AppendLine(" and td.f_test in (1104769646, 1312288843) ")
.AppendLine(" group by se.f_sgrp, ")
.AppendLine(" iq.pr_name, ")
.AppendLine(" iq.pd_name ")
.AppendLine(" order by iq.pr_name ")
.AppendLine(" for json path; ");
return result.ToString();
} // cSpell:enable
private static List<string> Convert(int[] night)
{
List<string> results = new();
foreach (int reactor in night)
results.Add(reactor.ToString());
return results;
}
List<string[]> IInfinityQSV3Repository.GetEpiProTempVerificationRows(int[] night)
{
List<string[]>? results;
List<string> eppReactorNumbers = new();
List<string> nightSiftReactors = Convert(night);
ReadOnlyDictionary<int, Reactor> eppReactors = GetReactorsMatchingType("EPP");
foreach (KeyValuePair<int, Reactor> keyValuePair in eppReactors)
eppReactorNumbers.Add($"'{keyValuePair.Key}'");
if (!string.IsNullOrEmpty(_MockRoot))
{
string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IInfinityQSV3Repository.GetEpiProTempVerificationRows)}.json"));
results = JsonSerializer.Deserialize<List<string[]>>(json);
if (results is null)
throw new NullReferenceException(nameof(results));
}
else
{
bool found;
results = new();
int loadedCount;
Reactor? reactor;
string loadedRDS;
int reactorNumber;
TimeSpan timeSpan;
List<string> columns;
List<int> used = new();
List<int> dayShiftOrder = new();
long ticks = DateTime.Now.Ticks;
List<int> nightShiftOrder = new();
InfinityQS1090FullLoad infinityQS1090FullLoad;
IInfinityQSV3Repository infinityQSV3Repository = this;
string commandText = infinityQSV3Repository.GetCommandText(eppReactorNumbers);
StringBuilder stringBuilder = GetForJsonPath(_DBConnectionFactory, commandText);
InfinityQS1090FullLoad[]? infinityQS1090FullLoads = stringBuilder.Length == 0 ? Array.Empty<InfinityQS1090FullLoad>() : JsonSerializer.Deserialize(stringBuilder.ToString(), InfinityQS1090FullLoadArraySourceGenerationContext.Default.InfinityQS1090FullLoadArray);
if (infinityQS1090FullLoads is null)
throw new NullReferenceException(nameof(infinityQS1090FullLoads));
for (int i = 0; i < infinityQS1090FullLoads.Length; i++)
{
infinityQS1090FullLoad = infinityQS1090FullLoads[i];
if (infinityQS1090FullLoad.Reactor is null)
continue;
if (!int.TryParse(infinityQS1090FullLoad.Reactor, out reactorNumber))
continue;
if (!eppReactors.TryGetValue(reactorNumber, out reactor))
continue;
if (!nightSiftReactors.Contains(infinityQS1090FullLoad.Reactor))
dayShiftOrder.Add(i);
else
nightShiftOrder.Add(i);
}
for (int i = 0; i < infinityQS1090FullLoads.Length; i++)
{
if (used.Contains(i) || !dayShiftOrder.Contains(i))
continue;
infinityQS1090FullLoad = infinityQS1090FullLoads[i];
if (infinityQS1090FullLoad.Reactor is null)
continue;
if (!int.TryParse(infinityQS1090FullLoad.Reactor, out reactorNumber))
continue;
if (!eppReactors.TryGetValue(reactorNumber, out reactor))
continue;
used.Add(i);
found = false;
timeSpan = new(ticks - infinityQS1090FullLoad.SubGroupIdFormatted.Ticks);
loadedCount = reactor.LoadedRDS is null ? 0 : reactor.LoadedRDS.Count;
loadedRDS = reactor.LoadedRDS is null ? "&nbsp;" : reactor.LoadedRDS[0].ToString();
results.Add(new string[]{
reactor.ReactorNo.ToString(),
reactor.E10State,
loadedRDS,
infinityQS1090FullLoad.Value.ToString(),
infinityQS1090FullLoad.TemperatureOffsetPercentage.ToString(),
infinityQS1090FullLoad.SubGroupIdFormatted.ToString(),
Math.Floor(timeSpan.TotalHours).ToString()
});
for (int j = i + 1; j < infinityQS1090FullLoads.Length; j++)
{
if (used.Contains(j) || !nightShiftOrder.Contains(j))
continue;
infinityQS1090FullLoad = infinityQS1090FullLoads[j];
if (infinityQS1090FullLoad.Reactor is null)
continue;
if (!int.TryParse(infinityQS1090FullLoad.Reactor, out reactorNumber))
continue;
if (!eppReactors.TryGetValue(reactorNumber, out reactor))
continue;
used.Add(j);
found = true;
timeSpan = new(ticks - infinityQS1090FullLoad.SubGroupIdFormatted.Ticks);
loadedCount = reactor.LoadedRDS is null ? 0 : reactor.LoadedRDS.Count;
loadedRDS = reactor.LoadedRDS is null ? "&nbsp;" : reactor.LoadedRDS[0].ToString();
columns = new();
columns.AddRange(results[^1]);
columns.AddRange(new string[]
{
"&nbsp;",
reactor.ReactorNo.ToString(),
reactor.E10State,
loadedRDS,
infinityQS1090FullLoad.Value.ToString(),
infinityQS1090FullLoad.TemperatureOffsetPercentage.ToString(),
infinityQS1090FullLoad.SubGroupIdFormatted.ToString(),
Math.Floor(timeSpan.TotalHours).ToString()
});
results[^1] = columns.ToArray();
break;
}
if (!found)
{
columns = new();
columns.AddRange(results[^1]);
columns.Add("&nbsp;");
columns.Add("&nbsp;");
columns.Add("&nbsp;");
columns.Add("&nbsp;");
columns.Add("&nbsp;");
columns.Add("&nbsp;");
columns.Add("&nbsp;");
columns.Add("&nbsp;");
results[^1] = columns.ToArray();
}
}
}
return results;
}
string IInfinityQSV3Repository.GetEpiProTempVerification(int[] night)
{
StringBuilder result = new();
IInfinityQSV3Repository infinityQSV3Repository = this;
List<string[]> collection = infinityQSV3Repository.GetEpiProTempVerificationRows(night);
foreach (string[] row in collection)
{
_ = result.Append("<tr>");
foreach (string column in row)
_ = result.Append("<td>").Append(column).Append("</td>");
_ = result.Append("</tr>");
}
return result.ToString();
}
}