Tests passed using Mock

This commit is contained in:
Mike Phares 2023-11-01 08:27:25 -07:00
parent f684c4b7ef
commit 3dd4034a84
81 changed files with 171126 additions and 139391 deletions

View File

@ -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] [*.cs]
csharp_indent_block_contents = true csharp_indent_block_contents = true
csharp_indent_braces = false 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_before_open_brace = all
csharp_new_line_between_query_expression_clauses = true csharp_new_line_between_query_expression_clauses = true
csharp_prefer_braces = false csharp_prefer_braces = false
csharp_prefer_qualified_reference = true:error
csharp_prefer_simple_default_expression = true:warning csharp_prefer_simple_default_expression = true:warning
csharp_prefer_simple_using_statement = true:warning csharp_prefer_simple_using_statement = true:warning
csharp_prefer_static_local_function = 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.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.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.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.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.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.IDE0004.severity = warning # IDE0004: Cast is redundant.
dotnet_diagnostic.IDE0005.severity = warning # Using directive is unnecessary 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.IDE0031.severity = warning # Use null propagation (IDE0031)
dotnet_diagnostic.IDE0047.severity = warning # IDE0047: Parentheses can be removed 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.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.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.severity = warning
dotnet_naming_rule.abstract_method_should_be_pascal_case.style = pascal_case dotnet_naming_rule.abstract_method_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.abstract_method_should_be_pascal_case.symbols = abstract_method dotnet_naming_rule.abstract_method_should_be_pascal_case.symbols = abstract_method

4
.gitignore vendored
View File

@ -340,4 +340,6 @@ ASALocalRun/
!.vscode/thunder-tests/ !.vscode/thunder-tests/
# Libman.json # Libman.json
/wwwroot/lib/* /wwwroot/lib/*
.kanbn/**/*

View File

@ -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;
}

View File

@ -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

View File

@ -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~~

16
.vscode/tasks.json vendored
View File

@ -22,8 +22,8 @@
"-p", "-p",
"${workspaceFolder}/Server/OI.Metrology.Server.csproj", "${workspaceFolder}/Server/OI.Metrology.Server.csproj",
"set", "set",
"asdf", "_Application",
"123" "oi-metrology-viewer.Server"
], ],
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
}, },
@ -39,6 +39,18 @@
], ],
"problemMatcher": "$msCompile" "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", "label": "publishServer",
"command": "dotnet", "command": "dotnet",

View File

@ -27,17 +27,17 @@
<Content Remove="compilerconfig.json" /> <Content Remove="compilerconfig.json" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Dapper" Version="2.0.143" /> <PackageReference Include="Dapper" Version="2.1.4" />
<PackageReference Include="EntityFramework" Version="6.4.4" /> <PackageReference Include="EntityFramework" Version="6.4.4" />
<PackageReference Include="jQuery" Version="3.7.0" /> <PackageReference Include="jQuery" Version="3.7.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.1" /> <PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" /> <PackageReference Include="Serilog.AspNetCore" Version="6.0.0" />
<PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00032" /> <PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00032" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" /> <PackageReference Include="Serilog.Settings.Configuration" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" /> <PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" /> <PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />

View File

@ -86,13 +86,13 @@ public class Program
if (WindowsServiceHelpers.IsWindowsService()) if (WindowsServiceHelpers.IsWindowsService())
{ {
_ = webApplicationBuilder.Services.AddSingleton<IHostLifetime, WindowsServiceLifetime>(); _ = webApplicationBuilder.Services.AddSingleton<IHostLifetime, WindowsServiceLifetime>();
#pragma warning disable CA1416
_ = webApplicationBuilder.Logging.AddEventLog(settings => _ = webApplicationBuilder.Logging.AddEventLog(settings =>
{ {
#pragma warning disable CA1416
if (string.IsNullOrEmpty(settings.SourceName)) if (string.IsNullOrEmpty(settings.SourceName))
settings.SourceName = webApplicationBuilder.Environment.ApplicationName; settings.SourceName = webApplicationBuilder.Environment.ApplicationName;
#pragma warning restore
}); });
#pragma warning restore
} }
WebApplication webApplication = webApplicationBuilder.Build(); WebApplication webApplication = webApplicationBuilder.Build();
if (!webApplicationBuilder.Environment.IsDevelopment()) if (!webApplicationBuilder.Environment.IsDevelopment())

View File

@ -70,6 +70,12 @@
"endsPattern": "^.*Application started.*" "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": []
} }
] ]
} }

View File

@ -56,7 +56,7 @@ public partial class InboundController : ControllerBase, IInboundController<IAct
{ {
string? json = GetJson(Request.Body); string? json = GetJson(Request.Body);
DataResponse dataResponse = _InboundRepository.Data(_MetrologyRepository, _InboundDataService, tooltype, json); DataResponse dataResponse = _InboundRepository.Data(_MetrologyRepository, _InboundDataService, tooltype, json);
if (!dataResponse.Errors.Any()) if (dataResponse.Errors.Count == 0)
return Ok(dataResponse); return Ok(dataResponse);
else else
return BadRequest(dataResponse); return BadRequest(dataResponse);

View File

@ -0,0 +1,55 @@
using Microsoft.AspNetCore.Mvc;
namespace OI.Metrology.Server.ApiControllers;
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models.Stateless;
using System.Text.Json;
[Route("api/[controller]")]
public class InfinityQSV3Controller : Controller, IInfinityQSV3Controller<IActionResult>
{
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<InfinityQSV3[]> 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<InfinityQSDescriptorV3[]> 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<InfinityQSV3[]> 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);
}
}

View File

@ -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<IActionResult>
{
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);
}
}

View File

@ -1 +1 @@
{"apiLoggingContentTypes":null,"apiLoggingPathPrefixes":null,"apiLogPath":null,"apiUrl":null,"attachmentPath":null,"buildNumber":"1","company":"Infineon Technologies Americas Corp.","connectionString":null,"gitCommitSeven":"1234567","inboundApiAllowedIPList":null,"isDevelopment":true,"isStaging":false,"mockRoot":null,"monAResource":null,"monASite":null,"oi2SqlConnectionString":null,"oiExportPath":null,"urLs":null,"workingDirectoryName":null} {"apiExportPath":null,"apiLoggingContentTypes":null,"apiLoggingPathPrefixes":null,"apiLogPath":null,"apiUrl":null,"attachmentPath":null,"buildNumber":"1000014","company":"Infineon Technologies Americas Corp.","connectionString":null,"gitCommitSeven":"6bc0487","inboundApiAllowedIPList":null,"isDevelopment":false,"isStaging":false,"mockRoot":null,"monAResource":null,"monASite":null,"oi2SqlConnectionString":null,"tableToPath":null,"urLs":null,"workingDirectoryName":null}

View File

@ -1 +1 @@
1-1234567 1000014-6bc0487

View File

@ -1 +0,0 @@
asdf

View File

@ -1,4 +1,90 @@
{ {
"Results": [], "Results": [
"TotalRows": 0 {
"ID": 0,
"InsertDate": "0001-01-01T00:00:00",
"AttachmentID": "00000000-0000-0000-0000-000000000000",
"Title": null,
"Date": "0001-01-01T00:00:00",
"ToolTypeID": 0,
"ToolTypeName": null,
"MesEntity": "TENCOR2",
"Employee": "PRE",
"Layer": null,
"PSN": "",
"RDS": "",
"Reactor": "",
"Recipe": "8IN.2QUAL",
"Zone": null
},
{
"ID": 0,
"InsertDate": "0001-01-01T00:00:00",
"AttachmentID": "00000000-0000-0000-0000-000000000000",
"Title": null,
"Date": "0001-01-01T00:00:00",
"ToolTypeID": 0,
"ToolTypeName": null,
"MesEntity": "TENCOR3",
"Employee": "",
"Layer": null,
"PSN": "",
"RDS": "",
"Reactor": "",
"Recipe": "8INCLEAN",
"Zone": null
},
{
"ID": 0,
"InsertDate": "0001-01-01T00:00:00",
"AttachmentID": "00000000-0000-0000-0000-000000000000",
"Title": null,
"Date": "0001-01-01T00:00:00",
"ToolTypeID": 0,
"ToolTypeName": null,
"MesEntity": "TENCOR3",
"Employee": "",
"Layer": null,
"PSN": "",
"RDS": "",
"Reactor": "",
"Recipe": "8IN_THIN ROTR",
"Zone": null
},
{
"ID": 0,
"InsertDate": "0001-01-01T00:00:00",
"AttachmentID": "00000000-0000-0000-0000-000000000000",
"Title": null,
"Date": "0001-01-01T00:00:00",
"ToolTypeID": 0,
"ToolTypeName": null,
"MesEntity": "TENCOR3",
"Employee": "",
"Layer": null,
"PSN": "",
"RDS": "",
"Reactor": "",
"Recipe": "8IN_PTYPE_ROTR",
"Zone": null
},
{
"ID": 0,
"InsertDate": "0001-01-01T00:00:00",
"AttachmentID": "00000000-0000-0000-0000-000000000000",
"Title": null,
"Date": "0001-01-01T00:00:00",
"ToolTypeID": 0,
"ToolTypeName": null,
"MesEntity": "TENCOR3",
"Employee": "",
"Layer": null,
"PSN": "",
"RDS": "",
"Reactor": "",
"Recipe": "AS_IFX_ROTR",
"Zone": null
}
],
"TotalRows": 5
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,19 @@
{ {
"Results": [ "Results": [
{ {
"EV_COUNT": 0,
"CL_COUNT": 0,
"SL_COUNT": 0,
"SE_SGRP": 1677273357, "SE_SGRP": 1677273357,
"SE_SGTM": 1677273300, "SE_SGTM": 1677273300,
"SE_TSNO": 1, "SE_TSNO": 1,
"TD_TEST": 1650647347,
"PR_NAME": "61", "PR_NAME": "61",
"JD_NAME": "CDE5", "JD_NAME": "CDE5",
"PL_NAME": "575908", "PL_NAME": "575908",
"PD_NAME": "5012", "PD_NAME": "5012",
"TD_TEST": 1650647347,
"TD_NAME": "T", "TD_NAME": "T",
"SE_VAL": 270, "SE_VAL": 270
"EV_COUNT": 0
} }
], ],
"TotalRows": 1 "TotalRows": 1

View File

@ -1,22 +1,35 @@
select iq.ev_count, iq.cl_count, iq.sl_count, iq.se_sgrp, iq.se_sgtm, iq.se_tsno, iq.td_test, iq.pr_name, iq.jd_name, iq.pl_name, iq.pd_name, iq.td_name, iq.se_val
from (
select select
se.f_sgrp se_sgrp, se.f_sgrp se_sgrp,
se.f_sgtm se_sgtm, se.f_sgtm se_sgtm,
se.f_tsno se_tsno, se.f_tsno se_tsno,
se.f_val se_val, se.f_val se_val,
rd.f_name rd_name, pr.f_name pr_name,
jd.f_name jd_name, jd.f_name jd_name,
pl.f_name pl_name, pl.f_name pl_name,
pd.f_name pd_name, pd.f_name pd_name,
td.f_test td_test, td.f_test td_test,
td.f_name td_name, td.f_name td_name,
(select count(cl.f_part)
from [spcepiworld].[dbo].[ctrl_lim] cl
where cl.f_part = pd.f_part
and cl.f_test = td.f_test
) cl_count,
(select count(sl.f_part)
from [spcepiworld].[dbo].[spec_lim] sl
where sl.f_part = pd.f_part
and sl.f_test = td.f_test
) sl_count,
(select count(ev.f_evnt) (select count(ev.f_evnt)
from [spcepiworld].[dbo].[evnt_inf] ev from [spcepiworld].[dbo].[evnt_inf] ev
where ev.f_prcs = rd.f_prcs where ev.f_prcs = pr.f_prcs
and ev.f_part = pd.f_part and ev.f_part = pd.f_part
and ev.f_sgtm = se.f_sgtm) ev_count and ev.f_sgtm = se.f_sgtm
) ev_count
from [spcepiworld].[dbo].[sgrp_ext] se from [spcepiworld].[dbo].[sgrp_ext] se
join [spcepiworld].[dbo].[prcs_dat] rd join [spcepiworld].[dbo].[prcs_dat] pr
on se.f_prcs = rd.f_prcs on se.f_prcs = pr.f_prcs
join [spcepiworld].[dbo].[job_dat] jd join [spcepiworld].[dbo].[job_dat] jd
on se.f_job = jd.f_job on se.f_job = jd.f_job
join [spcepiworld].[dbo].[part_lot] pl join [spcepiworld].[dbo].[part_lot] pl
@ -27,9 +40,11 @@
on se.f_test = td.f_test on se.f_test = td.f_test
where se.f_flag = 0 where se.f_flag = 0
and se.f_sgrp = 1677273357 and se.f_sgrp = 1677273357
and rd.f_name = '61' and pr.f_name = '61'
and pd.f_name = '5012' and pd.f_name = '5012'
and jd.f_name = 'CDE5' and jd.f_name = 'CDE5'
and pl.f_name = '575908' and pl.f_name = '575908'
and dateadd(HH, -7, (dateadd(SS, convert(bigint, se.f_sgtm), '19700101'))) = '2023-02-24 15:15:00' and dateadd(HH, -7, (dateadd(SS, convert(bigint, se.f_sgtm), '19700101'))) = '2023-02-24 15:15:00'
) as iq
order by iq.ev_count desc, iq.cl_count desc, iq.sl_count desc, iq.se_sgrp, iq.se_tsno, iq.td_test
for json path for json path

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,19 @@
{ {
"Results": [ "Results": [
{ {
"EventCount": 0,
"ControlLimitCount": 0,
"SpecLimitCount": 0,
"SubGroupId": 1677273357, "SubGroupId": 1677273357,
"SubGroupDateTime": 1677273300, "SubGroupDateTime": 1677273300,
"SiteNumber": 1, "SiteNumber": 1,
"VariableNumber": 1650647347,
"Process": "61", "Process": "61",
"Job": "CDE5", "Job": "CDE5",
"Lot": "575908", "Lot": "575908",
"Part": "5012", "Part": "5012",
"VariableNumber": 1650647347,
"Variable": "T", "Variable": "T",
"Value": 270, "Value": 270
"EventCount": 0
} }
], ],
"TotalRows": 1 "TotalRows": 1

View File

@ -0,0 +1,78 @@
select case when iq.sl_loos is null then 0 else iq.sl_loos end +
case when iq.sl_uoos is null then 0 else iq.sl_uoos end +
iq.ev_count as iq_sum,
iq.sl_aflag,
iq.sl_loos,
iq.sl_uoos,
iq.se_sgrp,
iq.se_sgtm,
iq.se_tsno,
iq.td_test,
iq.pr_name,
iq.jd_name,
iq.pl_name,
iq.pd_name,
iq.td_name,
iq.se_val,
iq.sl_eflag,
iq.sl_scal,
iq.sl_sls,
iq.sl_usl
from (
select
se.f_sgrp se_sgrp,
se.f_sgtm se_sgtm,
se.f_tsno se_tsno,
se.f_val se_val,
pr.f_name pr_name,
jd.f_name jd_name,
pl.f_name pl_name,
pd.f_name pd_name,
td.f_test td_test,
td.f_name td_name,
sl.f_eflag sl_eflag,
sl.f_aflag sl_aflag,
sl.f_scal sl_scal,
sl.f_lsl sl_sls,
sl.f_usl sl_usl,
case when sl.f_aflag is null or sl.f_aflag = 0 then null else
case when round(se.f_val, sl.F_scal, 1) < sl.f_lsl then 1 else 0 end
end as sl_loos,
case when sl.f_aflag is null or sl.f_aflag = 0 then null else
case when round(se.f_val, sl.F_scal, 1) > sl.f_usl then 1 else 0 end
end as sl_uoos,
(select count(ev.f_evnt)
from [spcepiworld].[dbo].[evnt_inf] ev
where ev.f_prcs = pr.f_prcs
and ev.f_part = pd.f_part
and ev.f_sgtm = se.f_sgtm
) ev_count
from [spcepiworld].[dbo].[sgrp_ext] se
join [spcepiworld].[dbo].[prcs_dat] pr
on se.f_prcs = pr.f_prcs
join [spcepiworld].[dbo].[job_dat] jd
on se.f_job = jd.f_job
join [spcepiworld].[dbo].[part_lot] pl
on se.f_lot = pl.f_lot
join [spcepiworld].[dbo].[part_dat] pd
on se.f_part = pd.f_part
join [spcepiworld].[dbo].[test_dat] td
on se.f_test = td.f_test
left join [spcepiworld].[dbo].[spec_lim] sl
on se.f_part = sl.f_part
and se.f_test = sl.f_test
where se.f_flag = 0
and (sl.f_prcs is null or se.f_prcs = sl.f_prcs or sl.f_prcs = 0)
and se.f_sgrp = 1698497987
and pr.f_name = '61'
and pd.f_name = '5012'
and jd.f_name = 'CDE5'
and pl.f_name = '575908'
and dateadd(HH, -7, (dateadd(SS, convert(bigint, se.f_sgtm), '19700101'))) = '2023-02-24 15:15:00'
) as iq
order by iq.sl_loos + iq.sl_uoos + iq.ev_count desc,
iq.sl_aflag desc,
iq.se_sgrp,
iq.se_tsno,
iq.td_test
for json path

File diff suppressed because it is too large Load Diff

View File

@ -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
}

View File

@ -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
}

View File

@ -0,0 +1 @@
[{"ProcessMean":1.750000000000000e+001,"ProcessSigma":5.800000000000000e+000}]

View File

@ -0,0 +1 @@
[{"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"}]

View File

@ -1,23 +1 @@
{ {"Results":[{"InsertDate":null,"Run Header":null,"Title":null,"AttachmentID":null,"Position":"Average","Thickness":"NaN","ID":-1},{"InsertDate":null,"Run Header":null,"Title":null,"AttachmentID":null,"Position":"Std Dev","Thickness":"NaN","ID":-2}],"TotalRows":2}
"Results": [
{
"InsertDate": null,
"Run Header": null,
"Title": null,
"AttachmentID": null,
"Position": "Average",
"Thickness": "NaN",
"ID": -1
},
{
"InsertDate": null,
"Run Header": null,
"Title": null,
"AttachmentID": null,
"Position": "Std Dev",
"Thickness": "NaN",
"ID": -2
}
],
"TotalRows": 2
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@
"DataTableName": "BioRadRunData", "DataTableName": "BioRadRunData",
"ExportSPName": "Export_BioRad", "ExportSPName": "Export_BioRad",
"HeaderGridAttributes": null, "HeaderGridAttributes": null,
"DataGridAttributes": null, "DataGridAttributes": "{ \u0022pinButton\u0022: true }",
"DataGridSortBy": "LEN(Position), Position", "DataGridSortBy": "LEN(Position), Position",
"DataGridStatsColumn": "Thickness", "DataGridStatsColumn": "Thickness",
"DataGridStatsStdDevType": " ", "DataGridStatsStdDevType": " ",
@ -224,7 +224,7 @@
"ApiName": "SentToMetrology", "ApiName": "SentToMetrology",
"ColumnName": "SentToMetrology", "ColumnName": "SentToMetrology",
"DisplayTitle": "SentToOI", "DisplayTitle": "SentToOI",
"GridDisplayOrder": 9, "GridDisplayOrder": 10,
"GridAttributes": "{ \u0022dataType:\u0022: \u0022bool\u0022, \u0022formatter\u0022: \u0022boolToYesNo\u0022 }", "GridAttributes": "{ \u0022dataType:\u0022: \u0022bool\u0022, \u0022formatter\u0022: \u0022boolToYesNo\u0022 }",
"TableDisplayOrder": 14 "TableDisplayOrder": 14
}, },
@ -274,7 +274,7 @@
"ApiName": "Wafer", "ApiName": "Wafer",
"ColumnName": "Wafer", "ColumnName": "Wafer",
"DisplayTitle": "Wafer", "DisplayTitle": "Wafer",
"GridDisplayOrder": 0, "GridDisplayOrder": 9,
"GridAttributes": null, "GridAttributes": null,
"TableDisplayOrder": 9 "TableDisplayOrder": 9
}, },

View File

@ -23,7 +23,11 @@
{ {
"ToolTypeName": "TencorSP1", "ToolTypeName": "TencorSP1",
"ID": 6 "ID": 6
},
{
"ToolTypeName": "SRP",
"ID": 7
} }
], ],
"TotalRows": 6 "TotalRows": 7
} }

