From 644cde644dce91050264cce5bd8859ca0cfef553 Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Fri, 24 Mar 2023 09:49:34 -0700 Subject: [PATCH] Fix-Event II --- .vscode/tasks.json | 70 +++++++++------ Server/Controllers/PagesController.cs | 2 +- Server/Repositories/InfinityQSRepository.cs | 15 ++-- Server/Repositories/InfinityQSV2Repository.cs | 19 ++-- Shared/DataModels/InfinityQSEvent.cs | 90 +++++-------------- Shared/DataModels/Pinned.cs | 2 +- Tests/UnitAwaitingDispoController.cs | 2 +- 7 files changed, 91 insertions(+), 109 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 3db76d0..710b24c 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,6 +1,50 @@ { "version": "2.0.0", + "options": { + "env": { + "serverUserSecretsId": "6501aa0f-8499-4be5-96a9-e99b11323eeb" + } + }, "tasks": [ + { + "label": "userSecretsInit", + "command": "dotnet", + "type": "process", + "args": [ + "user-secrets", + "-p", + "${workspaceFolder}/Server/OI.Metrology.Server.csproj", + "init" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "userSecretsSet", + "command": "dotnet", + "type": "process", + "args": [ + "user-secrets", + "-p", + "${workspaceFolder}/Server/OI.Metrology.Server.csproj", + "set", + "asdf", + "123" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "userSecretsMkLink", + "command": "cmd", + "type": "shell", + "args": [ + "/c", + "mklink", + "/J", + ".vscode\\UserSecrets", + "${userHome}\\AppData\\Roaming\\Microsoft\\UserSecrets\\$env:serverUserSecretsId" + ], + "problemMatcher": "$msCompile" + }, { "label": "buildServer", "command": "dotnet", @@ -167,32 +211,6 @@ "endsPattern": "^.*Application started.*" } } - }, - { - "label": "userSecretsInit", - "command": "dotnet", - "type": "process", - "args": [ - "user-secrets", - "-p", - "${workspaceFolder}/Server/OI.Metrology.Server.csproj", - "init" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "userSecretsSet", - "command": "dotnet", - "type": "process", - "args": [ - "user-secrets", - "-p", - "${workspaceFolder}/Server/OI.Metrology.Server.csproj", - "set", - "asdf", - "123" - ], - "problemMatcher": "$msCompile" } ] } \ No newline at end of file diff --git a/Server/Controllers/PagesController.cs b/Server/Controllers/PagesController.cs index c7c52a1..8bf3f31 100644 --- a/Server/Controllers/PagesController.cs +++ b/Server/Controllers/PagesController.cs @@ -15,7 +15,7 @@ public class PagesController : Controller public PagesController(AppSettings appSettings, IMetrologyRepository metrologyRepository) { - _AppSettings=appSettings; + _AppSettings = appSettings; _MetrologyRepository = metrologyRepository; _IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase); } diff --git a/Server/Repositories/InfinityQSRepository.cs b/Server/Repositories/InfinityQSRepository.cs index 52c9bdf..00c155a 100644 --- a/Server/Repositories/InfinityQSRepository.cs +++ b/Server/Repositories/InfinityQSRepository.cs @@ -187,12 +187,15 @@ public class InfinityQSRepository : IInfinityQSRepository if (infinityQSBase.SE_SGTM is null) throw new ArgumentException(nameof(infinityQSBase.SE_SGTM)); _ = result - .AppendLine(" select ev.f_evnt, ") - .AppendLine(" ev.f_sgtm, ") - .AppendLine(" pr.f_name, ") - .AppendLine(" pd.f_name, ") - .AppendLine(" td.f_name, ") - .AppendLine(" ev.f_name ") + .AppendLine(" select ") + .AppendLine(" ev.f_evnt [ev_evnt], ") + .AppendLine(" ev.f_sgtm [ev_sgtm], ") + .AppendLine(" dateadd(HH, -7, (dateadd(SS, convert(bigint, ev.f_sgtm), '19700101'))) [ev_utc7], ") + .AppendLine(" pr.f_name [pr_name], ") + .AppendLine(" pd.f_name [pd_name], ") + .AppendLine(" td.f_test [td_test], ") + .AppendLine(" td.f_name [td_name], ") + .AppendLine(" ev.f_name [ev_name] ") .AppendLine(" from [spcepiworld].[dbo].[evnt_inf] ev ") .AppendLine(" join [spcepiworld].[dbo].[prcs_dat] pr ") .AppendLine(" on ev.f_prcs = pr.f_prcs ") diff --git a/Server/Repositories/InfinityQSV2Repository.cs b/Server/Repositories/InfinityQSV2Repository.cs index 6934cbd..8b966ef 100644 --- a/Server/Repositories/InfinityQSV2Repository.cs +++ b/Server/Repositories/InfinityQSV2Repository.cs @@ -26,7 +26,7 @@ public class InfinityQSV2Repository : IInfinityQSV2Repository { StringBuilder result = new(); if (string.IsNullOrEmpty(subGroupId)) - throw new ArgumentException(nameof(subGroupId)); + throw new ArgumentException(null, nameof(subGroupId)); _ = result .AppendLine(" select ") .AppendLine(" sd.f_sgrp sd_sgrp, ") @@ -50,7 +50,7 @@ public class InfinityQSV2Repository : IInfinityQSV2Repository StringBuilder result = new(); const string dateTimeFormat = "yyyy-MM-dd HH:mm:ss"; if (!string.IsNullOrEmpty(dateTime) && (dateTime.Contains('-') || dateTime.Contains(' ') || dateTime.Contains(':')) && dateTime.Length != dateTimeFormat.Length) - throw new ArgumentException(nameof(dateTime)); + throw new ArgumentException(null, nameof(dateTime)); _ = result .AppendLine(" select ") .AppendLine(" se.f_sgrp se_sgrp, ") @@ -190,12 +190,15 @@ public class InfinityQSV2Repository : IInfinityQSV2Repository if (infinityQSBase.SubGroupDateTime is null) throw new ArgumentException(nameof(infinityQSBase.SubGroupDateTime)); _ = result - .AppendLine(" select ev.f_evnt, ") - .AppendLine(" ev.f_sgtm, ") - .AppendLine(" pr.f_name, ") - .AppendLine(" pd.f_name, ") - .AppendLine(" td.f_name, ") - .AppendLine(" ev.f_name ") + .AppendLine(" select ") + .AppendLine(" ev.f_evnt [ev_evnt], ") + .AppendLine(" ev.f_sgtm [ev_sgtm], ") + .AppendLine(" dateadd(HH, -7, (dateadd(SS, convert(bigint, ev.f_sgtm), '19700101'))) [ev_utc7], ") + .AppendLine(" pr.f_name [pr_name], ") + .AppendLine(" pd.f_name [pd_name], ") + .AppendLine(" td.f_test [td_test], ") + .AppendLine(" td.f_name [td_name], ") + .AppendLine(" ev.f_name [ev_name] ") .AppendLine(" from [spcepiworld].[dbo].[evnt_inf] ev ") .AppendLine(" join [spcepiworld].[dbo].[prcs_dat] pr ") .AppendLine(" on ev.f_prcs = pr.f_prcs ") diff --git a/Shared/DataModels/InfinityQSEvent.cs b/Shared/DataModels/InfinityQSEvent.cs index a86c23a..eaa07ee 100644 --- a/Shared/DataModels/InfinityQSEvent.cs +++ b/Shared/DataModels/InfinityQSEvent.cs @@ -1,27 +1,13 @@ namespace OI.Metrology.Shared.DataModels; -public record InfinityQSEvent(int F_EVNT, - int F_CRTM, - int F_EDTM, - int F_TYPE, - string F_NAME, - int F_EMPL, - int F_EVTM, - int F_PRCS, - int F_PART, - int F_TEST, - int F_SGTM, - int F_ACC, - int F_ACEM, - int F_ACTM, - int F_CAC, - int F_CAEM, - int F_CATM, - int F_FLAG, - int F_USER, - int F_DSBL, - int F_RFC, - int F_TRTM) +public record InfinityQSEvent(int EV_EVNT, + int EV_SGTM, + string EV_UTC7, + string PR_NAME, + string PD_NAME, + int TD_TEST, + string TD_NAME, + string EV_NAME) { public static InfinityQSEventV2[] Convert(InfinityQSEvent[] collection) @@ -34,53 +20,25 @@ public record InfinityQSEvent(int F_EVNT, public static InfinityQSEventV2 Map(InfinityQSEvent item) { - InfinityQSEventV2 result = new(item.F_EVNT, - item.F_CRTM, - item.F_EDTM, - item.F_TYPE, - item.F_NAME, - item.F_EMPL, - item.F_EVTM, - item.F_PRCS, - item.F_PART, - item.F_TEST, - item.F_SGTM, - item.F_ACC, - item.F_ACEM, - item.F_ACTM, - item.F_CAC, - item.F_CAEM, - item.F_CATM, - item.F_FLAG, - item.F_USER, - item.F_DSBL, - item.F_RFC, - item.F_TRTM); + InfinityQSEventV2 result = new(item.EV_EVNT, + item.EV_SGTM, + item.EV_UTC7, + item.PR_NAME, + item.PD_NAME, + item.TD_TEST, + item.TD_NAME, + item.EV_NAME); return result; } } -public record InfinityQSEventV2(int Evnt, - int Crtm, - int Edtm, - int Type, - string Name, - int Empl, - int Evtm, - int Prcs, - int Part, - int Test, - int Sgtm, - int Acc, - int Acem, - int Actm, - int Cac, - int Caem, - int Catm, - int Flag, - int User, - int Dsbl, - int Rfc, - int Trtm) +public record InfinityQSEventV2(int EventId, + int SubGroupDateTimeId, + string SubGroupDateTime, + string Process, + string Part, + int VariableNumber, + string Variable, + string Name) { } \ No newline at end of file diff --git a/Shared/DataModels/Pinned.cs b/Shared/DataModels/Pinned.cs index d81af1d..7c970bb 100644 --- a/Shared/DataModels/Pinned.cs +++ b/Shared/DataModels/Pinned.cs @@ -24,7 +24,7 @@ public class Pinned : HeaderCommon ToolTypeName = headerCommon.ToolTypeName; MesEntity = headerCommon.MesEntity; - + Employee = headerCommon.Employee; Layer = headerCommon.Layer; PSN = headerCommon.PSN; diff --git a/Tests/UnitAwaitingDispoController.cs b/Tests/UnitAwaitingDispoController.cs index 8fa1379..a816459 100644 --- a/Tests/UnitAwaitingDispoController.cs +++ b/Tests/UnitAwaitingDispoController.cs @@ -54,7 +54,7 @@ public class UnitAwaitingDispoController public async Task IndexApi() { HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + _Logger.Information("Starting Web Application"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(IMetrologyRepository.GetAwaitingDisposition)}Api.json"), json); _Logger.Information($"{_TestContext?.TestName} completed");