This commit is contained in:
2023-02-08 07:16:09 -07:00
parent 90d58e8e9c
commit 65a3c6e7f6
12 changed files with 821 additions and 531 deletions

View File

@ -0,0 +1,60 @@
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models.Stateless;
using System.Text.Json;
namespace OI.Metrology.Server.Repository;
public class PinRepository : IPinRepository
{
private readonly string _MockRoot;
private readonly Serilog.ILogger _Log;
public PinRepository(string mockRoot)
{
_MockRoot = mockRoot;
_Log = Serilog.Log.ForContext<PinRepository>();
}
Result<HeaderCommond[]> IPinRepository.GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde)
{
Result<HeaderCommond[]>? r;
if (!id.Equals(IPinRepository.ToolId.BioRad) && !id.Equals(IPinRepository.ToolId.CDE))
r = new() { Results = Array.Empty<HeaderCommond>(), TotalRows = 0 };
else
{
if (!string.IsNullOrEmpty(_MockRoot))
{
string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), "GetPinnedTableApi.json"));
r = JsonSerializer.Deserialize<Result<HeaderCommond[]>>(json);
if (r is null)
throw new NullReferenceException(nameof(r));
}
else
{
List<HeaderCommond> results = new();
HeaderCommon? cdeHeader = cde is null ? null : JsonSerializer.Deserialize<HeaderCommon>(cde);
HeaderCommon? bioRadHeader = bioRad is null ? null : JsonSerializer.Deserialize<HeaderCommon>(bioRad);
if (bioRadHeader is not null)
{
System.Data.DataTable dataTable = metrologyRepository.GetData((int)IPinRepository.ToolId.BioRad, bioRadHeader.ID);
if (dataTable.Rows.Count == 11)
;
}
if (cdeHeader is not null)
{
System.Data.DataTable dataTable = metrologyRepository.GetData((int)IPinRepository.ToolId.CDE, cdeHeader.ID);
if (dataTable.Rows.Count == 11)
;
}
r = new()
{
Results = results.ToArray(),
TotalRows = results.Count,
};
}
}
return r;
}
}