View File

@ -1,280 +1,357 @@
{ {
"Results": [ "Results": [
{ {
"RunDataSheet": "586337", "RunDataSheet": "586820",
"Reactor": 54, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 1,
"Pocket": "1", "Pocket": "1",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 40,
"InSlotNumber": 24,
"OutCassetteNumber": 36,
"OutSlotNumber": 21,
"PSN": "4445"
}, },
{ {
"RunDataSheet": "586337", "RunDataSheet": "586820",
"Reactor": 54, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 2,
"Pocket": "2", "Pocket": "2",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 40,
"InSlotNumber": 25,
"OutCassetteNumber": 36,
"OutSlotNumber": 22,
"PSN": "4445"
}, },
{ {
"RunDataSheet": "586337", "RunDataSheet": "586820",
"Reactor": 54, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 3,
"Pocket": "3", "Pocket": "3",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 1,
"OutCassetteNumber": 36,
"OutSlotNumber": 23,
"PSN": "4445"
}, },
{ {
"RunDataSheet": "586337", "RunDataSheet": "586820",
"Reactor": 54, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 4,
"Pocket": "4", "Pocket": "4",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 2,
"OutCassetteNumber": 36,
"OutSlotNumber": 24,
"PSN": "4445"
}, },
{ {
"RunDataSheet": "586337", "RunDataSheet": "586820",
"Reactor": 54, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 5,
"Pocket": "5", "Pocket": "5",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 3,
"OutCassetteNumber": 36,
"OutSlotNumber": 25,
"PSN": "4445"
}, },
{ {
"RunDataSheet": "586337", "RunDataSheet": "586820",
"Reactor": 54, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 6,
"Pocket": "6", "Pocket": "6",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 4,
"OutCassetteNumber": 37,
"OutSlotNumber": 1,
"PSN": "4445"
}, },
{ {
"RunDataSheet": "586337", "RunDataSheet": "586820",
"Reactor": 54, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 7,
"Pocket": "7", "Pocket": "7",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 5,
"OutCassetteNumber": 37,
"OutSlotNumber": 2,
"PSN": "4445"
}, },
{ {
"RunDataSheet": "586337", "RunDataSheet": "586820",
"Reactor": 54, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 8,
"Pocket": "8", "Pocket": "8",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 6,
"OutCassetteNumber": 37,
"OutSlotNumber": 3,
"PSN": "4445"
}, },
{ {
"RunDataSheet": "586345", "RunDataSheet": "586821",
"Reactor": 52, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 9,
"Pocket": "1", "Pocket": "1",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 7,
"OutCassetteNumber": -1,
"OutSlotNumber": -1,
"PSN": "4445"
}, },
{ {
"RunDataSheet": "586345", "RunDataSheet": "586821",
"Reactor": 52, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 10,
"Pocket": "2", "Pocket": "2",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 8,
"OutCassetteNumber": 37,
"OutSlotNumber": 4,
"PSN": "4445"
}, },
{ {
"RunDataSheet": "586345", "RunDataSheet": "586821",
"Reactor": 52, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 11,
"Pocket": "3", "Pocket": "3",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 9,
"OutCassetteNumber": 37,
"OutSlotNumber": 5,
"PSN": "4445"
}, },
{ {
"RunDataSheet": "586345", "RunDataSheet": "586821",
"Reactor": 52, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 12,
"Pocket": "4", "Pocket": "4",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 10,
"OutCassetteNumber": 37,
"OutSlotNumber": 6,
"PSN": "4445"
}, },
{ {
"RunDataSheet": "586345", "RunDataSheet": "586821",
"Reactor": 52, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 13,
"Pocket": "5", "Pocket": "5",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 11,
"OutCassetteNumber": 37,
"OutSlotNumber": 7,
"PSN": "4445"
}, },
{ {
"RunDataSheet": "586345", "RunDataSheet": "586821",
"Reactor": 52, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 14,
"Pocket": "6", "Pocket": "6",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 12,
"OutCassetteNumber": 37,
"OutSlotNumber": 8,
"PSN": "4445"
}, },
{ {
"RunDataSheet": "586345", "RunDataSheet": "586821",
"Reactor": 52, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 15,
"Pocket": "7", "Pocket": "7",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 13,
"OutCassetteNumber": 37,
"OutSlotNumber": 9,
"PSN": "4445"
}, },
{ {
"RunDataSheet": "586345", "RunDataSheet": "586821",
"Reactor": 52, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 16,
"Pocket": "8", "Pocket": "8",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 14,
"OutCassetteNumber": 37,
"OutSlotNumber": 10,
"PSN": "4445"
}, },
{ {
"RunDataSheet": "586347", "RunDataSheet": "586822",
"Reactor": 54, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 17,
"Pocket": "1", "Pocket": "1",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 15,
"OutCassetteNumber": 37,
"OutSlotNumber": 11,
"PSN": "4445"
}, },
{ {
"RunDataSheet": "586347", "RunDataSheet": "586822",
"Reactor": 54, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 18,
"Pocket": "2", "Pocket": "2",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 16,
"OutCassetteNumber": 37,
"OutSlotNumber": 12,
"PSN": "4445"
}, },
{ {
"RunDataSheet": "586347", "RunDataSheet": "586822",
"Reactor": 54, "Reactor": 52,
"PSN": "4445", "Pocket": "3",
"RecipeName": "Phosphorus", "Zone": "1",
"RecipeNumber": 743, "InCassetteNumber": 41,
"SpecType": "Production", "InSlotNumber": 17,
"SlotNumber": 19, "OutCassetteNumber": 37,
"Pocket": "3", "OutSlotNumber": 13,
"Zone": "1" "PSN": "4445"
}, },
{ {
"RunDataSheet": "586347", "RunDataSheet": "586822",
"Reactor": 54, "Reactor": 52,
"PSN": "4445", "Pocket": "4",
"RecipeName": "Phosphorus", "Zone": "1",
"RecipeNumber": 743, "InCassetteNumber": 41,
"SpecType": "Production", "InSlotNumber": 18,
"SlotNumber": 20, "OutCassetteNumber": 37,
"Pocket": "4", "OutSlotNumber": 14,
"Zone": "1" "PSN": "4445"
}, },
{ {
"RunDataSheet": "586347", "RunDataSheet": "586822",
"Reactor": 54, "Reactor": 52,
"PSN": "4445", "Pocket": "5",
"RecipeName": "Phosphorus", "Zone": "1",
"RecipeNumber": 743, "InCassetteNumber": 41,
"SpecType": "Production", "InSlotNumber": 19,
"SlotNumber": 21, "OutCassetteNumber": 37,
"Pocket": "5", "OutSlotNumber": 15,
"Zone": "1" "PSN": "4445"
}, },
{ {
"RunDataSheet": "586347", "RunDataSheet": "586822",
"Reactor": 54, "Reactor": 52,
"PSN": "4445", "Pocket": "6",
"RecipeName": "Phosphorus", "Zone": "1",
"RecipeNumber": 743, "InCassetteNumber": 41,
"SpecType": "Production", "InSlotNumber": 20,
"SlotNumber": 22, "OutCassetteNumber": 37,
"Pocket": "6", "OutSlotNumber": 16,
"Zone": "1" "PSN": "4445"
}, },
{ {
"RunDataSheet": "586347", "RunDataSheet": "586822",
"Reactor": 54, "Reactor": 52,
"PSN": "4445", "Pocket": "7",
"RecipeName": "Phosphorus", "Zone": "1",
"RecipeNumber": 743, "InCassetteNumber": 41,
"SpecType": "Production", "InSlotNumber": 21,
"SlotNumber": 23, "OutCassetteNumber": 37,
"Pocket": "7", "OutSlotNumber": 17,
"Zone": "1" "PSN": "4445"
}, },
{ {
"RunDataSheet": "586347", "RunDataSheet": "586822",
"Reactor": 54, "Reactor": 52,
"PSN": "4445", "Pocket": "8",
"RecipeName": "Phosphorus", "Zone": "1",
"RecipeNumber": 743, "InCassetteNumber": 41,
"SpecType": "Production", "InSlotNumber": 22,
"SlotNumber": 24, "OutCassetteNumber": 37,
"Pocket": "8", "OutSlotNumber": 18,
"Zone": "1" "PSN": "4445"
}, },
{ {
"RunDataSheet": "586381", "RunDataSheet": "586827",
"Reactor": 52, "Reactor": 52,
"PSN": "4445",
"RecipeName": "Phosphorus",
"RecipeNumber": 743,
"SpecType": "Production",
"SlotNumber": 25,
"Pocket": "1", "Pocket": "1",
"Zone": "1" "Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 23,
"OutCassetteNumber": -1,
"OutSlotNumber": -1,
"PSN": "4445"
},
{
"RunDataSheet": "586827",
"Reactor": 52,
"Pocket": "2",
"Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 24,
"OutCassetteNumber": 37,
"OutSlotNumber": 19,
"PSN": "4445"
},
{
"RunDataSheet": "586827",
"Reactor": 52,
"Pocket": "3",
"Zone": "1",
"InCassetteNumber": 41,
"InSlotNumber": 25,
"OutCassetteNumber": 37,
"OutSlotNumber": 20,
"PSN": "4445"
},
{
"RunDataSheet": "586827",
"Reactor": 52,
"Pocket": "4",
"Zone": "1",
"InCassetteNumber": 42,
"InSlotNumber": 1,
"OutCassetteNumber": 37,
"OutSlotNumber": 21,
"PSN": "4445"
},
{
"RunDataSheet": "586827",
"Reactor": 52,
"Pocket": "5",
"Zone": "1",
"InCassetteNumber": 42,
"InSlotNumber": 2,
"OutCassetteNumber": 37,
"OutSlotNumber": 22,
"PSN": "4445"
},
{
"RunDataSheet": "586827",
"Reactor": 52,
"Pocket": "6",
"Zone": "1",
"InCassetteNumber": 42,
"InSlotNumber": 3,
"OutCassetteNumber": -1,
"OutSlotNumber": -1,
"PSN": "4445"
},
{
"RunDataSheet": "586827",
"Reactor": 52,
"Pocket": "7",
"Zone": "1",
"InCassetteNumber": 42,
"InSlotNumber": 4,
"OutCassetteNumber": 37,
"OutSlotNumber": 24,
"PSN": "4445"
},
{
"RunDataSheet": "586827",
"Reactor": 52,
"Pocket": "8",
"Zone": "1",
"InCassetteNumber": 42,
"InSlotNumber": 5,
"OutCassetteNumber": 37,
"OutSlotNumber": 25,
"PSN": "4445"
} }
], ],
"TotalRows": 25 "TotalRows": 32
} }

View File

@ -0,0 +1,2 @@
[*.cs]
csharp_preserve_single_line_statements = true

View File

