60 lines
2.2 KiB
C#
60 lines
2.2 KiB
C#
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;
|
|
}
|
|
|
|
} |