Need DB
This commit is contained in:
60
Server/Repositories/PinRepository.cs
Normal file
60
Server/Repositories/PinRepository.cs
Normal 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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user