@ -1,35 +1,31 @@
using System.ComponentModel.DataAnnotations;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization;
namespace OI.Metrology.Server.Models.Binder; namespace OI.Metrology.Server.Models.Binder;
public class AppSettings public class AppSettings
{ {
#nullable disable public string? ApiExportPath { get; set; }
public string? ApiLoggingContentTypes { get; set; }
[Display(Name = "Api Export Path"), Required] public string ApiExportPath { get; set; } public string? ApiLoggingPathPrefixes { get; set; }
[Display(Name = "Api Logging Content Types"), Required] public string ApiLoggingContentTypes { get; set; } public string? ApiLogPath { get; set; }
[Display(Name = "Api Logging Path Prefixes"), Required] public string ApiLoggingPathPrefixes { get; set; } public string? ApiUrl { get; set; }
[Display(Name = "Api Log Path"), Required] public string ApiLogPath { get; set; } public string? AttachmentPath { get; set; }
[Display(Name = "Api URL"), Required] public string ApiUrl { get; set; } public string? BuildNumber { get; set; }
[Display(Name = "Attachment Path"), Required] public string AttachmentPath { get; set; } public string? Company { get; set; }
[Display(Name = "Build Number"), Required] public string BuildNumber { get; set; } public string? ConnectionString { get; set; }
[Display(Name = "Company"), Required] public string Company { get; set; } public string? GitCommitSeven { get; set; }
[Display(Name = "Connection String"), Required] public string ConnectionString { get; set; } public string? InboundApiAllowedIPList { get; set; }
[Display(Name = "Git Commit Seven"), Required] public string GitCommitSeven { get; set; } public bool? IsDevelopment { get; set; }
[Display(Name = "Inbound Api Allowed IP List"), Required] public string InboundApiAllowedIPList { get; set; } public bool? IsStaging { get; set; }
[Display(Name = "Is Development"), Required] public bool? IsDevelopment { get; set; } public string? MockRoot { get; set; }
[Display(Name = "Is Staging"), Required] public bool? IsStaging { get; set; } public string? MonAResource { get; set; }
[Display(Name = "Mock Root"), Required] public string MockRoot { get; set; } public string? MonASite { get; set; }
[Display(Name = "MonA Resource"), Required] public string MonAResource { get; set; } public string? Oi2SqlConnectionString { get; set; }
[Display(Name = "MonA Site"), Required] public string MonASite { get; set; } public Dictionary<string, string>? TableToPath { get; set; }
[Display(Name = "Oi 2 Sql Connection String"), Required] public string Oi2SqlConnectionString { get; set; } public string? URLs { get; set; }
[Display(Name = "Table to Path"), Required] public Dictionary<string, string> TableToPath { get; set; } public string? WorkingDirectoryName { 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 override string ToString() public override string ToString()
{ {
@ -40,48 +36,27 @@ public class AppSettings
private static Models.AppSettings Get(AppSettings? appSettings) private static Models.AppSettings Get(AppSettings? appSettings)
{ {
Models.AppSettings result; Models.AppSettings result;
if (appSettings is null) if (appSettings is null) throw new NullReferenceException(nameof(appSettings));
throw new NullReferenceException(nameof(appSettings)); if (appSettings.ApiExportPath is null) throw new NullReferenceException(nameof(ApiExportPath));
if (appSettings.ApiExportPath is null) if (appSettings.ApiLoggingContentTypes is null) throw new NullReferenceException(nameof(ApiLoggingContentTypes));
throw new NullReferenceException(nameof(ApiExportPath)); if (appSettings.ApiLoggingPathPrefixes is null) throw new NullReferenceException(nameof(ApiLoggingPathPrefixes));
if (appSettings.ApiLoggingContentTypes is null) if (appSettings.ApiLogPath is null) throw new NullReferenceException(nameof(ApiLogPath));
throw new NullReferenceException(nameof(ApiLoggingContentTypes)); if (appSettings.ApiUrl is null) throw new NullReferenceException(nameof(ApiUrl));
if (appSettings.ApiLoggingPathPrefixes is null) if (appSettings.AttachmentPath is null) throw new NullReferenceException(nameof(AttachmentPath));
throw new NullReferenceException(nameof(ApiLoggingPathPrefixes)); if (appSettings.BuildNumber is null) throw new NullReferenceException(nameof(BuildNumber));
if (appSettings.ApiLogPath is null) if (appSettings.Company is null) throw new NullReferenceException(nameof(Company));
throw new NullReferenceException(nameof(ApiLogPath)); if (appSettings.ConnectionString is null) throw new NullReferenceException(nameof(ConnectionString));
if (appSettings.ApiUrl is null) if (appSettings.GitCommitSeven is null) throw new NullReferenceException(nameof(GitCommitSeven));
throw new NullReferenceException(nameof(ApiUrl)); if (appSettings.InboundApiAllowedIPList is null) throw new NullReferenceException(nameof(InboundApiAllowedIPList));
if (appSettings.AttachmentPath is null) if (appSettings.IsDevelopment is null) throw new NullReferenceException(nameof(IsDevelopment));
throw new NullReferenceException(nameof(AttachmentPath)); if (appSettings.IsStaging is null) throw new NullReferenceException(nameof(IsStaging));
if (appSettings.BuildNumber is null) if (appSettings.MockRoot is null) throw new NullReferenceException(nameof(MockRoot));
throw new NullReferenceException(nameof(BuildNumber)); if (appSettings.MonAResource is null) throw new NullReferenceException(nameof(MonAResource));
if (appSettings.Company is null) if (appSettings.MonASite is null) throw new NullReferenceException(nameof(MonASite));
throw new NullReferenceException(nameof(Company)); if (appSettings.Oi2SqlConnectionString is null) throw new NullReferenceException(nameof(Oi2SqlConnectionString));
if (appSettings.ConnectionString is null) if (appSettings.URLs is null) throw new NullReferenceException(nameof(URLs));
throw new NullReferenceException(nameof(ConnectionString)); if (appSettings.TableToPath is null) throw new NullReferenceException(nameof(TableToPath));
if (appSettings.GitCommitSeven is null) if (appSettings.WorkingDirectoryName is null) throw new NullReferenceException(nameof(WorkingDirectoryName));
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( result = new(
appSettings.ApiExportPath, appSettings.ApiExportPath,
appSettings.ApiLoggingContentTypes, appSettings.ApiLoggingContentTypes,
@ -109,9 +84,31 @@ public class AppSettings
public static Models.AppSettings Get(IConfigurationRoot configurationRoot) public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
{ {
Models.AppSettings result; Models.AppSettings result;
#pragma warning disable IL3050, IL2026
AppSettings? appSettings = configurationRoot.Get<AppSettings>(); AppSettings? appSettings = configurationRoot.Get<AppSettings>();
#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); result = Get(appSettings);
return result; return result;
} }
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(AppSettings))]
internal partial class BinderAppSettingsSourceGenerationContext : JsonSerializerContext
{
} }

View File

@ -24,22 +24,19 @@
<Content Remove="compilerconfig.json" /> <Content Remove="compilerconfig.json" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Dapper" Version="2.0.143" /> <PackageReference Include="Dapper" Version="2.1.4" />
<PackageReference Include="EntityFramework" Version="6.4.4" /> <PackageReference Include="EntityFramework" Version="6.4.4" />
<PackageReference Include="jQuery" Version="3.7.0" /> <PackageReference Include="jQuery" Version="3.7.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="7.0.9" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="7.0.13" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.1" /> <PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00032" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" /> <PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" /> <PackageReference Include="System.Drawing.Common" Version="7.0.0" />
@ -56,12 +53,6 @@
<None Include="compilerconfig.json" /> <None Include="compilerconfig.json" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="appsettings.Development.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Mike\service-shop.json"> <None Include="Data\Mike\service-shop.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
@ -92,18 +83,6 @@
<None Include="Data\Tests\InfinityQS-GetCommandText.sql"> <None Include="Data\Tests\InfinityQS-GetCommandText.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Include="Data\Tests\InfinityQS-GetData.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Tests\InfinityQS-GetDescriptors.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Tests\InfinityQS-GetEvents.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Tests\InfinityQS-GetHeader.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Tests\InfinityQSV2-GetCommandText.sql"> <None Include="Data\Tests\InfinityQSV2-GetCommandText.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
@ -119,6 +98,21 @@
<None Include="Data\Tests\InfinityQSV2-GetHeader.json"> <None Include="Data\Tests\InfinityQSV2-GetHeader.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Include="Data\Tests\InfinityQSV3-GetData.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Tests\InfinityQSV3-GetDescriptors.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Tests\InfinityQSV3-GetHeader.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Tests\InfinityQSV3-GetProductDataAverageSumOfDefectsProcessMeanProcessSigma.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Tests\OpenInsightV1-GetTencorRun.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\Tests\Pin-GetPinnedTable.json"> <None Include="Data\Tests\Pin-GetPinnedTable.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
@ -134,10 +128,10 @@
<None Include="Data\Tests\ToolTypes-GetHeaderFields.json"> <None Include="Data\Tests\ToolTypes-GetHeaderFields.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Include="Data\Tests\ToolTypes-GetHeaderTitles.json"> <None Include="Data\Tests\ToolTypes-GetHeaders.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Include="Data\Tests\ToolTypes-GetHeaders.json"> <None Include="Data\Tests\ToolTypes-GetHeaderTitles.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Include="Data\Tests\ToolTypes-GetToolTypeMetadata.json"> <None Include="Data\Tests\ToolTypes-GetToolTypeMetadata.json">

View File

@ -8,7 +8,6 @@ using OI.Metrology.Shared.Models;
using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.Models.Stateless;
using OI.Metrology.Shared.Repositories; using OI.Metrology.Shared.Repositories;
using OI.Metrology.Shared.Services; using OI.Metrology.Shared.Services;
using Serilog;
using System.Reflection; using System.Reflection;
namespace OI.Metrology.Server; namespace OI.Metrology.Server;
@ -41,19 +40,17 @@ public class Program
public static int Main(string[] args) public static int Main(string[] args)
{ {
LoggerConfiguration loggerConfiguration = new(); ILogger<Program>? logger = null;
(string assemblyName, WebApplicationOptions _) = Get(args); (string assemblyName, WebApplicationOptions _) = Get(args);
WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder(args); WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder(args);
_ = webApplicationBuilder.Configuration.AddUserSecrets<Program>(); _ = webApplicationBuilder.Configuration.AddUserSecrets<Program>();
AppSettings appSettings = Models.Binder.AppSettings.Get(webApplicationBuilder.Configuration); 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)) if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
throw new Exception("Working directory name must have a value!"); throw new Exception("Working directory name must have a value!");
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assemblyName, appSettings.WorkingDirectoryName); string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assemblyName, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory); Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, webApplicationBuilder.Configuration);
_ = SerilogHostBuilderExtensions.UseSerilog(webApplicationBuilder.Host);
Log.Logger = loggerConfiguration.CreateLogger();
Serilog.ILogger log = Log.ForContext<Program>();
try try
{ {
_ = webApplicationBuilder.Services.AddMemoryCache(); _ = webApplicationBuilder.Services.AddMemoryCache();
@ -77,12 +74,14 @@ public class Program
_ = webApplicationBuilder.Services.AddSingleton<IAppSettingsRepository<Models.Binder.AppSettings>>(_ => appSettingsRepository); _ = webApplicationBuilder.Services.AddSingleton<IAppSettingsRepository<Models.Binder.AppSettings>>(_ => appSettingsRepository);
_ = webApplicationBuilder.Services.AddSingleton<IInfinityQSRepository, InfinityQSRepository>(_ => new(appSettings.MockRoot, sqlDbConnectionFactory)); _ = webApplicationBuilder.Services.AddSingleton<IInfinityQSRepository, InfinityQSRepository>(_ => new(appSettings.MockRoot, sqlDbConnectionFactory));
_ = webApplicationBuilder.Services.AddSingleton<IInfinityQSV2Repository, InfinityQSV2Repository>(_ => new(appSettings.MockRoot, sqlDbConnectionFactory)); _ = webApplicationBuilder.Services.AddSingleton<IInfinityQSV2Repository, InfinityQSV2Repository>(_ => new(appSettings.MockRoot, sqlDbConnectionFactory));
_ = webApplicationBuilder.Services.AddSingleton<IInfinityQSV3Repository, InfinityQSV3Repository>(_ => new(appSettings.MockRoot, sqlDbConnectionFactory));
_ = webApplicationBuilder.Services.AddSingleton<IWorkMaterialRepository, WorkMaterialRepository>(_ => new(appSettings.MockRoot, sqlDbConnectionFactory)); _ = webApplicationBuilder.Services.AddSingleton<IWorkMaterialRepository, WorkMaterialRepository>(_ => new(appSettings.MockRoot, sqlDbConnectionFactory));
_ = webApplicationBuilder.Services.AddScoped<IExportRepository, ExportRepository>(); _ = webApplicationBuilder.Services.AddScoped<IExportRepository, ExportRepository>();
_ = webApplicationBuilder.Services.AddScoped<IAttachmentsService, AttachmentsService>(); _ = webApplicationBuilder.Services.AddScoped<IAttachmentsService, AttachmentsService>();
_ = webApplicationBuilder.Services.AddScoped<IInboundDataService, InboundDataService>(); _ = webApplicationBuilder.Services.AddScoped<IInboundDataService, InboundDataService>();
_ = webApplicationBuilder.Services.AddScoped<IMetrologyRepository, MetrologyRepository>(); _ = webApplicationBuilder.Services.AddScoped<IMetrologyRepository, MetrologyRepository>();
_ = webApplicationBuilder.Services.AddScoped<IOpenInsightV1Repository, OpenInsightV1Repository>();
_ = webApplicationBuilder.Services.AddSwaggerGen(); _ = webApplicationBuilder.Services.AddSwaggerGen();
_ = webApplicationBuilder.Services.AddSession(sessionOptions => _ = webApplicationBuilder.Services.AddSession(sessionOptions =>
@ -104,6 +103,7 @@ public class Program
}); });
} }
WebApplication webApplication = webApplicationBuilder.Build(); WebApplication webApplication = webApplicationBuilder.Build();
logger = webApplication.Services.GetRequiredService<ILogger<Program>>();
_ = webApplication.UseCors(corsPolicyBuilder => corsPolicyBuilder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()); _ = webApplication.UseCors(corsPolicyBuilder => corsPolicyBuilder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
if (!webApplicationBuilder.Environment.IsDevelopment()) if (!webApplicationBuilder.Environment.IsDevelopment())
{ {
@ -121,26 +121,21 @@ public class Program
_ = webApplication.UseSwagger(); _ = webApplication.UseSwagger();
_ = webApplication.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Server V1")); _ = 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.UseFileServer(enableDirectoryBrowsing: true);
_ = webApplication.UseStaticFiles(); _ = webApplication.UseStaticFiles();
_ = webApplication.UseSession(); _ = webApplication.UseSession();
_ = webApplication.UseMiddleware<ApiLoggingMiddleware>(); _ = webApplication.UseMiddleware<ApiLoggingMiddleware>();
_ = webApplication.MapControllers(); _ = webApplication.MapControllers();
log.Information("Starting Web Application"); logger.LogInformation("Starting Web Application");
webApplication.Run(); webApplication.Run();
return 0; return 0;
} }
catch (Exception ex) catch (Exception ex)
{ {
log.Fatal(ex, "Host terminated unexpectedly"); try
return 1; { logger?.LogCritical(ex, "Host terminated unexpectedly"); }
} catch (Exception) { }
finally throw;
{
Log.CloseAndFlush();
} }
} }

View File

@ -31,8 +31,6 @@ public class AppSettingsRepository : IAppSettingsRepository<Models.Binder.AppSet
return result; return result;
} }
string IAppSettingsRepository<Models.Binder.AppSettings>.GetBuildNumberAndGitCommitSeven() => GetBuildNumberAndGitCommitSeven();
internal void VerifyConnectionStrings() internal void VerifyConnectionStrings()
{ {
if (string.IsNullOrEmpty(_AppSettings.ConnectionString)) if (string.IsNullOrEmpty(_AppSettings.ConnectionString))
@ -53,6 +51,8 @@ public class AppSettingsRepository : IAppSettingsRepository<Models.Binder.AppSet
#endif #endif
} }
string IAppSettingsRepository<Models.Binder.AppSettings>.GetBuildNumberAndGitCommitSeven() => GetBuildNumberAndGitCommitSeven();
void IAppSettingsRepository<Models.Binder.AppSettings>.VerifyConnectionStrings() => VerifyConnectionStrings(); void IAppSettingsRepository<Models.Binder.AppSettings>.VerifyConnectionStrings() => VerifyConnectionStrings();
} }

View File

@ -23,14 +23,14 @@ public class ClientSettingsRepository : IClientSettingsRepository
return results; return results;
} }
List<string> IClientSettingsRepository.GetClientSettings(IPAddress? remoteIpAddress) => GetClientSettings(remoteIpAddress);
internal static string GetIpAddress(IPAddress? remoteIpAddress) internal static string GetIpAddress(IPAddress? remoteIpAddress)
{ {
string result = remoteIpAddress is null ? string.Empty : remoteIpAddress.ToString(); string result = remoteIpAddress is null ? string.Empty : remoteIpAddress.ToString();
return result; return result;
} }
List<string> IClientSettingsRepository.GetClientSettings(IPAddress? remoteIpAddress) => GetClientSettings(remoteIpAddress);
string IClientSettingsRepository.GetIpAddress(IPAddress? remoteIpAddress) => GetIpAddress(remoteIpAddress); string IClientSettingsRepository.GetIpAddress(IPAddress? remoteIpAddress) => GetIpAddress(remoteIpAddress);
} }

View File

