From 66f38fcf331d8997092c06f7f935b5fe7cd52887 Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Wed, 5 Apr 2023 13:15:24 -0700 Subject: [PATCH] nuget bump and userSecrets tasks and query update for event Allow multiple ids are present --- .vscode/tasks.json | 44 +++++++++ Archive/OI.Metrology.Archive.csproj | 4 +- Server/Controllers/PagesController.cs | 2 +- Server/OI.Metrology.Server.csproj | 6 +- Server/Repositories/InfinityQSRepository.cs | 41 ++++++++- Server/Repositories/InfinityQSV2Repository.cs | 45 ++++++++-- Shared/DataModels/InfinityQSEvent.cs | 90 +++++-------------- Shared/DataModels/Pinned.cs | 2 +- .../Models/Stateless/IInfinityQSRepository.cs | 1 + .../Stateless/IInfinityQSV2Repository.cs | 1 + Shared/OI.Metrology.Shared.csproj | 2 +- Tests/OI.Metrology.Tests.csproj | 2 +- Tests/UnitAwaitingDispoController.cs | 2 +- Tests/UnitTestAppSettingsController.cs | 14 +++ Tests/UnitTestClientSettingsController.cs | 2 +- Tests/UnitTestExportController.cs | 20 +++++ Tests/UnitTestInfinityQSController.cs | 38 +++++--- Tests/UnitTestInfinityQSV2Controller.cs | 39 +++++--- View/OI.Metrology.View.csproj | 6 +- azure-pipelines-server-development.yml | 51 +++++++---- azure-pipelines-server.yml | 30 +++---- 21 files changed, 296 insertions(+), 146 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 9e50e35..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", diff --git a/Archive/OI.Metrology.Archive.csproj b/Archive/OI.Metrology.Archive.csproj index a0d7d79..7023d0a 100644 --- a/Archive/OI.Metrology.Archive.csproj +++ b/Archive/OI.Metrology.Archive.csproj @@ -29,8 +29,8 @@ - - + + 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/OI.Metrology.Server.csproj b/Server/OI.Metrology.Server.csproj index 332c474..8031c60 100644 --- a/Server/OI.Metrology.Server.csproj +++ b/Server/OI.Metrology.Server.csproj @@ -27,15 +27,15 @@ - - + + - + diff --git a/Server/Repositories/InfinityQSRepository.cs b/Server/Repositories/InfinityQSRepository.cs index 9001770..5e295fc 100644 --- a/Server/Repositories/InfinityQSRepository.cs +++ b/Server/Repositories/InfinityQSRepository.cs @@ -116,9 +116,9 @@ public class InfinityQSRepository : IInfinityQSRepository InfinityQSBase[]? results = JsonSerializer.Deserialize(stringBuilder.ToString(), new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); if (results is null) throw new NullReferenceException(nameof(results)); - if (results.Select(l => l.SE_SGRP).Distinct().Count() != 1) - throw new NotSupportedException("Multiple ids are present!"); - result = (from l in results orderby l.SE_TSNO, l.TD_TEST select l).First(); + // if (results.Select(l => l.SE_SGRP).Distinct().Count() != 1) + // throw new NotSupportedException("Multiple ids are present!"); + result = (from l in results orderby l.SE_SGRP, l.SE_TSNO, l.TD_TEST select l).First(); return result; } @@ -177,6 +177,39 @@ public class InfinityQSRepository : IInfinityQSRepository return result; } + string IInfinityQSRepository.GetCommandText(InfinityQSBase infinityQSBase) + { + StringBuilder result = new(); + if (string.IsNullOrEmpty(infinityQSBase.PR_NAME)) + throw new ArgumentException(nameof(infinityQSBase.PR_NAME)); + if (string.IsNullOrEmpty(infinityQSBase.PD_NAME)) + throw new ArgumentException(nameof(infinityQSBase.PD_NAME)); + if (infinityQSBase.SE_SGTM is null) + throw new ArgumentException(nameof(infinityQSBase.SE_SGTM)); + _ = result + .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 ") + .AppendLine(" join [spcepiworld].[dbo].[part_dat] pd ") + .AppendLine(" on ev.f_part = pd.f_part ") + .AppendLine(" join [spcepiworld].[dbo].[test_dat] td ") + .AppendLine(" on ev.f_test = td.f_test ") + .Append(" where pr.f_name = '").Append(infinityQSBase.PR_NAME).AppendLine("' ") + .Append(" and pd.f_name = '").Append(infinityQSBase.PD_NAME).AppendLine("' ") + .Append(" and ev.f_sgtm = ").Append(infinityQSBase.SE_SGTM).AppendLine(" ") + .AppendLine(" for json path "); + return result.ToString(); + } + Result IInfinityQSRepository.GetEvents(string subGroupId) { Result? result; @@ -196,7 +229,7 @@ public class InfinityQSRepository : IInfinityQSRepository results = Array.Empty(); else { - string commandText = $"select * from [spcepiworld].[dbo].[evnt_inf] ev where ev.f_prcs = '{infinityQSBase.PR_NAME}' and ev.f_part = '{infinityQSBase.PD_NAME}' and ev.f_sgtm = {infinityQSBase.SE_SGTM} "; + string commandText = infinityQSRepository.GetCommandText(infinityQSBase); StringBuilder stringBuilder = GetForJsonPath(_DBConnectionFactory, commandText); results = JsonSerializer.Deserialize(stringBuilder.ToString(), new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); if (results is null) diff --git a/Server/Repositories/InfinityQSV2Repository.cs b/Server/Repositories/InfinityQSV2Repository.cs index b23acc7..973adef 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, ") @@ -117,9 +117,9 @@ public class InfinityQSV2Repository : IInfinityQSV2Repository if (collection is null) throw new NullReferenceException(nameof(collection)); InfinityQSBaseV2[] results = InfinityQSBase.Convert(collection); - if (results.Select(l => l.SubGroupId).Distinct().Count() != 1) - throw new NotSupportedException("Multiple ids are present!"); - result = (from l in results orderby l.SiteNumber, l.VariableNumber select l).First(); + // if (results.Select(l => l.SubGroupId).Distinct().Count() != 1) + // throw new NotSupportedException("Multiple ids are present!"); + result = (from l in results orderby l.SubGroupId, l.SiteNumber, l.VariableNumber select l).First(); return result; } @@ -180,6 +180,39 @@ public class InfinityQSV2Repository : IInfinityQSV2Repository return result; } + string IInfinityQSV2Repository.GetCommandText(InfinityQSBaseV2 infinityQSBase) + { + StringBuilder result = new(); + if (string.IsNullOrEmpty(infinityQSBase.Process)) + throw new ArgumentException(nameof(infinityQSBase.Process)); + if (string.IsNullOrEmpty(infinityQSBase.Part)) + throw new ArgumentException(nameof(infinityQSBase.Part)); + if (infinityQSBase.SubGroupDateTime is null) + throw new ArgumentException(nameof(infinityQSBase.SubGroupDateTime)); + _ = result + .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 ") + .AppendLine(" join [spcepiworld].[dbo].[part_dat] pd ") + .AppendLine(" on ev.f_part = pd.f_part ") + .AppendLine(" join [spcepiworld].[dbo].[test_dat] td ") + .AppendLine(" on ev.f_test = td.f_test ") + .Append(" where pr.f_name = '").Append(infinityQSBase.Process).AppendLine("' ") + .Append(" and pd.f_name = '").Append(infinityQSBase.Part).AppendLine("' ") + .Append(" and ev.f_sgtm = ").Append(infinityQSBase.SubGroupDateTime).AppendLine(" ") + .AppendLine(" for json path "); + return result.ToString(); + } + Result IInfinityQSV2Repository.GetEvents(string subGroupId) { Result? result; @@ -199,7 +232,7 @@ public class InfinityQSV2Repository : IInfinityQSV2Repository collection = Array.Empty(); else { - string commandText = $"select * from [spcepiworld].[dbo].[evnt_inf] ev where ev.f_prcs = '{infinityQSBase.Process}' and ev.f_part = '{infinityQSBase.Part}' and ev.f_sgtm = {infinityQSBase.SubGroupDateTime} "; + string commandText = infinityQSV2Repository.GetCommandText(infinityQSBase); StringBuilder stringBuilder = GetForJsonPath(_DBConnectionFactory, commandText); collection = JsonSerializer.Deserialize(stringBuilder.ToString(), new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); if (collection is null) 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/Shared/Models/Stateless/IInfinityQSRepository.cs b/Shared/Models/Stateless/IInfinityQSRepository.cs index 1b35a79..3f046e0 100644 --- a/Shared/Models/Stateless/IInfinityQSRepository.cs +++ b/Shared/Models/Stateless/IInfinityQSRepository.cs @@ -6,6 +6,7 @@ public interface IInfinityQSRepository { string GetCommandText(string subGroupId); + string GetCommandText(InfinityQSBase infinityQSBase); string GetCommandText(string? subGroupId, string? process, string? job, string? part, string? lot, string? dateTime); Result GetData(string subGroupId); Result GetDescriptors(string subGroupId); diff --git a/Shared/Models/Stateless/IInfinityQSV2Repository.cs b/Shared/Models/Stateless/IInfinityQSV2Repository.cs index 566c16c..31db4b1 100644 --- a/Shared/Models/Stateless/IInfinityQSV2Repository.cs +++ b/Shared/Models/Stateless/IInfinityQSV2Repository.cs @@ -6,6 +6,7 @@ public interface IInfinityQSV2Repository { string GetCommandText(string subGroupId); + string GetCommandText(InfinityQSBaseV2 infinityQSBase); string GetCommandText(string? subGroupId, string? process, string? job, string? part, string? lot, string? dateTime); Result GetData(string subGroupId); Result GetDescriptors(string subGroupId); diff --git a/Shared/OI.Metrology.Shared.csproj b/Shared/OI.Metrology.Shared.csproj index 526a475..9301b92 100644 --- a/Shared/OI.Metrology.Shared.csproj +++ b/Shared/OI.Metrology.Shared.csproj @@ -31,7 +31,7 @@ - + \ No newline at end of file diff --git a/Tests/OI.Metrology.Tests.csproj b/Tests/OI.Metrology.Tests.csproj index 3af27c8..3a478d7 100644 --- a/Tests/OI.Metrology.Tests.csproj +++ b/Tests/OI.Metrology.Tests.csproj @@ -32,7 +32,7 @@ - + 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"); diff --git a/Tests/UnitTestAppSettingsController.cs b/Tests/UnitTestAppSettingsController.cs index 575fbf3..c9132eb 100644 --- a/Tests/UnitTestAppSettingsController.cs +++ b/Tests/UnitTestAppSettingsController.cs @@ -29,12 +29,20 @@ public class UnitTestAppSettingsController _ControllerName = nameof(Server.ApiControllers.AppSettingsController)[..^10]; } + private static void NonThrowTryCatch() + { + try + { throw new Exception(); } + catch (Exception) { } + } + [TestMethod] public void TestControllerName() { _Logger.Information("Starting Web Application"); Assert.AreEqual(IAppSettingsController.GetRouteName(), _ControllerName); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -45,6 +53,7 @@ public class UnitTestAppSettingsController IAppSettingsRepository appSettingsRepository = serviceProvider.GetRequiredService>(); appSettingsRepository.VerifyConnectionStrings(); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -55,6 +64,7 @@ public class UnitTestAppSettingsController AppSettings appSettings = serviceProvider.GetRequiredService(); Assert.IsNotNull(appSettings); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -66,6 +76,7 @@ public class UnitTestAppSettingsController Server.Models.Binder.AppSettings appSettings = appSettingsRepository.GetAppSettings(); Assert.IsTrue(appSettings is not null); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -82,6 +93,7 @@ public class UnitTestAppSettingsController Assert.IsNotNull(json); Assert.IsTrue(json != "[]"); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -93,6 +105,7 @@ public class UnitTestAppSettingsController string result = appSettingsRepository.GetBuildNumberAndGitCommitSeven(); Assert.IsTrue(result is not null); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -108,6 +121,7 @@ public class UnitTestAppSettingsController File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetBuildNumberAndGitCommitSeven)}.json"), json); Assert.IsNotNull(json); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } } \ No newline at end of file diff --git a/Tests/UnitTestClientSettingsController.cs b/Tests/UnitTestClientSettingsController.cs index c4b14ab..5d0e835 100644 --- a/Tests/UnitTestClientSettingsController.cs +++ b/Tests/UnitTestClientSettingsController.cs @@ -54,8 +54,8 @@ public class UnitTestClientSettingsController { HttpClient httpClient = _WebApplicationFactory.CreateClient(); _Logger.Information("Starting Web Application"); - string actionName = nameof(IClientSettingsController.Action.Client); #if DEBUG + string actionName = nameof(IClientSettingsController.Action.Client); HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}"); Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode); Assert.AreEqual("application/json; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString()); diff --git a/Tests/UnitTestExportController.cs b/Tests/UnitTestExportController.cs index 4a5613f..8e296e5 100644 --- a/Tests/UnitTestExportController.cs +++ b/Tests/UnitTestExportController.cs @@ -29,12 +29,20 @@ public class UnitTestExportController _ControllerName = nameof(Server.ApiControllers.ExportController)[..^10]; } + private static void NonThrowTryCatch() + { + try + { throw new Exception(); } + catch (Exception) { } + } + [TestMethod] public void TestControllerName() { _Logger.Information("Starting Web Application"); Assert.AreEqual(IExportController.GetRouteName(), _ControllerName); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } private static HeaderCommon GetHeaderCommon() => @@ -52,6 +60,7 @@ public class UnitTestExportController string result = exportRepository.GetExport(GetHeaderCommon()); Assert.IsNotNull(result); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -63,6 +72,7 @@ public class UnitTestExportController File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetExport)}.txt"), result); Assert.IsNotNull(result); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -73,6 +83,7 @@ public class UnitTestExportController HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/export", GetStringContent()); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -84,6 +95,7 @@ public class UnitTestExportController Result result = exportRepository.GetHeaders(GetHeaderCommon()); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -96,6 +108,7 @@ public class UnitTestExportController Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -106,6 +119,7 @@ public class UnitTestExportController HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/headers", GetStringContent()); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -117,6 +131,7 @@ public class UnitTestExportController Result result = exportRepository.GetLogistics(GetHeaderCommon()); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -129,6 +144,7 @@ public class UnitTestExportController Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -139,6 +155,7 @@ public class UnitTestExportController HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/logistics", GetStringContent()); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -150,6 +167,7 @@ public class UnitTestExportController string result = exportRepository.GetProcessDataStandardFormat(GetHeaderCommon()); Assert.IsNotNull(result); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -161,6 +179,7 @@ public class UnitTestExportController File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetProcessDataStandardFormat)}.pdsf"), result); Assert.IsNotNull(result); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -171,6 +190,7 @@ public class UnitTestExportController HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/processDataStandardFormat", GetStringContent()); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } } \ No newline at end of file diff --git a/Tests/UnitTestInfinityQSController.cs b/Tests/UnitTestInfinityQSController.cs index 2b3fb8b..f4c5c15 100644 --- a/Tests/UnitTestInfinityQSController.cs +++ b/Tests/UnitTestInfinityQSController.cs @@ -28,15 +28,23 @@ public class UnitTestInfinityQSController _ControllerName = nameof(Server.ApiControllers.InfinityQSController)[..^10]; } + private static void NonThrowTryCatch() + { + try + { throw new Exception(); } + catch (Exception) { } + } + [TestMethod] public void TestControllerName() { _Logger.Information("Starting Web Application"); Assert.AreEqual(IInfinityQSController.GetRouteName(), _ControllerName); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -48,9 +56,10 @@ public class UnitTestInfinityQSController string result = infinityQSRepository.GetCommandText("1677273357", "61", "CDE5", "5012", "575908", ""); Assert.IsNotNull(result); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -62,9 +71,10 @@ public class UnitTestInfinityQSController File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCommandText)}.sql"), json); Assert.IsNotNull(json); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -82,9 +92,10 @@ public class UnitTestInfinityQSController Assert.IsNotNull(result?.Results[0].TD_NAME); Assert.IsNotNull(result?.Results[0].TD_TEST); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -98,9 +109,10 @@ public class UnitTestInfinityQSController Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -115,9 +127,10 @@ public class UnitTestInfinityQSController Assert.IsNotNull(result?.Results[0].SD_SGRP); Assert.IsNotNull(result?.Results[0].SD_TSNO); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -131,9 +144,10 @@ public class UnitTestInfinityQSController Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -145,9 +159,10 @@ public class UnitTestInfinityQSController Result result = infinityQSRepository.GetEvents("1677273357"); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -160,9 +175,10 @@ public class UnitTestInfinityQSController Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -174,9 +190,10 @@ public class UnitTestInfinityQSController Result result = infinityQSRepository.GetHeader("1677273357"); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -189,6 +206,7 @@ public class UnitTestInfinityQSController Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } } \ No newline at end of file diff --git a/Tests/UnitTestInfinityQSV2Controller.cs b/Tests/UnitTestInfinityQSV2Controller.cs index 60bc595..c83deab 100644 --- a/Tests/UnitTestInfinityQSV2Controller.cs +++ b/Tests/UnitTestInfinityQSV2Controller.cs @@ -28,17 +28,22 @@ public class UnitTestInfinityQSV2Controller _ControllerName = nameof(Server.ApiControllers.InfinityQSV2Controller)[..^10]; } + private static void NonThrowTryCatch() + { + try + { throw new Exception(); } + catch (Exception) { } + } + [TestMethod] public void TestControllerName() { _Logger.Information("Starting Web Application"); Assert.AreEqual(IInfinityQSV2Controller.GetRouteName(), _ControllerName); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true - [Ignore] -#endif [TestMethod] public void GetCommandText() { @@ -48,9 +53,10 @@ public class UnitTestInfinityQSV2Controller string result = infinityQSV2Repository.GetCommandText("1677273357", "61", "CDE5", "5012", "575908", ""); Assert.IsNotNull(result); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -62,9 +68,10 @@ public class UnitTestInfinityQSV2Controller File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCommandText)}.sql"), json); Assert.IsNotNull(json); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -82,9 +89,10 @@ public class UnitTestInfinityQSV2Controller Assert.IsNotNull(result?.Results[0].VariableNumber); Assert.IsNotNull(result?.Results[0].SubGroupDateTime); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -98,9 +106,10 @@ public class UnitTestInfinityQSV2Controller Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -115,9 +124,10 @@ public class UnitTestInfinityQSV2Controller Assert.IsNotNull(result?.Results[0].SubGroupId); Assert.IsNotNull(result?.Results[0].SiteNumber); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -131,9 +141,10 @@ public class UnitTestInfinityQSV2Controller Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -145,9 +156,10 @@ public class UnitTestInfinityQSV2Controller Result result = infinityQSV2Repository.GetEvents("1677273357"); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -160,9 +172,10 @@ public class UnitTestInfinityQSV2Controller Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -174,9 +187,10 @@ public class UnitTestInfinityQSV2Controller Result result = infinityQSV2Repository.GetHeader("1677273357"); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -189,6 +203,7 @@ public class UnitTestInfinityQSV2Controller Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } } \ No newline at end of file diff --git a/View/OI.Metrology.View.csproj b/View/OI.Metrology.View.csproj index 8de7e60..a539bc7 100644 --- a/View/OI.Metrology.View.csproj +++ b/View/OI.Metrology.View.csproj @@ -8,14 +8,14 @@ - - + + - + diff --git a/azure-pipelines-server-development.yml b/azure-pipelines-server-development.yml index 0a10f87..9165699 100644 --- a/azure-pipelines-server-development.yml +++ b/azure-pipelines-server-development.yml @@ -43,7 +43,7 @@ steps: set configuration=Debug echo %configuration% echo ##vso[task.setvariable variable=Configuration;]%configuration% - echo ($Configuration) + echo $(Configuration) displayName: Configuration - script: | @@ -61,16 +61,32 @@ steps: echo $(GitCommitSeven) displayName: GitCommitSeven + - script: | + set uuId=A6302662940458499454E35D28FCC9F7 + echo %uuId% + echo ##vso[task.setvariable variable=UUId;]%uuId% + echo $(UUId) + displayName: UUId + + - script: | + set pwEncoding=AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAtBhT01pNnUGaN/uPLxZGvAAAAAACAAAAAAADZgAAwAAAABAAAAAM4xlYguhv7jzchU8dq9pVAAAAAASAAACgAAAAEAAAANS9rIoaYfNq5TwCmTrqElsgAAAA7O4J52FqCctXlCxYB2J5b/W4T+pZCN2zwFj7XCAFW6IUAAAAhQsBDOERAUZJdtSy8AfxwOAZflo= + echo %pwEncoding% + echo ##vso[task.setvariable variable=PwEncoding;]%pwEncoding% + echo $(PwEncoding) + displayName: PwEncoding + - script: | echo $(Build.BuildId) echo $(Build.Reason) echo $(Build.Repository.Id) echo $(Build.Repository.Name) echo $(Build.SourceVersion) - echo $(CoreVersion) echo $(Configuration) - echo $(NugetSource) + echo $(CoreVersion) echo $(GitCommitSeven) + echo $(NugetSource) + echo $(PwEncoding) + echo $(UUId) REM echo $(pipelinePassword) displayName: "Echo Check" @@ -132,6 +148,14 @@ steps: testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" searchFolder: "$(System.DefaultWorkingDirectory)/.vscode" + - task: PublishTestResults@2 + displayName: "Publish Test Results **/coverage.cobertura.xml" + inputs: + testResultsFormat: VSTest + testResultsFiles: "**/coverage.cobertura.xml" + testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" + searchFolder: "$(System.DefaultWorkingDirectory)/.vscode" + - task: mspremier.CreateWorkItem.CreateWorkItem-task.CreateWorkItem@1 displayName: "Create work item" inputs: @@ -141,16 +165,10 @@ steps: assignedTo: "$(Build.RequestedForId)" enabled: false - - script: '"C:\program files\dotnet\dotnet.exe" publish --configuration $(Configuration) --runtime win-x64 --self-contained -o $(Build.ArtifactStagingDirectory)\Server --source $(NugetSource)' + - script: '"C:\program files\dotnet\dotnet.exe" publish --configuration $(Configuration) --runtime win-x64 --self-contained -o "D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server" --source $(NugetSource)' workingDirectory: Server displayName: "Core Publish" - - task: CopyFiles@2 - displayName: "Copy Files" - inputs: - SourceFolder: '$(Build.ArtifactStagingDirectory)\Server' - TargetFolder: 'D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server' - - script: 'sc stop "$(Build.Repository.Name)-$(Configuration)"' workingDirectory: Server displayName: "Service Control - Stop" @@ -171,10 +189,10 @@ steps: displayName: "Echo Path" - powershell: | - $data = @('$(downloadSecureFileKDBX.secureFilePath)', '-c:GetEntryString', '-Field:Password', '-refx-UUID:A6302662940458499454E35D28FCC9F7', '-pw-enc:AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAtBhT01pNnUGaN/uPLxZGvAAAAAACAAAAAAADZgAAwAAAABAAAAAM4xlYguhv7jzchU8dq9pVAAAAAASAAACgAAAAEAAAANS9rIoaYfNq5TwCmTrqElsgAAAA7O4J52FqCctXlCxYB2J5b/W4T+pZCN2zwFj7XCAFW6IUAAAAhQsBDOERAUZJdtSy8AfxwOAZflo=') + $data = @('$(downloadSecureFileKDBX.secureFilePath)', '-c:GetEntryString', '-Field:Password', '-refx-UUID:$(UUId)', '-pw-enc:$(PwEncoding)') $data.count $processStartInfo = New-Object System.Diagnostics.ProcessStartInfo - $processStartInfo.FileName = "C:\Users\meseafsvc\AppData\Local\IFXApps\KeePass-2.51.1---KPScript-2.51.1\KPScript.exe" + $processStartInfo.FileName = "C:\Users\$(USERNAME)\AppData\Local\IFXApps\KeePass-2.51.1---KPScript-2.51.1\KPScript.exe" $processStartInfo.RedirectStandardError = $true $processStartInfo.RedirectStandardOutput = $true $processStartInfo.UseShellExecute = $false @@ -190,7 +208,7 @@ steps: Write-Host "##vso[task.setvariable variable=pipelinePassword;]$stdout" displayName: pipelinePassword - - script: 'sc create "$(Build.Repository.Name)-$(Configuration)" start= delayed-auto DisplayName= "$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)" binPath= D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server\$(ExeName).exe obj= INFINEON\meseafsvc password="$(pipelinePassword)"' + - script: 'sc create "$(Build.Repository.Name)-$(Configuration)" start= delayed-auto DisplayName= "$(Build.Repository.Name)-$(Configuration)-$(GitCommitSeven)-$(Build.BuildId)" binPath= D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server\$(ExeName).exe obj= INFINEON\$(USERNAME) password="$(pipelinePassword)"' workingDirectory: Server displayName: "Service Control - Create" @@ -210,10 +228,5 @@ steps: workingDirectory: Server displayName: "Core Clean - Server" - - script: '"C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration)' - workingDirectory: Server - displayName: "Core Clean - Server" - - - script: 'echo $(Build.SourceVersion)-$(Build.BuildId)>bin_x_x_\Debug\$(CoreVersion)\win-x64\$(Build.Repository.Name).txt' - workingDirectory: "EAF Viewer" + - script: 'echo $(Build.SourceVersion)-$(Build.BuildId)>bin_x_x_\$(Configuration)\$(CoreVersion)\win-x64\$(Build.Repository.Name).txt' displayName: "Force Fail" diff --git a/azure-pipelines-server.yml b/azure-pipelines-server.yml index 5ef60c1..29e7346 100644 --- a/azure-pipelines-server.yml +++ b/azure-pipelines-server.yml @@ -21,8 +21,8 @@ pool: variables: # solution: '**/*.sln' # buildPlatform: 'Any CPU' - buildConfiguration: 'Release' - ASPNETCORE_ENVIRONMENT: 'Production' + buildConfiguration: "Release" + ASPNETCORE_ENVIRONMENT: "Production" steps: - script: | @@ -82,10 +82,10 @@ steps: - script: '"C:\program files\dotnet\dotnet.exe" build --configuration $(Configuration) --source $(NugetSource)' workingDirectory: Server displayName: "Core Build - Server" - + - powershell: Get-ChildItem .\ -include TestResults -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse } workingDirectory: "$(System.DefaultWorkingDirectory)/.vscode" - displayName: 'PowerShell Script' + displayName: "PowerShell Script" - script: "dotnet test --configuration $(Configuration)" workingDirectory: Tests @@ -110,6 +110,14 @@ steps: testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" searchFolder: "$(System.DefaultWorkingDirectory)/.vscode" + - task: PublishTestResults@2 + displayName: "Publish Test Results **/coverage.cobertura.xml" + inputs: + testResultsFormat: VSTest + testResultsFiles: "**/coverage.cobertura.xml" + testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" + searchFolder: "$(System.DefaultWorkingDirectory)/.vscode" + - task: mspremier.CreateWorkItem.CreateWorkItem-task.CreateWorkItem@1 displayName: "Create work item" inputs: @@ -119,26 +127,18 @@ steps: assignedTo: "$(Build.RequestedForId)" enabled: false - - script: '"C:\program files\dotnet\dotnet.exe" publish --configuration $(Configuration) --runtime win-x64 --self-contained -o $(Build.ArtifactStagingDirectory)\Server --source $(NugetSource)' + - script: '"C:\program files\dotnet\dotnet.exe" publish --configuration $(Configuration) --runtime win-x64 --self-contained -o "D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server" --source $(NugetSource)' workingDirectory: Server displayName: "Core Publish" - - task: CopyFiles@2 - displayName: "Copy Files" - inputs: - SourceFolder: '$(Build.ArtifactStagingDirectory)\Server' - TargetFolder: 'D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server' - - task: PublishBuildArtifacts@1 displayName: "Publish Artifact: drop" enabled: false - - script: | - "C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration) + - script: '"C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration)' workingDirectory: Tests displayName: "Core Clean - Tests" - - script: | - "C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration) + - script: '"C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration)' workingDirectory: Server displayName: "Core Clean - Server"