diff --git a/.editorconfig b/.editorconfig index 6a59641..e394f93 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,3 +1,19 @@ +[*.md] +end_of_line = crlf +file_header_template = unset +indent_size = 2 +indent_style = space +insert_final_newline = false +root = true +tab_width = 2 +[*.csproj] +end_of_line = crlf +file_header_template = unset +indent_size = 2 +indent_style = space +insert_final_newline = false +root = true +tab_width = 2 [*.cs] csharp_indent_block_contents = true csharp_indent_braces = false @@ -13,6 +29,7 @@ csharp_new_line_before_members_in_object_initializers = true csharp_new_line_before_open_brace = all csharp_new_line_between_query_expression_clauses = true csharp_prefer_braces = false +csharp_prefer_qualified_reference = true:error csharp_prefer_simple_default_expression = true:warning csharp_prefer_simple_using_statement = true:warning csharp_prefer_static_local_function = true:warning @@ -79,15 +96,22 @@ dotnet_code_quality.CAXXXX.api_surface = private, internal dotnet_diagnostic.CA1825.severity = warning # CA1823: Avoid zero-length array allocations dotnet_diagnostic.CA1829.severity = warning # CA1829: Use Length/Count property instead of Count() when available dotnet_diagnostic.CA1834.severity = warning # CA1834: Consider using 'StringBuilder.Append(char)' when applicable +dotnet_diagnostic.CA1860.severity = error # CA1860: Prefer comparing 'Count' to 0 rather than using 'Any()', both for clarity and for performance +dotnet_diagnostic.CA1869.severity = none # CA1869: Avoid creating a new 'JsonSerializerOptions' instance for every serialization operation. Cache and reuse instances instead. +dotnet_diagnostic.CA2254.severity = none # CA2254: The logging message template should not vary between calls to 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' dotnet_diagnostic.IDE0001.severity = warning # IDE0001: Simplify name dotnet_diagnostic.IDE0002.severity = warning # Simplify (member access) - System.Version.Equals("1", "2"); Version.Equals("1", "2"); dotnet_diagnostic.IDE0004.severity = warning # IDE0004: Cast is redundant. dotnet_diagnostic.IDE0005.severity = warning # Using directive is unnecessary +dotnet_diagnostic.IDE0028.severity = error # IDE0028: Collection initialization can be simplified dotnet_diagnostic.IDE0031.severity = warning # Use null propagation (IDE0031) dotnet_diagnostic.IDE0047.severity = warning # IDE0047: Parentheses can be removed dotnet_diagnostic.IDE0049.severity = warning # Use language keywords instead of framework type names for type references (IDE0049) dotnet_diagnostic.IDE0060.severity = warning # IDE0060: Remove unused parameter -dotnet_diagnostic.IDE0270.severity = warning # IDE0270: Null check can be simplified +dotnet_diagnostic.IDE0290.severity = none # Use primary constructor [Distance]csharp(IDE0290) +dotnet_diagnostic.IDE0300.severity = error # IDE0300: Collection initialization can be simplified +dotnet_diagnostic.IDE0301.severity = error #IDE0301: Collection initialization can be simplified +dotnet_diagnostic.IDE0305.severity = none # IDE0305: Collection initialization can be simplified dotnet_naming_rule.abstract_method_should_be_pascal_case.severity = warning dotnet_naming_rule.abstract_method_should_be_pascal_case.style = pascal_case dotnet_naming_rule.abstract_method_should_be_pascal_case.symbols = abstract_method diff --git a/.gitignore b/.gitignore index e5ca0f7..dd7b20d 100644 --- a/.gitignore +++ b/.gitignore @@ -340,4 +340,6 @@ ASALocalRun/ !.vscode/thunder-tests/ # Libman.json -/wwwroot/lib/* \ No newline at end of file +/wwwroot/lib/* + +.kanbn/**/* \ No newline at end of file diff --git a/.kanbn/board.css b/.kanbn/board.css deleted file mode 100644 index 427c0bd..0000000 --- a/.kanbn/board.css +++ /dev/null @@ -1,28 +0,0 @@ -.kanbn-column-wip .kanbn-column-task-list { - border-color: #6929c4; -} -.kanbn-column-next .kanbn-column-task-list { - border-color: #1192e8; -} -.kanbn-column-wait .kanbn-column-task-list { - border-color: #005d5d; -} -.kanbn-column-later .kanbn-column-task-list { - border-color: #9f1853; -} -.kanbn-column-maybe .kanbn-column-task-list { - border-color: #fa4d56; -} -.kanbn-column-friday .kanbn-column-task-list { - border-color: #570408; -} -.kanbn-column-done .kanbn-column-task-list { - border-color: #198038; -} -.kanbn-task-data-workload { - display: none; -} -.kanbn-task-data-relation { - display: block; - color: #198038; -} diff --git a/.kanbn/index.md b/.kanbn/index.md deleted file mode 100644 index 3106b8b..0000000 --- a/.kanbn/index.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -startedColumns: - - 'In Progress' -completedColumns: - - Done -dateFormat: mm/dd ---- - -# OI-Metrology - -## Backlog - -- [change-eaf-to-save-and-info-pdsf](tasks/change-eaf-to-save-and-info-pdsf.md) - -## Todo - -## In Progress - -## Done diff --git a/.kanbn/tasks/change-eaf-to-save-and-info-pdsf.md b/.kanbn/tasks/change-eaf-to-save-and-info-pdsf.md deleted file mode 100644 index f5d515e..0000000 --- a/.kanbn/tasks/change-eaf-to-save-and-info-pdsf.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -created: "2023-06-27T13:07:40.782Z" -updated: "2023-07-18T17:46:17.284Z" -status: "1-Backlog" -type: "note" ---- - -# change-eaf-to-save-and-info-pdsf - -## Sub-tasks - -- [ ] change-eaf-to-save-and-info-pdsf - -## Relations - -- ~~change-eaf-to-save-and-info-pdsf.md~~ diff --git a/.vscode/tasks.json b/.vscode/tasks.json index ad47041..9ba5d7d 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -22,8 +22,8 @@ "-p", "${workspaceFolder}/Server/OI.Metrology.Server.csproj", "set", - "asdf", - "123" + "_Application", + "oi-metrology-viewer.Server" ], "problemMatcher": "$msCompile" }, @@ -39,6 +39,18 @@ ], "problemMatcher": "$msCompile" }, + { + "label": "buildTests", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/Tests/OI.Metrology.Tests.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, { "label": "publishServer", "command": "dotnet", diff --git a/Server/.vscode/tasks.json b/Server/.vscode/tasks.json index 82dead4..0a3c6c0 100644 --- a/Server/.vscode/tasks.json +++ b/Server/.vscode/tasks.json @@ -70,6 +70,12 @@ "endsPattern": "^.*Application started.*" } } + }, + { + "label": "File-Folder-Helper AOT s V Repositories", + "type": "shell", + "command": "& L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net7.0/win-x64/publish/File-Folder-Helper.exe s V Repositories", + "problemMatcher": [] } ] } \ No newline at end of file diff --git a/Server/ApiControllers/InboundController.cs b/Server/ApiControllers/InboundController.cs index 6014b26..bff439f 100644 --- a/Server/ApiControllers/InboundController.cs +++ b/Server/ApiControllers/InboundController.cs @@ -56,7 +56,7 @@ public partial class InboundController : ControllerBase, IInboundController +{ + + private readonly IInfinityQSV3Repository _InfinityQSRepositoryV3; + + public InfinityQSV3Controller(IInfinityQSV3Repository InfinityQSRepositoryV3) => _InfinityQSRepositoryV3 = InfinityQSRepositoryV3; + + [HttpGet("{sub_group_id}/commandText")] + public IActionResult GetCommandText(string sub_group_id, string process, string job, string part, string lot, string date_time) + { + string commandText = _InfinityQSRepositoryV3.GetCommandText(sub_group_id, process, job, part, lot, date_time); + return Content(commandText, "text/plain; charset=utf-8"); + } + + [HttpGet("{sub_group_id}/data")] + public IActionResult GetData(string sub_group_id) + { + Result result = _InfinityQSRepositoryV3.GetData(sub_group_id); + string json = JsonSerializer.Serialize(result, ResultInfinityQSV3SourceGenerationContext.Default.ResultInfinityQSV3Array); + return Content(json, "application/json", System.Text.Encoding.UTF8); + } + + [HttpGet("{sub_group_id}/descriptors")] + public IActionResult GetDescriptors(string sub_group_id) + { + Result result = _InfinityQSRepositoryV3.GetDescriptors(sub_group_id); + string json = JsonSerializer.Serialize(result, ResultInfinityQSDescriptorV3SourceGenerationContext.Default.ResultInfinityQSDescriptorV3Array); + return Content(json, "application/json", System.Text.Encoding.UTF8); + } + + [HttpGet("{sub_group_id}/header")] + public IActionResult GetHeader(string sub_group_id) + { + Result result = _InfinityQSRepositoryV3.GetHeader(sub_group_id); + string json = JsonSerializer.Serialize(result, ResultInfinityQSV3SourceGenerationContext.Default.ResultInfinityQSV3Array); + return Content(json, "application/json", System.Text.Encoding.UTF8); + } + + [HttpGet("{process}/product-data-average-sum-of-defects-process-mean-process-sigma")] + public IActionResult GetProductDataAverageSumOfDefectsProcessMeanProcessSigma(string process, string? recipe) + { + string result = _InfinityQSRepositoryV3.GetProductDataAverageSumOfDefectsProcessMeanProcessSigma(process, recipe); + return Content(result, "application/json", System.Text.Encoding.UTF8); + } + +} \ No newline at end of file diff --git a/Server/ApiControllers/OpenInsightV1Controller.cs b/Server/ApiControllers/OpenInsightV1Controller.cs new file mode 100644 index 0000000..68a5f69 --- /dev/null +++ b/Server/ApiControllers/OpenInsightV1Controller.cs @@ -0,0 +1,24 @@ +using Microsoft.AspNetCore.Mvc; + +namespace OI.Metrology.Server.ApiControllers; + +using OI.Metrology.Shared.Models.Stateless; + +[Route("api/[controller]")] +public class OpenInsightV1Controller : Controller, IOpenInsightV1Controller +{ + + private readonly IOpenInsightV1Repository _OpenInsightRepository; + + public OpenInsightV1Controller(IOpenInsightV1Repository openInsightRepository) => + _OpenInsightRepository = openInsightRepository; + + [HttpGet] + [Route("{rds}/tencor-run")] + public IActionResult GetTencorRun(string rds, string? insert_date, string? recipe) + { + string result = _OpenInsightRepository.GetTencorRun(rds, insert_date, recipe); + return Content(result, "application/json", System.Text.Encoding.UTF8); + } + +} \ No newline at end of file diff --git a/Server/Data/Tests/InfinityQSV3-GetData.json b/Server/Data/Tests/InfinityQSV3-GetData.json new file mode 100644 index 0000000..59e9da0 --- /dev/null +++ b/Server/Data/Tests/InfinityQSV3-GetData.json @@ -0,0 +1,1023 @@ +{ + "Results": [ + { + "iq_sum": 1, + "sl_aflag": 34, + "sl_loos": 0, + "sl_uoos": 1, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240302, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RhoAvgMean", + "se_val": 12.66, + "sl_eflag": 42, + "sl_scal": 4, + "sl_sls": 12.379, + "sl_usl": 12.561 + }, + { + "iq_sum": 1, + "sl_aflag": 34, + "sl_loos": 0, + "sl_uoos": 1, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240302, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RhoAvgMean", + "se_val": 12.66, + "sl_eflag": 42, + "sl_scal": 4, + "sl_sls": 12.379, + "sl_usl": 12.561 + }, + { + "iq_sum": 0, + "sl_aflag": 34, + "sl_loos": 0, + "sl_uoos": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240282, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "Area", + "se_val": 0.0209, + "sl_eflag": 42, + "sl_scal": 4, + "sl_sls": 0.0205, + "sl_usl": 0.0225 + }, + { + "iq_sum": 0, + "sl_aflag": 34, + "sl_loos": 0, + "sl_uoos": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240304, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RhoAvgStdDev", + "se_val": 0.05644, + "sl_eflag": 42, + "sl_scal": 4, + "sl_sls": -0.693, + "sl_usl": 1.305 + }, + { + "iq_sum": 0, + "sl_aflag": 34, + "sl_loos": 0, + "sl_uoos": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1677809897, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "Variation", + "se_val": 18.542081, + "sl_eflag": 42, + "sl_scal": 4, + "sl_sls": 12, + "sl_usl": 21 + }, + { + "iq_sum": 0, + "sl_aflag": 34, + "sl_loos": 0, + "sl_uoos": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240282, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "Area", + "se_val": 0.0209, + "sl_eflag": 42, + "sl_scal": 4, + "sl_sls": 0.0205, + "sl_usl": 0.0225 + }, + { + "iq_sum": 0, + "sl_aflag": 34, + "sl_loos": 0, + "sl_uoos": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240304, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RhoAvgStdDev", + "se_val": 0.05644, + "sl_eflag": 42, + "sl_scal": 4, + "sl_sls": -0.693, + "sl_usl": 1.305 + }, + { + "iq_sum": 0, + "sl_aflag": 34, + "sl_loos": 0, + "sl_uoos": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1677809897, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "Variation", + "se_val": 18.542081, + "sl_eflag": 42, + "sl_scal": 4, + "sl_sls": 12, + "sl_usl": 21 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1654782822, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RhoAvg", + "se_val": 12.66 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1656695902, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "GradeStdDev", + "se_val": 6.875 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240283, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "Ccomp", + "se_val": 1.02 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240284, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "FlatZ", + "se_val": 8.023 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240285, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "FlatZMean", + "se_val": 8.023 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240286, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "FlatZRadialGradient", + "se_val": 0 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240287, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "FlatZStdDev", + "se_val": -1 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240288, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "Grade", + "se_val": 2.086 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240289, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "GradeMean", + "se_val": 1.989 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240290, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "GradeRadialGradient", + "se_val": 4.861 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240291, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "NAvg", + "se_val": 344300000000000 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240292, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "NAvgMean", + "se_val": 344400000000000 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240293, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "NAvgRadialGradient", + "se_val": 0.04068 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240294, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "NAvgStdDev", + "se_val": 0.05753 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240295, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "Nsl", + "se_val": 345700000000000 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240296, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "NslMean", + "se_val": 345800000000000 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240297, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "NslRadialGradient", + "se_val": 0.03264 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240298, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "NslStdDev", + "se_val": 0.04617 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240299, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "PhaseMean", + "se_val": 90 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240300, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "PhaseRadialGradient", + "se_val": 0 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240301, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "PhaseStdDev", + "se_val": -1 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240303, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RhoAvgRadialGradient", + "se_val": 0.03991 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240305, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "Rhosl", + "se_val": 12.61 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240306, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RhoslMean", + "se_val": 12.61 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240307, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RhoslRadialGradient", + "se_val": 0.03202 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240308, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RhoslStdDev", + "se_val": 0.04528 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240309, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RsMean", + "se_val": -1 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240310, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RsRadialGradient", + "se_val": 0 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240311, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RsStdDev", + "se_val": -1 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240312, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "Vd", + "se_val": 0.585 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240313, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "VdMean", + "se_val": 0.5892 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240314, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "VdRadialGradient", + "se_val": 0.7408 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240315, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "VdStdDev", + "se_val": 1.048 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1654782822, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RhoAvg", + "se_val": 12.65 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1656695902, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "GradeStdDev", + "se_val": 6.875 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240283, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "Ccomp", + "se_val": 1.02 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240284, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "FlatZ", + "se_val": 8.023 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240285, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "FlatZMean", + "se_val": 8.023 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240286, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "FlatZRadialGradient", + "se_val": 0 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240287, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "FlatZStdDev", + "se_val": -1 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240288, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "Grade", + "se_val": 1.892 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240289, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "GradeMean", + "se_val": 1.989 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240290, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "GradeRadialGradient", + "se_val": 4.861 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240291, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "NAvg", + "se_val": 344600000000000 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240292, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "NAvgMean", + "se_val": 344400000000000 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240293, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "NAvgRadialGradient", + "se_val": 0.04068 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240294, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "NAvgStdDev", + "se_val": 0.05753 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240295, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "Nsl", + "se_val": 345900000000000 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240296, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "NslMean", + "se_val": 345800000000000 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240297, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "NslRadialGradient", + "se_val": 0.03264 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240298, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "NslStdDev", + "se_val": 0.04617 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240299, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "PhaseMean", + "se_val": 90 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240300, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "PhaseRadialGradient", + "se_val": 0 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240301, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "PhaseStdDev", + "se_val": -1 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240303, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RhoAvgRadialGradient", + "se_val": 0.03991 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240305, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "Rhosl", + "se_val": 12.602 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240306, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RhoslMean", + "se_val": 12.61 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240307, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RhoslRadialGradient", + "se_val": 0.03202 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240308, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RhoslStdDev", + "se_val": 0.04528 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240309, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RsMean", + "se_val": -1 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240310, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RsRadialGradient", + "se_val": 0 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240311, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RsStdDev", + "se_val": -1 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240312, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "Vd", + "se_val": 0.594 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240313, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "VdMean", + "se_val": 0.5892 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240314, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "VdRadialGradient", + "se_val": 0.7408 + }, + { + "iq_sum": 0, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 2, + "td_test": 1657240315, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "VdStdDev", + "se_val": 1.048 + } + ], + "TotalRows": 74 +} \ No newline at end of file diff --git a/Server/Data/Tests/InfinityQSV3-GetDescriptors.json b/Server/Data/Tests/InfinityQSV3-GetDescriptors.json new file mode 100644 index 0000000..a3da596 --- /dev/null +++ b/Server/Data/Tests/InfinityQSV3-GetDescriptors.json @@ -0,0 +1,152 @@ +{ + "Results": [ + { + "sd_sgrp": 1698497987, + "sd_tsno": 1, + "dd_dsgp": 1657291789, + "gd_name": "CondType", + "dd_name": "N" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 2, + "dd_dsgp": 1657291789, + "gd_name": "CondType", + "dd_name": "N" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 1, + "dd_dsgp": 1657291790, + "gd_name": "GLimit", + "dd_name": "2000.00 \u00B5" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 2, + "dd_dsgp": 1657291790, + "gd_name": "GLimit", + "dd_name": "2000.00 \u00B5" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 1, + "dd_dsgp": 1657296863, + "gd_name": "Model", + "dd_name": "PARALLEL" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 2, + "dd_dsgp": 1657296863, + "gd_name": "Model", + "dd_name": "PARALLEL" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 0, + "dd_dsgp": 1657296864, + "gd_name": "Pattern", + "dd_name": "ONEPT.PAT" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 1, + "dd_dsgp": 1657296865, + "gd_name": "Phase", + "dd_name": "90.000" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 2, + "dd_dsgp": 1657296865, + "gd_name": "Phase", + "dd_name": "90.000" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 1, + "dd_dsgp": 1657296866, + "gd_name": "Plan", + "dd_name": "5PT MES" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 2, + "dd_dsgp": 1657296866, + "gd_name": "Plan", + "dd_name": "5PT MES" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 1, + "dd_dsgp": 1657296867, + "gd_name": "RampRate", + "dd_name": "2500" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 2, + "dd_dsgp": 1657296867, + "gd_name": "RampRate", + "dd_name": "2500" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 1, + "dd_dsgp": 1657296868, + "gd_name": "RhoMethod", + "dd_name": "ASTM: F723 - 82" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 2, + "dd_dsgp": 1657296868, + "gd_name": "RhoMethod", + "dd_name": "ASTM: F723 - 82" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 1, + "dd_dsgp": 1657296869, + "gd_name": "StartVoltage", + "dd_name": "-5.00" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 2, + "dd_dsgp": 1657296869, + "gd_name": "StartVoltage", + "dd_name": "-5.00" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 1, + "dd_dsgp": 1657296870, + "gd_name": "StopVoltage", + "dd_name": "-20.00" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 2, + "dd_dsgp": 1657296870, + "gd_name": "StopVoltage", + "dd_name": "-20.00" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 1, + "dd_dsgp": 1657296871, + "gd_name": "WaferSize", + "dd_name": "150.00" + }, + { + "sd_sgrp": 1698497987, + "sd_tsno": 2, + "dd_dsgp": 1657296871, + "gd_name": "WaferSize", + "dd_name": "150.00" + } + ], + "TotalRows": 21 +} \ No newline at end of file diff --git a/Server/Data/Tests/InfinityQSV3-GetHeader.json b/Server/Data/Tests/InfinityQSV3-GetHeader.json new file mode 100644 index 0000000..cbd797f --- /dev/null +++ b/Server/Data/Tests/InfinityQSV3-GetHeader.json @@ -0,0 +1,25 @@ +{ + "Results": [ + { + "iq_sum": 1, + "sl_aflag": 34, + "sl_loos": 0, + "sl_uoos": 1, + "se_sgrp": 1698497987, + "se_sgtm": 1698497973, + "se_tsno": 1, + "td_test": 1657240302, + "pr_name": "HGCV2", + "jd_name": "HGCV2", + "pl_name": "-", + "pd_name": "High", + "td_name": "RhoAvgMean", + "se_val": 12.66, + "sl_eflag": 42, + "sl_scal": 4, + "sl_sls": 12.379, + "sl_usl": 12.561 + } + ], + "TotalRows": 1 +} \ No newline at end of file diff --git a/Server/Data/Tests/InfinityQSV3-GetProductDataAverageSumOfDefectsProcessMeanProcessSigma.json b/Server/Data/Tests/InfinityQSV3-GetProductDataAverageSumOfDefectsProcessMeanProcessSigma.json new file mode 100644 index 0000000..173a90b --- /dev/null +++ b/Server/Data/Tests/InfinityQSV3-GetProductDataAverageSumOfDefectsProcessMeanProcessSigma.json @@ -0,0 +1 @@ +[{"ProcessMean":1.750000000000000e+001,"ProcessSigma":5.800000000000000e+000}] \ No newline at end of file diff --git a/Server/Data/Tests/OpenInsightV1-GetTencorRun.json b/Server/Data/Tests/OpenInsightV1-GetTencorRun.json new file mode 100644 index 0000000..c5b6979 --- /dev/null +++ b/Server/Data/Tests/OpenInsightV1-GetTencorRun.json @@ -0,0 +1 @@ +[{"RDS":"615071","AttachmentId":"EF1EA71C-E04B-4214-997B-CF07D05D044A","Slot":"*02","SumOfDefects":"17","Sort":"PASS","InsertDate":"2023-10-30T19:00:20.133"},{"RDS":"615071","AttachmentId":"A9CBA5F8-0690-4B73-9AD5-3DE545CE6C80","Slot":"*03","SumOfDefects":"36","Sort":"PASS","InsertDate":"2023-10-30T19:00:20.137"},{"RDS":"615071","AttachmentId":"542485EE-5F84-4F33-895F-1F3239E97E4A","Slot":"*05","SumOfDefects":"19","Sort":"PASS","InsertDate":"2023-10-30T19:00:20.140"},{"RDS":"615071","AttachmentId":"A28C8618-6BDB-43C9-97F5-2440EAD32425","Slot":"*06","SumOfDefects":"35","Sort":"PASS","InsertDate":"2023-10-30T19:00:20.140"},{"RDS":"615071","AttachmentId":"09D11F28-34E2-4B8B-8A19-C87285FDB210","Slot":"*07","SumOfDefects":"11","Sort":"PASS","InsertDate":"2023-10-30T19:00:20.140"},{"RDS":"615071","AttachmentId":"596E73A4-1955-4BC1-AD96-549D2E604699","Slot":"*08","SumOfDefects":"16","Sort":"PASS","InsertDate":"2023-10-30T19:00:20.147"},{"RDS":"615071","AttachmentId":"17C0783F-A5B4-4121-8D5B-7E2E20E81DFD","Slot":"*09","SumOfDefects":"35","Sort":"PASS","InsertDate":"2023-10-30T19:00:20.230"},{"RDS":"615071","AttachmentId":"BDEF4C5F-537D-48AB-B696-77D0A5FCF592","Slot":"*10","SumOfDefects":"28","Sort":"PASS","InsertDate":"2023-10-30T19:00:20.247"},{"RDS":"615071","AttachmentId":"AA0BDFA9-10FC-44F6-B21B-AC2DFB0A5F33","Slot":"*12","SumOfDefects":"43","Sort":"PASS","InsertDate":"2023-10-30T19:00:20.250"},{"RDS":"615071","AttachmentId":"434E49DF-2BF8-4793-864C-76F5C561B3DD","Slot":"*13","SumOfDefects":"23","Sort":"PASS","InsertDate":"2023-10-30T19:00:20.250"},{"RDS":"615071","AttachmentId":"F5FAA898-1C28-48AF-A25F-749F8F658E61","Slot":"*14","SumOfDefects":"34","Sort":"PASS","InsertDate":"2023-10-30T19:00:20.257"},{"RDS":"615071","AttachmentId":"F37E2A95-9189-4832-9793-3CDF9F525EB0","Slot":"*15","SumOfDefects":"50","Sort":"PASS","InsertDate":"2023-10-30T19:00:20.257"},{"RDS":"615071","AttachmentId":"AE6B3D7C-C4BF-4067-9199-FF3BC44DA153","Slot":"*16","SumOfDefects":"53","Sort":"PASS","InsertDate":"2023-10-30T19:00:20.257"},{"RDS":"615071","AttachmentId":"1679140B-42A5-445F-AE70-CE559C32254E","Slot":"*18","SumOfDefects":"907","Sort":"FAIL","InsertDate":"2023-10-30T19:00:20.260"},{"RDS":"615071","AttachmentId":"43CA162D-A04B-4A37-90D7-83BABAF2D3AB","Slot":"*01","SumOfDefects":"100","Sort":"FAIL","InsertDate":"2023-10-30T18:48:57.617"},{"RDS":"615071","AttachmentId":"706C7D0E-4EC1-4042-9DAA-3D141532B6E1","Slot":"*04","SumOfDefects":"12","Sort":"PASS","InsertDate":"2023-10-30T18:48:57.623"},{"RDS":"615071","AttachmentId":"4CECFAC9-745E-4235-BAD9-BE57D1FB450E","Slot":"*11","SumOfDefects":"22","Sort":"PASS","InsertDate":"2023-10-30T18:48:57.627"},{"RDS":"615071","AttachmentId":"B62DE99D-2060-4627-A006-C5FA0DC779BE","Slot":"*17","SumOfDefects":"279","Sort":"FAIL","InsertDate":"2023-10-30T18:48:57.630"}] \ No newline at end of file diff --git a/Server/Models/Binder/.editorconfig b/Server/Models/Binder/.editorconfig new file mode 100644 index 0000000..1c444cd --- /dev/null +++ b/Server/Models/Binder/.editorconfig @@ -0,0 +1,2 @@ +[*.cs] +csharp_preserve_single_line_statements = true \ No newline at end of file diff --git a/Server/Models/Binder/AppSettings.cs b/Server/Models/Binder/AppSettings.cs index 1af153b..8dfd42f 100644 --- a/Server/Models/Binder/AppSettings.cs +++ b/Server/Models/Binder/AppSettings.cs @@ -1,35 +1,31 @@ -using System.ComponentModel.DataAnnotations; using System.Text.Json; +using System.Text.Json.Serialization; namespace OI.Metrology.Server.Models.Binder; public class AppSettings { -#nullable disable - - [Display(Name = "Api Export Path"), Required] public string ApiExportPath { get; set; } - [Display(Name = "Api Logging Content Types"), Required] public string ApiLoggingContentTypes { get; set; } - [Display(Name = "Api Logging Path Prefixes"), Required] public string ApiLoggingPathPrefixes { get; set; } - [Display(Name = "Api Log Path"), Required] public string ApiLogPath { get; set; } - [Display(Name = "Api URL"), Required] public string ApiUrl { get; set; } - [Display(Name = "Attachment Path"), Required] public string AttachmentPath { get; set; } - [Display(Name = "Build Number"), Required] public string BuildNumber { get; set; } - [Display(Name = "Company"), Required] public string Company { get; set; } - [Display(Name = "Connection String"), Required] public string ConnectionString { get; set; } - [Display(Name = "Git Commit Seven"), Required] public string GitCommitSeven { get; set; } - [Display(Name = "Inbound Api Allowed IP List"), Required] public string InboundApiAllowedIPList { get; set; } - [Display(Name = "Is Development"), Required] public bool? IsDevelopment { get; set; } - [Display(Name = "Is Staging"), Required] public bool? IsStaging { get; set; } - [Display(Name = "Mock Root"), Required] public string MockRoot { get; set; } - [Display(Name = "MonA Resource"), Required] public string MonAResource { get; set; } - [Display(Name = "MonA Site"), Required] public string MonASite { get; set; } - [Display(Name = "Oi 2 Sql Connection String"), Required] public string Oi2SqlConnectionString { get; set; } - [Display(Name = "Table to Path"), Required] public Dictionary TableToPath { get; set; } - [Display(Name = "URLs"), Required] public string URLs { get; set; } - [Display(Name = "Working Directory Name"), Required] public string WorkingDirectoryName { get; set; } - -#nullable restore + public string? ApiExportPath { get; set; } + public string? ApiLoggingContentTypes { get; set; } + public string? ApiLoggingPathPrefixes { get; set; } + public string? ApiLogPath { get; set; } + public string? ApiUrl { get; set; } + public string? AttachmentPath { get; set; } + public string? BuildNumber { get; set; } + public string? Company { get; set; } + public string? ConnectionString { get; set; } + public string? GitCommitSeven { get; set; } + public string? InboundApiAllowedIPList { get; set; } + public bool? IsDevelopment { get; set; } + public bool? IsStaging { get; set; } + public string? MockRoot { get; set; } + public string? MonAResource { get; set; } + public string? MonASite { get; set; } + public string? Oi2SqlConnectionString { get; set; } + public Dictionary? TableToPath { get; set; } + public string? URLs { get; set; } + public string? WorkingDirectoryName { get; set; } public override string ToString() { @@ -40,48 +36,27 @@ public class AppSettings private static Models.AppSettings Get(AppSettings? appSettings) { Models.AppSettings result; - if (appSettings is null) - throw new NullReferenceException(nameof(appSettings)); - if (appSettings.ApiExportPath is null) - throw new NullReferenceException(nameof(ApiExportPath)); - if (appSettings.ApiLoggingContentTypes is null) - throw new NullReferenceException(nameof(ApiLoggingContentTypes)); - if (appSettings.ApiLoggingPathPrefixes is null) - throw new NullReferenceException(nameof(ApiLoggingPathPrefixes)); - if (appSettings.ApiLogPath is null) - throw new NullReferenceException(nameof(ApiLogPath)); - if (appSettings.ApiUrl is null) - throw new NullReferenceException(nameof(ApiUrl)); - if (appSettings.AttachmentPath is null) - throw new NullReferenceException(nameof(AttachmentPath)); - if (appSettings.BuildNumber is null) - throw new NullReferenceException(nameof(BuildNumber)); - if (appSettings.Company is null) - throw new NullReferenceException(nameof(Company)); - if (appSettings.ConnectionString is null) - throw new NullReferenceException(nameof(ConnectionString)); - if (appSettings.GitCommitSeven is null) - throw new NullReferenceException(nameof(GitCommitSeven)); - if (appSettings.InboundApiAllowedIPList is null) - throw new NullReferenceException(nameof(InboundApiAllowedIPList)); - if (appSettings.IsDevelopment is null) - throw new NullReferenceException(nameof(IsDevelopment)); - if (appSettings.IsStaging is null) - throw new NullReferenceException(nameof(IsStaging)); - if (appSettings.MockRoot is null) - throw new NullReferenceException(nameof(MockRoot)); - if (appSettings.MonAResource is null) - throw new NullReferenceException(nameof(MonAResource)); - if (appSettings.MonASite is null) - throw new NullReferenceException(nameof(MonASite)); - if (appSettings.Oi2SqlConnectionString is null) - throw new NullReferenceException(nameof(Oi2SqlConnectionString)); - if (appSettings.URLs is null) - throw new NullReferenceException(nameof(URLs)); - if (appSettings.TableToPath is null) - throw new NullReferenceException(nameof(TableToPath)); - if (appSettings.WorkingDirectoryName is null) - throw new NullReferenceException(nameof(WorkingDirectoryName)); + if (appSettings is null) throw new NullReferenceException(nameof(appSettings)); + if (appSettings.ApiExportPath is null) throw new NullReferenceException(nameof(ApiExportPath)); + if (appSettings.ApiLoggingContentTypes is null) throw new NullReferenceException(nameof(ApiLoggingContentTypes)); + if (appSettings.ApiLoggingPathPrefixes is null) throw new NullReferenceException(nameof(ApiLoggingPathPrefixes)); + if (appSettings.ApiLogPath is null) throw new NullReferenceException(nameof(ApiLogPath)); + if (appSettings.ApiUrl is null) throw new NullReferenceException(nameof(ApiUrl)); + if (appSettings.AttachmentPath is null) throw new NullReferenceException(nameof(AttachmentPath)); + if (appSettings.BuildNumber is null) throw new NullReferenceException(nameof(BuildNumber)); + if (appSettings.Company is null) throw new NullReferenceException(nameof(Company)); + if (appSettings.ConnectionString is null) throw new NullReferenceException(nameof(ConnectionString)); + if (appSettings.GitCommitSeven is null) throw new NullReferenceException(nameof(GitCommitSeven)); + if (appSettings.InboundApiAllowedIPList is null) throw new NullReferenceException(nameof(InboundApiAllowedIPList)); + if (appSettings.IsDevelopment is null) throw new NullReferenceException(nameof(IsDevelopment)); + if (appSettings.IsStaging is null) throw new NullReferenceException(nameof(IsStaging)); + if (appSettings.MockRoot is null) throw new NullReferenceException(nameof(MockRoot)); + if (appSettings.MonAResource is null) throw new NullReferenceException(nameof(MonAResource)); + if (appSettings.MonASite is null) throw new NullReferenceException(nameof(MonASite)); + if (appSettings.Oi2SqlConnectionString is null) throw new NullReferenceException(nameof(Oi2SqlConnectionString)); + if (appSettings.URLs is null) throw new NullReferenceException(nameof(URLs)); + if (appSettings.TableToPath is null) throw new NullReferenceException(nameof(TableToPath)); + if (appSettings.WorkingDirectoryName is null) throw new NullReferenceException(nameof(WorkingDirectoryName)); result = new( appSettings.ApiExportPath, appSettings.ApiLoggingContentTypes, @@ -109,9 +84,31 @@ public class AppSettings public static Models.AppSettings Get(IConfigurationRoot configurationRoot) { Models.AppSettings result; +#pragma warning disable IL3050, IL2026 AppSettings? appSettings = configurationRoot.Get(); +#pragma warning restore IL3050, IL2026 + if (appSettings?.ApiExportPath is null) + { + foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers) + { + if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider) + continue; + if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider) + continue; + if (!physicalFileProvider.Root.Contains("UserSecrets")) + continue; + throw new NotSupportedException(physicalFileProvider.Root); + } + throw new NotSupportedException("Not found!"); + } result = Get(appSettings); return result; } +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(AppSettings))] +internal partial class BinderAppSettingsSourceGenerationContext : JsonSerializerContext +{ } \ No newline at end of file diff --git a/Server/Program.cs b/Server/Program.cs index 716182c..da73757 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -8,7 +8,6 @@ using OI.Metrology.Shared.Models; using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.Repositories; using OI.Metrology.Shared.Services; -using Serilog; using System.Reflection; namespace OI.Metrology.Server; @@ -41,19 +40,17 @@ public class Program public static int Main(string[] args) { - LoggerConfiguration loggerConfiguration = new(); + ILogger? logger = null; (string assemblyName, WebApplicationOptions _) = Get(args); WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder(args); _ = webApplicationBuilder.Configuration.AddUserSecrets(); AppSettings appSettings = Models.Binder.AppSettings.Get(webApplicationBuilder.Configuration); + if (string.IsNullOrEmpty(appSettings.Company)) + throw new Exception("Company name must have a value!"); if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName)) throw new Exception("Working directory name must have a value!"); string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assemblyName, appSettings.WorkingDirectoryName); Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory); - _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, webApplicationBuilder.Configuration); - _ = SerilogHostBuilderExtensions.UseSerilog(webApplicationBuilder.Host); - Log.Logger = loggerConfiguration.CreateLogger(); - Serilog.ILogger log = Log.ForContext(); try { _ = webApplicationBuilder.Services.AddMemoryCache(); @@ -77,12 +74,14 @@ public class Program _ = webApplicationBuilder.Services.AddSingleton>(_ => appSettingsRepository); _ = webApplicationBuilder.Services.AddSingleton(_ => new(appSettings.MockRoot, sqlDbConnectionFactory)); _ = webApplicationBuilder.Services.AddSingleton(_ => new(appSettings.MockRoot, sqlDbConnectionFactory)); + _ = webApplicationBuilder.Services.AddSingleton(_ => new(appSettings.MockRoot, sqlDbConnectionFactory)); _ = webApplicationBuilder.Services.AddSingleton(_ => new(appSettings.MockRoot, sqlDbConnectionFactory)); _ = webApplicationBuilder.Services.AddScoped(); _ = webApplicationBuilder.Services.AddScoped(); _ = webApplicationBuilder.Services.AddScoped(); _ = webApplicationBuilder.Services.AddScoped(); + _ = webApplicationBuilder.Services.AddScoped(); _ = webApplicationBuilder.Services.AddSwaggerGen(); _ = webApplicationBuilder.Services.AddSession(sessionOptions => @@ -104,6 +103,7 @@ public class Program }); } WebApplication webApplication = webApplicationBuilder.Build(); + logger = webApplication.Services.GetRequiredService>(); _ = webApplication.UseCors(corsPolicyBuilder => corsPolicyBuilder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()); if (!webApplicationBuilder.Environment.IsDevelopment()) { @@ -121,26 +121,21 @@ public class Program _ = webApplication.UseSwagger(); _ = webApplication.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Server V1")); } - _ = webApplication.Lifetime.ApplicationStopped.Register(Log.CloseAndFlush); - _ = ApplicationBuilderSerilogClientExtensions.UseSerilogIngestion(webApplication); - _ = SerilogApplicationBuilderExtensions.UseSerilogRequestLogging(webApplication); _ = webApplication.UseFileServer(enableDirectoryBrowsing: true); _ = webApplication.UseStaticFiles(); _ = webApplication.UseSession(); _ = webApplication.UseMiddleware(); _ = webApplication.MapControllers(); - log.Information("Starting Web Application"); + logger.LogInformation("Starting Web Application"); webApplication.Run(); return 0; } catch (Exception ex) { - log.Fatal(ex, "Host terminated unexpectedly"); - return 1; - } - finally - { - Log.CloseAndFlush(); + try + { logger?.LogCritical(ex, "Host terminated unexpectedly"); } + catch (Exception) { } + throw; } } diff --git a/Server/Repositories/AppSettingsRepository.cs b/Server/Repositories/AppSettingsRepository.cs index 200f905..dbfda4d 100644 --- a/Server/Repositories/AppSettingsRepository.cs +++ b/Server/Repositories/AppSettingsRepository.cs @@ -31,8 +31,6 @@ public class AppSettingsRepository : IAppSettingsRepository.GetBuildNumberAndGitCommitSeven() => GetBuildNumberAndGitCommitSeven(); - internal void VerifyConnectionStrings() { if (string.IsNullOrEmpty(_AppSettings.ConnectionString)) @@ -53,6 +51,8 @@ public class AppSettingsRepository : IAppSettingsRepository.GetBuildNumberAndGitCommitSeven() => GetBuildNumberAndGitCommitSeven(); + void IAppSettingsRepository.VerifyConnectionStrings() => VerifyConnectionStrings(); } \ No newline at end of file diff --git a/Server/Repositories/ClientSettingsRepository.cs b/Server/Repositories/ClientSettingsRepository.cs index cf88ffd..9e03e7e 100644 --- a/Server/Repositories/ClientSettingsRepository.cs +++ b/Server/Repositories/ClientSettingsRepository.cs @@ -23,14 +23,14 @@ public class ClientSettingsRepository : IClientSettingsRepository return results; } - List IClientSettingsRepository.GetClientSettings(IPAddress? remoteIpAddress) => GetClientSettings(remoteIpAddress); - internal static string GetIpAddress(IPAddress? remoteIpAddress) { string result = remoteIpAddress is null ? string.Empty : remoteIpAddress.ToString(); return result; } + List IClientSettingsRepository.GetClientSettings(IPAddress? remoteIpAddress) => GetClientSettings(remoteIpAddress); + string IClientSettingsRepository.GetIpAddress(IPAddress? remoteIpAddress) => GetIpAddress(remoteIpAddress); } \ No newline at end of file diff --git a/Server/Repositories/ExportRepository.cs b/Server/Repositories/ExportRepository.cs index 57b5188..7348da5 100644 --- a/Server/Repositories/ExportRepository.cs +++ b/Server/Repositories/ExportRepository.cs @@ -9,17 +9,17 @@ namespace OI.Metrology.Server.Repository; public class ExportRepository : IExportRepository { - private readonly Serilog.ILogger _Log; private readonly string _RepositoryName; private readonly AppSettings _AppSettings; + private readonly ILogger _Logger; private readonly Dictionary> _RdsToHeaderCommonCollection; - public ExportRepository(AppSettings appSettings) + public ExportRepository(ILogger logger, AppSettings appSettings) { + _Logger = logger; _AppSettings = appSettings; _RdsToHeaderCommonCollection = new(); _RepositoryName = nameof(ExportRepository)[..^10]; - _Log = Serilog.Log.ForContext(); } private static string[] Get() @@ -93,7 +93,7 @@ public class ExportRepository : IExportRepository if (jsonElement is not null && jsonElement.Value.ValueKind == JsonValueKind.Object) { jsonProperties = (from l in jsonElement.Value.EnumerateObject() where l.Name == ticks select l).ToArray(); - if (jsonProperties.Any() && long.TryParse(jsonProperties[0].Value.ToString(), out long ticksValue)) + if (jsonProperties.Length != 0 && long.TryParse(jsonProperties[0].Value.ToString(), out long ticksValue)) hc.Date = new(ticksValue); } results.Add(hc); diff --git a/Server/Repositories/InboundRepository.cs b/Server/Repositories/InboundRepository.cs index 4d4b3b0..4c986c5 100644 --- a/Server/Repositories/InboundRepository.cs +++ b/Server/Repositories/InboundRepository.cs @@ -65,7 +65,7 @@ public class InboundRepository : IInboundRepository else { inboundDataService.ValidateJSONFields(jToken, 0, metaData, result.Errors, result.Warnings); - if (!result.Errors.Any()) + if (result.Errors.Count == 0) { try { diff --git a/Server/Repositories/InfinityQSV3Repository.cs b/Server/Repositories/InfinityQSV3Repository.cs new file mode 100644 index 0000000..0d60f88 --- /dev/null +++ b/Server/Repositories/InfinityQSV3Repository.cs @@ -0,0 +1,321 @@ +using OI.Metrology.Shared.DataModels; +using OI.Metrology.Shared.Models.Stateless; +using OI.Metrology.Shared.Repositories; +using System.Data; +using System.Data.Common; +using System.Text; +using System.Text.Json; + +namespace OI.Metrology.Server.Repository; + +public class InfinityQSV3Repository : IInfinityQSV3Repository +{ + + private readonly string _MockRoot; + private readonly string _RepositoryName; + private readonly IDbConnectionFactory _DBConnectionFactory; + + public InfinityQSV3Repository(string mockRoot, IDbConnectionFactory dbConnectionFactory) + { + _MockRoot = mockRoot; + _DBConnectionFactory = dbConnectionFactory; + _RepositoryName = nameof(InfinityQSV3Repository)[..^10]; + } + + string IInfinityQSV3Repository.GetCommandText(string subGroupId) + { + StringBuilder result = new(); + if (string.IsNullOrEmpty(subGroupId)) + throw new ArgumentException(null, nameof(subGroupId)); + _ = result + .AppendLine(" select ") + .AppendLine(" sd.f_sgrp sd_sgrp, ") + .AppendLine(" sd.f_tsno sd_tsno, ") + .AppendLine(" dd.f_dsgp dd_dsgp, ") + .AppendLine(" dg.f_name gd_name, ") + .AppendLine(" dd.f_name dd_name ") + .AppendLine(" from [SPCEPIWORLD].[dbo].[SGRP_DSC] sd ") + .AppendLine(" join [SPCEPIWORLD].[dbo].[DESC_DAT] dd ") + .AppendLine(" on sd.f_dsgp = dd.f_dsgp ") + .AppendLine(" and sd.f_desc = dd.f_desc ") + .AppendLine(" join [SPCEPIWORLD].[dbo].[DESC_GRP] dg ") + .AppendLine(" on dd.f_dsgp = dg.f_dsgp "); + _ = result.Append(" where sd.f_sgrp = ").Append(subGroupId).AppendLine(" "); + _ = result.AppendLine(" for json path "); + return result.ToString(); + } + + string IInfinityQSV3Repository.GetCommandText(string? subGroupId, string? process, string? job, string? part, string? lot, string? dateTime) + { + 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(null, nameof(dateTime)); + _ = result + .AppendLine(" select case when iq.sl_loos is null then 0 else iq.sl_loos end + ") + .AppendLine(" case when iq.sl_uoos is null then 0 else iq.sl_uoos end + ") + .AppendLine(" iq.ev_count as iq_sum, ") + .AppendLine(" iq.sl_aflag, ") + .AppendLine(" iq.sl_loos, ") + .AppendLine(" iq.sl_uoos, ") + .AppendLine(" iq.se_sgrp, ") + .AppendLine(" iq.se_sgtm, ") + .AppendLine(" iq.se_tsno, ") + .AppendLine(" iq.td_test, ") + .AppendLine(" iq.pr_name, ") + .AppendLine(" iq.jd_name, ") + .AppendLine(" iq.pl_name, ") + .AppendLine(" iq.pd_name, ") + .AppendLine(" iq.td_name, ") + .AppendLine(" iq.se_val, ") + .AppendLine(" iq.sl_eflag, ") + .AppendLine(" iq.sl_scal, ") + .AppendLine(" iq.sl_sls, ") + .AppendLine(" iq.sl_usl ") + .AppendLine(" from ( ") + .AppendLine(" select ") + .AppendLine(" se.f_sgrp se_sgrp, ") + .AppendLine(" se.f_sgtm se_sgtm, ") + .AppendLine(" se.f_tsno se_tsno, ") + .AppendLine(" se.f_val se_val, ") + .AppendLine(" pr.f_name pr_name, ") + .AppendLine(" jd.f_name jd_name, ") + .AppendLine(" pl.f_name pl_name, ") + .AppendLine(" pd.f_name pd_name, ") + .AppendLine(" td.f_test td_test, ") + .AppendLine(" td.f_name td_name, ") + .AppendLine(" sl.f_eflag sl_eflag, ") + .AppendLine(" sl.f_aflag sl_aflag, ") + .AppendLine(" sl.f_scal sl_scal, ") + .AppendLine(" sl.f_lsl sl_sls, ") + .AppendLine(" sl.f_usl sl_usl, ") + .AppendLine(" case when sl.f_aflag is null or sl.f_aflag = 0 then null else ") + .AppendLine(" case when round(se.f_val, sl.F_scal, 1) < sl.f_lsl then 1 else 0 end ") + .AppendLine(" end as sl_loos, ") + .AppendLine(" case when sl.f_aflag is null or sl.f_aflag = 0 then null else ") + .AppendLine(" case when round(se.f_val, sl.F_scal, 1) > sl.f_usl then 1 else 0 end ") + .AppendLine(" end as sl_uoos, ") + .AppendLine(" (select count(ev.f_evnt) ") + .AppendLine(" from [spcepiworld].[dbo].[evnt_inf] ev ") + .AppendLine(" where ev.f_prcs = pr.f_prcs ") + .AppendLine(" and ev.f_part = pd.f_part ") + .AppendLine(" and ev.f_sgtm = se.f_sgtm ") + .AppendLine(" ) ev_count ") + .AppendLine(" from [spcepiworld].[dbo].[sgrp_ext] se ") + .AppendLine(" join [spcepiworld].[dbo].[prcs_dat] pr ") + .AppendLine(" on se.f_prcs = pr.f_prcs ") + .AppendLine(" join [spcepiworld].[dbo].[job_dat] jd ") + .AppendLine(" on se.f_job = jd.f_job ") + .AppendLine(" join [spcepiworld].[dbo].[part_lot] pl ") + .AppendLine(" on se.f_lot = pl.f_lot ") + .AppendLine(" join [spcepiworld].[dbo].[part_dat] pd ") + .AppendLine(" on se.f_part = pd.f_part ") + .AppendLine(" join [spcepiworld].[dbo].[test_dat] td ") + .AppendLine(" on se.f_test = td.f_test ") + .AppendLine(" left join [spcepiworld].[dbo].[spec_lim] sl ") + .AppendLine(" on se.f_part = sl.f_part ") + .AppendLine(" and se.f_test = sl.f_test ") + .AppendLine(" where se.f_flag = 0 ") + .AppendLine(" and (sl.f_prcs is null or se.f_prcs = sl.f_prcs or sl.f_prcs = 0) "); + if (!string.IsNullOrEmpty(subGroupId)) + _ = result.Append(" and se.f_sgrp = ").Append(subGroupId.Split(" ")[0]).AppendLine(" "); + if (!string.IsNullOrEmpty(process)) + _ = result.Append(" and pr.f_name = '").Append(process).AppendLine("' "); + if (!string.IsNullOrEmpty(part)) + _ = result.Append(" and pd.f_name = '").Append(part).AppendLine("' "); + if (!string.IsNullOrEmpty(job)) + _ = result.Append(" and jd.f_name = '").Append(job).AppendLine("' "); + if (!string.IsNullOrEmpty(lot)) + _ = result.Append(" and pl.f_name = '").Append(lot).AppendLine("' "); + if (!string.IsNullOrEmpty(dateTime) && (dateTime.Contains('-') || dateTime.Contains(' ') || dateTime.Contains(':'))) + _ = result.Append(" and dateadd(HH, -7, (dateadd(SS, convert(bigint, se.f_sgtm), '19700101'))) = '").Append(dateTime).AppendLine("' "); + _ = result.AppendLine(" ) as iq ") + .AppendLine(" order by iq.sl_loos + iq.sl_uoos + iq.ev_count desc, ") + .AppendLine(" iq.sl_aflag desc, ") + .AppendLine(" iq.se_sgrp, ") + .AppendLine(" iq.se_tsno, ") + .AppendLine(" iq.td_test ") + .AppendLine(" for json path "); + return result.ToString(); + } + + private static StringBuilder GetForJsonPath(IDbConnectionFactory dbConnectionFactory, string commandText) + { + StringBuilder stringBuilder = new(); + using DbConnection dbConnection = dbConnectionFactory.GetDbConnection(); + DbCommand dbCommand = dbConnection.CreateCommand(); + dbCommand.CommandText = commandText; + DbDataReader dbDataReader = dbCommand.ExecuteReader(CommandBehavior.SequentialAccess); + while (dbDataReader.Read()) + _ = stringBuilder.Append(dbDataReader.GetString(0)); + return stringBuilder; + } + + private static InfinityQSV3 GetInfinityQSV3(IDbConnectionFactory dbConnectionFactory, IInfinityQSV3Repository infinityQSV3Repository, string subGroupId) + { + InfinityQSV3 result; + string commandText = infinityQSV3Repository.GetCommandText(subGroupId, process: string.Empty, job: string.Empty, part: string.Empty, lot: string.Empty, dateTime: string.Empty); + StringBuilder stringBuilder = GetForJsonPath(dbConnectionFactory, commandText); + InfinityQSV3[]? results = stringBuilder.Length == 0 ? Array.Empty() : JsonSerializer.Deserialize(stringBuilder.ToString(), ResultInfinityQSV3SourceGenerationContext.Default.InfinityQSV3Array); // , new JsonSerializerOptions { PropertyNameCaseInsensitive = true } + if (results is null) + throw new NullReferenceException(nameof(results)); + result = results.First(); + return result; + } + + Result IInfinityQSV3Repository.GetData(string subGroupId) + { + Result? result; + if (!string.IsNullOrEmpty(_MockRoot)) + { + string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IInfinityQSV3Repository.GetData)}.json")); + result = JsonSerializer.Deserialize(json, ResultInfinityQSV3SourceGenerationContext.Default.ResultInfinityQSV3Array); + if (result is null) + throw new NullReferenceException(nameof(result)); + } + else + { + IInfinityQSV3Repository infinityQSV3Repository = this; + InfinityQSV3 infinityQSV3 = GetInfinityQSV3(_DBConnectionFactory, infinityQSV3Repository, subGroupId); + string commandText = infinityQSV3Repository.GetCommandText(subGroupId, process: infinityQSV3.Process, job: infinityQSV3.Job, part: infinityQSV3.Part, lot: infinityQSV3.Lot, dateTime: string.Concat(infinityQSV3.SubGroupDateTime)); + StringBuilder stringBuilder = GetForJsonPath(_DBConnectionFactory, commandText); + InfinityQSV3[]? results = stringBuilder.Length == 0 ? Array.Empty() : JsonSerializer.Deserialize(stringBuilder.ToString(), ResultInfinityQSV3SourceGenerationContext.Default.InfinityQSV3Array); // , new JsonSerializerOptions { PropertyNameCaseInsensitive = true } + if (results is null) + throw new NullReferenceException(nameof(results)); + result = new() + { + Results = results, + TotalRows = results.Length, + }; + } + return result; + } + + Result IInfinityQSV3Repository.GetDescriptors(string subGroupId) + { + Result? result; + if (!string.IsNullOrEmpty(_MockRoot)) + { + string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IInfinityQSV3Repository.GetDescriptors)}.json")); + result = JsonSerializer.Deserialize(json, ResultInfinityQSDescriptorV3SourceGenerationContext.Default.ResultInfinityQSDescriptorV3Array); + if (result is null) + throw new NullReferenceException(nameof(result)); + } + else + { + IInfinityQSV3Repository infinityQSV3Repository = this; + string commandText = infinityQSV3Repository.GetCommandText(subGroupId); + StringBuilder stringBuilder = GetForJsonPath(_DBConnectionFactory, commandText); + InfinityQSDescriptorV3[]? results = stringBuilder.Length == 0 ? Array.Empty() : JsonSerializer.Deserialize(stringBuilder.ToString(), ResultInfinityQSDescriptorV3SourceGenerationContext.Default.InfinityQSDescriptorV3Array); // , new JsonSerializerOptions { PropertyNameCaseInsensitive = true } + if (results is null) + throw new NullReferenceException(nameof(results)); + result = new() + { + Results = results, + TotalRows = results.Length, + }; + } + return result; + } + + string IInfinityQSV3Repository.GetCommandText(InfinityQSV3 infinityQSV3) + { + StringBuilder result = new(); + if (string.IsNullOrEmpty(infinityQSV3.Process)) + throw new ArgumentException(nameof(infinityQSV3.Process)); + if (string.IsNullOrEmpty(infinityQSV3.Part)) + throw new ArgumentException(nameof(infinityQSV3.Part)); + _ = 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(infinityQSV3.Process).AppendLine("' ") + .Append(" and pd.f_name = '").Append(infinityQSV3.Part).AppendLine("' ") + .Append(" and ev.f_sgtm = ").Append(infinityQSV3.SubGroupDateTime).AppendLine(" ") + .AppendLine(" for json path "); + return result.ToString(); + } + + Result IInfinityQSV3Repository.GetHeader(string subGroupId) + { + Result? result; + if (!string.IsNullOrEmpty(_MockRoot)) + { + string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IInfinityQSV3Repository.GetHeader)}.json")); + result = JsonSerializer.Deserialize(json, ResultInfinityQSV3SourceGenerationContext.Default.ResultInfinityQSV3Array); + if (result is null) + throw new NullReferenceException(nameof(result)); + } + else + { + IInfinityQSV3Repository infinityQSV3Repository = this; + InfinityQSV3 infinityQSV3 = GetInfinityQSV3(_DBConnectionFactory, infinityQSV3Repository, subGroupId); + InfinityQSV3[] results = new InfinityQSV3[] { infinityQSV3 }; + result = new() + { + Results = results, + TotalRows = results.Length, + }; + } + return result; + } + + string IInfinityQSV3Repository.GetCommandText(string process, string? part) + { + StringBuilder result = new(); + if (string.IsNullOrEmpty(process)) + throw new ArgumentException(null, nameof(process)); + if (string.IsNullOrEmpty(part)) + throw new ArgumentException(null, nameof(part)); + _ = result + .AppendLine(" select [f_mean] as ProcessMean, ") + .AppendLine(" [f_sp] as ProcessSigma ") + .AppendLine(" from [spcepiworld].[dbo].[test_dat] test ") + .AppendLine(" join [spcepiworld].[dbo].[ctrl_lim] ctrl ") + .AppendLine(" on test.f_test = ctrl.f_test ") + .AppendLine(" and test.f_tsgp = 1104848523 /* Product Data */ ") + .AppendLine(" join [spcepiworld].[dbo].[part_dat] part ") + .AppendLine(" on part.f_part = ctrl.f_part ") + .AppendLine(" and ctrl.f_test = 1125073605 /* Average Sum of Defects */ ") + .AppendLine(" join [spcepiworld].[dbo].[prcs_dat] process ") + .AppendLine(" on process.f_prcs = ctrl.f_prcs ") + .AppendLine(" where test.f_name = 'Average Sum of Defects' ") + .Append(" and process.f_name = '").Append(process).AppendLine("' ") + .Append(" and part.f_name = '").Append(part).AppendLine("' ") + .AppendLine(" for json path; "); + return result.ToString(); + } + + string IInfinityQSV3Repository.GetProductDataAverageSumOfDefectsProcessMeanProcessSigma(string process, string? recipe) + { + StringBuilder result; + if (!string.IsNullOrEmpty(_MockRoot)) + { + string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IInfinityQSV3Repository.GetProductDataAverageSumOfDefectsProcessMeanProcessSigma)}.json")); + result = new(json); + } + else + { + IInfinityQSV3Repository infinityQSV3Repository = this; + string commandText = infinityQSV3Repository.GetCommandText(process, recipe); + result = GetForJsonPath(_DBConnectionFactory, commandText); + if (result.Length == 0) + result = new("{}"); + } + return result.ToString(); + } + +} \ No newline at end of file diff --git a/Server/Repositories/OpenInsightV1Repository.cs b/Server/Repositories/OpenInsightV1Repository.cs new file mode 100644 index 0000000..a0f2f1d --- /dev/null +++ b/Server/Repositories/OpenInsightV1Repository.cs @@ -0,0 +1,85 @@ +using OI.Metrology.Server.Models; +using OI.Metrology.Shared.Models.Stateless; +using OI.Metrology.Shared.Repositories; +using System.Data; +using System.Data.Common; +using System.Text; + +#pragma warning disable CS8600, CS8602, CS8603, CS8604, CS8625 + +namespace OI.Metrology.Server.Repositories; + +public class OpenInsightV1Repository : IOpenInsightV1Repository +{ + private readonly string _MockRoot; + private readonly string _RepositoryName; + private readonly IDbConnectionFactory _DBConnectionFactory; + + public OpenInsightV1Repository(AppSettings appSettings, IDbConnectionFactory dbConnectionFactory) + { + _MockRoot = appSettings.MockRoot; + _DBConnectionFactory = dbConnectionFactory; + _RepositoryName = nameof(OpenInsightV1Repository)[..^10]; + } + + string IOpenInsightV1Repository.GetCommandText(string rds, string? insertDate, string? recipe) + { + StringBuilder result = new(); + if (string.IsNullOrEmpty(rds)) + throw new ArgumentException(null, nameof(rds)); + if (string.IsNullOrEmpty(insertDate)) + throw new ArgumentException(null, nameof(insertDate)); + if (string.IsNullOrEmpty(recipe)) + throw new ArgumentException(null, nameof(recipe)); + _ = result + .AppendLine(" select header.RDS, ") + .AppendLine(" child.AttachmentId, ") + .AppendLine(" child.Slot, ") + .AppendLine(" child.SumOfDefects, ") + .AppendLine(" child.Sort, ") + .AppendLine(" child.InsertDate ") + .AppendLine(" from metrology.dbo.tencorRunHeader header ") + .AppendLine(" inner join metrology.dbo.TencorRunData child ") + .AppendLine(" on header.id = child.headerId ") + .Append(" where header.rds = '").Append(rds).AppendLine("' ") + .Append(" and header.recipe like '").Append(recipe).AppendLine("%' ") + .Append(" and child.insertdate between (select(dateadd(minute, -5, '").Append(insertDate).AppendLine("'))) ") + .Append(" and (select(dateadd(minute, 5, '").Append(insertDate).AppendLine("'))) ") + .AppendLine(" order by header.insertdate desc, ") + .AppendLine(" child.slot asc ") + .AppendLine(" for json path; "); + return result.ToString(); + } + + private static StringBuilder GetForJsonPath(IDbConnectionFactory dbConnectionFactory, string commandText) + { + StringBuilder stringBuilder = new(); + using DbConnection dbConnection = dbConnectionFactory.GetDbConnection(); + DbCommand dbCommand = dbConnection.CreateCommand(); + dbCommand.CommandText = commandText; + DbDataReader dbDataReader = dbCommand.ExecuteReader(CommandBehavior.SequentialAccess); + while (dbDataReader.Read()) + _ = stringBuilder.Append(dbDataReader.GetString(0)); + return stringBuilder; + } + + string IOpenInsightV1Repository.GetTencorRun(string rds, string? insertDate, string? recipe) + { + StringBuilder result; + if (!string.IsNullOrEmpty(_MockRoot)) + { + string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IOpenInsightV1Repository.GetTencorRun)}.json")); + result = new(json); + } + else + { + IOpenInsightV1Repository openInsightRepository = this; + string commandText = openInsightRepository.GetCommandText(rds, insertDate, recipe); + result = GetForJsonPath(_DBConnectionFactory, commandText); + if (result.Length == 0) + result = new("{}"); + } + return result.ToString(); + } + +} \ No newline at end of file diff --git a/Server/Repositories/PinRepository.cs b/Server/Repositories/PinRepository.cs index d7191eb..2478d4d 100644 --- a/Server/Repositories/PinRepository.cs +++ b/Server/Repositories/PinRepository.cs @@ -8,7 +8,6 @@ public class PinRepository : IPinRepository { private readonly string _MockRoot; - private readonly Serilog.ILogger _Log; private readonly string _RepositoryName; private readonly Dictionary> _RdsToHeaderCommonCollection; @@ -17,7 +16,6 @@ public class PinRepository : IPinRepository _MockRoot = mockRoot; _RdsToHeaderCommonCollection = new(); _RepositoryName = nameof(PinRepository)[..^10]; - _Log = Serilog.Log.ForContext(); } void IPinRepository.SetPinnedTable(HeaderCommon headerCommon) diff --git a/Server/Repositories/ServiceShopOrderRepository.cs b/Server/Repositories/ServiceShopOrderRepository.cs index 3267236..e2e3ce2 100644 --- a/Server/Repositories/ServiceShopOrderRepository.cs +++ b/Server/Repositories/ServiceShopOrderRepository.cs @@ -1,6 +1,5 @@ using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.ViewModels; -using Serilog.Context; using System.Text.Json; namespace OI.Metrology.Server.Repository; @@ -8,9 +7,10 @@ namespace OI.Metrology.Server.Repository; public class ServiceShopOrderRepository : IServiceShopOrderRepository { - private readonly Serilog.ILogger _Log; + private readonly ILogger _Logger; - public ServiceShopOrderRepository() => _Log = Serilog.Log.ForContext(); + public ServiceShopOrderRepository(ILogger logger) => + _Logger = logger; private static ServiceShopOrder[] GetServiceShopOrders(Shared.Models.ServiceShop? serviceShop) { @@ -35,13 +35,8 @@ public class ServiceShopOrderRepository : IServiceShopOrderRepository async Task IServiceShopOrderRepository.GetAllServiceShopOrders() { ServiceShopOrder[] results; - string? methodName = IMethodName.GetActualAsyncMethodName(); - using (LogContext.PushProperty("MethodName", methodName)) - { - _Log.Debug("() => ..."); - Shared.Models.ServiceShop? serviceShop = await Task.Run(GetServiceShopOrders); - results = GetServiceShopOrders(serviceShop); - } + Shared.Models.ServiceShop? serviceShop = await Task.Run(GetServiceShopOrders); + results = GetServiceShopOrders(serviceShop); return results.ToArray(); } diff --git a/Server/Repositories/ToolTypesRepository.cs b/Server/Repositories/ToolTypesRepository.cs index da15e19..52d00bb 100644 --- a/Server/Repositories/ToolTypesRepository.cs +++ b/Server/Repositories/ToolTypesRepository.cs @@ -11,13 +11,11 @@ public class ToolTypesRepository : IToolTypesRepository { private readonly string _MockRoot; - private readonly Serilog.ILogger _Log; private readonly string _RepositoryName; public ToolTypesRepository(string mockRoot) { _MockRoot = mockRoot; - _Log = Serilog.Log.ForContext(); _RepositoryName = nameof(ToolTypesRepository)[..^10]; } @@ -257,32 +255,6 @@ public class ToolTypesRepository : IToolTypesRepository return r; } - protected static string GetRowData(DataRow dr) - { - StringBuilder result = new(); - for (int i = 0; i < dr.Table.Columns.Count; i++) - { - if (i > 0) - _ = result.Append(','); - object v = dr[i]; - if (v is not null && !Convert.IsDBNull(v)) - _ = result.Append(FormatForCSV(string.Concat(Convert.ToString(v)))); - } - return result.ToString(); - } - - protected static string GetColumnHeaders(DataTable dataTable) - { - StringBuilder result = new(); - for (int i = 0; i < dataTable.Columns.Count; i++) - { - if (i > 0) - _ = result.Append(','); - _ = result.Append(FormatForCSV(dataTable.Columns[i].ColumnName.TrimEnd('_'))); - } - return result.ToString(); - } - protected static string FormatForCSV(string v) { StringBuilder result = new(v.Length + 2); @@ -306,6 +278,32 @@ public class ToolTypesRepository : IToolTypesRepository return result.ToString(); } + protected static string GetColumnHeaders(DataTable dataTable) + { + StringBuilder result = new(); + for (int i = 0; i < dataTable.Columns.Count; i++) + { + if (i > 0) + _ = result.Append(','); + _ = result.Append(FormatForCSV(dataTable.Columns[i].ColumnName.TrimEnd('_'))); + } + return result.ToString(); + } + + protected static string GetRowData(DataRow dr) + { + StringBuilder result = new(); + for (int i = 0; i < dr.Table.Columns.Count; i++) + { + if (i > 0) + _ = result.Append(','); + object v = dr[i]; + if (v is not null && !Convert.IsDBNull(v)) + _ = result.Append(FormatForCSV(string.Concat(Convert.ToString(v)))); + } + return result.ToString(); + } + byte[] IToolTypesRepository.GetCSVExport(IMetrologyRepository metrologyRepository, int toolTypeId, DateTime? datebegin, DateTime? dateend) { byte[] results; diff --git a/Server/Repositories/WorkMaterialRepository.cs b/Server/Repositories/WorkMaterialRepository.cs index a7b8123..abaa6ce 100644 --- a/Server/Repositories/WorkMaterialRepository.cs +++ b/Server/Repositories/WorkMaterialRepository.cs @@ -63,18 +63,6 @@ public class WorkMaterialRepository : IWorkMaterialRepository return result.ToString(); } - private static StringBuilder GetForJsonPath(IDbConnectionFactory dbConnectionFactory, string commandText) - { - StringBuilder stringBuilder = new(); - using DbConnection dbConnection = dbConnectionFactory.GetDbConnection(useOI2Sql: true); - DbCommand dbCommand = dbConnection.CreateCommand(); - dbCommand.CommandText = commandText; - DbDataReader dbDataReader = dbCommand.ExecuteReader(CommandBehavior.SequentialAccess); - while (dbDataReader.Read()) - _ = stringBuilder.Append(dbDataReader.GetString(0)); - return stringBuilder; - } - private static (int?, int?, int?, bool) GetWorkOrder(string mid) { int? workOrderStep = null; @@ -108,6 +96,18 @@ public class WorkMaterialRepository : IWorkMaterialRepository return new(workOrderNumber, workOrderStep, workOrderCassette, workOrderStep is not null || workOrderNumber is not null || workOrderCassette is not null); } + private static StringBuilder GetForJsonPath(IDbConnectionFactory dbConnectionFactory, string commandText) + { + StringBuilder stringBuilder = new(); + using DbConnection dbConnection = dbConnectionFactory.GetDbConnection(useOI2Sql: true); + DbCommand dbCommand = dbConnection.CreateCommand(); + dbCommand.CommandText = commandText; + DbDataReader dbDataReader = dbCommand.ExecuteReader(CommandBehavior.SequentialAccess); + while (dbDataReader.Read()) + _ = stringBuilder.Append(dbDataReader.GetString(0)); + return stringBuilder; + } + Result IWorkMaterialRepository.GetCassette(string mid) { Result? result; @@ -132,7 +132,7 @@ public class WorkMaterialRepository : IWorkMaterialRepository IWorkMaterialRepository workMaterialRepository = this; string commandText = workMaterialRepository.GetCommandText(workOrderNumber, workOrderStep, workOrderCassette); StringBuilder stringBuilder = GetForJsonPath(_DBConnectionFactory, commandText); - JsonElement[]? jsonElements = JsonSerializer.Deserialize(stringBuilder.ToString()); + JsonElement[]? jsonElements = stringBuilder.Length == 0 ? Array.Empty() : JsonSerializer.Deserialize(stringBuilder.ToString()); if (jsonElements is null) throw new NullReferenceException(nameof(jsonElements)); foreach (JsonElement jsonElement in jsonElements) @@ -140,7 +140,7 @@ public class WorkMaterialRepository : IWorkMaterialRepository if (jsonElement.ValueKind != JsonValueKind.Object) continue; jsonProperties = jsonElement.EnumerateObject().ToArray(); - if (!jsonProperties.Any()) + if (jsonProperties.Length == 0) continue; group = JsonSerializer.Deserialize(jsonProperties.First().Value.ToString(), new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); if (group is null) diff --git a/Server/Services/AttachmentsService.cs b/Server/Services/AttachmentsService.cs index d99e43b..f71fb9e 100644 --- a/Server/Services/AttachmentsService.cs +++ b/Server/Services/AttachmentsService.cs @@ -143,10 +143,10 @@ public class AttachmentsService : IAttachmentsService if (!Directory.Exists(checkDirectory)) continue; files.AddRange(Directory.GetFiles(checkDirectory)); - if (files.Any()) + if (files.Count != 0) break; } - result = !files.Any() ? null : files.First(); + result = files.Count == 0 ? null : files.First(); return result; } diff --git a/Server/Services/SpreadingResistanceProfileService.cs b/Server/Services/SpreadingResistanceProfileService.cs index f352674..8e8f3c2 100644 --- a/Server/Services/SpreadingResistanceProfileService.cs +++ b/Server/Services/SpreadingResistanceProfileService.cs @@ -1,5 +1,6 @@ using Adaptation.FileHandlers.json; using OI.Metrology.Shared.Models.Stateless; +using System.Collections.ObjectModel; using System.Drawing; using System.Text; using System.Text.Json; @@ -95,7 +96,7 @@ public class SpreadingResistanceProfileService : ISpreadingResistanceProfileServ return rectangles.ToArray(); } - private static string[] GetRectanglesDescriptions(Info info, Setup setup, List layers) + private static ReadOnlyCollection GetRectanglesDescriptions(Info info, Setup setup, List layers) { List results = new() { @@ -123,7 +124,7 @@ public class SpreadingResistanceProfileService : ISpreadingResistanceProfileServ _ = stringBuilder.AppendLine(string.Concat("First Pt. ", layer.FirstPoint, " Last Pt. ", layer.LastPoint, " Type ", layer.Type, " Smoothing ", layer.Smoothing, " Correction ", layer.Correction)); _ = stringBuilder.AppendLine(string.Join(" ", info.Comments)); results[0] = stringBuilder.ToString(); - return results.ToArray(); + return new(results); } internal static byte[] GetImageBytes(CSV csv) @@ -182,8 +183,8 @@ public class SpreadingResistanceProfileService : ISpreadingResistanceProfileServ graphics.FillRectangles(Brushes.White, rectangles); graphics.DrawRectangles(pen, rectangles); - string[] descriptions = GetRectanglesDescriptions(csv.Info, csv.Setup, csv.LayerHeader.Layers); - for (int i = 0; i < descriptions.Length; i++) + ReadOnlyCollection descriptions = GetRectanglesDescriptions(csv.Info, csv.Setup, csv.LayerHeader.Layers); + for (int i = 0; i < descriptions.Count; i++) graphics.DrawString(descriptions[i], consolas, brush, rectangles[i]); DrawLine(graphics, concentrationPen, 13, 6, 13, 40); diff --git a/Server/Services/csv/CSV.cs b/Server/Services/csv/CSV.cs index ae0581f..e88b33d 100644 --- a/Server/Services/csv/CSV.cs +++ b/Server/Services/csv/CSV.cs @@ -35,7 +35,7 @@ public class CSV # else string[] lines = File.ReadAllLines(path, System.Text.Encoding.GetEncoding("ISO-8859-1")); // µ³® # endif - string? fileVersion = !lines.Any() ? null : GetFileVersion(lines.First()); + string? fileVersion = lines.Length == 0 ? null : GetFileVersion(lines.First()); for (int i = 1; i < lines.Length; i++) { if (lines[i].StartsWith("--INFO--")) diff --git a/Server/appsettings.Development.json b/Server/appsettings.Development.json deleted file mode 100644 index 67028c2..0000000 --- a/Server/appsettings.Development.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "ApiExportPath": "\\\\messdv002.na.infineon.com\\Candela", - "ApiUrl": "~/api", - "ConnectionString": "Data Source=MESSAD1001\\TEST1,59583;Integrated Security=True;Initial Catalog=Metrology;", - "IsDevelopment": true, - "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": { - "Using": [ - "Serilog.Sinks.Console", - "Serilog.Sinks.File" - ], - "MinimumLevel": "Debug", - "WriteTo": [ - { - "Name": "Debug", - "Args": { - "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}" - } - }, - { - "Name": "Console", - "Args": { - "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}" - } - }, - { - "Name": "File", - "Args": { - "path": "%workingDirectory% - Log/log-.txt", - "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}", - "rollingInterval": "Hour" - } - } - ], - "Enrich": [ - "FromLogContext", - "WithMachineName", - "WithThreadId" - ], - "Properties": { - "Application": "Sample" - } - }, - "URLs": "https://localhost:7130;http://localhost:5126" -} \ No newline at end of file diff --git a/Shared/DataModels/InfinityQSDescriptorV3.cs b/Shared/DataModels/InfinityQSDescriptorV3.cs new file mode 100644 index 0000000..8db062e --- /dev/null +++ b/Shared/DataModels/InfinityQSDescriptorV3.cs @@ -0,0 +1,21 @@ +using System.Text.Json.Serialization; + +namespace OI.Metrology.Shared.DataModels; + +public record InfinityQSDescriptorV3([property: JsonPropertyName("sd_sgrp")] int? SubGroupId, + [property: JsonPropertyName("sd_tsno")] int? SiteNumber, + [property: JsonPropertyName("dd_dsgp")] int? VariableNumber, + [property: JsonPropertyName("gd_name")] string? Variable, + [property: JsonPropertyName("dd_name")] string? Value); + +[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)] +[JsonSerializable(typeof(InfinityQSDescriptorV3))] +public partial class InfinityQSDescriptorV3SourceGenerationContext : JsonSerializerContext +{ +} + +[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)] +[JsonSerializable(typeof(Result))] +public partial class ResultInfinityQSDescriptorV3SourceGenerationContext : JsonSerializerContext +{ +} \ No newline at end of file diff --git a/Shared/DataModels/InfinityQSEventV3.cs b/Shared/DataModels/InfinityQSEventV3.cs new file mode 100644 index 0000000..3b487aa --- /dev/null +++ b/Shared/DataModels/InfinityQSEventV3.cs @@ -0,0 +1,24 @@ +using System.Text.Json.Serialization; + +namespace OI.Metrology.Shared.DataModels; + +public record InfinityQSEventV3([property: JsonPropertyName("ev_evnt")] int EventId, + [property: JsonPropertyName("ev_sgtm")] int SubGroupDateTimeId, + [property: JsonPropertyName("ev_utc7")] string SubGroupDateTime, + [property: JsonPropertyName("pr_name")] string Process, + [property: JsonPropertyName("pd_name")] string Part, + [property: JsonPropertyName("td_test")] int VariableNumber, + [property: JsonPropertyName("td_name")] string Variable, + [property: JsonPropertyName("ev_name")] string Name); + +[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)] +[JsonSerializable(typeof(InfinityQSEventV3))] +public partial class InfinityQSEventV3SourceGenerationContext : JsonSerializerContext +{ +} + +[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)] +[JsonSerializable(typeof(Result))] +public partial class ResultInfinityQSEventV3SourceGenerationContext : JsonSerializerContext +{ +} \ No newline at end of file diff --git a/Shared/DataModels/InfinityQSV3.cs b/Shared/DataModels/InfinityQSV3.cs new file mode 100644 index 0000000..66c9b02 --- /dev/null +++ b/Shared/DataModels/InfinityQSV3.cs @@ -0,0 +1,34 @@ +using System.Text.Json.Serialization; + +namespace OI.Metrology.Shared.DataModels; + +public record InfinityQSV3([property: JsonPropertyName("iq_sum")] int SumOOS, + [property: JsonPropertyName("sl_aflag")] int? AlarmFlag, + [property: JsonPropertyName("sl_loos")] int? LowerOOS, + [property: JsonPropertyName("sl_uoos")] int? UperOOS, + [property: JsonPropertyName("se_sgrp")] int SubGroupId, + [property: JsonPropertyName("se_sgtm")] int SubGroupDateTime, + [property: JsonPropertyName("se_tsno")] int SiteNumber, + [property: JsonPropertyName("td_test")] int VariableNumber, + [property: JsonPropertyName("pr_name")] string? Process, + [property: JsonPropertyName("jd_name")] string? Job, + [property: JsonPropertyName("pl_name")] string? Lot, + [property: JsonPropertyName("pd_name")] string? Part, + [property: JsonPropertyName("td_name")] string? Variable, + [property: JsonPropertyName("se_val")] double? Value, + [property: JsonPropertyName("sl_eflag")] int? EnableFlag, + [property: JsonPropertyName("sl_scal")] int? Scale, + [property: JsonPropertyName("sl_sls")] double? LowerSpecLimit, + [property: JsonPropertyName("sl_usl")] double? UperSpecLimit); + +[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)] +[JsonSerializable(typeof(InfinityQSV3))] +public partial class InfinityQSV3SourceGenerationContext : JsonSerializerContext +{ +} + +[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)] +[JsonSerializable(typeof(Result))] +public partial class ResultInfinityQSV3SourceGenerationContext : JsonSerializerContext +{ +} \ No newline at end of file diff --git a/Shared/Models/Stateless/IIOpenInsightV1Repository.cs b/Shared/Models/Stateless/IIOpenInsightV1Repository.cs new file mode 100644 index 0000000..2b70a78 --- /dev/null +++ b/Shared/Models/Stateless/IIOpenInsightV1Repository.cs @@ -0,0 +1,9 @@ +namespace OI.Metrology.Shared.Models.Stateless; + +public interface IOpenInsightV1Repository +{ + + string GetTencorRun(string rds, string? insertDate, string? recipe); + string GetCommandText(string rds, string? insertDate, string? recipe); + +} \ No newline at end of file diff --git a/Shared/Models/Stateless/IInfinityQSV3Controller.cs b/Shared/Models/Stateless/IInfinityQSV3Controller.cs new file mode 100644 index 0000000..998ab92 --- /dev/null +++ b/Shared/Models/Stateless/IInfinityQSV3Controller.cs @@ -0,0 +1,17 @@ +namespace OI.Metrology.Shared.Models.Stateless; + +public interface IInfinityQSV3Controller +{ + + enum Action : int + { + Index = 0, + MarkAsPinned = 1 + } + + static string GetRouteName() => nameof(IInfinityQSV3Controller)[1..^10]; + T GetCommandText(string sub_group_id, string process, string job, string part, string lot, string date_time); + T GetData(string sub_group_id); + T GetHeader(string sub_group_id); + +} \ No newline at end of file diff --git a/Shared/Models/Stateless/IInfinityQSV3Repository.cs b/Shared/Models/Stateless/IInfinityQSV3Repository.cs new file mode 100644 index 0000000..e6c95d8 --- /dev/null +++ b/Shared/Models/Stateless/IInfinityQSV3Repository.cs @@ -0,0 +1,17 @@ +using OI.Metrology.Shared.DataModels; + +namespace OI.Metrology.Shared.Models.Stateless; + +public interface IInfinityQSV3Repository +{ + + string GetCommandText(string subGroupId); + string GetCommandText(string process, string? part); + string GetCommandText(InfinityQSV3 infinityQSV2); + string GetProductDataAverageSumOfDefectsProcessMeanProcessSigma(string process, string? recipe); + string GetCommandText(string? subGroupId, string? process, string? job, string? part, string? lot, string? dateTime); + Result GetData(string subGroupId); + Result GetDescriptors(string subGroupId); + Result GetHeader(string subGroupId); + +} \ No newline at end of file diff --git a/Shared/Models/Stateless/IOpenInsightV1Controller.cs b/Shared/Models/Stateless/IOpenInsightV1Controller.cs new file mode 100644 index 0000000..fa30524 --- /dev/null +++ b/Shared/Models/Stateless/IOpenInsightV1Controller.cs @@ -0,0 +1,9 @@ +namespace OI.Metrology.Shared.Models.Stateless; + +public interface IOpenInsightV1Controller +{ + + static string GetRouteName() => nameof(IOpenInsightV1Controller)[1..^10]; + T GetTencorRun(string rds, string? insertDate, string? recipe); + +} \ No newline at end of file diff --git a/Tests/UnitAwaitingDispoController.cs b/Tests/UnitAwaitingDispoController.cs index a816459..15dfcf3 100644 --- a/Tests/UnitAwaitingDispoController.cs +++ b/Tests/UnitAwaitingDispoController.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.Models.Stateless; -using Serilog; using System.Net.Http.Json; namespace OI.Metrology.Tests; @@ -13,10 +13,10 @@ public class UnitAwaitingDispoController #pragma warning disable CS8618 - private static ILogger _Logger; + private static ILogger? _Logger; private static string _ControllerName; private static TestContext _TestContext; - private static WebApplicationFactory _WebApplicationFactory; + private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -24,83 +24,87 @@ public class UnitAwaitingDispoController public static void ClassInitAsync(TestContext testContext) { _TestContext = testContext; - _Logger = Log.ForContext(); _WebApplicationFactory = new WebApplicationFactory(); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + _Logger = serviceProvider.GetRequiredService>(); _ControllerName = nameof(Server.ApiControllers.AwaitingDispoController)[..^10]; } [TestMethod] public void TestControllerName() { - _Logger.Information("Starting Web Application"); + _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IAwaitingDispoController.GetRouteName(), _ControllerName); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [Ignore] [TestMethod] public void Index() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService(); - IEnumerable awaitingDispositions = metrologyRepository.GetAwaitingDisposition(); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService(); + IEnumerable? awaitingDispositions = metrologyRepository?.GetAwaitingDisposition(); Assert.IsTrue(awaitingDispositions is not null); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [Ignore] [TestMethod] public async Task IndexApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); 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"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [Ignore] [TestMethod] public void MarkAsReviewed() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService(); - _ = metrologyRepository.UpdateReviewDate(toolTypeId: 1, headerId: 1, clearDate: false); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService(); + _ = metrologyRepository?.UpdateReviewDate(toolTypeId: 1, headerId: 1, clearDate: false); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [Ignore] [TestMethod] public async Task MarkAsReviewedApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); _ = await httpClient.GetFromJsonAsync($"api/{_ControllerName}/markasreviewed"); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [Ignore] [TestMethod] public void MarkAsAwaiting() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService(); - int dateCleared = metrologyRepository.UpdateReviewDate(toolTypeId: 1, headerId: 1, clearDate: true); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService(); + int? dateCleared = metrologyRepository?.UpdateReviewDate(toolTypeId: 1, headerId: 1, clearDate: true); Assert.IsTrue(dateCleared <= 1); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [Ignore] [TestMethod] public async Task MarkAsAwaitingApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); _ = await httpClient.PostAsync($"api/{_ControllerName}/markasawaiting", null); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } } \ No newline at end of file diff --git a/Tests/UnitInboundController.cs b/Tests/UnitInboundController.cs index fd769ea..b311b7b 100644 --- a/Tests/UnitInboundController.cs +++ b/Tests/UnitInboundController.cs @@ -1,7 +1,8 @@ using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.Models.Stateless; -using Serilog; using System.Text; namespace OI.Metrology.Tests; @@ -12,10 +13,10 @@ public class UnitInboundController #pragma warning disable CS8618 - private static ILogger _Logger; + private static ILogger? _Logger; private static string _ControllerName; private static TestContext _TestContext; - private static WebApplicationFactory _WebApplicationFactory; + private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -23,8 +24,9 @@ public class UnitInboundController public static void ClassInitAsync(TestContext testContext) { _TestContext = testContext; - _Logger = Log.ForContext(); _WebApplicationFactory = new WebApplicationFactory(); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + _Logger = serviceProvider.GetRequiredService>(); _ControllerName = nameof(Server.ApiControllers.InboundController)[..^10]; } @@ -38,9 +40,9 @@ public class UnitInboundController [TestMethod] public void TestControllerName() { - _Logger.Information("Starting Web Application"); + _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IInboundController.GetRouteName(), _ControllerName); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } @@ -54,10 +56,11 @@ public class UnitInboundController [TestMethod] public async Task DataApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); _ = await httpClient.PostAsync($"api/{_ControllerName}/BioRad", GetStringContent()); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } @@ -65,10 +68,11 @@ public class UnitInboundController [TestMethod] public async Task AttachFileApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); _ = await httpClient.PostAsync($"api/{_ControllerName}/BioRad/attachment", GetStringContent()); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } diff --git a/Tests/UnitTestAppSettingsController.cs b/Tests/UnitTestAppSettingsController.cs index c9132eb..e48193d 100644 --- a/Tests/UnitTestAppSettingsController.cs +++ b/Tests/UnitTestAppSettingsController.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using OI.Metrology.Server.Models; using OI.Metrology.Shared.Models.Stateless; -using Serilog; using System.Net; namespace OI.Metrology.Tests; @@ -13,10 +13,10 @@ public class UnitTestAppSettingsController #pragma warning disable CS8618 - private static ILogger _Logger; + private static ILogger? _Logger; private static string _ControllerName; private static TestContext _TestContext; - private static WebApplicationFactory _WebApplicationFactory; + private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -24,8 +24,9 @@ public class UnitTestAppSettingsController public static void ClassInitAsync(TestContext testContext) { _TestContext = testContext; - _Logger = Log.ForContext(); _WebApplicationFactory = new WebApplicationFactory(); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + _Logger = serviceProvider.GetRequiredService>(); _ControllerName = nameof(Server.ApiControllers.AppSettingsController)[..^10]; } @@ -39,88 +40,90 @@ public class UnitTestAppSettingsController [TestMethod] public void TestControllerName() { - _Logger.Information("Starting Web Application"); + _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IAppSettingsController.GetRouteName(), _ControllerName); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public void TestConnectionString() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IAppSettingsRepository appSettingsRepository = serviceProvider.GetRequiredService>(); - appSettingsRepository.VerifyConnectionStrings(); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IAppSettingsRepository? appSettingsRepository = serviceProvider?.GetRequiredService>(); + appSettingsRepository?.VerifyConnectionStrings(); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public void AppSettings() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - AppSettings appSettings = serviceProvider.GetRequiredService(); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + AppSettings? appSettings = serviceProvider?.GetRequiredService(); Assert.IsNotNull(appSettings); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public void GetAppSettings() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IAppSettingsRepository appSettingsRepository = serviceProvider.GetRequiredService>(); - Server.Models.Binder.AppSettings appSettings = appSettingsRepository.GetAppSettings(); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IAppSettingsRepository? appSettingsRepository = serviceProvider?.GetRequiredService>(); + Server.Models.Binder.AppSettings? appSettings = appSettingsRepository?.GetAppSettings(); Assert.IsTrue(appSettings is not null); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public async Task GetAppSettingsApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string actionName = nameof(IAppSettingsController.Action.App); - HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}"); + 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()); string json = await httpResponseMessage.Content.ReadAsStringAsync(); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetAppSettings)}.json"), json); Assert.IsNotNull(json); Assert.IsTrue(json != "[]"); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public void GetBuildNumberAndGitCommitSeven() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IAppSettingsRepository appSettingsRepository = serviceProvider.GetRequiredService>(); - string result = appSettingsRepository.GetBuildNumberAndGitCommitSeven(); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IAppSettingsRepository? appSettingsRepository = serviceProvider?.GetRequiredService>(); + string? result = appSettingsRepository?.GetBuildNumberAndGitCommitSeven(); Assert.IsTrue(result is not null); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public async Task GetBuildNumberAndGitCommitSevenApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string actionName = nameof(IAppSettingsController.Action.DevOps); - HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}"); + HttpResponseMessage? httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}"); Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode); Assert.AreEqual("text/plain; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString()); string json = await httpResponseMessage.Content.ReadAsStringAsync(); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetBuildNumberAndGitCommitSeven)}.json"), json); Assert.IsNotNull(json); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } diff --git a/Tests/UnitTestClientSettingsController.cs b/Tests/UnitTestClientSettingsController.cs index 5d0e835..69c3068 100644 --- a/Tests/UnitTestClientSettingsController.cs +++ b/Tests/UnitTestClientSettingsController.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using OI.Metrology.Shared.Models.Stateless; -using Serilog; using System.Net; namespace OI.Metrology.Tests; @@ -12,10 +12,10 @@ public class UnitTestClientSettingsController #pragma warning disable CS8618 - private static ILogger _Logger; + private static ILogger? _Logger; private static string _ControllerName; private static TestContext _TestContext; - private static WebApplicationFactory _WebApplicationFactory; + private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -23,38 +23,40 @@ public class UnitTestClientSettingsController public static void ClassInitAsync(TestContext testContext) { _TestContext = testContext; - _Logger = Log.ForContext(); _WebApplicationFactory = new WebApplicationFactory(); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + _Logger = serviceProvider.GetRequiredService>(); _ControllerName = nameof(Server.ApiControllers.ClientSettingsController)[..^10]; } [TestMethod] public void TestControllerName() { - _Logger.Information("Starting Web Application"); + _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IClientSettingsController.GetRouteName(), _ControllerName); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public void GetClientSettings() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IClientSettingsRepository clientSettingsRepository = serviceProvider.GetRequiredService(); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IClientSettingsRepository? clientSettingsRepository = serviceProvider?.GetRequiredService(); #if DEBUG - List clientSettings = clientSettingsRepository.GetClientSettings(null); + List? clientSettings = clientSettingsRepository?.GetClientSettings(null); Assert.IsTrue(clientSettings is not null); #endif - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public async Task GetClientSettingsApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); #if DEBUG + Assert.IsTrue(httpClient is not null); string actionName = nameof(IClientSettingsController.Action.Client); HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}"); Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode); @@ -64,25 +66,26 @@ public class UnitTestClientSettingsController Assert.IsNotNull(json); Assert.IsTrue(json != "[]"); #endif - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public void GetIpAddress() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IClientSettingsRepository clientSettingsRepository = serviceProvider.GetRequiredService(); - string? ipAddress = clientSettingsRepository.GetIpAddress(null); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IClientSettingsRepository? clientSettingsRepository = serviceProvider?.GetRequiredService(); + string? ipAddress = clientSettingsRepository?.GetIpAddress(null); Assert.IsTrue(ipAddress is not null); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public async Task GetIpAddressApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string actionName = nameof(IClientSettingsController.Action.IP); HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}"); Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode); @@ -90,7 +93,7 @@ public class UnitTestClientSettingsController string json = await httpResponseMessage.Content.ReadAsStringAsync(); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetIpAddress)}.json"), json); Assert.IsNotNull(json); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } } \ No newline at end of file diff --git a/Tests/UnitTestExportController.cs b/Tests/UnitTestExportController.cs index 8e296e5..a442c2a 100644 --- a/Tests/UnitTestExportController.cs +++ b/Tests/UnitTestExportController.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.Models.Stateless; -using Serilog; using System.Text; namespace OI.Metrology.Tests; @@ -13,10 +13,10 @@ public class UnitTestExportController #pragma warning disable CS8618 - private static ILogger _Logger; + private static ILogger? _Logger; private static string _ControllerName; private static TestContext _TestContext; - private static WebApplicationFactory _WebApplicationFactory; + private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -24,8 +24,9 @@ public class UnitTestExportController public static void ClassInitAsync(TestContext testContext) { _TestContext = testContext; - _Logger = Log.ForContext(); _WebApplicationFactory = new WebApplicationFactory(); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + _Logger = serviceProvider.GetRequiredService>(); _ControllerName = nameof(Server.ApiControllers.ExportController)[..^10]; } @@ -39,9 +40,9 @@ public class UnitTestExportController [TestMethod] public void TestControllerName() { - _Logger.Information("Starting Web Application"); + _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IExportController.GetRouteName(), _ControllerName); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } @@ -54,142 +55,150 @@ public class UnitTestExportController [TestMethod] public void GetExport() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IExportRepository exportRepository = serviceProvider.GetRequiredService(); - string result = exportRepository.GetExport(GetHeaderCommon()); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IExportRepository? exportRepository = serviceProvider?.GetRequiredService(); + string? result = exportRepository?.GetExport(GetHeaderCommon()); Assert.IsNotNull(result); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public async Task GetExportApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/export"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetExport)}.txt"), result); Assert.IsNotNull(result); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public async Task PostExportApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/export", GetStringContent()); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public void GetHeaders() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IExportRepository exportRepository = serviceProvider.GetRequiredService(); - Result result = exportRepository.GetHeaders(GetHeaderCommon()); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IExportRepository? exportRepository = serviceProvider?.GetRequiredService(); + Result? result = exportRepository?.GetHeaders(GetHeaderCommon()); Assert.IsNotNull(result?.Results); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public async Task GetHeadersApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/headers"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeaders)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public async Task PostHeadersApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/headers", GetStringContent()); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public void GetLogistics() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IExportRepository exportRepository = serviceProvider.GetRequiredService(); - Result result = exportRepository.GetLogistics(GetHeaderCommon()); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IExportRepository? exportRepository = serviceProvider?.GetRequiredService(); + Result? result = exportRepository?.GetLogistics(GetHeaderCommon()); Assert.IsNotNull(result?.Results); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public async Task GetLogisticsApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/logistics"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetLogistics)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public async Task PostLogisticsApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/logistics", GetStringContent()); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public void GetProcessDataStandardFormat() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IExportRepository exportRepository = serviceProvider.GetRequiredService(); - string result = exportRepository.GetProcessDataStandardFormat(GetHeaderCommon()); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IExportRepository? exportRepository = serviceProvider?.GetRequiredService(); + string? result = exportRepository?.GetProcessDataStandardFormat(GetHeaderCommon()); Assert.IsNotNull(result); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public async Task GetProcessDataStandardFormatApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/processDataStandardFormat"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetProcessDataStandardFormat)}.pdsf"), result); Assert.IsNotNull(result); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public async Task PostProcessDataStandardFormatApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/processDataStandardFormat", GetStringContent()); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } diff --git a/Tests/UnitTestISpreadingResistanceProfileController.cs b/Tests/UnitTestISpreadingResistanceProfileController.cs index e3ce0df..340b716 100644 --- a/Tests/UnitTestISpreadingResistanceProfileController.cs +++ b/Tests/UnitTestISpreadingResistanceProfileController.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using OI.Metrology.Shared.Models.Stateless; -using Serilog; namespace OI.Metrology.Tests; @@ -11,10 +11,10 @@ public class UnitTestISpreadingResistanceProfileController #pragma warning disable CS8618 - private static ILogger _Logger; + private static ILogger? _Logger; private static string _ControllerName; private static TestContext _TestContext; - private static WebApplicationFactory _WebApplicationFactory; + private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -22,9 +22,10 @@ public class UnitTestISpreadingResistanceProfileController public static void ClassInitAsync(TestContext testContext) { _TestContext = testContext; - _Logger = Log.ForContext(); _WebApplicationFactory = new WebApplicationFactory(); - _ControllerName = nameof(Server.ApiControllers.InfinityQSController)[..^10]; + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + _Logger = serviceProvider.GetRequiredService>(); + _ControllerName = nameof(Server.ApiControllers.SpreadingResistanceProfileController)[..^10]; } private static void NonThrowTryCatch() @@ -37,16 +38,16 @@ public class UnitTestISpreadingResistanceProfileController [TestMethod] public void TestControllerName() { - _Logger.Information("Starting Web Application"); - Assert.AreEqual(IInfinityQSController.GetRouteName(), _ControllerName); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("Starting Web Application"); + Assert.AreEqual(ISpreadingResistanceProfileController.GetRouteName(), _ControllerName); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public void GetSpreadingResistanceProfileServiceImageBytes() { - _Logger.Information("Starting Web Application"); + _Logger?.LogInformation("Starting Web Application"); string directory = "D:/wwwRoot"; if (!Directory.Exists(directory)) _ = Directory.CreateDirectory(directory); @@ -54,13 +55,14 @@ public class UnitTestISpreadingResistanceProfileController if (File.Exists(file)) { string json = File.ReadAllText(file); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - ISpreadingResistanceProfileService spreadingResistanceProfileService = serviceProvider.GetRequiredService(); - byte[] bytes = spreadingResistanceProfileService.GetImageBytes(json); - Assert.IsTrue(bytes.Any()); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + ISpreadingResistanceProfileService? spreadingResistanceProfileService = serviceProvider?.GetRequiredService(); + byte[]? bytes = spreadingResistanceProfileService?.GetImageBytes(json); + Assert.IsTrue(bytes is not null); + Assert.IsTrue(bytes.Length != 0); File.WriteAllBytes(Path.Combine(directory, "srp.png"), bytes); } - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } diff --git a/Tests/UnitTestInfinityQSV2Controller.cs b/Tests/UnitTestInfinityQSV2Controller.cs index 9f9631a..1165a38 100644 --- a/Tests/UnitTestInfinityQSV2Controller.cs +++ b/Tests/UnitTestInfinityQSV2Controller.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.Models.Stateless; -using Serilog; namespace OI.Metrology.Tests; @@ -12,10 +12,10 @@ public class UnitTestInfinityQSV2Controller #pragma warning disable CS8618 - private static ILogger _Logger; + private static ILogger? _Logger; private static string _ControllerName; private static TestContext _TestContext; - private static WebApplicationFactory _WebApplicationFactory; + private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -23,8 +23,9 @@ public class UnitTestInfinityQSV2Controller public static void ClassInitAsync(TestContext testContext) { _TestContext = testContext; - _Logger = Log.ForContext(); _WebApplicationFactory = new WebApplicationFactory(); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + _Logger = serviceProvider.GetRequiredService>(); _ControllerName = nameof(Server.ApiControllers.InfinityQSV2Controller)[..^10]; } @@ -38,21 +39,21 @@ public class UnitTestInfinityQSV2Controller [TestMethod] public void TestControllerName() { - _Logger.Information("Starting Web Application"); + _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IInfinityQSV2Controller.GetRouteName(), _ControllerName); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public void GetCommandText() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IInfinityQSV2Repository infinityQSV2Repository = serviceProvider.GetRequiredService(); - string result = infinityQSV2Repository.GetCommandText("1677273357", "61", "CDE5", "5012", "575908", ""); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IInfinityQSV2Repository? infinityQSV2Repository = serviceProvider?.GetRequiredService(); + string? result = infinityQSV2Repository?.GetCommandText("1677273357", "61", "CDE5", "5012", "575908", ""); Assert.IsNotNull(result); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } @@ -62,12 +63,13 @@ public class UnitTestInfinityQSV2Controller [TestMethod] public async Task GetCommandTextApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/commandText/?process=61&job=CDE5&part=5012&lot=575908&date_time=2023-02-24 15:15:00"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCommandText)}.sql"), json); Assert.IsNotNull(json); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } @@ -77,18 +79,18 @@ public class UnitTestInfinityQSV2Controller [TestMethod] public void GetData() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IInfinityQSV2Repository infinityQSV2Repository = serviceProvider.GetRequiredService(); - Result result = infinityQSV2Repository.GetData("1677273357"); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IInfinityQSV2Repository? infinityQSV2Repository = serviceProvider?.GetRequiredService(); + Result? result = infinityQSV2Repository?.GetData("1677273357"); Assert.IsNotNull(result?.Results); - Assert.IsTrue(result?.Results.Any()); + Assert.IsTrue(result?.Results.Length != 0); Assert.IsNotNull(result?.Results[0].Process); Assert.IsNotNull(result?.Results[0].Variable); Assert.IsNotNull(result?.Results[0].SiteNumber); Assert.IsNotNull(result?.Results[0].VariableNumber); Assert.IsNotNull(result?.Results[0].SubGroupDateTime); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } @@ -98,14 +100,15 @@ public class UnitTestInfinityQSV2Controller [TestMethod] public async Task GetDataApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); //string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357 575908_2023-02-24 14-18-05.txt/data"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/data"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetData)}.json"), json); - Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); + Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } @@ -115,15 +118,15 @@ public class UnitTestInfinityQSV2Controller [TestMethod] public void GetDescriptors() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IInfinityQSV2Repository infinityQSV2Repository = serviceProvider.GetRequiredService(); - Result result = infinityQSV2Repository.GetDescriptors("1677273357"); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IInfinityQSV2Repository? infinityQSV2Repository = serviceProvider?.GetRequiredService(); + Result? result = infinityQSV2Repository?.GetDescriptors("1677273357"); Assert.IsNotNull(result?.Results); - Assert.IsTrue(result?.Results.Any()); + Assert.IsTrue(result?.Results.Length != 0); Assert.IsNotNull(result?.Results[0].SubGroupId); Assert.IsNotNull(result?.Results[0].SiteNumber); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } @@ -133,14 +136,15 @@ public class UnitTestInfinityQSV2Controller [TestMethod] public async Task GetDescriptorsApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); //string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357 575908_2023-02-24 14-18-05.txt/descriptors"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/descriptors"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetDescriptors)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } @@ -150,12 +154,12 @@ public class UnitTestInfinityQSV2Controller [TestMethod] public void GetEvents() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IInfinityQSV2Repository infinityQSV2Repository = serviceProvider.GetRequiredService(); - Result result = infinityQSV2Repository.GetEvents("1677273357"); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IInfinityQSV2Repository? infinityQSV2Repository = serviceProvider?.GetRequiredService(); + Result? result = infinityQSV2Repository?.GetEvents("1677273357"); Assert.IsNotNull(result?.Results); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } @@ -165,13 +169,14 @@ public class UnitTestInfinityQSV2Controller [TestMethod] public async Task GetEventsApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/events"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetEvents)}.json"), json); - Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); + Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } @@ -181,12 +186,13 @@ public class UnitTestInfinityQSV2Controller [TestMethod] public void GetHeader() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IInfinityQSV2Repository infinityQSV2Repository = serviceProvider.GetRequiredService(); - Result result = infinityQSV2Repository.GetHeader("1677273357"); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IInfinityQSV2Repository? infinityQSV2Repository = serviceProvider?.GetRequiredService(); + Result? result = infinityQSV2Repository?.GetHeader("1677273357"); Assert.IsNotNull(result?.Results); - _Logger.Information($"{_TestContext?.TestName} completed"); + Assert.IsNotNull(result?.Results[0].Part); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } @@ -196,13 +202,15 @@ public class UnitTestInfinityQSV2Controller [TestMethod] public async Task GetHeaderApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/header"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeader)}.json"), json); - Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); + Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger.Information($"{_TestContext?.TestName} completed"); + Assert.IsNotNull(result?.Results[0].Part); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } diff --git a/Tests/UnitTestInfinityQSV3Controller.cs b/Tests/UnitTestInfinityQSV3Controller.cs new file mode 100644 index 0000000..1793f88 --- /dev/null +++ b/Tests/UnitTestInfinityQSV3Controller.cs @@ -0,0 +1,216 @@ +using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using OI.Metrology.Shared.DataModels; +using OI.Metrology.Shared.Models.Stateless; + +namespace OI.Metrology.Tests; + +[TestClass] +public class UnitTestInfinityQSV3Controller +{ + +#pragma warning disable CS8618 + + private static ILogger? _Logger; + private static string _ControllerName; + private static TestContext _TestContext; + private static WebApplicationFactory? _WebApplicationFactory; + +#pragma warning restore + + [ClassInitialize] + public static void ClassInitAsync(TestContext testContext) + { + _TestContext = testContext; + _WebApplicationFactory = new WebApplicationFactory(); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + _Logger = serviceProvider.GetRequiredService>(); + _ControllerName = nameof(Server.ApiControllers.InfinityQSV3Controller)[..^10]; + } + + private static void NonThrowTryCatch() + { + try + { throw new Exception(); } + catch (Exception) { } + } + + [TestMethod] + public void TestControllerName() + { + _Logger?.LogInformation("Starting Web Application"); + Assert.AreEqual(IInfinityQSV3Controller.GetRouteName(), _ControllerName); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + NonThrowTryCatch(); + } + + [TestMethod] + public void GetCommandText() + { + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IInfinityQSV3Repository? infinityQSV3Repository = serviceProvider?.GetRequiredService(); + string? result = infinityQSV3Repository?.GetCommandText("1698497987", "61", "CDE5", "5012", "575908", ""); + Assert.IsNotNull(result); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + NonThrowTryCatch(); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public async Task GetCommandTextApi() + { + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); + string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1698497987/commandText/?process=61&job=CDE5&part=5012&lot=575908&date_time=2023-02-24 15:15:00"); + File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCommandText)}.sql"), json); + Assert.IsNotNull(json); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + NonThrowTryCatch(); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void GetData() + { + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IInfinityQSV3Repository? infinityQSV3Repository = serviceProvider?.GetRequiredService(); + Result? result = infinityQSV3Repository?.GetData("1698497987"); + Assert.IsNotNull(result?.Results); + Assert.IsTrue(result?.Results.Length != 0); + Assert.IsNotNull(result?.Results[0].Process); + Assert.IsNotNull(result?.Results[0].Variable); + Assert.IsNotNull(result?.Results[0].SiteNumber); + Assert.IsNotNull(result?.Results[0].VariableNumber); + Assert.IsNotNull(result?.Results[0].SubGroupDateTime); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + NonThrowTryCatch(); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public async Task GetDataApi() + { + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); + //string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1698497987 575908_2023-02-24 14-18-05.txt/data"); + string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1698497987/data"); + File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetData)}.json"), json); + Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); + Assert.IsNotNull(result?.Results); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + NonThrowTryCatch(); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void GetDescriptors() + { + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IInfinityQSV3Repository? infinityQSV3Repository = serviceProvider?.GetRequiredService(); + Result? result = infinityQSV3Repository?.GetDescriptors("1698497987"); + Assert.IsNotNull(result?.Results); + Assert.IsTrue(result?.Results.Length != 0); + Assert.IsNotNull(result?.Results[0].SubGroupId); + Assert.IsNotNull(result?.Results[0].SiteNumber); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + NonThrowTryCatch(); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public async Task GetDescriptorsApi() + { + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); + //string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1698497987 575908_2023-02-24 14-18-05.txt/descriptors"); + string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1698497987/descriptors"); + File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetDescriptors)}.json"), json); + Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); + Assert.IsNotNull(result?.Results); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + NonThrowTryCatch(); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void GetHeader() + { + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IInfinityQSV3Repository? infinityQSV3Repository = serviceProvider?.GetRequiredService(); + Result? result = infinityQSV3Repository?.GetHeader("1698497987"); + Assert.IsNotNull(result?.Results); + Assert.IsNotNull(result?.Results[0].Part); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + NonThrowTryCatch(); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public async Task GetHeaderApi() + { + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); + string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1698497987/header"); + File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeader)}.json"), json); + Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); + Assert.IsNotNull(result?.Results); + Assert.IsNotNull(result?.Results[0].Part); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + NonThrowTryCatch(); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void GetProductDataAverageSumOfDefectsProcessMeanProcessSigma() + { + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IInfinityQSV3Repository? infinityQSV3Repository = serviceProvider?.GetRequiredService(); + string? result = infinityQSV3Repository?.GetProductDataAverageSumOfDefectsProcessMeanProcessSigma("41", "8IN_THIN ROTR"); + Assert.IsNotNull(result); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + NonThrowTryCatch(); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public async Task GetProductDataAverageSumOfDefectsProcessMeanProcessSigmaApi() + { + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); + string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/41/product-data-average-sum-of-defects-process-mean-process-sigma?recipe=8IN_THIN ROTR"); + File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetProductDataAverageSumOfDefectsProcessMeanProcessSigma)}.json"), result); + Assert.IsNotNull(result); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + NonThrowTryCatch(); + } + +} \ No newline at end of file diff --git a/Tests/UnitTestOpenInsightV1Controller.cs b/Tests/UnitTestOpenInsightV1Controller.cs new file mode 100644 index 0000000..a2ff8d7 --- /dev/null +++ b/Tests/UnitTestOpenInsightV1Controller.cs @@ -0,0 +1,71 @@ +using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using OI.Metrology.Shared.Models.Stateless; + +namespace OI.Metrology.Tests; + +[TestClass] +public class UnitTestOpenInsightV1Controller +{ + +#pragma warning disable CS8618 + + private static ILogger? _Logger; + private static string _ControllerName; + private static TestContext _TestContext; + private static WebApplicationFactory? _WebApplicationFactory; + +#pragma warning restore + + [ClassInitialize] + public static void ClassInitAsync(TestContext testContext) + { + _TestContext = testContext; + _WebApplicationFactory = new WebApplicationFactory(); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + _Logger = serviceProvider.GetRequiredService>(); + _ControllerName = nameof(Server.ApiControllers.OpenInsightV1Controller)[..^10]; + } + + private static void NonThrowTryCatch() + { + try + { throw new Exception(); } + catch (Exception) { } + } + + [TestMethod] + public void TestControllerName() + { + _Logger?.LogInformation("Starting Web Application"); + Assert.AreEqual(IOpenInsightV1Controller.GetRouteName(), _ControllerName); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + } + + [TestMethod] + public void GetTencorRun() + { + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IOpenInsightV1Repository? openInsightRepository = serviceProvider?.GetRequiredService(); + string? result = openInsightRepository?.GetTencorRun("615071", "10/30/2023 06:48:34PM", "6IN_EPP ROTR"); + Assert.IsNotNull(result); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + NonThrowTryCatch(); + } + + [TestMethod] + public async Task GetTencorRunApi() + { + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); + string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/615071/tencor-run?insert_date=10/30/2023 06:48:34PM&recipe=6IN_EPP ROTR"); + File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetTencorRun)}.json"), result); + Assert.IsNotNull(result); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + NonThrowTryCatch(); + } + +} \ No newline at end of file diff --git a/Tests/UnitTestPinController.cs b/Tests/UnitTestPinController.cs index 2b462ec..cfc947d 100644 --- a/Tests/UnitTestPinController.cs +++ b/Tests/UnitTestPinController.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.Models.Stateless; -using Serilog; namespace OI.Metrology.Tests; @@ -12,10 +12,10 @@ public class UnitTestPinController #pragma warning disable CS8618 - private static ILogger _Logger; + private static ILogger? _Logger; private static string _ControllerName; private static TestContext _TestContext; - private static WebApplicationFactory _WebApplicationFactory; + private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -23,41 +23,44 @@ public class UnitTestPinController public static void ClassInitAsync(TestContext testContext) { _TestContext = testContext; - _Logger = Log.ForContext(); _WebApplicationFactory = new WebApplicationFactory(); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + _Logger = serviceProvider.GetRequiredService>(); _ControllerName = nameof(Server.ApiControllers.PinController)[..^10]; } [TestMethod] public void TestControllerName() { - _Logger.Information("Starting Web Application"); + _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IPinController.GetRouteName(), _ControllerName); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public void GetPinnedTable() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService(); - IPinRepository pinRepository = serviceProvider.GetRequiredService(); - Result result = pinRepository.GetPinnedTable(metrologyRepository, id: 1, cde_id: null, biorad_id: null, rds: null); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService(); + IPinRepository? pinRepository = serviceProvider?.GetRequiredService(); + Assert.IsTrue(metrologyRepository is not null); + Result? result = pinRepository?.GetPinnedTable(metrologyRepository, id: 1, cde_id: null, biorad_id: null, rds: null); Assert.IsNotNull(result?.Results); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public async Task GetPinnedTableApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/-1/pinned"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetPinnedTable)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } } \ No newline at end of file diff --git a/Tests/UnitTestReactorController.cs b/Tests/UnitTestReactorController.cs index 917b716..42a96aa 100644 --- a/Tests/UnitTestReactorController.cs +++ b/Tests/UnitTestReactorController.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.Models.Stateless; -using Serilog; namespace OI.Metrology.Tests; @@ -12,10 +12,10 @@ public class UnitTestReactorController #pragma warning disable CS8618 - private static ILogger _Logger; + private static ILogger? _Logger; private static string _ControllerName; private static TestContext _TestContext; - private static WebApplicationFactory _WebApplicationFactory; + private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -23,8 +23,9 @@ public class UnitTestReactorController public static void ClassInitAsync(TestContext testContext) { _TestContext = testContext; - _Logger = Log.ForContext(); _WebApplicationFactory = new WebApplicationFactory(); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + _Logger = serviceProvider.GetRequiredService>(); _ControllerName = nameof(Server.ApiControllers.ReactorsController)[..^10]; } @@ -38,47 +39,48 @@ public class UnitTestReactorController [TestMethod] public void TestControllerName() { - _Logger.Information("Starting Web Application"); + _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IReactorsController.GetRouteName(), _ControllerName); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public void GetReactors() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IReactorsRepository reactorsRepository = serviceProvider.GetRequiredService(); - Result result = reactorsRepository.EvenReactors(); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IReactorsRepository? reactorsRepository = serviceProvider?.GetRequiredService(); + Result? result = reactorsRepository?.EvenReactors(); Assert.IsNotNull(result?.Results); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public async Task GetReactorsApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/true/"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetReactors)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } [TestMethod] public void GetKey() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IReactorsRepository reactorsRepository = serviceProvider.GetRequiredService(); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IReactorsRepository? reactorsRepository = serviceProvider?.GetRequiredService(); WorkMaterialOut workMaterialOut = new() { RunDataSheet = "123456", Username = "phares" }; - string? result = reactorsRepository.GetKey(workMaterialOut, save: false); + string? result = reactorsRepository?.GetKey(workMaterialOut, save: false); Assert.IsNotNull(result); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } diff --git a/Tests/UnitTestServiceShopOrderController.cs b/Tests/UnitTestServiceShopOrderController.cs index 829e2d9..ffc2a7e 100644 --- a/Tests/UnitTestServiceShopOrderController.cs +++ b/Tests/UnitTestServiceShopOrderController.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.ViewModels; -using Serilog; namespace OI.Metrology.Tests; @@ -12,10 +12,10 @@ public class UnitTestServiceShopOrderController #pragma warning disable CS8618 - private static ILogger _Logger; + private static ILogger? _Logger; private static string _ControllerName; private static TestContext _TestContext; - private static WebApplicationFactory _WebApplicationFactory; + private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -23,17 +23,18 @@ public class UnitTestServiceShopOrderController public static void ClassInitAsync(TestContext testContext) { _TestContext = testContext; - _Logger = Log.ForContext(); _WebApplicationFactory = new WebApplicationFactory(); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + _Logger = serviceProvider.GetRequiredService>(); _ControllerName = nameof(Server.ApiControllers.ServiceShopOrderController)[..^10]; } [TestMethod] public void TestControllerName() { - _Logger.Information("Starting Web Application"); + _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IServiceShopOrderController.GetRouteName(), _ControllerName); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] @@ -43,36 +44,38 @@ public class UnitTestServiceShopOrderController throw new NullReferenceException(nameof(_Logger)); ServiceShopOrder[] serviceShopOrders = IServiceShopOrder.GetServiceShopOrders(null); Assert.IsNotNull(serviceShopOrders); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public async Task GetAllServiceShopOrders() { - _Logger.Information("Starting Web Application"); - ServiceShopOrder[] serviceShopOrders; - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IServiceShopOrderRepository serviceShopOrderRepository = serviceProvider.GetRequiredService(); + _Logger?.LogInformation("Starting Web Application"); + ServiceShopOrder[]? serviceShopOrders; + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IServiceShopOrderRepository? serviceShopOrderRepository = serviceProvider?.GetRequiredService(); + Assert.IsTrue(serviceShopOrderRepository is not null); serviceShopOrders = await serviceShopOrderRepository.GetAllServiceShopOrders(); Assert.IsTrue(serviceShopOrders is not null); serviceShopOrders = await serviceShopOrderRepository.GetServiceShopOrders("23188d3d-9b75-ed11-ab8b-0050568f2fc3"); - Assert.IsTrue(serviceShopOrders is not null && serviceShopOrders.Any()); + Assert.IsTrue(serviceShopOrders is not null && serviceShopOrders.Length != 0); Assert.IsNotNull(serviceShopOrders[0].ToString()); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public async Task GetAllServiceShopOrdersApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string actionName = nameof(IServiceShopOrderController.Action.All); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/{actionName}"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetAllServiceShopOrders)}.json"), json); ServiceShopOrder[]? serviceShopOrders = System.Text.Json.JsonSerializer.Deserialize(json); Assert.IsNotNull(serviceShopOrders); - Assert.IsTrue(serviceShopOrders.Any()); - _Logger.Information($"{_TestContext?.TestName} completed"); + Assert.IsTrue(serviceShopOrders.Length != 0); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } } \ No newline at end of file diff --git a/Tests/UnitTestToolTypesController.cs b/Tests/UnitTestToolTypesController.cs index d62d2e5..87b53c5 100644 --- a/Tests/UnitTestToolTypesController.cs +++ b/Tests/UnitTestToolTypesController.cs @@ -1,9 +1,9 @@ using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.Services; -using Serilog; using System.Data; using System.Net.Http.Json; @@ -15,10 +15,10 @@ public class UnitTestToolTypesController #pragma warning disable CS8618 - private static ILogger _Logger; + private static ILogger? _Logger; private static string _ControllerName; private static TestContext _TestContext; - private static WebApplicationFactory _WebApplicationFactory; + private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -26,8 +26,9 @@ public class UnitTestToolTypesController public static void ClassInitAsync(TestContext testContext) { _TestContext = testContext; - _Logger = Log.ForContext(); _WebApplicationFactory = new WebApplicationFactory(); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + _Logger = serviceProvider.GetRequiredService>(); _ControllerName = nameof(Server.ApiControllers.ToolTypesController)[..^10]; } @@ -41,252 +42,274 @@ public class UnitTestToolTypesController [TestMethod] public void TestControllerName() { - _Logger.Information("Starting Web Application"); + _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IToolTypesController.GetRouteName(), _ControllerName); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public void Index() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService(); - IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService(); - Result result = toolTypesRepository.Index(metrologyRepository); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService(); + IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService(); + Assert.IsTrue(metrologyRepository is not null); + Result? result = toolTypesRepository?.Index(metrologyRepository); Assert.IsNotNull(result?.Results); - Assert.IsTrue(result.Results.Any()); + Assert.IsTrue(result.Results.Length != 0); Assert.IsFalse(result.Results.All(l => l.ID == 0)); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public async Task IndexApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(Index)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - Assert.IsTrue(result.Results.Any()); + Assert.IsTrue(result.Results.Length != 0); Assert.IsFalse(result.Results.All(l => l.ID == 0)); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public void GetToolTypeMetadata() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService(); - IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService(); - Result result = toolTypesRepository.GetToolTypeMetadata(metrologyRepository, id: 1, sortby: string.Empty); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService(); + IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService(); + Assert.IsTrue(metrologyRepository is not null); + Result? result = toolTypesRepository?.GetToolTypeMetadata(metrologyRepository, id: 1, sortby: string.Empty); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result.Results.Metadata); - Assert.IsTrue(result.Results.Metadata.Any()); + Assert.IsTrue(result.Results.Metadata.Length != 0); Assert.IsFalse(result.Results.Metadata.All(l => l.ToolTypeID == 0)); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public async Task GetToolTypeMetadataApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetToolTypeMetadata)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result.Results.Metadata); - Assert.IsTrue(result.Results.Metadata.Any()); + Assert.IsTrue(result.Results.Metadata.Length != 0); Assert.IsFalse(result.Results.Metadata.All(l => l.ToolTypeID == 0)); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public void GetHeaders() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService(); - IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService(); - Result result = toolTypesRepository.GetHeaders(metrologyRepository, id: 1, datebegin: null, dateend: null, page: null, pagesize: null, headerid: null); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService(); + IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService(); + Assert.IsTrue(metrologyRepository is not null); + Result? result = toolTypesRepository?.GetHeaders(metrologyRepository, id: 1, datebegin: null, dateend: null, page: null, pagesize: null, headerid: null); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result.Results.Rows.Count > 0); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public async Task GetHeadersApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeaders)}.json"), json); Result? result = Newtonsoft.Json.JsonConvert.DeserializeObject>(json); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result.Results.Rows.Count > 0); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public void GetHeaderTitles() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService(); - IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService(); - Result result = toolTypesRepository.GetHeaderTitles(metrologyRepository, id: -1, page: null, pagesize: null); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService(); + IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService(); + Assert.IsTrue(metrologyRepository is not null); + Result? result = toolTypesRepository?.GetHeaderTitles(metrologyRepository, id: -1, page: null, pagesize: null); Assert.IsNotNull(result?.Results); - Assert.IsTrue(result.Results.Any()); - _Logger.Information($"{_TestContext?.TestName} completed"); + Assert.IsTrue(result?.Results.Length != 0); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public async Task GetHeaderTitlesApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/-1/headertitles"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeaderTitles)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - Assert.IsTrue(result.Results.Any()); - _Logger.Information($"{_TestContext?.TestName} completed"); + Assert.IsTrue(result.Results.Length != 0); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public void GetHeaderFields() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService(); - IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService(); - Result result = toolTypesRepository.GetHeaderFields(metrologyRepository, id: 1, headerid: 1); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService(); + IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService(); + Assert.IsTrue(metrologyRepository is not null); + Result? result = toolTypesRepository?.GetHeaderFields(metrologyRepository, id: 1, headerid: 1); Assert.IsNotNull(result?.Results); - Assert.IsTrue(result.Results.Any()); - _Logger.Information($"{_TestContext?.TestName} completed"); + Assert.IsTrue(result.Results.Length != 0); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public async Task GetHeaderFieldsApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers/1/fields"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeaderFields)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - Assert.IsTrue(result.Results.Any()); - _Logger.Information($"{_TestContext?.TestName} completed"); + Assert.IsTrue(result.Results.Length != 0); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public void GetData() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService(); - IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService(); - Result result = toolTypesRepository.GetData(metrologyRepository, id: 1, headerid: 1); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService(); + IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService(); + Assert.IsTrue(metrologyRepository is not null); + Result? result = toolTypesRepository?.GetData(metrologyRepository, id: 1, headerid: 1); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result.Results.Rows.Count > 0); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [TestMethod] public async Task GetDataApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers/1/data"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetData)}.json"), json); Result? result = Newtonsoft.Json.JsonConvert.DeserializeObject>(json); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result.Results.Rows.Count > 0); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [Ignore] [TestMethod] public void GetExportData() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService(); - IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService(); - Result result = toolTypesRepository.GetExportData(metrologyRepository, toolTypeId: 1, datebegin: null, dateend: null); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService(); + IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService(); + Assert.IsTrue(metrologyRepository is not null); + Result? result = toolTypesRepository?.GetExportData(metrologyRepository, toolTypeId: 1, datebegin: null, dateend: null); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result.Results.Rows.Count > 0); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [Ignore] [TestMethod] public async Task GetExportDataApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/export"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetExportData)}.json"), json); Result? result = Newtonsoft.Json.JsonConvert.DeserializeObject>(json); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result.Results.Rows.Count > 0); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [Ignore] [TestMethod] public void GetAttachment() { - _Logger.Information("Starting Web Application"); + _Logger?.LogInformation("Starting Web Application"); int toolTypeId = 1; string tabletype = "data"; string filename = "data.txt"; string attachmentId = "ffdf5410-ca19-4097-bfa4-b398e236d07e"; - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IAttachmentsService attachmentsService = serviceProvider.GetRequiredService(); - IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService(); - IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService(); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IAttachmentsService? attachmentsService = serviceProvider?.GetRequiredService(); + IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService(); + IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService(); + Assert.IsTrue(attachmentsService is not null); + Assert.IsTrue(metrologyRepository is not null); + Assert.IsTrue(toolTypesRepository is not null); (string? message, string? _, Stream? _) = toolTypesRepository.GetAttachment(metrologyRepository, attachmentsService, toolTypeId, tabletype, attachmentId, filename); Assert.IsTrue(message is null); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [Ignore] [TestMethod] public async Task GetAttachmentApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); _ = await httpClient.GetFromJsonAsync($"api/{_ControllerName}/1/data/files/ffdf5410-ca19-4097-bfa4-b398e236d07e/data.txt"); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [Ignore] [TestMethod] public void OIExport() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IAttachmentsService attachmentsService = serviceProvider.GetRequiredService(); - IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService(); - IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService(); - Server.Models.AppSettings appSettings = serviceProvider.GetRequiredService(); - string? message = toolTypesRepository.OIExport(metrologyRepository, attachmentsService, appSettings.AttachmentPath, appSettings.TableToPath, toolTypeId: 1, headerid: 1); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IAttachmentsService? attachmentsService = serviceProvider?.GetRequiredService(); + IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService(); + IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService(); + Server.Models.AppSettings? appSettings = serviceProvider?.GetRequiredService(); + Assert.IsTrue(appSettings is not null); + Assert.IsTrue(attachmentsService is not null); + Assert.IsTrue(metrologyRepository is not null); + string? message = toolTypesRepository?.OIExport(metrologyRepository, attachmentsService, appSettings.AttachmentPath, appSettings.TableToPath, toolTypeId: 1, headerid: 1); Assert.IsTrue(message is null); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } [Ignore] [TestMethod] public async Task OIExportApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); - _ = await httpClient.GetFromJsonAsync($"api/{_ControllerName}/1/headers/1/oiexport"); - _Logger.Information($"{_TestContext?.TestName} completed"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); + _ = await httpClient.GetFromJsonAsync($"api/{_ControllerName}/1/headers/1/export"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); } } \ No newline at end of file diff --git a/Tests/UnitTestWorkMaterialController.cs b/Tests/UnitTestWorkMaterialController.cs index a966212..7ed60d8 100644 --- a/Tests/UnitTestWorkMaterialController.cs +++ b/Tests/UnitTestWorkMaterialController.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.Models.Stateless; -using Serilog; namespace OI.Metrology.Tests; @@ -12,10 +12,10 @@ public class UnitTestWorkMaterialController #pragma warning disable CS8618 - private static ILogger _Logger; + private static ILogger? _Logger; private static string _ControllerName; private static TestContext _TestContext; - private static WebApplicationFactory _WebApplicationFactory; + private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -23,8 +23,9 @@ public class UnitTestWorkMaterialController public static void ClassInitAsync(TestContext testContext) { _TestContext = testContext; - _Logger = Log.ForContext(); _WebApplicationFactory = new WebApplicationFactory(); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + _Logger = serviceProvider.GetRequiredService>(); _ControllerName = nameof(Server.ApiControllers.WorkMaterialController)[..^10]; } @@ -38,9 +39,9 @@ public class UnitTestWorkMaterialController [TestMethod] public void TestControllerName() { - _Logger.Information("Starting Web Application"); + _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IWorkMaterialController.GetRouteName(), _ControllerName); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } @@ -50,12 +51,12 @@ public class UnitTestWorkMaterialController [TestMethod] public void GetCassette() { - _Logger.Information("Starting Web Application"); - IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; - IWorkMaterialRepository workMaterialRepository = serviceProvider.GetRequiredService(); - Result result = workMaterialRepository.GetCassette("O171927.1.37"); + _Logger?.LogInformation("Starting Web Application"); + IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; + IWorkMaterialRepository? workMaterialRepository = serviceProvider?.GetRequiredService(); + Result? result = workMaterialRepository?.GetCassette("O171927.1.37"); Assert.IsNotNull(result?.Results); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); } @@ -65,13 +66,14 @@ public class UnitTestWorkMaterialController [TestMethod] public async Task GetCassetteApi() { - HttpClient httpClient = _WebApplicationFactory.CreateClient(); - _Logger.Information("Starting Web Application"); + HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); + _Logger?.LogInformation("Starting Web Application"); + Assert.IsTrue(httpClient is not null); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/O171927.1.37/"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCassette)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger.Information($"{_TestContext?.TestName} completed"); + _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); NonThrowTryCatch(); }