@ -9,17 +9,17 @@ namespace OI.Metrology.Server.Repository;
public class ExportRepository : IExportRepository public class ExportRepository : IExportRepository
{ {
private readonly Serilog.ILogger _Log;
private readonly string _RepositoryName; private readonly string _RepositoryName;
private readonly AppSettings _AppSettings; private readonly AppSettings _AppSettings;
private readonly ILogger<ExportRepository> _Logger;
private readonly Dictionary<string, Dictionary<long, HeaderCommon>> _RdsToHeaderCommonCollection; private readonly Dictionary<string, Dictionary<long, HeaderCommon>> _RdsToHeaderCommonCollection;
public ExportRepository(AppSettings appSettings) public ExportRepository(ILogger<ExportRepository> logger, AppSettings appSettings)
{ {
_Logger = logger;
_AppSettings = appSettings; _AppSettings = appSettings;
_RdsToHeaderCommonCollection = new(); _RdsToHeaderCommonCollection = new();
_RepositoryName = nameof(ExportRepository)[..^10]; _RepositoryName = nameof(ExportRepository)[..^10];
_Log = Serilog.Log.ForContext<ExportRepository>();
} }
private static string[] Get() private static string[] Get()
@ -93,7 +93,7 @@ public class ExportRepository : IExportRepository
if (jsonElement is not null && jsonElement.Value.ValueKind == JsonValueKind.Object) if (jsonElement is not null && jsonElement.Value.ValueKind == JsonValueKind.Object)
{ {
jsonProperties = (from l in jsonElement.Value.EnumerateObject() where l.Name == ticks select l).ToArray(); 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); hc.Date = new(ticksValue);
} }
results.Add(hc); results.Add(hc);

View File

@ -65,7 +65,7 @@ public class InboundRepository : IInboundRepository
else else
{ {
inboundDataService.ValidateJSONFields(jToken, 0, metaData, result.Errors, result.Warnings); inboundDataService.ValidateJSONFields(jToken, 0, metaData, result.Errors, result.Warnings);
if (!result.Errors.Any()) if (result.Errors.Count == 0)
{ {
try try
{ {

View File

@ -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<InfinityQSV3>() : 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<InfinityQSV3[]> IInfinityQSV3Repository.GetData(string subGroupId)
{
Result<InfinityQSV3[]>? 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<InfinityQSV3>() : 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<InfinityQSDescriptorV3[]> IInfinityQSV3Repository.GetDescriptors(string subGroupId)
{
Result<InfinityQSDescriptorV3[]>? 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<InfinityQSDescriptorV3>() : 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<InfinityQSV3[]> IInfinityQSV3Repository.GetHeader(string subGroupId)
{
Result<InfinityQSV3[]>? 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();
}
}

View File

@ -606,7 +606,7 @@ public class MetrologyRepository : IMetrologyRepository
IEnumerable<HeaderCommon> results; IEnumerable<HeaderCommon> results;
ToolType[] toolTypes = GetToolTypes().ToArray(); ToolType[] toolTypes = GetToolTypes().ToArray();
if (!toolTypes.Any() || toolTypes.FirstOrDefault() is null) if (toolTypes.Length == 0 || toolTypes.FirstOrDefault() is null)
throw new Exception("Invalid tool type ID"); throw new Exception("Invalid tool type ID");
ToolType tt; ToolType tt;

View File

@ -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();
}
}

View File

@ -8,7 +8,6 @@ public class PinRepository : IPinRepository
{ {
private readonly string _MockRoot; private readonly string _MockRoot;
private readonly Serilog.ILogger _Log;
private readonly string _RepositoryName; private readonly string _RepositoryName;
private readonly Dictionary<string, Dictionary<long, HeaderCommon>> _RdsToHeaderCommonCollection; private readonly Dictionary<string, Dictionary<long, HeaderCommon>> _RdsToHeaderCommonCollection;
@ -17,7 +16,6 @@ public class PinRepository : IPinRepository
_MockRoot = mockRoot; _MockRoot = mockRoot;
_RdsToHeaderCommonCollection = new(); _RdsToHeaderCommonCollection = new();
_RepositoryName = nameof(PinRepository)[..^10]; _RepositoryName = nameof(PinRepository)[..^10];
_Log = Serilog.Log.ForContext<PinRepository>();
} }
void IPinRepository.SetPinnedTable(HeaderCommon headerCommon) void IPinRepository.SetPinnedTable(HeaderCommon headerCommon)

View File

@ -1,6 +1,5 @@
using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.Models.Stateless;
using OI.Metrology.Shared.ViewModels; using OI.Metrology.Shared.ViewModels;
using Serilog.Context;
using System.Text.Json; using System.Text.Json;
namespace OI.Metrology.Server.Repository; namespace OI.Metrology.Server.Repository;
@ -8,9 +7,10 @@ namespace OI.Metrology.Server.Repository;
public class ServiceShopOrderRepository : IServiceShopOrderRepository public class ServiceShopOrderRepository : IServiceShopOrderRepository
{ {
private readonly Serilog.ILogger _Log; private readonly ILogger<ServiceShopOrderRepository> _Logger;
public ServiceShopOrderRepository() => _Log = Serilog.Log.ForContext<ServiceShopOrderRepository>(); public ServiceShopOrderRepository(ILogger<ServiceShopOrderRepository> logger) =>
_Logger = logger;
private static ServiceShopOrder[] GetServiceShopOrders(Shared.Models.ServiceShop? serviceShop) private static ServiceShopOrder[] GetServiceShopOrders(Shared.Models.ServiceShop? serviceShop)
{ {
@ -35,13 +35,8 @@ public class ServiceShopOrderRepository : IServiceShopOrderRepository
async Task<ServiceShopOrder[]> IServiceShopOrderRepository.GetAllServiceShopOrders() async Task<ServiceShopOrder[]> IServiceShopOrderRepository.GetAllServiceShopOrders()
{ {
ServiceShopOrder[] results; ServiceShopOrder[] results;
string? methodName = IMethodName.GetActualAsyncMethodName(); Shared.Models.ServiceShop? serviceShop = await Task.Run(GetServiceShopOrders);
using (LogContext.PushProperty("MethodName", methodName)) results = GetServiceShopOrders(serviceShop);
{
_Log.Debug("() => ...");
Shared.Models.ServiceShop? serviceShop = await Task.Run(GetServiceShopOrders);
results = GetServiceShopOrders(serviceShop);
}
return results.ToArray(); return results.ToArray();
} }

View File

@ -11,13 +11,11 @@ public class ToolTypesRepository : IToolTypesRepository
{ {
private readonly string _MockRoot; private readonly string _MockRoot;
private readonly Serilog.ILogger _Log;
private readonly string _RepositoryName; private readonly string _RepositoryName;
public ToolTypesRepository(string mockRoot) public ToolTypesRepository(string mockRoot)
{ {
_MockRoot = mockRoot; _MockRoot = mockRoot;
_Log = Serilog.Log.ForContext<ToolTypesRepository>();
_RepositoryName = nameof(ToolTypesRepository)[..^10]; _RepositoryName = nameof(ToolTypesRepository)[..^10];
} }
@ -257,32 +255,6 @@ public class ToolTypesRepository : IToolTypesRepository
return r; 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) protected static string FormatForCSV(string v)
{ {
StringBuilder result = new(v.Length + 2); StringBuilder result = new(v.Length + 2);
@ -306,6 +278,32 @@ public class ToolTypesRepository : IToolTypesRepository
return result.ToString(); 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[] IToolTypesRepository.GetCSVExport(IMetrologyRepository metrologyRepository, int toolTypeId, DateTime? datebegin, DateTime? dateend)
{ {
byte[] results; byte[] results;

View File

@ -63,18 +63,6 @@ public class WorkMaterialRepository : IWorkMaterialRepository
return result.ToString(); 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) private static (int?, int?, int?, bool) GetWorkOrder(string mid)
{ {
int? workOrderStep = null; 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); 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<WorkMaterialV2[]> IWorkMaterialRepository.GetCassette(string mid) Result<WorkMaterialV2[]> IWorkMaterialRepository.GetCassette(string mid)
{ {
Result<WorkMaterialV2[]>? result; Result<WorkMaterialV2[]>? result;
@ -132,7 +132,7 @@ public class WorkMaterialRepository : IWorkMaterialRepository
IWorkMaterialRepository workMaterialRepository = this; IWorkMaterialRepository workMaterialRepository = this;
string commandText = workMaterialRepository.GetCommandText(workOrderNumber, workOrderStep, workOrderCassette); string commandText = workMaterialRepository.GetCommandText(workOrderNumber, workOrderStep, workOrderCassette);
StringBuilder stringBuilder = GetForJsonPath(_DBConnectionFactory, commandText); StringBuilder stringBuilder = GetForJsonPath(_DBConnectionFactory, commandText);
JsonElement[]? jsonElements = JsonSerializer.Deserialize<JsonElement[]>(stringBuilder.ToString()); JsonElement[]? jsonElements = stringBuilder.Length == 0 ? Array.Empty<JsonElement>() : JsonSerializer.Deserialize<JsonElement[]>(stringBuilder.ToString());
if (jsonElements is null) if (jsonElements is null)
throw new NullReferenceException(nameof(jsonElements)); throw new NullReferenceException(nameof(jsonElements));
foreach (JsonElement jsonElement in jsonElements) foreach (JsonElement jsonElement in jsonElements)
@ -140,7 +140,7 @@ public class WorkMaterialRepository : IWorkMaterialRepository
if (jsonElement.ValueKind != JsonValueKind.Object) if (jsonElement.ValueKind != JsonValueKind.Object)
continue; continue;
jsonProperties = jsonElement.EnumerateObject().ToArray(); jsonProperties = jsonElement.EnumerateObject().ToArray();
if (!jsonProperties.Any()) if (jsonProperties.Length == 0)
continue; continue;
group = JsonSerializer.Deserialize<WorkMaterial[]>(jsonProperties.First().Value.ToString(), new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); group = JsonSerializer.Deserialize<WorkMaterial[]>(jsonProperties.First().Value.ToString(), new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
if (group is null) if (group is null)

View File

@ -143,10 +143,10 @@ public class AttachmentsService : IAttachmentsService
if (!Directory.Exists(checkDirectory)) if (!Directory.Exists(checkDirectory))
continue; continue;
files.AddRange(Directory.GetFiles(checkDirectory)); files.AddRange(Directory.GetFiles(checkDirectory));
if (files.Any()) if (files.Count != 0)
break; break;
} }
result = !files.Any() ? null : files.First(); result = files.Count == 0 ? null : files.First();
return result; return result;
} }

View File

@ -1,5 +1,6 @@
using Adaptation.FileHandlers.json; using Adaptation.FileHandlers.json;
using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.Models.Stateless;
using System.Collections.ObjectModel;
using System.Drawing; using System.Drawing;
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
@ -95,7 +96,7 @@ public class SpreadingResistanceProfileService : ISpreadingResistanceProfileServ
return rectangles.ToArray(); return rectangles.ToArray();
} }
private static string[] GetRectanglesDescriptions(Info info, Setup setup, List<Layer> layers) private static ReadOnlyCollection<string> GetRectanglesDescriptions(Info info, Setup setup, List<Layer> layers)
{ {
List<string> results = new() List<string> 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.Concat("First Pt. ", layer.FirstPoint, " Last Pt. ", layer.LastPoint, " Type ", layer.Type, " Smoothing ", layer.Smoothing, " Correction ", layer.Correction));
_ = stringBuilder.AppendLine(string.Join(" ", info.Comments)); _ = stringBuilder.AppendLine(string.Join(" ", info.Comments));
results[0] = stringBuilder.ToString(); results[0] = stringBuilder.ToString();
return results.ToArray(); return new(results);
} }
internal static byte[] GetImageBytes(CSV csv) internal static byte[] GetImageBytes(CSV csv)
@ -182,8 +183,8 @@ public class SpreadingResistanceProfileService : ISpreadingResistanceProfileServ
graphics.FillRectangles(Brushes.White, rectangles); graphics.FillRectangles(Brushes.White, rectangles);
graphics.DrawRectangles(pen, rectangles); graphics.DrawRectangles(pen, rectangles);
string[] descriptions = GetRectanglesDescriptions(csv.Info, csv.Setup, csv.LayerHeader.Layers); ReadOnlyCollection<string> descriptions = GetRectanglesDescriptions(csv.Info, csv.Setup, csv.LayerHeader.Layers);
for (int i = 0; i < descriptions.Length; i++) for (int i = 0; i < descriptions.Count; i++)
graphics.DrawString(descriptions[i], consolas, brush, rectangles[i]); graphics.DrawString(descriptions[i], consolas, brush, rectangles[i]);
DrawLine(graphics, concentrationPen, 13, 6, 13, 40); DrawLine(graphics, concentrationPen, 13, 6, 13, 40);

View File

@ -35,7 +35,7 @@ public class CSV
# else # else
string[] lines = File.ReadAllLines(path, System.Text.Encoding.GetEncoding("ISO-8859-1")); // µ³® string[] lines = File.ReadAllLines(path, System.Text.Encoding.GetEncoding("ISO-8859-1")); // µ³®
# endif # 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++) for (int i = 1; i < lines.Length; i++)
{ {
if (lines[i].StartsWith("--INFO--")) if (lines[i].StartsWith("--INFO--"))

View File

@ -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"
}

View File

@ -1,77 +0,0 @@
{
"AllowedHosts": "*",
"ApiExportPath": "\\\\mesfs.infineon.com\\EC_Metrology_Si",
"ApiLoggingContentTypes": "application/json",
"ApiLoggingPathPrefixes": "/api/inbound",
"ApiUrl": "~/api",
"ApiLogPath": "D:\\Metrology\\MetrologyAPILogs",
"AttachmentPath": "\\\\mesfs.infineon.com\\EC_Metrology_Si\\MetrologyAttachments",
"BuildNumber": "1",
"Company": "Infineon Technologies Americas Corp.",
"ConnectionString": "Data Source=messqlec1.infineon.com\\PROD1,53959;Integrated Security=True;Initial Catalog=Metrology;",
"GitCommitSeven": "1234567",
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Log4netProvider": "Debug",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"InboundApiAllowedIPList": "",
"IsDevelopment": false,
"IsStaging": false,
"MockRoot": "",
"MonAResource": "OI_Metrology_Viewer_EC",
"MonASite": "auc",
"Oi2SqlConnectionString": "Data Source=messqlec1.infineon.com\\PROD1,53959;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;",
"Serilog": {
"Using": [
"Serilog.Sinks.Console",
"Serilog.Sinks.File"
],
"MinimumLevel": "Information",
"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"
}
},
"TableToPath": {
"SPVRunHeader": "\\\\messa01ec.infineon.com\\apps\\Metrology\\MET08ANLYSDIFAAST230\\Source",
"TencorRunHeader": "\\\\messa01ec.infineon.com\\apps\\Metrology\\MET08DDUPSFS6420\\Source",
"SP1RunHeader": "\\\\messa01ec.infineon.com\\apps\\Metrology\\MET08DDUPSP1TBI\\Source",
"MercuryProbeRunHeader": "\\\\messa01ec.infineon.com\\apps\\Metrology\\MET08RESIHGCV\\Source",
"CDERunHeader": "\\\\messa01ec.infineon.com\\apps\\Metrology\\MET08RESIMAPCDE\\Source",
"SRPRunHeader": "\\\\messa01ec.infineon.com\\apps\\Metrology\\MET08RESISRP2100\\Source",
"BioRadRunHeader": "\\\\messa01ec.infineon.com\\apps\\Metrology\\MET08THFTIRQS408M\\Source",
"StratusBioRadRunHeader": "\\\\messa01ec.infineon.com\\apps\\Metrology\\MET08THFTIRSTRATUS\\Source"
},
"URLs": "http://localhost:5002;",
"WorkingDirectoryName": "IFXApps"
}

View File

@ -1027,8 +1027,22 @@ function oiExportButtonRunInfo() {
}); });
} }
function setInitialDateTimesRunInfo() { function setInitialDateTimesRunInfo(milliseconds) {
var startTime = new Date(Date.now() - 6 * 60 * 60 * 1000);//6 hours back from now if (!milliseconds)
{
var startDate = $("#StartDate").igDatePicker("value");
var startTime = $("#StartTime").igTimePicker("value");
var endDate = $("#EndDate").igDatePicker("value");
var endTime = $("#EndTime").igTimePicker("value");
var startDateTime = new Date(
startDate.getFullYear(), startDate.getMonth(), startDate.getDate(),
startTime.getHours(), startTime.getMinutes(), startTime.getSeconds());
var endDateTime = new Date(
endDate.getFullYear(), endDate.getMonth(), endDate.getDate(),
endTime.getHours(), endTime.getMinutes(), endTime.getSeconds());
milliseconds = Math.abs(endDateTime - startDateTime);
}
var startTime = new Date(Date.now() - milliseconds);
$("#StartDate").igDatePicker({ $("#StartDate").igDatePicker({
dateInputFormat: "date", dateInputFormat: "date",
value: startTime, value: startTime,
@ -1079,7 +1093,7 @@ function initRunInfo(apiUrl, initialToolTypeID, initialHeaderId, initialHeaderAt
initialSelectedItems: [{ value: initialToolTypeID }] initialSelectedItems: [{ value: initialToolTypeID }]
}); });
}); });
setInitialDateTimesRunInfo(); setInitialDateTimesRunInfo(6 * 60 * 60 * 1000);
$("#HeaderGrid").on("dblclick", "tr", loadDetailsRunInfo); $("#HeaderGrid").on("dblclick", "tr", loadDetailsRunInfo);
$("#LoadHeadersButton").click(loadHeaderGridRunInfo); $("#LoadHeadersButton").click(loadHeaderGridRunInfo);
$("#GetDataButton").click(loadDetailsRunInfo); $("#GetDataButton").click(loadDetailsRunInfo);
@ -1090,7 +1104,7 @@ function initRunInfo(apiUrl, initialToolTypeID, initialHeaderId, initialHeaderAt
$("#OIExportButton").click(oiExportButtonRunInfo); $("#OIExportButton").click(oiExportButtonRunInfo);
setInterval(function () { setInterval(function () {
if ($("#chkAutoRefresh").is(':checked')) { if ($("#chkAutoRefresh").is(':checked')) {
setInitialDateTimesRunInfo(); setInitialDateTimesRunInfo(null);
$("#LoadHeadersButton").click(); $("#LoadHeadersButton").click();
} }
}, 180000); }, 180000);

View File

@ -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<InfinityQSDescriptorV3[]>))]
public partial class ResultInfinityQSDescriptorV3SourceGenerationContext : JsonSerializerContext
{
}

View File

@ -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<InfinityQSEventV3[]>))]
public partial class ResultInfinityQSEventV3SourceGenerationContext : JsonSerializerContext
{
}

View File

@ -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<InfinityQSV3[]>))]
public partial class ResultInfinityQSV3SourceGenerationContext : JsonSerializerContext
{
}

View File

@ -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);
}

View File

@ -0,0 +1,17 @@
namespace OI.Metrology.Shared.Models.Stateless;
public interface IInfinityQSV3Controller<T>
{
enum Action : int
{
Index = 0,
MarkAsPinned = 1
}
static string GetRouteName() => nameof(IInfinityQSV3Controller<T>)[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);
}

View File

@ -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<InfinityQSV3[]> GetData(string subGroupId);
Result<InfinityQSDescriptorV3[]> GetDescriptors(string subGroupId);
Result<InfinityQSV3[]> GetHeader(string subGroupId);
}

View File

@ -0,0 +1,9 @@
namespace OI.Metrology.Shared.Models.Stateless;
public interface IOpenInsightV1Controller<T>
{
static string GetRouteName() => nameof(IOpenInsightV1Controller<T>)[1..^10];
T GetTencorRun(string rds, string? insertDate, string? recipe);
}

View File

@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<LangVersion>10.0</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<RuntimeIdentifier>win-x64</RuntimeIdentifier> <RuntimeIdentifier>win-x64</RuntimeIdentifier>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>

View File

@ -2,7 +2,6 @@
<PropertyGroup> <PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<LangVersion>10.0</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<RuntimeIdentifier>win-x64</RuntimeIdentifier> <RuntimeIdentifier>win-x64</RuntimeIdentifier>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
@ -32,11 +31,11 @@
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.9" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.11" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" /> <PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" /> <PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" /> <PackageReference Include="Serilog.Settings.Configuration" Version="7.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" /> <PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" /> <PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog" Version="3.0.1" /> <PackageReference Include="Serilog" Version="3.0.1" />
@ -46,12 +45,6 @@
<ProjectReference Include="..\Server\OI.Metrology.Server.csproj" /> <ProjectReference Include="..\Server\OI.Metrology.Server.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\Server\appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\Server\appsettings.Development.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\.Data\RdsMaxRepo.json"> <None Include="..\.Data\RdsMaxRepo.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>

View File

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.Models.Stateless;
using Serilog;
using System.Net.Http.Json; using System.Net.Http.Json;
namespace OI.Metrology.Tests; namespace OI.Metrology.Tests;
@ -13,10 +13,10 @@ public class UnitAwaitingDispoController
#pragma warning disable CS8618 #pragma warning disable CS8618
private static ILogger _Logger; private static ILogger? _Logger;
private static string _ControllerName; private static string _ControllerName;
private static TestContext _TestContext; private static TestContext _TestContext;
private static WebApplicationFactory<Server.Program> _WebApplicationFactory; private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore #pragma warning restore
@ -24,83 +24,87 @@ public class UnitAwaitingDispoController
public static void ClassInitAsync(TestContext testContext) public static void ClassInitAsync(TestContext testContext)
{ {
_TestContext = testContext; _TestContext = testContext;
_Logger = Log.ForContext<UnitAwaitingDispoController>();
_WebApplicationFactory = new WebApplicationFactory<Server.Program>(); _WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.AwaitingDispoController)[..^10]; _ControllerName = nameof(Server.ApiControllers.AwaitingDispoController)[..^10];
} }
[TestMethod] [TestMethod]
public void TestControllerName() public void TestControllerName()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IAwaitingDispoController<string>.GetRouteName(), _ControllerName); Assert.AreEqual(IAwaitingDispoController<string>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[Ignore] [Ignore]
[TestMethod] [TestMethod]
public void Index() public void Index()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>(); IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IEnumerable<AwaitingDisposition> awaitingDispositions = metrologyRepository.GetAwaitingDisposition(); IEnumerable<AwaitingDisposition>? awaitingDispositions = metrologyRepository?.GetAwaitingDisposition();
Assert.IsTrue(awaitingDispositions is not null); Assert.IsTrue(awaitingDispositions is not null);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[Ignore] [Ignore]
[TestMethod] [TestMethod]
public async Task IndexApi() public async Task IndexApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(IMetrologyRepository.GetAwaitingDisposition)}Api.json"), json); 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] [Ignore]
[TestMethod] [TestMethod]
public void MarkAsReviewed() public void MarkAsReviewed()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>(); IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
_ = metrologyRepository.UpdateReviewDate(toolTypeId: 1, headerId: 1, clearDate: false); _ = metrologyRepository?.UpdateReviewDate(toolTypeId: 1, headerId: 1, clearDate: false);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[Ignore] [Ignore]
[TestMethod] [TestMethod]
public async Task MarkAsReviewedApi() public async Task MarkAsReviewedApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
_ = await httpClient.GetFromJsonAsync<object>($"api/{_ControllerName}/markasreviewed"); _ = await httpClient.GetFromJsonAsync<object>($"api/{_ControllerName}/markasreviewed");
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[Ignore] [Ignore]
[TestMethod] [TestMethod]
public void MarkAsAwaiting() public void MarkAsAwaiting()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>(); IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
int dateCleared = metrologyRepository.UpdateReviewDate(toolTypeId: 1, headerId: 1, clearDate: true); int? dateCleared = metrologyRepository?.UpdateReviewDate(toolTypeId: 1, headerId: 1, clearDate: true);
Assert.IsTrue(dateCleared <= 1); Assert.IsTrue(dateCleared <= 1);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[Ignore] [Ignore]
[TestMethod] [TestMethod]
public async Task MarkAsAwaitingApi() public async Task MarkAsAwaitingApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
_ = await httpClient.PostAsync($"api/{_ControllerName}/markasawaiting", null); _ = await httpClient.PostAsync($"api/{_ControllerName}/markasawaiting", null);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
} }

