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(); } Result IPinRepository.GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde) { Result? r; if (!id.Equals(IPinRepository.ToolId.BioRad) && !id.Equals(IPinRepository.ToolId.CDE)) r = new() { Results = Array.Empty(), TotalRows = 0 }; else { if (!string.IsNullOrEmpty(_MockRoot)) { string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), "GetPinnedTableApi.json")); r = JsonSerializer.Deserialize>(json); if (r is null) throw new NullReferenceException(nameof(r)); } else { List results = new(); HeaderCommon? cdeHeader = cde is null ? null : JsonSerializer.Deserialize(cde); HeaderCommon? bioRadHeader = bioRad is null ? null : JsonSerializer.Deserialize(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; } }