diff --git a/Server/Repositories/PinRepository.cs b/Server/Repositories/PinRepository.cs index 6129abf..a1f2e58 100644 --- a/Server/Repositories/PinRepository.cs +++ b/Server/Repositories/PinRepository.cs @@ -19,7 +19,11 @@ public class PinRepository : IPinRepository Result IPinRepository.GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde) { Result? r; - if (!id.Equals(IPinRepository.ToolId.BioRad) && !id.Equals(IPinRepository.ToolId.CDE)) + HeaderCommon? cdeHeader = cde is null ? null : JsonSerializer.Deserialize(cde); + long cdeId = cdeHeader is null ? (long)IPinRepository.ToolId.CDE : cdeHeader.ToolTypeID; + HeaderCommon? bioRadHeader = bioRad is null ? null : JsonSerializer.Deserialize(bioRad); + long bioRadId = bioRadHeader is null ? (long)IPinRepository.ToolId.BioRad : bioRadHeader.ToolTypeID; + if (cdeHeader is not null && cdeHeader.ToolTypeID != id && bioRadHeader?.ToolTypeID != id) r = new() { Results = Array.Empty(), TotalRows = 0 }; else { @@ -32,20 +36,52 @@ public class PinRepository : IPinRepository } else { + const int rows = 11; + List values; + const int points = 9; + HeaderCommond headerCommond; 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) - ; + const int columns = 10; + System.Data.DataTable dataTable = metrologyRepository.GetData((int)bioRadHeader.ToolTypeID, bioRadHeader.ID); + if (dataTable.Rows.Count == rows && dataTable.Columns.Count == columns) + { + values = new(); + const int rs = 5; + for (int i = 0; i < dataTable.Rows.Count - 1; i++) + { + if (dataTable.Rows[i]?.ItemArray[rs] is null) + break; + values.Add(string.Concat(dataTable.Rows[i].ItemArray[rs])); + } + if (values.Count > points) + { + headerCommond = new(bioRadHeader, values); + results.Add(headerCommond); + } + } } if (cdeHeader is not null) { - System.Data.DataTable dataTable = metrologyRepository.GetData((int)IPinRepository.ToolId.CDE, cdeHeader.ID); - if (dataTable.Rows.Count == 11) - ; + const int columns = 7; + System.Data.DataTable dataTable = metrologyRepository.GetData((int)cdeHeader.ToolTypeID, cdeHeader.ID); + if (dataTable.Rows.Count == rows && dataTable.Columns.Count == columns) + { + values = new(); + const int rs = 5; + for (int i = 0; i < dataTable.Rows.Count - 1; i++) + { + if (dataTable.Rows[i]?.ItemArray[rs] is null) + break; + values.Add(string.Concat(dataTable.Rows[i].ItemArray[rs])); + } + if (values.Count > points) + { + headerCommond = new(cdeHeader, values); + results.Add(headerCommond); + } + } } r = new() { diff --git a/Server/appsettings.Development.json b/Server/appsettings.Development.json index fde98bb..f6635b1 100644 --- a/Server/appsettings.Development.json +++ b/Server/appsettings.Development.json @@ -1,7 +1,9 @@ { - "ConnectionString": "Data Source=MESSAD1001\\TEST1,59583;Integrated Security=True;Initial Catalog=Metrology;", + "xConnectionString": "Data Source=MESSAD1001\\TEST1,59583;Integrated Security=True;Initial Catalog=Metrology;", + "ConnectionString": "Data Source=messv01ec.ec.local\\PROD1,53959;Integrated Security=True;Initial Catalog=Metrology;", "IsDevelopment": true, - "MockRoot": "/Data/Tests", + "xMockRoot": "/Data/Tests", + "MockRoot": "", "MonAResource": "OI_Metrology_Viewer_IFX", "Oi2SqlConnectionString": "Data Source=MESSAD1001\\TEST1,59583;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;", "Serilog": { diff --git a/Shared/DataModels/HeaderCommond.cs b/Shared/DataModels/HeaderCommond.cs index a26fb61..a0f9e5d 100644 --- a/Shared/DataModels/HeaderCommond.cs +++ b/Shared/DataModels/HeaderCommond.cs @@ -2,16 +2,39 @@ public class HeaderCommond : HeaderCommon { - public string? PointA { get; set; } - public string? PointB { get; set; } - public string? PointC { get; set; } - public string? PointD { get; set; } - public string? PointE { get; set; } - public string? PointF { get; set; } - public string? PointG { get; set; } - public string? PointH { get; set; } - public string? PointI { get; set; } - public string? PointJ { get; set; } - public string? PointK { get; set; } - public string? PointL { get; set; } + + public string PointA { get; set; } + public string PointB { get; set; } + public string PointC { get; set; } + public string PointD { get; set; } + public string PointE { get; set; } + public string PointF { get; set; } + public string PointG { get; set; } + public string PointH { get; set; } + public string PointI { get; set; } + + public HeaderCommond(HeaderCommon headerCommon, List values) + { + ID = headerCommon.ID; + InsertDate = headerCommon.InsertDate; + AttachmentID = headerCommon.AttachmentID; + Title = headerCommon.Title; + Recipe = headerCommon.Recipe; + Date = headerCommon.Date; + ToolTypeID = headerCommon.ToolTypeID; + ToolTypeName = headerCommon.ToolTypeName; + Reactor = headerCommon.Reactor; + RDS = headerCommon.RDS; + PSN = headerCommon.PSN; + PointA = values[0]; + PointB = values[1]; + PointC = values[2]; + PointD = values[3]; + PointE = values[4]; + PointF = values[5]; + PointG = values[6]; + PointH = values[7]; + PointI = values[8]; + } + } \ No newline at end of file diff --git a/Shared/Models/Stateless/IPinRepository.cs b/Shared/Models/Stateless/IPinRepository.cs index 88788a8..6e9257d 100644 --- a/Shared/Models/Stateless/IPinRepository.cs +++ b/Shared/Models/Stateless/IPinRepository.cs @@ -7,12 +7,12 @@ public interface IPinRepository enum ToolId { - BioRad = 0, - CDE = 1, - Tencor = 2, - HgCV = 3, - Stratus = 4, - SP1 = 5, + BioRad = 1, + CDE = 2, + Tencor = 3, + HgCV = 4, + Stratus = 5, + SP1 = 6, } Result GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde); diff --git a/Tests/OI.Metrology.Tests.csproj b/Tests/OI.Metrology.Tests.csproj index 0ae91f2..be585e9 100644 --- a/Tests/OI.Metrology.Tests.csproj +++ b/Tests/OI.Metrology.Tests.csproj @@ -32,7 +32,7 @@ - + diff --git a/Tests/UnitTestPinController.cs b/Tests/UnitTestPinController.cs index 3c8814e..81f8c0c 100644 --- a/Tests/UnitTestPinController.cs +++ b/Tests/UnitTestPinController.cs @@ -43,9 +43,9 @@ public class UnitTestPinController IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService(); IPinRepository pinRepository = serviceProvider.GetRequiredService(); - string? cde = System.Text.Json.JsonSerializer.Serialize(new HeaderCommon { ID = 0, ToolTypeID = 0 }); - string? bioRad = System.Text.Json.JsonSerializer.Serialize(new HeaderCommon { ID = 0, ToolTypeID = 0 }); - Result result = pinRepository.GetPinnedTable(metrologyRepository, id: 0, bioRad, cde); + string? cde = System.Text.Json.JsonSerializer.Serialize(new HeaderCommon { ID = 196984, ToolTypeID = 2 }); + string? bioRad = System.Text.Json.JsonSerializer.Serialize(new HeaderCommon { ID = 321568, ToolTypeID = 1 }); + Result result = pinRepository.GetPinnedTable(metrologyRepository, id: 1, bioRad, cde); Assert.IsNotNull(result?.Results); Assert.IsTrue(result.Results.Any()); _Logger.Information($"{_TestContext?.TestName} completed");