View File

@ -1,7 +1,8 @@
using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.Models.Stateless;
using Serilog;
using System.Text; using System.Text;
namespace OI.Metrology.Tests; namespace OI.Metrology.Tests;
@ -12,10 +13,10 @@ public class UnitInboundController
#pragma warning disable CS8618 #pragma warning disable CS8618
private static ILogger _Logger; private static ILogger? _Logger;
private static string _ControllerName; private static string _ControllerName;
private static TestContext _TestContext; private static TestContext _TestContext;
private static WebApplicationFactory<Server.Program> _WebApplicationFactory; private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore #pragma warning restore
@ -23,8 +24,9 @@ public class UnitInboundController
public static void ClassInitAsync(TestContext testContext) public static void ClassInitAsync(TestContext testContext)
{ {
_TestContext = testContext; _TestContext = testContext;
_Logger = Log.ForContext<UnitInboundController>();
_WebApplicationFactory = new WebApplicationFactory<Server.Program>(); _WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.InboundController)[..^10]; _ControllerName = nameof(Server.ApiControllers.InboundController)[..^10];
} }
@ -38,9 +40,9 @@ public class UnitInboundController
[TestMethod] [TestMethod]
public void TestControllerName() public void TestControllerName()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IInboundController<string>.GetRouteName(), _ControllerName); Assert.AreEqual(IInboundController<string>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
@ -54,10 +56,11 @@ public class UnitInboundController
[TestMethod] [TestMethod]
public async Task DataApi() public async Task DataApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
_ = await httpClient.PostAsync($"api/{_ControllerName}/BioRad", GetStringContent()); _ = await httpClient.PostAsync($"api/{_ControllerName}/BioRad", GetStringContent());
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
@ -65,10 +68,11 @@ public class UnitInboundController
[TestMethod] [TestMethod]
public async Task AttachFileApi() public async Task AttachFileApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
_ = await httpClient.PostAsync($"api/{_ControllerName}/BioRad/attachment", GetStringContent()); _ = await httpClient.PostAsync($"api/{_ControllerName}/BioRad/attachment", GetStringContent());
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }

View File

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OI.Metrology.Server.Models; using OI.Metrology.Server.Models;
using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.Models.Stateless;
using Serilog;
using System.Net; using System.Net;
namespace OI.Metrology.Tests; namespace OI.Metrology.Tests;
@ -13,10 +13,10 @@ public class UnitTestAppSettingsController
#pragma warning disable CS8618 #pragma warning disable CS8618
private static ILogger _Logger; private static ILogger? _Logger;
private static string _ControllerName; private static string _ControllerName;
private static TestContext _TestContext; private static TestContext _TestContext;
private static WebApplicationFactory<Server.Program> _WebApplicationFactory; private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore #pragma warning restore
@ -24,8 +24,9 @@ public class UnitTestAppSettingsController
public static void ClassInitAsync(TestContext testContext) public static void ClassInitAsync(TestContext testContext)
{ {
_TestContext = testContext; _TestContext = testContext;
_Logger = Log.ForContext<UnitTestAppSettingsController>();
_WebApplicationFactory = new WebApplicationFactory<Server.Program>(); _WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.AppSettingsController)[..^10]; _ControllerName = nameof(Server.ApiControllers.AppSettingsController)[..^10];
} }
@ -39,88 +40,90 @@ public class UnitTestAppSettingsController
[TestMethod] [TestMethod]
public void TestControllerName() public void TestControllerName()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IAppSettingsController<object>.GetRouteName(), _ControllerName); Assert.AreEqual(IAppSettingsController<object>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public void TestConnectionString() public void TestConnectionString()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IAppSettingsRepository<Server.Models.Binder.AppSettings> appSettingsRepository = serviceProvider.GetRequiredService<IAppSettingsRepository<Server.Models.Binder.AppSettings>>(); IAppSettingsRepository<Server.Models.Binder.AppSettings>? appSettingsRepository = serviceProvider?.GetRequiredService<IAppSettingsRepository<Server.Models.Binder.AppSettings>>();
appSettingsRepository.VerifyConnectionStrings(); appSettingsRepository?.VerifyConnectionStrings();
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public void AppSettings() public void AppSettings()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
AppSettings appSettings = serviceProvider.GetRequiredService<AppSettings>(); AppSettings? appSettings = serviceProvider?.GetRequiredService<AppSettings>();
Assert.IsNotNull(appSettings); Assert.IsNotNull(appSettings);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public void GetAppSettings() public void GetAppSettings()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IAppSettingsRepository<Server.Models.Binder.AppSettings> appSettingsRepository = serviceProvider.GetRequiredService<IAppSettingsRepository<Server.Models.Binder.AppSettings>>(); IAppSettingsRepository<Server.Models.Binder.AppSettings>? appSettingsRepository = serviceProvider?.GetRequiredService<IAppSettingsRepository<Server.Models.Binder.AppSettings>>();
Server.Models.Binder.AppSettings appSettings = appSettingsRepository.GetAppSettings(); Server.Models.Binder.AppSettings? appSettings = appSettingsRepository?.GetAppSettings();
Assert.IsTrue(appSettings is not null); Assert.IsTrue(appSettings is not null);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public async Task GetAppSettingsApi() public async Task GetAppSettingsApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string actionName = nameof(IAppSettingsController<object>.Action.App); string actionName = nameof(IAppSettingsController<object>.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(HttpStatusCode.OK, httpResponseMessage.StatusCode);
Assert.AreEqual("application/json; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString()); Assert.AreEqual("application/json; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString());
string json = await httpResponseMessage.Content.ReadAsStringAsync(); string json = await httpResponseMessage.Content.ReadAsStringAsync();
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetAppSettings)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetAppSettings)}.json"), json);
Assert.IsNotNull(json); Assert.IsNotNull(json);
Assert.IsTrue(json != "[]"); Assert.IsTrue(json != "[]");
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public void GetBuildNumberAndGitCommitSeven() public void GetBuildNumberAndGitCommitSeven()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IAppSettingsRepository<Server.Models.Binder.AppSettings> appSettingsRepository = serviceProvider.GetRequiredService<IAppSettingsRepository<Server.Models.Binder.AppSettings>>(); IAppSettingsRepository<Server.Models.Binder.AppSettings>? appSettingsRepository = serviceProvider?.GetRequiredService<IAppSettingsRepository<Server.Models.Binder.AppSettings>>();
string result = appSettingsRepository.GetBuildNumberAndGitCommitSeven(); string? result = appSettingsRepository?.GetBuildNumberAndGitCommitSeven();
Assert.IsTrue(result is not null); Assert.IsTrue(result is not null);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public async Task GetBuildNumberAndGitCommitSevenApi() public async Task GetBuildNumberAndGitCommitSevenApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string actionName = nameof(IAppSettingsController<object>.Action.DevOps); string actionName = nameof(IAppSettingsController<object>.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(HttpStatusCode.OK, httpResponseMessage.StatusCode);
Assert.AreEqual("text/plain; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString()); Assert.AreEqual("text/plain; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString());
string json = await httpResponseMessage.Content.ReadAsStringAsync(); string json = await httpResponseMessage.Content.ReadAsStringAsync();
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetBuildNumberAndGitCommitSeven)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetBuildNumberAndGitCommitSeven)}.json"), json);
Assert.IsNotNull(json); Assert.IsNotNull(json);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }

View File

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.Models.Stateless;
using Serilog;
using System.Net; using System.Net;
namespace OI.Metrology.Tests; namespace OI.Metrology.Tests;
@ -12,10 +12,10 @@ public class UnitTestClientSettingsController
#pragma warning disable CS8618 #pragma warning disable CS8618
private static ILogger _Logger; private static ILogger? _Logger;
private static string _ControllerName; private static string _ControllerName;
private static TestContext _TestContext; private static TestContext _TestContext;
private static WebApplicationFactory<Server.Program> _WebApplicationFactory; private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore #pragma warning restore
@ -23,38 +23,40 @@ public class UnitTestClientSettingsController
public static void ClassInitAsync(TestContext testContext) public static void ClassInitAsync(TestContext testContext)
{ {
_TestContext = testContext; _TestContext = testContext;
_Logger = Log.ForContext<UnitTestClientSettingsController>();
_WebApplicationFactory = new WebApplicationFactory<Server.Program>(); _WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.ClientSettingsController)[..^10]; _ControllerName = nameof(Server.ApiControllers.ClientSettingsController)[..^10];
} }
[TestMethod] [TestMethod]
public void TestControllerName() public void TestControllerName()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IClientSettingsController<object>.GetRouteName(), _ControllerName); Assert.AreEqual(IClientSettingsController<object>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public void GetClientSettings() public void GetClientSettings()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IClientSettingsRepository clientSettingsRepository = serviceProvider.GetRequiredService<IClientSettingsRepository>(); IClientSettingsRepository? clientSettingsRepository = serviceProvider?.GetRequiredService<IClientSettingsRepository>();
#if DEBUG #if DEBUG
List<string> clientSettings = clientSettingsRepository.GetClientSettings(null); List<string>? clientSettings = clientSettingsRepository?.GetClientSettings(null);
Assert.IsTrue(clientSettings is not null); Assert.IsTrue(clientSettings is not null);
#endif #endif
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public async Task GetClientSettingsApi() public async Task GetClientSettingsApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
#if DEBUG #if DEBUG
Assert.IsTrue(httpClient is not null);
string actionName = nameof(IClientSettingsController<object>.Action.Client); string actionName = nameof(IClientSettingsController<object>.Action.Client);
HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}"); HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}");
Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode); Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode);
@ -64,25 +66,26 @@ public class UnitTestClientSettingsController
Assert.IsNotNull(json); Assert.IsNotNull(json);
Assert.IsTrue(json != "[]"); Assert.IsTrue(json != "[]");
#endif #endif
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public void GetIpAddress() public void GetIpAddress()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IClientSettingsRepository clientSettingsRepository = serviceProvider.GetRequiredService<IClientSettingsRepository>(); IClientSettingsRepository? clientSettingsRepository = serviceProvider?.GetRequiredService<IClientSettingsRepository>();
string? ipAddress = clientSettingsRepository.GetIpAddress(null); string? ipAddress = clientSettingsRepository?.GetIpAddress(null);
Assert.IsTrue(ipAddress is not null); Assert.IsTrue(ipAddress is not null);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public async Task GetIpAddressApi() public async Task GetIpAddressApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string actionName = nameof(IClientSettingsController<object>.Action.IP); string actionName = nameof(IClientSettingsController<object>.Action.IP);
HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}"); HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}");
Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode); Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode);
@ -90,7 +93,7 @@ public class UnitTestClientSettingsController
string json = await httpResponseMessage.Content.ReadAsStringAsync(); string json = await httpResponseMessage.Content.ReadAsStringAsync();
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetIpAddress)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetIpAddress)}.json"), json);
Assert.IsNotNull(json); Assert.IsNotNull(json);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
} }

View File

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.Models.Stateless;
using Serilog;
using System.Text; using System.Text;
namespace OI.Metrology.Tests; namespace OI.Metrology.Tests;
@ -13,10 +13,10 @@ public class UnitTestExportController
#pragma warning disable CS8618 #pragma warning disable CS8618
private static ILogger _Logger; private static ILogger? _Logger;
private static string _ControllerName; private static string _ControllerName;
private static TestContext _TestContext; private static TestContext _TestContext;
private static WebApplicationFactory<Server.Program> _WebApplicationFactory; private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore #pragma warning restore
@ -24,8 +24,9 @@ public class UnitTestExportController
public static void ClassInitAsync(TestContext testContext) public static void ClassInitAsync(TestContext testContext)
{ {
_TestContext = testContext; _TestContext = testContext;
_Logger = Log.ForContext<UnitTestExportController>();
_WebApplicationFactory = new WebApplicationFactory<Server.Program>(); _WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.ExportController)[..^10]; _ControllerName = nameof(Server.ApiControllers.ExportController)[..^10];
} }
@ -39,9 +40,9 @@ public class UnitTestExportController
[TestMethod] [TestMethod]
public void TestControllerName() public void TestControllerName()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IExportController<string>.GetRouteName(), _ControllerName); Assert.AreEqual(IExportController<string>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
@ -54,142 +55,150 @@ public class UnitTestExportController
[TestMethod] [TestMethod]
public void GetExport() public void GetExport()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IExportRepository exportRepository = serviceProvider.GetRequiredService<IExportRepository>(); IExportRepository? exportRepository = serviceProvider?.GetRequiredService<IExportRepository>();
string result = exportRepository.GetExport(GetHeaderCommon()); string? result = exportRepository?.GetExport(GetHeaderCommon());
Assert.IsNotNull(result); Assert.IsNotNull(result);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public async Task GetExportApi() public async Task GetExportApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/export"); string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/export");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetExport)}.txt"), result); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetExport)}.txt"), result);
Assert.IsNotNull(result); Assert.IsNotNull(result);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public async Task PostExportApi() public async Task PostExportApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/export", GetStringContent()); HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/export", GetStringContent());
Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public void GetHeaders() public void GetHeaders()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IExportRepository exportRepository = serviceProvider.GetRequiredService<IExportRepository>(); IExportRepository? exportRepository = serviceProvider?.GetRequiredService<IExportRepository>();
Result<HeaderCommon[]> result = exportRepository.GetHeaders(GetHeaderCommon()); Result<HeaderCommon[]>? result = exportRepository?.GetHeaders(GetHeaderCommon());
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public async Task GetHeadersApi() public async Task GetHeadersApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/headers"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/headers");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeaders)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeaders)}.json"), json);
Result<HeaderCommon[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<HeaderCommon[]>>(json); Result<HeaderCommon[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<HeaderCommon[]>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public async Task PostHeadersApi() public async Task PostHeadersApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/headers", GetStringContent()); HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/headers", GetStringContent());
Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public void GetLogistics() public void GetLogistics()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IExportRepository exportRepository = serviceProvider.GetRequiredService<IExportRepository>(); IExportRepository? exportRepository = serviceProvider?.GetRequiredService<IExportRepository>();
Result<HeaderCommon[]> result = exportRepository.GetLogistics(GetHeaderCommon()); Result<HeaderCommon[]>? result = exportRepository?.GetLogistics(GetHeaderCommon());
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public async Task GetLogisticsApi() public async Task GetLogisticsApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/logistics"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/logistics");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetLogistics)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetLogistics)}.json"), json);
Result<HeaderCommon[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<HeaderCommon[]>>(json); Result<HeaderCommon[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<HeaderCommon[]>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public async Task PostLogisticsApi() public async Task PostLogisticsApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/logistics", GetStringContent()); HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/logistics", GetStringContent());
Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public void GetProcessDataStandardFormat() public void GetProcessDataStandardFormat()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IExportRepository exportRepository = serviceProvider.GetRequiredService<IExportRepository>(); IExportRepository? exportRepository = serviceProvider?.GetRequiredService<IExportRepository>();
string result = exportRepository.GetProcessDataStandardFormat(GetHeaderCommon()); string? result = exportRepository?.GetProcessDataStandardFormat(GetHeaderCommon());
Assert.IsNotNull(result); Assert.IsNotNull(result);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public async Task GetProcessDataStandardFormatApi() public async Task GetProcessDataStandardFormatApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/processDataStandardFormat"); string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/processDataStandardFormat");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetProcessDataStandardFormat)}.pdsf"), result); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetProcessDataStandardFormat)}.pdsf"), result);
Assert.IsNotNull(result); Assert.IsNotNull(result);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public async Task PostProcessDataStandardFormatApi() public async Task PostProcessDataStandardFormatApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/processDataStandardFormat", GetStringContent()); HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/processDataStandardFormat", GetStringContent());
Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }

