Multiple Tool Types for Run Headers

This commit is contained in:
2023-01-23 12:03:06 -07:00
parent 3145c1b501
commit aae9cd18b2
7 changed files with 81 additions and 37 deletions

View File

@ -669,9 +669,12 @@ public class MetrologyRepository : IMetrologyRepository
return ds;
}
public IEnumerable<HeaderCommon> GetHeaderTitles(int toolTypeId, int? pageNo, int? pageSize, out long totalRecords)
public HeaderCommon[] GetHeaderTitles(int? toolTypeId, int? pageNo, int? pageSize, out long totalRecords)
{
ToolType tt = GetToolTypeByID(toolTypeId);
if (toolTypeId is null)
throw new Exception("Invalid tool type ID");
ToolType tt = GetToolTypeByID(toolTypeId.Value);
if (tt is null)
throw new Exception("Invalid tool type ID");
@ -680,17 +683,17 @@ public class MetrologyRepository : IMetrologyRepository
{
string sql = $"SELECT ID, InsertDate, AttachmentID, Title, [Date] FROM {tt.HeaderTableName} ORDER BY [Date] DESC ";
IEnumerable<HeaderCommon> headers;
HeaderCommon[] headers;
if (pageNo.HasValue && pageSize.HasValue)
{
sql += "OFFSET @PageNum * @PageSize ROWS FETCH NEXT @PageSize ROWS ONLY";
headers = conn.Query<HeaderCommon>(sql, param: new { PageNum = pageNo.Value, PageSize = pageSize.Value }).ToList();
headers = conn.Query<HeaderCommon>(sql, param: new { PageNum = pageNo.Value, PageSize = pageSize.Value }).ToArray();
}
else
{
headers = conn.Query<HeaderCommon>(sql).ToList();
headers = conn.Query<HeaderCommon>(sql).ToArray();
}
sql = $"SELECT COUNT(*) FROM [{tt.HeaderTableName}] ";