View File

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.Models.Stateless;
using Serilog;
namespace OI.Metrology.Tests; namespace OI.Metrology.Tests;
@ -11,10 +11,10 @@ public class UnitTestISpreadingResistanceProfileController
#pragma warning disable CS8618 #pragma warning disable CS8618
private static ILogger _Logger; private static ILogger? _Logger;
private static string _ControllerName; private static string _ControllerName;
private static TestContext _TestContext; private static TestContext _TestContext;
private static WebApplicationFactory<Server.Program> _WebApplicationFactory; private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore #pragma warning restore
@ -22,9 +22,10 @@ public class UnitTestISpreadingResistanceProfileController
public static void ClassInitAsync(TestContext testContext) public static void ClassInitAsync(TestContext testContext)
{ {
_TestContext = testContext; _TestContext = testContext;
_Logger = Log.ForContext<UnitTestISpreadingResistanceProfileController>();
_WebApplicationFactory = new WebApplicationFactory<Server.Program>(); _WebApplicationFactory = new WebApplicationFactory<Server.Program>();
_ControllerName = nameof(Server.ApiControllers.InfinityQSController)[..^10]; IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.SpreadingResistanceProfileController)[..^10];
} }
private static void NonThrowTryCatch() private static void NonThrowTryCatch()
@ -37,16 +38,16 @@ public class UnitTestISpreadingResistanceProfileController
[TestMethod] [TestMethod]
public void TestControllerName() public void TestControllerName()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IInfinityQSController<string>.GetRouteName(), _ControllerName); Assert.AreEqual(ISpreadingResistanceProfileController<string>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public void GetSpreadingResistanceProfileServiceImageBytes() public void GetSpreadingResistanceProfileServiceImageBytes()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
string directory = "D:/wwwRoot"; string directory = "D:/wwwRoot";
if (!Directory.Exists(directory)) if (!Directory.Exists(directory))
_ = Directory.CreateDirectory(directory); _ = Directory.CreateDirectory(directory);
@ -54,13 +55,14 @@ public class UnitTestISpreadingResistanceProfileController
if (File.Exists(file)) if (File.Exists(file))
{ {
string json = File.ReadAllText(file); string json = File.ReadAllText(file);
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
ISpreadingResistanceProfileService spreadingResistanceProfileService = serviceProvider.GetRequiredService<ISpreadingResistanceProfileService>(); ISpreadingResistanceProfileService? spreadingResistanceProfileService = serviceProvider?.GetRequiredService<ISpreadingResistanceProfileService>();
byte[] bytes = spreadingResistanceProfileService.GetImageBytes(json); byte[]? bytes = spreadingResistanceProfileService?.GetImageBytes(json);
Assert.IsTrue(bytes.Any()); Assert.IsTrue(bytes is not null);
Assert.IsTrue(bytes.Length != 0);
File.WriteAllBytes(Path.Combine(directory, "srp.png"), bytes); File.WriteAllBytes(Path.Combine(directory, "srp.png"), bytes);
} }
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }

View File

@ -85,7 +85,7 @@ public class UnitTestInfinityQSController
IInfinityQSRepository infinityQSRepository = serviceProvider.GetRequiredService<IInfinityQSRepository>(); IInfinityQSRepository infinityQSRepository = serviceProvider.GetRequiredService<IInfinityQSRepository>();
Result<InfinityQSBase[]> result = infinityQSRepository.GetData("1677273357"); Result<InfinityQSBase[]> result = infinityQSRepository.GetData("1677273357");
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
Assert.IsTrue(result?.Results.Any()); Assert.IsTrue(result?.Results.Length != 0);
Assert.IsNotNull(result?.Results[0].PR_NAME); Assert.IsNotNull(result?.Results[0].PR_NAME);
Assert.IsNotNull(result?.Results[0].SE_SGTM); Assert.IsNotNull(result?.Results[0].SE_SGTM);
Assert.IsNotNull(result?.Results[0].SE_TSNO); Assert.IsNotNull(result?.Results[0].SE_TSNO);
@ -123,7 +123,7 @@ public class UnitTestInfinityQSController
IInfinityQSRepository infinityQSRepository = serviceProvider.GetRequiredService<IInfinityQSRepository>(); IInfinityQSRepository infinityQSRepository = serviceProvider.GetRequiredService<IInfinityQSRepository>();
Result<InfinityQSDescriptor[]> result = infinityQSRepository.GetDescriptors("1677273357"); Result<InfinityQSDescriptor[]> result = infinityQSRepository.GetDescriptors("1677273357");
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
Assert.IsTrue(result?.Results.Any()); Assert.IsTrue(result?.Results.Length != 0);
Assert.IsNotNull(result?.Results[0].SD_SGRP); Assert.IsNotNull(result?.Results[0].SD_SGRP);
Assert.IsNotNull(result?.Results[0].SD_TSNO); Assert.IsNotNull(result?.Results[0].SD_TSNO);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");

View File

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.Models.Stateless;
using Serilog;
namespace OI.Metrology.Tests; namespace OI.Metrology.Tests;
@ -12,10 +12,10 @@ public class UnitTestInfinityQSV2Controller
#pragma warning disable CS8618 #pragma warning disable CS8618
private static ILogger _Logger; private static ILogger? _Logger;
private static string _ControllerName; private static string _ControllerName;
private static TestContext _TestContext; private static TestContext _TestContext;
private static WebApplicationFactory<Server.Program> _WebApplicationFactory; private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore #pragma warning restore
@ -23,8 +23,9 @@ public class UnitTestInfinityQSV2Controller
public static void ClassInitAsync(TestContext testContext) public static void ClassInitAsync(TestContext testContext)
{ {
_TestContext = testContext; _TestContext = testContext;
_Logger = Log.ForContext<UnitTestInfinityQSV2Controller>();
_WebApplicationFactory = new WebApplicationFactory<Server.Program>(); _WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.InfinityQSV2Controller)[..^10]; _ControllerName = nameof(Server.ApiControllers.InfinityQSV2Controller)[..^10];
} }
@ -38,21 +39,21 @@ public class UnitTestInfinityQSV2Controller
[TestMethod] [TestMethod]
public void TestControllerName() public void TestControllerName()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IInfinityQSV2Controller<string>.GetRouteName(), _ControllerName); Assert.AreEqual(IInfinityQSV2Controller<string>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public void GetCommandText() public void GetCommandText()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IInfinityQSV2Repository infinityQSV2Repository = serviceProvider.GetRequiredService<IInfinityQSV2Repository>(); IInfinityQSV2Repository? infinityQSV2Repository = serviceProvider?.GetRequiredService<IInfinityQSV2Repository>();
string result = infinityQSV2Repository.GetCommandText("1677273357", "61", "CDE5", "5012", "575908", ""); string? result = infinityQSV2Repository?.GetCommandText("1677273357", "61", "CDE5", "5012", "575908", "");
Assert.IsNotNull(result); Assert.IsNotNull(result);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
@ -62,12 +63,13 @@ public class UnitTestInfinityQSV2Controller
[TestMethod] [TestMethod]
public async Task GetCommandTextApi() public async Task GetCommandTextApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _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"); 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); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCommandText)}.sql"), json);
Assert.IsNotNull(json); Assert.IsNotNull(json);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
@ -77,18 +79,18 @@ public class UnitTestInfinityQSV2Controller
[TestMethod] [TestMethod]
public void GetData() public void GetData()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IInfinityQSV2Repository infinityQSV2Repository = serviceProvider.GetRequiredService<IInfinityQSV2Repository>(); IInfinityQSV2Repository? infinityQSV2Repository = serviceProvider?.GetRequiredService<IInfinityQSV2Repository>();
Result<InfinityQSBaseV2[]> result = infinityQSV2Repository.GetData("1677273357"); Result<InfinityQSBaseV2[]>? result = infinityQSV2Repository?.GetData("1677273357");
Assert.IsNotNull(result?.Results); 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].Process);
Assert.IsNotNull(result?.Results[0].Variable); Assert.IsNotNull(result?.Results[0].Variable);
Assert.IsNotNull(result?.Results[0].SiteNumber); Assert.IsNotNull(result?.Results[0].SiteNumber);
Assert.IsNotNull(result?.Results[0].VariableNumber); Assert.IsNotNull(result?.Results[0].VariableNumber);
Assert.IsNotNull(result?.Results[0].SubGroupDateTime); Assert.IsNotNull(result?.Results[0].SubGroupDateTime);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
@ -98,14 +100,15 @@ public class UnitTestInfinityQSV2Controller
[TestMethod] [TestMethod]
public async Task GetDataApi() public async Task GetDataApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _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 575908_2023-02-24 14-18-05.txt/data");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/data"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/data");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetData)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetData)}.json"), json);
Result<InfinityQSBaseV2[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSBaseV2[]>>(json); Result<InfinityQSBaseV2[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSBaseV2[]>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
@ -115,15 +118,15 @@ public class UnitTestInfinityQSV2Controller
[TestMethod] [TestMethod]
public void GetDescriptors() public void GetDescriptors()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IInfinityQSV2Repository infinityQSV2Repository = serviceProvider.GetRequiredService<IInfinityQSV2Repository>(); IInfinityQSV2Repository? infinityQSV2Repository = serviceProvider?.GetRequiredService<IInfinityQSV2Repository>();
Result<InfinityQSDescriptorV2[]> result = infinityQSV2Repository.GetDescriptors("1677273357"); Result<InfinityQSDescriptorV2[]>? result = infinityQSV2Repository?.GetDescriptors("1677273357");
Assert.IsNotNull(result?.Results); 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].SubGroupId);
Assert.IsNotNull(result?.Results[0].SiteNumber); Assert.IsNotNull(result?.Results[0].SiteNumber);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
@ -133,14 +136,15 @@ public class UnitTestInfinityQSV2Controller
[TestMethod] [TestMethod]
public async Task GetDescriptorsApi() public async Task GetDescriptorsApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _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 575908_2023-02-24 14-18-05.txt/descriptors");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/descriptors"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/descriptors");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetDescriptors)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetDescriptors)}.json"), json);
Result<InfinityQSDescriptorV2[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSDescriptorV2[]>>(json); Result<InfinityQSDescriptorV2[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSDescriptorV2[]>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
@ -150,12 +154,12 @@ public class UnitTestInfinityQSV2Controller
[TestMethod] [TestMethod]
public void GetEvents() public void GetEvents()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IInfinityQSV2Repository infinityQSV2Repository = serviceProvider.GetRequiredService<IInfinityQSV2Repository>(); IInfinityQSV2Repository? infinityQSV2Repository = serviceProvider?.GetRequiredService<IInfinityQSV2Repository>();
Result<InfinityQSEventV2[]> result = infinityQSV2Repository.GetEvents("1677273357"); Result<InfinityQSEventV2[]>? result = infinityQSV2Repository?.GetEvents("1677273357");
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
@ -165,13 +169,14 @@ public class UnitTestInfinityQSV2Controller
[TestMethod] [TestMethod]
public async Task GetEventsApi() public async Task GetEventsApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/events"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/events");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetEvents)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetEvents)}.json"), json);
Result<InfinityQSEvent[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSEvent[]>>(json); Result<InfinityQSEventV2[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSEventV2[]>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
@ -181,12 +186,13 @@ public class UnitTestInfinityQSV2Controller
[TestMethod] [TestMethod]
public void GetHeader() public void GetHeader()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IInfinityQSV2Repository infinityQSV2Repository = serviceProvider.GetRequiredService<IInfinityQSV2Repository>(); IInfinityQSV2Repository? infinityQSV2Repository = serviceProvider?.GetRequiredService<IInfinityQSV2Repository>();
Result<InfinityQSBaseV2[]> result = infinityQSV2Repository.GetHeader("1677273357"); Result<InfinityQSBaseV2[]>? result = infinityQSV2Repository?.GetHeader("1677273357");
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); Assert.IsNotNull(result?.Results[0].Part);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
@ -196,13 +202,15 @@ public class UnitTestInfinityQSV2Controller
[TestMethod] [TestMethod]
public async Task GetHeaderApi() public async Task GetHeaderApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/header"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/header");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeader)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeader)}.json"), json);
Result<InfinityQSBaseV2[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSBaseV2[]>>(json); Result<InfinityQSBaseV2[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSBaseV2[]>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); Assert.IsNotNull(result?.Results[0].Part);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }

View File

@ -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<Server.Program>? _WebApplicationFactory;
#pragma warning restore
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContext = testContext;
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_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<string>.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<IInfinityQSV3Repository>();
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<IInfinityQSV3Repository>();
Result<InfinityQSV3[]>? 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<InfinityQSV3[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSV3[]>>(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<IInfinityQSV3Repository>();
Result<InfinityQSDescriptorV3[]>? 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<InfinityQSDescriptorV3[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSDescriptorV3[]>>(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<IInfinityQSV3Repository>();
Result<InfinityQSV3[]>? 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<InfinityQSV3[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSV3[]>>(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<IInfinityQSV3Repository>();
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();
}
}

View File

@ -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<Server.Program>? _WebApplicationFactory;
#pragma warning restore
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContext = testContext;
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_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<string>.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<IOpenInsightV1Repository>();
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();
}
}

View File

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.Models.Stateless;
using Serilog;
namespace OI.Metrology.Tests; namespace OI.Metrology.Tests;
@ -12,10 +12,10 @@ public class UnitTestPinController
#pragma warning disable CS8618 #pragma warning disable CS8618
private static ILogger _Logger; private static ILogger? _Logger;
private static string _ControllerName; private static string _ControllerName;
private static TestContext _TestContext; private static TestContext _TestContext;
private static WebApplicationFactory<Server.Program> _WebApplicationFactory; private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore #pragma warning restore
@ -23,41 +23,44 @@ public class UnitTestPinController
public static void ClassInitAsync(TestContext testContext) public static void ClassInitAsync(TestContext testContext)
{ {
_TestContext = testContext; _TestContext = testContext;
_Logger = Log.ForContext<UnitTestPinController>();
_WebApplicationFactory = new WebApplicationFactory<Server.Program>(); _WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.PinController)[..^10]; _ControllerName = nameof(Server.ApiControllers.PinController)[..^10];
} }
[TestMethod] [TestMethod]
public void TestControllerName() public void TestControllerName()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IPinController<string>.GetRouteName(), _ControllerName); Assert.AreEqual(IPinController<string>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public void GetPinnedTable() public void GetPinnedTable()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>(); IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IPinRepository pinRepository = serviceProvider.GetRequiredService<IPinRepository>(); IPinRepository? pinRepository = serviceProvider?.GetRequiredService<IPinRepository>();
Result<Pinned[]> result = pinRepository.GetPinnedTable(metrologyRepository, id: 1, cde_id: null, biorad_id: null, rds: null); Assert.IsTrue(metrologyRepository is not null);
Result<Pinned[]>? result = pinRepository?.GetPinnedTable(metrologyRepository, id: 1, cde_id: null, biorad_id: null, rds: null);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public async Task GetPinnedTableApi() public async Task GetPinnedTableApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/-1/pinned"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/-1/pinned");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetPinnedTable)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetPinnedTable)}.json"), json);
Result<Pinned[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<Pinned[]>>(json); Result<Pinned[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<Pinned[]>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
} }

View File

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.Models.Stateless;
using Serilog;
namespace OI.Metrology.Tests; namespace OI.Metrology.Tests;
@ -12,10 +12,10 @@ public class UnitTestReactorController
#pragma warning disable CS8618 #pragma warning disable CS8618
private static ILogger _Logger; private static ILogger? _Logger;
private static string _ControllerName; private static string _ControllerName;
private static TestContext _TestContext; private static TestContext _TestContext;
private static WebApplicationFactory<Server.Program> _WebApplicationFactory; private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore #pragma warning restore
@ -23,8 +23,9 @@ public class UnitTestReactorController
public static void ClassInitAsync(TestContext testContext) public static void ClassInitAsync(TestContext testContext)
{ {
_TestContext = testContext; _TestContext = testContext;
_Logger = Log.ForContext<UnitTestReactorController>();
_WebApplicationFactory = new WebApplicationFactory<Server.Program>(); _WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.ReactorsController)[..^10]; _ControllerName = nameof(Server.ApiControllers.ReactorsController)[..^10];
} }
@ -38,47 +39,48 @@ public class UnitTestReactorController
[TestMethod] [TestMethod]
public void TestControllerName() public void TestControllerName()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IReactorsController<string>.GetRouteName(), _ControllerName); Assert.AreEqual(IReactorsController<string>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public void GetReactors() public void GetReactors()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IReactorsRepository reactorsRepository = serviceProvider.GetRequiredService<IReactorsRepository>(); IReactorsRepository? reactorsRepository = serviceProvider?.GetRequiredService<IReactorsRepository>();
Result<int[]> result = reactorsRepository.EvenReactors(); Result<int[]>? result = reactorsRepository?.EvenReactors();
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public async Task GetReactorsApi() public async Task GetReactorsApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/true/"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/true/");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetReactors)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetReactors)}.json"), json);
Result<int[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<int[]>>(json); Result<int[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<int[]>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
public void GetKey() public void GetKey()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IReactorsRepository reactorsRepository = serviceProvider.GetRequiredService<IReactorsRepository>(); IReactorsRepository? reactorsRepository = serviceProvider?.GetRequiredService<IReactorsRepository>();
WorkMaterialOut workMaterialOut = new() { RunDataSheet = "123456", Username = "phares" }; WorkMaterialOut workMaterialOut = new() { RunDataSheet = "123456", Username = "phares" };
string? result = reactorsRepository.GetKey(workMaterialOut, save: false); string? result = reactorsRepository?.GetKey(workMaterialOut, save: false);
Assert.IsNotNull(result); Assert.IsNotNull(result);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }

View File

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.Models.Stateless;
using OI.Metrology.Shared.ViewModels; using OI.Metrology.Shared.ViewModels;
using Serilog;
namespace OI.Metrology.Tests; namespace OI.Metrology.Tests;
@ -12,10 +12,10 @@ public class UnitTestServiceShopOrderController
#pragma warning disable CS8618 #pragma warning disable CS8618
private static ILogger _Logger; private static ILogger? _Logger;
private static string _ControllerName; private static string _ControllerName;
private static TestContext _TestContext; private static TestContext _TestContext;
private static WebApplicationFactory<Server.Program> _WebApplicationFactory; private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore #pragma warning restore
@ -23,17 +23,18 @@ public class UnitTestServiceShopOrderController
public static void ClassInitAsync(TestContext testContext) public static void ClassInitAsync(TestContext testContext)
{ {
_TestContext = testContext; _TestContext = testContext;
_Logger = Log.ForContext<UnitTestServiceShopOrderController>();
_WebApplicationFactory = new WebApplicationFactory<Server.Program>(); _WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.ServiceShopOrderController)[..^10]; _ControllerName = nameof(Server.ApiControllers.ServiceShopOrderController)[..^10];
} }
[TestMethod] [TestMethod]
public void TestControllerName() public void TestControllerName()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IServiceShopOrderController<string>.GetRouteName(), _ControllerName); Assert.AreEqual(IServiceShopOrderController<string>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
@ -43,36 +44,38 @@ public class UnitTestServiceShopOrderController
throw new NullReferenceException(nameof(_Logger)); throw new NullReferenceException(nameof(_Logger));
ServiceShopOrder[] serviceShopOrders = IServiceShopOrder.GetServiceShopOrders(null); ServiceShopOrder[] serviceShopOrders = IServiceShopOrder.GetServiceShopOrders(null);
Assert.IsNotNull(serviceShopOrders); Assert.IsNotNull(serviceShopOrders);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public async Task GetAllServiceShopOrders() public async Task GetAllServiceShopOrders()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
ServiceShopOrder[] serviceShopOrders; ServiceShopOrder[]? serviceShopOrders;
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IServiceShopOrderRepository serviceShopOrderRepository = serviceProvider.GetRequiredService<IServiceShopOrderRepository>(); IServiceShopOrderRepository? serviceShopOrderRepository = serviceProvider?.GetRequiredService<IServiceShopOrderRepository>();
Assert.IsTrue(serviceShopOrderRepository is not null);
serviceShopOrders = await serviceShopOrderRepository.GetAllServiceShopOrders(); serviceShopOrders = await serviceShopOrderRepository.GetAllServiceShopOrders();
Assert.IsTrue(serviceShopOrders is not null); Assert.IsTrue(serviceShopOrders is not null);
serviceShopOrders = await serviceShopOrderRepository.GetServiceShopOrders("23188d3d-9b75-ed11-ab8b-0050568f2fc3"); 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()); Assert.IsNotNull(serviceShopOrders[0].ToString());
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public async Task GetAllServiceShopOrdersApi() public async Task GetAllServiceShopOrdersApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string actionName = nameof(IServiceShopOrderController<object>.Action.All); string actionName = nameof(IServiceShopOrderController<object>.Action.All);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/{actionName}"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/{actionName}");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetAllServiceShopOrders)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetAllServiceShopOrders)}.json"), json);
ServiceShopOrder[]? serviceShopOrders = System.Text.Json.JsonSerializer.Deserialize<ServiceShopOrder[]>(json); ServiceShopOrder[]? serviceShopOrders = System.Text.Json.JsonSerializer.Deserialize<ServiceShopOrder[]>(json);
Assert.IsNotNull(serviceShopOrders); Assert.IsNotNull(serviceShopOrders);
Assert.IsTrue(serviceShopOrders.Any()); Assert.IsTrue(serviceShopOrders.Length != 0);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
} }

View File

@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.Models.Stateless;
using OI.Metrology.Shared.Services; using OI.Metrology.Shared.Services;
using Serilog;
using System.Data; using System.Data;
using System.Net.Http.Json; using System.Net.Http.Json;
@ -15,10 +15,10 @@ public class UnitTestToolTypesController
#pragma warning disable CS8618 #pragma warning disable CS8618
private static ILogger _Logger; private static ILogger? _Logger;
private static string _ControllerName; private static string _ControllerName;
private static TestContext _TestContext; private static TestContext _TestContext;
private static WebApplicationFactory<Server.Program> _WebApplicationFactory; private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore #pragma warning restore
@ -26,8 +26,9 @@ public class UnitTestToolTypesController
public static void ClassInitAsync(TestContext testContext) public static void ClassInitAsync(TestContext testContext)
{ {
_TestContext = testContext; _TestContext = testContext;
_Logger = Log.ForContext<UnitTestToolTypesController>();
_WebApplicationFactory = new WebApplicationFactory<Server.Program>(); _WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.ToolTypesController)[..^10]; _ControllerName = nameof(Server.ApiControllers.ToolTypesController)[..^10];
} }
@ -41,252 +42,274 @@ public class UnitTestToolTypesController
[TestMethod] [TestMethod]
public void TestControllerName() public void TestControllerName()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IToolTypesController<string>.GetRouteName(), _ControllerName); Assert.AreEqual(IToolTypesController<string>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public void Index() public void Index()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>(); IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>(); IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService<IToolTypesRepository>();
Result<ToolTypeNameId[]> result = toolTypesRepository.Index(metrologyRepository); Assert.IsTrue(metrologyRepository is not null);
Result<ToolTypeNameId[]>? result = toolTypesRepository?.Index(metrologyRepository);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Any()); Assert.IsTrue(result.Results.Length != 0);
Assert.IsFalse(result.Results.All(l => l.ID == 0)); Assert.IsFalse(result.Results.All(l => l.ID == 0));
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public async Task IndexApi() public async Task IndexApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(Index)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(Index)}.json"), json);
Result<ToolTypeNameId[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<ToolTypeNameId[]>>(json); Result<ToolTypeNameId[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<ToolTypeNameId[]>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Any()); Assert.IsTrue(result.Results.Length != 0);
Assert.IsFalse(result.Results.All(l => l.ID == 0)); Assert.IsFalse(result.Results.All(l => l.ID == 0));
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public void GetToolTypeMetadata() public void GetToolTypeMetadata()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>(); IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>(); IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService<IToolTypesRepository>();
Result<ToolTypeMetadataResult> result = toolTypesRepository.GetToolTypeMetadata(metrologyRepository, id: 1, sortby: string.Empty); Assert.IsTrue(metrologyRepository is not null);
Result<ToolTypeMetadataResult>? result = toolTypesRepository?.GetToolTypeMetadata(metrologyRepository, id: 1, sortby: string.Empty);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Metadata); 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)); Assert.IsFalse(result.Results.Metadata.All(l => l.ToolTypeID == 0));
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public async Task GetToolTypeMetadataApi() public async Task GetToolTypeMetadataApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetToolTypeMetadata)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetToolTypeMetadata)}.json"), json);
Result<ToolTypeMetadataResult>? result = System.Text.Json.JsonSerializer.Deserialize<Result<ToolTypeMetadataResult>>(json); Result<ToolTypeMetadataResult>? result = System.Text.Json.JsonSerializer.Deserialize<Result<ToolTypeMetadataResult>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Metadata); 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)); Assert.IsFalse(result.Results.Metadata.All(l => l.ToolTypeID == 0));
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public void GetHeaders() public void GetHeaders()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>(); IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>(); IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService<IToolTypesRepository>();
Result<DataTable> result = toolTypesRepository.GetHeaders(metrologyRepository, id: 1, datebegin: null, dateend: null, page: null, pagesize: null, headerid: null); Assert.IsTrue(metrologyRepository is not null);
Result<DataTable>? result = toolTypesRepository?.GetHeaders(metrologyRepository, id: 1, datebegin: null, dateend: null, page: null, pagesize: null, headerid: null);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0); Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public async Task GetHeadersApi() public async Task GetHeadersApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeaders)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeaders)}.json"), json);
Result<DataTable>? result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<DataTable>>(json); Result<DataTable>? result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<DataTable>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0); Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public void GetHeaderTitles() public void GetHeaderTitles()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>(); IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>(); IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService<IToolTypesRepository>();
Result<HeaderCommon[]> result = toolTypesRepository.GetHeaderTitles(metrologyRepository, id: -1, page: null, pagesize: null); Assert.IsTrue(metrologyRepository is not null);
Result<HeaderCommon[]>? result = toolTypesRepository?.GetHeaderTitles(metrologyRepository, id: -1, page: null, pagesize: null);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Any()); Assert.IsTrue(result?.Results.Length != 0);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public async Task GetHeaderTitlesApi() public async Task GetHeaderTitlesApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/-1/headertitles"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/-1/headertitles");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeaderTitles)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeaderTitles)}.json"), json);
Result<HeaderCommon[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<HeaderCommon[]>>(json); Result<HeaderCommon[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<HeaderCommon[]>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Any()); Assert.IsTrue(result.Results.Length != 0);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public void GetHeaderFields() public void GetHeaderFields()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>(); IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>(); IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService<IToolTypesRepository>();
Result<ColumnValue[]> result = toolTypesRepository.GetHeaderFields(metrologyRepository, id: 1, headerid: 1); Assert.IsTrue(metrologyRepository is not null);
Result<ColumnValue[]>? result = toolTypesRepository?.GetHeaderFields(metrologyRepository, id: 1, headerid: 1);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Any()); Assert.IsTrue(result.Results.Length != 0);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public async Task GetHeaderFieldsApi() public async Task GetHeaderFieldsApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers/1/fields"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers/1/fields");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeaderFields)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeaderFields)}.json"), json);
Result<ColumnValue[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<ColumnValue[]>>(json); Result<ColumnValue[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<ColumnValue[]>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Any()); Assert.IsTrue(result.Results.Length != 0);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public void GetData() public void GetData()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>(); IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>(); IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService<IToolTypesRepository>();
Result<DataTable> result = toolTypesRepository.GetData(metrologyRepository, id: 1, headerid: 1); Assert.IsTrue(metrologyRepository is not null);
Result<DataTable>? result = toolTypesRepository?.GetData(metrologyRepository, id: 1, headerid: 1);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0); Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[TestMethod] [TestMethod]
public async Task GetDataApi() public async Task GetDataApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers/1/data"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers/1/data");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetData)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetData)}.json"), json);
Result<DataTable>? result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<DataTable>>(json); Result<DataTable>? result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<DataTable>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0); Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[Ignore] [Ignore]
[TestMethod] [TestMethod]
public void GetExportData() public void GetExportData()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>(); IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>(); IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService<IToolTypesRepository>();
Result<DataTable> result = toolTypesRepository.GetExportData(metrologyRepository, toolTypeId: 1, datebegin: null, dateend: null); Assert.IsTrue(metrologyRepository is not null);
Result<DataTable>? result = toolTypesRepository?.GetExportData(metrologyRepository, toolTypeId: 1, datebegin: null, dateend: null);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0); Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[Ignore] [Ignore]
[TestMethod] [TestMethod]
public async Task GetExportDataApi() public async Task GetExportDataApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/export"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/export");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetExportData)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetExportData)}.json"), json);
Result<DataTable>? result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<DataTable>>(json); Result<DataTable>? result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<DataTable>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0); Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[Ignore] [Ignore]
[TestMethod] [TestMethod]
public void GetAttachment() public void GetAttachment()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
int toolTypeId = 1; int toolTypeId = 1;
string tabletype = "data"; string tabletype = "data";
string filename = "data.txt"; string filename = "data.txt";
string attachmentId = "ffdf5410-ca19-4097-bfa4-b398e236d07e"; string attachmentId = "ffdf5410-ca19-4097-bfa4-b398e236d07e";
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IAttachmentsService attachmentsService = serviceProvider.GetRequiredService<IAttachmentsService>(); IAttachmentsService? attachmentsService = serviceProvider?.GetRequiredService<IAttachmentsService>();
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>(); IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>(); IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService<IToolTypesRepository>();
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); (string? message, string? _, Stream? _) = toolTypesRepository.GetAttachment(metrologyRepository, attachmentsService, toolTypeId, tabletype, attachmentId, filename);
Assert.IsTrue(message is null); Assert.IsTrue(message is null);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[Ignore] [Ignore]
[TestMethod] [TestMethod]
public async Task GetAttachmentApi() public async Task GetAttachmentApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
_ = await httpClient.GetFromJsonAsync<object>($"api/{_ControllerName}/1/data/files/ffdf5410-ca19-4097-bfa4-b398e236d07e/data.txt"); _ = await httpClient.GetFromJsonAsync<object>($"api/{_ControllerName}/1/data/files/ffdf5410-ca19-4097-bfa4-b398e236d07e/data.txt");
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[Ignore] [Ignore]
[TestMethod] [TestMethod]
public void OIExport() public void OIExport()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IAttachmentsService attachmentsService = serviceProvider.GetRequiredService<IAttachmentsService>(); IAttachmentsService? attachmentsService = serviceProvider?.GetRequiredService<IAttachmentsService>();
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>(); IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>(); IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService<IToolTypesRepository>();
Server.Models.AppSettings appSettings = serviceProvider.GetRequiredService<Server.Models.AppSettings>(); Server.Models.AppSettings? appSettings = serviceProvider?.GetRequiredService<Server.Models.AppSettings>();
string? message = toolTypesRepository.OIExport(metrologyRepository, attachmentsService, appSettings.AttachmentPath, appSettings.TableToPath, toolTypeId: 1, headerid: 1); 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); Assert.IsTrue(message is null);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
[Ignore] [Ignore]
[TestMethod] [TestMethod]
public async Task OIExportApi() public async Task OIExportApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
_ = await httpClient.GetFromJsonAsync<object>($"api/{_ControllerName}/1/headers/1/oiexport"); Assert.IsTrue(httpClient is not null);
_Logger.Information($"{_TestContext?.TestName} completed"); _ = await httpClient.GetFromJsonAsync<object>($"api/{_ControllerName}/1/headers/1/export");
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
} }
} }

View File

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.Models.Stateless;
using Serilog;
namespace OI.Metrology.Tests; namespace OI.Metrology.Tests;
@ -12,10 +12,10 @@ public class UnitTestWorkMaterialController
#pragma warning disable CS8618 #pragma warning disable CS8618
private static ILogger _Logger; private static ILogger? _Logger;
private static string _ControllerName; private static string _ControllerName;
private static TestContext _TestContext; private static TestContext _TestContext;
private static WebApplicationFactory<Server.Program> _WebApplicationFactory; private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore #pragma warning restore
@ -23,8 +23,9 @@ public class UnitTestWorkMaterialController
public static void ClassInitAsync(TestContext testContext) public static void ClassInitAsync(TestContext testContext)
{ {
_TestContext = testContext; _TestContext = testContext;
_Logger = Log.ForContext<UnitTestWorkMaterialController>();
_WebApplicationFactory = new WebApplicationFactory<Server.Program>(); _WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.WorkMaterialController)[..^10]; _ControllerName = nameof(Server.ApiControllers.WorkMaterialController)[..^10];
} }
@ -38,9 +39,9 @@ public class UnitTestWorkMaterialController
[TestMethod] [TestMethod]
public void TestControllerName() public void TestControllerName()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IWorkMaterialController<string>.GetRouteName(), _ControllerName); Assert.AreEqual(IWorkMaterialController<string>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
@ -50,12 +51,12 @@ public class UnitTestWorkMaterialController
[TestMethod] [TestMethod]
public void GetCassette() public void GetCassette()
{ {
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IWorkMaterialRepository workMaterialRepository = serviceProvider.GetRequiredService<IWorkMaterialRepository>(); IWorkMaterialRepository? workMaterialRepository = serviceProvider?.GetRequiredService<IWorkMaterialRepository>();
Result<WorkMaterialV2[]> result = workMaterialRepository.GetCassette("O171927.1.37"); Result<WorkMaterialV2[]>? result = workMaterialRepository?.GetCassette("O171927.1.37");
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }
@ -65,13 +66,14 @@ public class UnitTestWorkMaterialController
[TestMethod] [TestMethod]
public async Task GetCassetteApi() public async Task GetCassetteApi()
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger.Information("Starting Web Application"); _Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/O171927.1.37/"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/O171927.1.37/");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCassette)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCassette)}.json"), json);
Result<WorkMaterialV2[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<WorkMaterialV2[]>>(json); Result<WorkMaterialV2[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<WorkMaterialV2[]>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch(); NonThrowTryCatch();
} }

View File

@ -8,12 +8,12 @@
<SupportedPlatform Include="browser" /> <SupportedPlatform Include="browser" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="MudBlazor" Version="6.7.0" /> <PackageReference Include="MudBlazor" Version="6.11.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.9" /> <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.13" />
<PackageReference Include="IgniteUI.Blazor" Version="22.2.24" /> <PackageReference Include="IgniteUI.Blazor" Version="22.2.24" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.BrowserConsole" Version="1.0.0" /> <PackageReference Include="Serilog.Sinks.BrowserConsole" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.BrowserHttp" Version="1.0.0-dev-00032" /> <PackageReference Include="Serilog.Sinks.BrowserHttp" Version="1.0.0-dev-00032" />
<PackageReference Include="System.Net.Http.Json" Version="7.0.1" /> <PackageReference Include="System.Net.Http.Json" Version="7.0.1" />
</ItemGroup> </ItemGroup>

View File

@ -15,7 +15,7 @@ trigger:
- "ClientHub/*" - "ClientHub/*"
pool: pool:
name: Mesa-IIS name: eaf
demands: OI-Metrology-Server-Development demands: OI-Metrology-Server-Development
variables: variables:

View File

@ -21,238 +21,238 @@ variables:
ASPNETCORE_ENVIRONMENT: "Production" ASPNETCORE_ENVIRONMENT: "Production"
stages: stages:
- stage: IFX # - stage: IFX
pool: # pool:
name: Mesa-Windows-Service # name: eaf
demands: OI-Metrology-Server-IFX # demands: OI-Metrology-Server-IFX
jobs: # jobs:
- job: IFX # - job: IFX
steps: # steps:
- script: | # - script: |
set exeName=OI.Metrology.Server # set exeName=OI.Metrology.Server
echo %exeName% # echo %exeName%
echo ##vso[task.setvariable variable=ExeName;]%exeName% # echo ##vso[task.setvariable variable=ExeName;]%exeName%
echo $(ExeName) # echo $(ExeName)
displayName: ExeName # displayName: ExeName
- script: | # - script: |
set coreVersion=net7.0 # set coreVersion=net7.0
echo %coreVersion% # echo %coreVersion%
echo ##vso[task.setvariable variable=CoreVersion;]%coreVersion% # echo ##vso[task.setvariable variable=CoreVersion;]%coreVersion%
echo $(CoreVersion) # echo $(CoreVersion)
displayName: CoreVersion # displayName: CoreVersion
- script: | # - script: |
set configuration=Debug # set configuration=Debug
echo %configuration% # echo %configuration%
echo ##vso[task.setvariable variable=Configuration;]%configuration% # echo ##vso[task.setvariable variable=Configuration;]%configuration%
echo $(Configuration) # echo $(Configuration)
displayName: Configuration # displayName: Configuration
- script: | # - script: |
set nugetSource=https://eaf-dev-reporting.mes.infineon.com/v3/index.json # set nugetSource=https://eaf-dev-reporting.mes.infineon.com/v3/index.json
echo %nugetSource% # echo %nugetSource%
echo ##vso[task.setvariable variable=NugetSource;]%nugetSource% # echo ##vso[task.setvariable variable=NugetSource;]%nugetSource%
echo $(NugetSource) # echo $(NugetSource)
displayName: NugetSource # displayName: NugetSource
- script: | # - script: |
set gitCommit=$(Build.SourceVersion) # set gitCommit=$(Build.SourceVersion)
set gitCommitSeven=%gitCommit:~0,7% # set gitCommitSeven=%gitCommit:~0,7%
echo %gitCommitSeven% # echo %gitCommitSeven%
echo ##vso[task.setvariable variable=GitCommitSeven;]%gitCommitSeven% # echo ##vso[task.setvariable variable=GitCommitSeven;]%gitCommitSeven%
echo $(GitCommitSeven) # echo $(GitCommitSeven)
displayName: GitCommitSeven # displayName: GitCommitSeven
- script: | # - script: |
set uuId=A6302662940458499454E35D28FCC9F7 # set uuId=A6302662940458499454E35D28FCC9F7
echo %uuId% # echo %uuId%
echo ##vso[task.setvariable variable=UUId;]%uuId% # echo ##vso[task.setvariable variable=UUId;]%uuId%
echo $(UUId) # echo $(UUId)
displayName: UUId # displayName: UUId
- script: | # - script: |
set pwEncoding=AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAtBhT01pNnUGaN/uPLxZGvAAAAAACAAAAAAADZgAAwAAAABAAAAAM4xlYguhv7jzchU8dq9pVAAAAAASAAACgAAAAEAAAANS9rIoaYfNq5TwCmTrqElsgAAAA7O4J52FqCctXlCxYB2J5b/W4T+pZCN2zwFj7XCAFW6IUAAAAhQsBDOERAUZJdtSy8AfxwOAZflo= # set pwEncoding=AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAtBhT01pNnUGaN/uPLxZGvAAAAAACAAAAAAADZgAAwAAAABAAAAAM4xlYguhv7jzchU8dq9pVAAAAAASAAACgAAAAEAAAANS9rIoaYfNq5TwCmTrqElsgAAAA7O4J52FqCctXlCxYB2J5b/W4T+pZCN2zwFj7XCAFW6IUAAAAhQsBDOERAUZJdtSy8AfxwOAZflo=
echo %pwEncoding% # echo %pwEncoding%
echo ##vso[task.setvariable variable=PwEncoding;]%pwEncoding% # echo ##vso[task.setvariable variable=PwEncoding;]%pwEncoding%
echo $(PwEncoding) # echo $(PwEncoding)
displayName: PwEncoding # displayName: PwEncoding
- script: | # - script: |
echo $(Build.BuildId) # echo $(Build.BuildId)
echo $(Build.Reason) # echo $(Build.Reason)
echo $(Build.Repository.Id) # echo $(Build.Repository.Id)
echo $(Build.Repository.Name) # echo $(Build.Repository.Name)
echo $(Build.SourceVersion) # echo $(Build.SourceVersion)
echo $(Configuration) # echo $(Configuration)
echo $(CoreVersion) # echo $(CoreVersion)
echo $(GitCommitSeven) # echo $(GitCommitSeven)
echo $(NugetSource) # echo $(NugetSource)
echo $(PwEncoding) # echo $(PwEncoding)
echo $(UUId) # echo $(UUId)
REM echo $(pipelinePassword) # REM echo $(pipelinePassword)
displayName: "Echo Check" # displayName: "Echo Check"
- script: '"C:\program files\dotnet\dotnet.exe" nuget locals all --clear' # - script: '"C:\program files\dotnet\dotnet.exe" nuget locals all --clear'
displayName: "Nuget Clear" # displayName: "Nuget Clear"
enabled: false # enabled: false
- script: | # - script: |
"C:\program files\dotnet\dotnet.exe" user-secrets init # "C:\program files\dotnet\dotnet.exe" user-secrets init
"C:\program files\dotnet\dotnet.exe" user-secrets set "BuildNumber" "$(Build.BuildId)" # "C:\program files\dotnet\dotnet.exe" user-secrets set "BuildNumber" "$(Build.BuildId)"
"C:\program files\dotnet\dotnet.exe" user-secrets set "GitCommitSeven" "$(GitCommitSeven)" # "C:\program files\dotnet\dotnet.exe" user-secrets set "GitCommitSeven" "$(GitCommitSeven)"
"C:\program files\dotnet\dotnet.exe" user-secrets list # "C:\program files\dotnet\dotnet.exe" user-secrets list
workingDirectory: Server # workingDirectory: Server
displayName: "Safe storage of app secrets - Server" # displayName: "Safe storage of app secrets - Server"
- script: | # - script: |
"C:\program files\dotnet\dotnet.exe" user-secrets set "IsDevelopment" true # "C:\program files\dotnet\dotnet.exe" user-secrets set "IsDevelopment" true
"C:\program files\dotnet\dotnet.exe" user-secrets set "MockRoot" "/Data/Tests" # "C:\program files\dotnet\dotnet.exe" user-secrets set "MockRoot" "/Data/Tests"
"C:\program files\dotnet\dotnet.exe" user-secrets set "URLs" "http://localhost:5002;" # "C:\program files\dotnet\dotnet.exe" user-secrets set "URLs" "http://localhost:5002;"
"C:\program files\dotnet\dotnet.exe" user-secrets set "MonAResource" "OI_Metrology_Viewer_IFX" # "C:\program files\dotnet\dotnet.exe" user-secrets set "MonAResource" "OI_Metrology_Viewer_IFX"
"C:\program files\dotnet\dotnet.exe" user-secrets set "ApiExportPath" "\\messdv002.na.infineon.com\Candela\Archive\API" # "C:\program files\dotnet\dotnet.exe" user-secrets set "ApiExportPath" "\\messdv002.na.infineon.com\Candela\Archive\API"
"C:\program files\dotnet\dotnet.exe" user-secrets set "ConnectionString" "Data Source=MESSAD1001\TEST1,59583;Integrated Security=True;Initial Catalog=Metrology;" # "C:\program files\dotnet\dotnet.exe" user-secrets set "ConnectionString" "Data Source=MESSAD1001\TEST1,59583;Integrated Security=True;Initial Catalog=Metrology;"
"C:\program files\dotnet\dotnet.exe" user-secrets set "Oi2SqlConnectionString" "Data Source=MESSAD1001\TEST1,59583;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;" # "C:\program files\dotnet\dotnet.exe" user-secrets set "Oi2SqlConnectionString" "Data Source=MESSAD1001\TEST1,59583;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;"
workingDirectory: Server # workingDirectory: Server
displayName: "Safe storage of app secrets II - Server" # displayName: "Safe storage of app secrets II - Server"
- script: '"C:\program files\dotnet\dotnet.exe" build --configuration $(Configuration) --source $(NugetSource)' # - script: '"C:\program files\dotnet\dotnet.exe" build --configuration $(Configuration) --source $(NugetSource)'
workingDirectory: Tests # workingDirectory: Tests
displayName: "Core Build - Tests" # displayName: "Core Build - Tests"
- script: '"C:\program files\dotnet\dotnet.exe" build --configuration $(Configuration) --source $(NugetSource)' # - script: '"C:\program files\dotnet\dotnet.exe" build --configuration $(Configuration) --source $(NugetSource)'
workingDirectory: Server # workingDirectory: Server
displayName: "Core Build - Server" # displayName: "Core Build - Server"
- powershell: Get-ChildItem .\ -include TestResults -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse } # - powershell: Get-ChildItem .\ -include TestResults -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }
workingDirectory: "$(System.DefaultWorkingDirectory)/.vscode" # workingDirectory: "$(System.DefaultWorkingDirectory)/.vscode"
displayName: "PowerShell Script" # displayName: "PowerShell Script"
- script: "dotnet test --configuration $(Configuration)" # - script: "dotnet test --configuration $(Configuration)"
workingDirectory: Tests # workingDirectory: Tests
displayName: "Core Test" # displayName: "Core Test"
enabled: false # enabled: false
- script: '"C:\program files\dotnet\dotnet.exe" tool restore' # - script: '"C:\program files\dotnet\dotnet.exe" tool restore'
workingDirectory: Server # workingDirectory: Server
displayName: "Tool Restore" # displayName: "Tool Restore"
enabled: false # enabled: false
- script: '"C:\program files\dotnet\dotnet.exe" ReportGenerator -reports:.vscode/TestResults/*/coverage.cobertura.xml -targetDir:$(Build.ArtifactStagingDirectory)\Coverage -reportTypes:Html_Dark' # - script: '"C:\program files\dotnet\dotnet.exe" ReportGenerator -reports:.vscode/TestResults/*/coverage.cobertura.xml -targetDir:$(Build.ArtifactStagingDirectory)\Coverage -reportTypes:Html_Dark'
workingDirectory: Server # workingDirectory: Server
displayName: "Report Generator" # displayName: "Report Generator"
enabled: false # enabled: false
- task: PublishTestResults@2 # - task: PublishTestResults@2
displayName: "Publish Test Results **/*.trx" # displayName: "Publish Test Results **/*.trx"
inputs: # inputs:
testResultsFormat: VSTest # testResultsFormat: VSTest
testResultsFiles: "**/*.trx" # testResultsFiles: "**/*.trx"
testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" # testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)"
searchFolder: "$(System.DefaultWorkingDirectory)/.vscode" # searchFolder: "$(System.DefaultWorkingDirectory)/.vscode"
- task: PublishTestResults@2 # - task: PublishTestResults@2
displayName: "Publish Test Results **/coverage.cobertura.xml" # displayName: "Publish Test Results **/coverage.cobertura.xml"
inputs: # inputs:
testResultsFormat: VSTest # testResultsFormat: VSTest
testResultsFiles: "**/coverage.cobertura.xml" # testResultsFiles: "**/coverage.cobertura.xml"
testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" # testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)"
searchFolder: "$(System.DefaultWorkingDirectory)/.vscode" # searchFolder: "$(System.DefaultWorkingDirectory)/.vscode"
- task: PublishCodeCoverageResults@1 # - task: PublishCodeCoverageResults@1
inputs: # inputs:
codeCoverageTool: "Cobertura" # codeCoverageTool: "Cobertura"
summaryFileLocation: "$(System.DefaultWorkingDirectory)/.vscode/TestResults/*/coverage.cobertura.xml" # summaryFileLocation: "$(System.DefaultWorkingDirectory)/.vscode/TestResults/*/coverage.cobertura.xml"
enabled: false # enabled: false
- task: mspremier.CreateWorkItem.CreateWorkItem-task.CreateWorkItem@1 # - task: mspremier.CreateWorkItem.CreateWorkItem-task.CreateWorkItem@1
displayName: "Create work item" # displayName: "Create work item"
inputs: # inputs:
teamProject: "Mesa_FI" # teamProject: "Mesa_FI"
workItemType: Bug # workItemType: Bug
title: $(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration) # title: $(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)
assignedTo: "$(Build.RequestedForId)" # assignedTo: "$(Build.RequestedForId)"
enabled: false # enabled: false
- script: '"C:\program files\dotnet\dotnet.exe" publish --configuration $(Configuration) --runtime win-x64 --self-contained -o "D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server" --source $(NugetSource)' # - script: '"C:\program files\dotnet\dotnet.exe" publish --configuration $(Configuration) --runtime win-x64 --self-contained -o "D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server" --source $(NugetSource)'
workingDirectory: Server # workingDirectory: Server
displayName: "Core Publish" # displayName: "Core Publish"
- task: DownloadSecureFile@1 # - task: DownloadSecureFile@1
name: downloadSecureFileKDBX # name: downloadSecureFileKDBX
displayName: "Download secure file" # displayName: "Download secure file"
inputs: # inputs:
secureFile: "Infineon-NA.kdbx" # secureFile: "Infineon-NA.kdbx"
- script: echo "<$(downloadSecureFileKDBX.secureFilePath)>" # - script: echo "<$(downloadSecureFileKDBX.secureFilePath)>"
displayName: "Echo Path" # displayName: "Echo Path"
- script: '"C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration)' # - script: '"C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration)'
workingDirectory: Tests # workingDirectory: Tests
displayName: "Core Clean - Tests" # displayName: "Core Clean - Tests"
enabled: false # enabled: false
- script: '"C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration)' # - script: '"C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration)'
workingDirectory: Server # workingDirectory: Server
displayName: "Core Clean - Server" # displayName: "Core Clean - Server"
- powershell: | # - powershell: |
$data = @('$(downloadSecureFileKDBX.secureFilePath)', '-c:GetEntryString', '-Field:Password', '-refx-UUID:$(UUId)', '-pw-enc:$(PwEncoding)') # $data = @('$(downloadSecureFileKDBX.secureFilePath)', '-c:GetEntryString', '-Field:Password', '-refx-UUID:$(UUId)', '-pw-enc:$(PwEncoding)')
$data.count # $data.count
$processStartInfo = New-Object System.Diagnostics.ProcessStartInfo # $processStartInfo = New-Object System.Diagnostics.ProcessStartInfo
$processStartInfo.FileName = "C:\Users\$(USERNAME)\AppData\Local\IFXApps\KeePass-2.51.1---KPScript-2.51.1\KPScript.exe" # $processStartInfo.FileName = "C:\Users\$(USERNAME)\AppData\Local\IFXApps\KeePass-2.51.1---KPScript-2.51.1\KPScript.exe"
$processStartInfo.RedirectStandardError = $true # $processStartInfo.RedirectStandardError = $true
$processStartInfo.RedirectStandardOutput = $true # $processStartInfo.RedirectStandardOutput = $true
$processStartInfo.UseShellExecute = $false # $processStartInfo.UseShellExecute = $false
$processStartInfo.Arguments = $data # $processStartInfo.Arguments = $data
$process = New-Object System.Diagnostics.Process # $process = New-Object System.Diagnostics.Process
$process.StartInfo = $processStartInfo # $process.StartInfo = $processStartInfo
$process.Start() | Out-Null # $process.Start() | Out-Null
$process.WaitForExit() # $process.WaitForExit()
$stdout = $process.StandardOutput.ReadToEnd() # $stdout = $process.StandardOutput.ReadToEnd()
$stderr = $process.StandardError.ReadToEnd() # $stderr = $process.StandardError.ReadToEnd()
Write-Host "stderr: $stderr" # Write-Host "stderr: $stderr"
Write-Host "exit code: " + $process.ExitCode # Write-Host "exit code: " + $process.ExitCode
Write-Host "##vso[task.setvariable variable=pipelinePassword;]$stdout" # Write-Host "##vso[task.setvariable variable=pipelinePassword;]$stdout"
displayName: pipelinePassword # displayName: pipelinePassword
- script: 'sc create "$(ExeName)" start= delayed-auto DisplayName= "$(Build.Repository.Name)-$(Configuration)-$(GitCommitSeven)-$(Build.BuildId)" binPath= D:\$(CoreVersion)\$(Build.Repository.Name)\Server\$(ExeName).exe obj= INFINEON\$(USERNAME) password="$(pipelinePassword)"' # - script: 'sc create "$(ExeName)" start= delayed-auto DisplayName= "$(Build.Repository.Name)-$(Configuration)-$(GitCommitSeven)-$(Build.BuildId)" binPath= D:\$(CoreVersion)\$(Build.Repository.Name)\Server\$(ExeName).exe obj= INFINEON\$(USERNAME) password="$(pipelinePassword)"'
workingDirectory: Server # workingDirectory: Server
displayName: "Service Control - Create" # displayName: "Service Control - Create"
continueOnError: true # continueOnError: true
- script: 'sc config "$(ExeName)" DisplayName= "$(Build.Repository.Name)-$(Configuration)-$(GitCommitSeven)-$(Build.BuildId)"' # - script: 'sc config "$(ExeName)" DisplayName= "$(Build.Repository.Name)-$(Configuration)-$(GitCommitSeven)-$(Build.BuildId)"'
displayName: "Service Control - Configure" # displayName: "Service Control - Configure"
- script: 'sc stop "$(ExeName)"' # - script: 'sc stop "$(ExeName)"'
displayName: "Service Control - Stop" # displayName: "Service Control - Stop"
continueOnError: true # continueOnError: true
- script: 'rmdir "D:\$(CoreVersion)\$(Build.Repository.Name)\Server"' # - script: 'rmdir "D:\$(CoreVersion)\$(Build.Repository.Name)\Server"'
displayName: "Remove directory" # displayName: "Remove directory"
continueOnError: true # continueOnError: true
- script: 'mklink /J "D:\$(CoreVersion)\$(Build.Repository.Name)\Server" "D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server"' # - script: 'mklink /J "D:\$(CoreVersion)\$(Build.Repository.Name)\Server" "D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server"'
displayName: "Link directory" # displayName: "Link directory"
continueOnError: true # continueOnError: true
- script: 'sc start "$(ExeName)"' # - script: 'sc start "$(ExeName)"'
displayName: "Service Control - Start" # displayName: "Service Control - Start"
- task: PublishBuildArtifacts@1 # - task: PublishBuildArtifacts@1
displayName: "Publish Artifact: drop" # displayName: "Publish Artifact: drop"
enabled: false # enabled: false
- script: 'echo $(Build.SourceVersion)-$(Build.BuildId)>bin_x_x_\$(Configuration)\$(CoreVersion)\win-x64\$(Build.Repository.Name).txt' # - script: 'echo $(Build.SourceVersion)-$(Build.BuildId)>bin_x_x_\$(Configuration)\$(CoreVersion)\win-x64\$(Build.Repository.Name).txt'
displayName: "Force Fail" # displayName: "Force Fail"
enabled: false # enabled: false
- stage: EC - stage: EC
pool: pool:
name: Mesa-IIS name: open-insight-metrology-viewer
demands: OI-Metrology-Server-EC demands: OI-Metrology-Server-EC
jobs: jobs:
@ -273,7 +273,7 @@ stages:
displayName: Configuration displayName: Configuration
- script: | - script: |
set nugetSource=https://messa08ec.ec.local/v3/index.json set nugetSource=https://eaf-prod.mes.infineon.com/v3/index.json
echo %nugetSource% echo %nugetSource%
echo ##vso[task.setvariable variable=NugetSource;]%nugetSource% echo ##vso[task.setvariable variable=NugetSource;]%nugetSource%
echo $(NugetSource) echo $(NugetSource)