10 Commits

Author SHA1 Message Date
23f6e83c8d NonThrowTryCatch 2023-03-24 12:57:35 -07:00
644cde644d Fix-Event II 2023-03-24 09:49:34 -07:00
243c8dd888 nuget bump and userSecrets tasks and
query update for event
2023-03-17 09:52:48 -07:00
994556d453 Change from ticks to IQS ID and SC
Change pool to Windows-Service
Build Tests first
Disable Tests
2023-03-09 11:26:07 -07:00
8040a7c6b5 Better data (BioRad)
EC / IFX
FromBody bug fix
Made ID optional and are get all files now
2023-03-08 12:47:22 -07:00
de048b6842 Removed FromBody 2023-03-08 10:04:15 -07:00
db44756142 DNS Name
Nuget Bump
Path Week Bug
2023-03-07 10:37:17 -07:00
66f9347223 Mixed Content: The page at 2023-03-06 13:13:08 -07:00
a0d0f33c83 Skip tests that don't work in IFX 2023-03-06 12:51:00 -07:00
1712743c46 Added View, Recipe Paramaters and Export 2023-03-06 12:00:24 -07:00
30 changed files with 817 additions and 203 deletions

44
.vscode/tasks.json vendored
View File

@ -1,6 +1,50 @@
{ {
"version": "2.0.0", "version": "2.0.0",
"options": {
"env": {
"serverUserSecretsId": "6501aa0f-8499-4be5-96a9-e99b11323eeb"
}
},
"tasks": [ "tasks": [
{
"label": "userSecretsInit",
"command": "dotnet",
"type": "process",
"args": [
"user-secrets",
"-p",
"${workspaceFolder}/Server/OI.Metrology.Server.csproj",
"init"
],
"problemMatcher": "$msCompile"
},
{
"label": "userSecretsSet",
"command": "dotnet",
"type": "process",
"args": [
"user-secrets",
"-p",
"${workspaceFolder}/Server/OI.Metrology.Server.csproj",
"set",
"asdf",
"123"
],
"problemMatcher": "$msCompile"
},
{
"label": "userSecretsMkLink",
"command": "cmd",
"type": "shell",
"args": [
"/c",
"mklink",
"/J",
".vscode\\UserSecrets",
"${userHome}\\AppData\\Roaming\\Microsoft\\UserSecrets\\$env:serverUserSecretsId"
],
"problemMatcher": "$msCompile"
},
{ {
"label": "buildServer", "label": "buildServer",
"command": "dotnet", "command": "dotnet",

View File

@ -123,5 +123,76 @@
"value": "1" "value": "1"
} }
] ]
},
{
"_id": "4eafe190-e59e-4a3e-af76-356f62fde842",
"colId": "history",
"containerId": "",
"name": "https://oi-metrology-viewer-prod.mes.infineon.com/api/tooltypes",
"url": "https://oi-metrology-viewer-prod.mes.infineon.com/api/tooltypes",
"method": "GET",
"sortNum": 0,
"created": "2023-03-07T17:20:54.044Z",
"modified": "2023-03-07T17:20:54.044Z",
"headers": [],
"params": [],
"tests": []
},
{
"_id": "280ea9be-50e3-4813-8eb0-ffff739fe196",
"colId": "history",
"containerId": "",
"name": "GetHeaders",
"url": "https://oi-metrology-viewer-prod.mes.infineon.com/api/export/headers",
"method": "GET",
"sortNum": 0,
"created": "2023-03-07T17:21:05.219Z",
"modified": "2023-03-07T19:35:11.146Z",
"headers": [],
"params": [],
"body": {
"type": "json",
"raw": "{\n \"PSN\": \"4698\",\n \"RDS\": \"578824\",\n \"Reactor\": \"62\",\n \"ID\": 1678296039\n}",
"form": []
},
"tests": []
},
{
"_id": "6d8098aa-eb50-422e-b38d-32709d985e8e",
"colId": "history",
"containerId": "",
"name": "GetHeaders-Dev",
"url": "http://mestsa008/api/export/headers",
"method": "POST",
"sortNum": 0,
"created": "2023-03-07T17:21:05.219Z",
"modified": "2023-03-08T18:18:04.054Z",
"headers": [],
"params": [],
"body": {
"type": "json",
"raw": "{\n \"PSN\": \"4698\",\n \"RDS\": \"578824\",\n \"Reactor\": \"62\",\n \"ID\": 1678296039\n}",
"form": []
},
"tests": []
},
{
"_id": "61383ad6-ceb4-4d98-86c1-bf00c0e4204d",
"colId": "history",
"containerId": "",
"name": "GetHeaders-localhost",
"url": "http://localhost:5126/api/export/headers",
"method": "GET",
"sortNum": 0,
"created": "2023-03-07T17:21:05.219Z",
"modified": "2023-03-08T19:05:54.744Z",
"headers": [],
"params": [],
"body": {
"type": "json",
"raw": "{\n \"PSN\": \"4698\",\n \"RDS\": \"578824\",\n \"Reactor\": \"62\",\n \"ID\": -1678296039\n}",
"form": []
},
"tests": []
} }
] ]

View File

@ -5,5 +5,19 @@
"created": "2023-02-27T20:07:11.913Z", "created": "2023-02-27T20:07:11.913Z",
"sortNum": 10000, "sortNum": 10000,
"folders": [] "folders": []
},
{
"_id": "fb96b15a-0cc4-48c7-8767-34f1242750e8",
"colName": "Export EC",
"created": "2023-03-08T17:16:29.420Z",
"sortNum": 20000,
"folders": []
},
{
"_id": "5bfd00bc-b58c-49d3-9f27-5acadd060a51",
"colName": "Export IFX",
"created": "2023-03-08T17:31:19.468Z",
"sortNum": 30000,
"folders": []
} }
] ]

View File

@ -265,5 +265,157 @@
"value": "2" "value": "2"
} }
] ]
},
{
"_id": "0aafd6ed-26a6-4a07-825c-8c1fee603b6a",
"colId": "fb96b15a-0cc4-48c7-8767-34f1242750e8",
"containerId": "",
"name": "GetHeaders",
"url": "https://oi-metrology-viewer-prod.mes.infineon.com/api/export/headers",
"method": "GET",
"sortNum": 10000,
"created": "2023-03-08T17:16:56.561Z",
"modified": "2023-03-08T17:17:39.783Z",
"headers": [],
"params": [],
"body": {
"type": "json",
"raw": "{\n \"PSN\": \"4698\",\n \"RDS\": \"578824\",\n \"Reactor\": \"62\",\n \"ID\": 1678296039\n}",
"form": []
},
"tests": []
},
{
"_id": "af298148-482d-4822-80ba-1abb86e1f9c2",
"colId": "fb96b15a-0cc4-48c7-8767-34f1242750e8",
"containerId": "",
"name": "GetExport",
"url": "https://oi-metrology-viewer-prod.mes.infineon.com/api/export/export",
"method": "GET",
"sortNum": 15000,
"created": "2023-03-08T17:17:47.597Z",
"modified": "2023-03-08T17:19:13.764Z",
"headers": [],
"params": [],
"body": {
"type": "json",
"raw": "{\n \"PSN\": \"4698\",\n \"RDS\": \"578824\",\n \"Reactor\": \"62\",\n \"ID\": 1678296039\n}",
"form": []
},
"tests": []
},
{
"_id": "a787c81d-381e-451d-9d96-e607f06efdaf",
"colId": "fb96b15a-0cc4-48c7-8767-34f1242750e8",
"containerId": "",
"name": "GetLogistics",
"url": "https://oi-metrology-viewer-prod.mes.infineon.com/api/export/logistics",
"method": "GET",
"sortNum": 30000,
"created": "2023-03-08T17:18:38.179Z",
"modified": "2023-03-08T17:19:21.874Z",
"headers": [],
"params": [],
"body": {
"type": "json",
"raw": "{\n \"PSN\": \"4698\",\n \"RDS\": \"578824\",\n \"Reactor\": \"62\",\n \"ID\": 1678296039\n}",
"form": []
},
"tests": []
},
{
"_id": "7e19c7d4-2d93-46e1-88fd-ba5312885713",
"colId": "fb96b15a-0cc4-48c7-8767-34f1242750e8",
"containerId": "",
"name": "GetProcessDataStandardFormat",
"url": "https://oi-metrology-viewer-prod.mes.infineon.com/api/export/pdsf",
"method": "GET",
"sortNum": 40000,
"created": "2023-03-08T17:18:49.042Z",
"modified": "2023-03-08T17:19:27.119Z",
"headers": [],
"params": [],
"body": {
"type": "json",
"raw": "{\n \"PSN\": \"4698\",\n \"RDS\": \"578824\",\n \"Reactor\": \"62\",\n \"ID\": 1678296039\n}",
"form": []
},
"tests": []
},
{
"_id": "25eb571f-064c-4b3f-8c20-666c66c1b123",
"colId": "5bfd00bc-b58c-49d3-9f27-5acadd060a51",
"containerId": "",
"name": "GetHeaders",
"url": "https://mestsa008.infineon.com:50302/api/export/headers",
"method": "GET",
"sortNum": 10000,
"created": "2023-03-08T17:31:19.471Z",
"modified": "2023-03-08T18:48:51.819Z",
"headers": [],
"params": [],
"body": {
"type": "json",
"raw": "{\n \"PSN\": \"4698\",\n \"RDS\": \"578824\",\n \"Reactor\": \"62\",\n \"ID\": 1678296039\n}",
"form": []
},
"tests": []
},
{
"_id": "f5feb8e3-0e82-4b47-a15e-97ef069a1539",
"colId": "5bfd00bc-b58c-49d3-9f27-5acadd060a51",
"containerId": "",
"name": "GetExport",
"url": "https://mestsa008.infineon.com:50302/api/export/export",
"method": "GET",
"sortNum": 15000,
"created": "2023-03-08T17:31:19.472Z",
"modified": "2023-03-08T17:31:19.472Z",
"headers": [],
"params": [],
"body": {
"type": "json",
"raw": "{\n \"PSN\": \"4698\",\n \"RDS\": \"578824\",\n \"Reactor\": \"62\",\n \"ID\": 1678296039\n}",
"form": []
},
"tests": []
},
{
"_id": "7fddba99-14a2-4c6a-bf4a-4b94391929cf",
"colId": "5bfd00bc-b58c-49d3-9f27-5acadd060a51",
"containerId": "",
"name": "GetLogistics",
"url": "https://mestsa008.infineon.com:50302/api/export/logistics",
"method": "GET",
"sortNum": 30000,
"created": "2023-03-08T17:31:19.473Z",
"modified": "2023-03-08T17:31:19.473Z",
"headers": [],
"params": [],
"body": {
"type": "json",
"raw": "{\n \"PSN\": \"4698\",\n \"RDS\": \"578824\",\n \"Reactor\": \"62\",\n \"ID\": 1678296039\n}",
"form": []
},
"tests": []
},
{
"_id": "07d5b0c3-684a-4cad-8a48-b164e8da87b0",
"colId": "5bfd00bc-b58c-49d3-9f27-5acadd060a51",
"containerId": "",
"name": "GetProcessDataStandardFormat",
"url": "https://mestsa008.infineon.com:50302/api/export/pdsf",
"method": "GET",
"sortNum": 40000,
"created": "2023-03-08T17:31:19.474Z",
"modified": "2023-03-08T17:31:19.474Z",
"headers": [],
"params": [],
"body": {
"type": "json",
"raw": "{\n \"PSN\": \"4698\",\n \"RDS\": \"578824\",\n \"Reactor\": \"62\",\n \"ID\": 1678296039\n}",
"form": []
},
"tests": []
} }
] ]

View File

@ -30,11 +30,11 @@
<PackageReference Include="Dapper" Version="2.0.123" /> <PackageReference Include="Dapper" Version="2.0.123" />
<PackageReference Include="EntityFramework" Version="6.4.4" /> <PackageReference Include="EntityFramework" Version="6.4.4" />
<PackageReference Include="jQuery" Version="3.6.3" /> <PackageReference Include="jQuery" Version="3.6.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> <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="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.Hosting.WindowsServices" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Serilog.AspNetCore" Version="6.1.0" /> <PackageReference Include="Serilog.AspNetCore" Version="6.1.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="3.4.0" /> <PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />

View File

@ -15,25 +15,68 @@ public class ExportController : Controller, IExportController<IActionResult>
public ExportController(IExportRepository exportRepository) => public ExportController(IExportRepository exportRepository) =>
_ExportRepository = exportRepository; _ExportRepository = exportRepository;
private static string? GetJson(Stream stream)
{
string? result;
if (!stream.CanRead)
result = null;
else
{
Task<string> task = new StreamReader(stream).ReadToEndAsync();
result = task.Result;
}
return result;
}
private static HeaderCommon GetHeaderCommon(Stream stream)
{
HeaderCommon? result;
string? json = GetJson(stream);
result = string.IsNullOrEmpty(json) ? null : JsonSerializer.Deserialize<HeaderCommon>(json);
result ??= new();
return result;
}
[HttpGet] [HttpGet]
[Route("export")] [Route("export")]
public IActionResult GetExport(HeaderCommon headerCommon) => public IActionResult GetExport() =>
Content(_ExportRepository.GetExport(headerCommon)); Content(_ExportRepository.GetExport(GetHeaderCommon(Request.Body)));
[HttpGet] [HttpGet]
[Route("headers")] [Route("headers")]
public IActionResult GetHeaders(HeaderCommon headerCommon) => public IActionResult GetHeaders() =>
Json(_ExportRepository.GetHeaders(headerCommon), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); Json(_ExportRepository.GetHeaders(GetHeaderCommon(Request.Body)), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true });
[HttpGet] [HttpGet]
[Route("logistics")] [Route("logistics")]
public IActionResult GetLogistics(HeaderCommon headerCommon) => public IActionResult GetLogistics() =>
Json(_ExportRepository.GetLogistics(headerCommon), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); Json(_ExportRepository.GetLogistics(GetHeaderCommon(Request.Body)), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true });
[HttpGet] [HttpGet]
[Route("pdsf")] [Route("pdsf")]
[Route("processDataStandardFormat")] [Route("processDataStandardFormat")]
public IActionResult GetProcessDataStandardFormat(HeaderCommon headerCommon) => public IActionResult GetProcessDataStandardFormat() =>
Content(_ExportRepository.GetProcessDataStandardFormat(headerCommon)); Content(_ExportRepository.GetProcessDataStandardFormat(GetHeaderCommon(Request.Body)));
[HttpPost]
[Route("export")]
public IActionResult PostExport() =>
Content(_ExportRepository.GetExport(GetHeaderCommon(Request.Body)));
[HttpPost]
[Route("headers")]
public IActionResult PostHeaders() =>
Json(_ExportRepository.GetHeaders(GetHeaderCommon(Request.Body)), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true });
[HttpPost]
[Route("logistics")]
public IActionResult PostLogistics() =>
Json(_ExportRepository.GetLogistics(GetHeaderCommon(Request.Body)), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true });
[HttpPost]
[Route("pdsf")]
[Route("processDataStandardFormat")]
public IActionResult PostProcessDataStandardFormat() =>
Content(_ExportRepository.GetProcessDataStandardFormat(GetHeaderCommon(Request.Body)));
} }

View File

@ -30,9 +30,29 @@ public partial class InboundController : ControllerBase, IInboundController<IAct
_MetrologyRepository = metrologyRepository; _MetrologyRepository = metrologyRepository;
} }
private static string? GetJson(Stream stream)
{
string? result;
if (!stream.CanRead)
result = null;
else
{
Task<string> task = new StreamReader(stream).ReadToEndAsync();
result = task.Result;
}
return result;
}
private static JToken GetJToken(Stream stream)
{
string? json = GetJson(stream);
JToken jsonbody = string.IsNullOrEmpty(json) ? JToken.Parse("{}") : JToken.Parse(json);
return jsonbody;
}
[HttpPost] [HttpPost]
[Route("{tooltype}")] [Route("{tooltype}")]
public IActionResult Post(string tooltype, [FromBody] JToken jsonbody) public IActionResult Post(string tooltype)
{ {
IPAddress? remoteIP = HttpContext.Connection.RemoteIpAddress; IPAddress? remoteIP = HttpContext.Connection.RemoteIpAddress;
if (!_InboundRepository.IsIPAddressAllowed(_AppSettings.InboundApiAllowedIPList, remoteIP)) if (!_InboundRepository.IsIPAddressAllowed(_AppSettings.InboundApiAllowedIPList, remoteIP))
@ -42,18 +62,7 @@ public partial class InboundController : ControllerBase, IInboundController<IAct
} }
else else
{ {
if (jsonbody is null || !jsonbody.Any()) JToken jsonbody = GetJToken(Request.Body);
{
if (!Request.Body.CanRead)
jsonbody = JToken.Parse("{}");
else
{
using Stream stream = Request.Body;
_ = stream.Seek(0, SeekOrigin.Begin);
string json = new StreamReader(stream).ReadToEnd();
jsonbody = JToken.Parse(json);
}
}
DataResponse dataResponse = _InboundRepository.Data(_MetrologyRepository, _InboundDataService, tooltype, jsonbody); DataResponse dataResponse = _InboundRepository.Data(_MetrologyRepository, _InboundDataService, tooltype, jsonbody);
if (!dataResponse.Errors.Any()) if (!dataResponse.Errors.Any())
return Ok(dataResponse); return Ok(dataResponse);

View File

@ -15,7 +15,7 @@ public class PagesController : Controller
public PagesController(AppSettings appSettings, IMetrologyRepository metrologyRepository) public PagesController(AppSettings appSettings, IMetrologyRepository metrologyRepository)
{ {
_AppSettings=appSettings; _AppSettings = appSettings;
_MetrologyRepository = metrologyRepository; _MetrologyRepository = metrologyRepository;
_IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase); _IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase);
} }

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName> <SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider> <SccProvider>SAK</SccProvider>
@ -28,14 +28,14 @@
<PackageReference Include="Dapper" Version="2.0.123" /> <PackageReference Include="Dapper" Version="2.0.123" />
<PackageReference Include="EntityFramework" Version="6.4.4" /> <PackageReference Include="EntityFramework" Version="6.4.4" />
<PackageReference Include="jQuery" Version="3.6.3" /> <PackageReference Include="jQuery" Version="3.6.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="7.0.2" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="7.0.4" />
<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.0" /> <PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<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.AspNetCore" Version="6.1.0" /> <PackageReference Include="Serilog.AspNetCore" Version="6.1.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" /> <PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />

View File

@ -9,7 +9,6 @@ namespace OI.Metrology.Server.Repository;
public class ExportRepository : IExportRepository public class ExportRepository : IExportRepository
{ {
private readonly string _MockRoot;
private readonly Serilog.ILogger _Log; private readonly Serilog.ILogger _Log;
private readonly string _RepositoryName; private readonly string _RepositoryName;
private readonly AppSettings _AppSettings; private readonly AppSettings _AppSettings;
@ -18,7 +17,6 @@ public class ExportRepository : IExportRepository
public ExportRepository(AppSettings appSettings) public ExportRepository(AppSettings appSettings)
{ {
_AppSettings = appSettings; _AppSettings = appSettings;
_MockRoot = appSettings.MockRoot;
_RdsToHeaderCommonCollection = new(); _RdsToHeaderCommonCollection = new();
_RepositoryName = nameof(ExportRepository)[..^10]; _RepositoryName = nameof(ExportRepository)[..^10];
_Log = Serilog.Log.ForContext<ExportRepository>(); _Log = Serilog.Log.ForContext<ExportRepository>();
@ -27,9 +25,10 @@ public class ExportRepository : IExportRepository
private static string[] Get() private static string[] Get()
{ {
DateTime dateTime = DateTime.Now; DateTime dateTime = DateTime.Now;
DateTime lastWeekDateTime = dateTime.AddDays(-7);
Calendar calendar = new CultureInfo("en-US").Calendar; Calendar calendar = new CultureInfo("en-US").Calendar;
string weekOfYear = calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00"); string weekOfYear = $"{dateTime:yyyy}_Week_{calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday):00}";
string lastWeekOfYear = calendar.GetWeekOfYear(dateTime.AddDays(7), CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00"); string lastWeekOfYear = $"{lastWeekDateTime:yyyy}_Week_{calendar.GetWeekOfYear(lastWeekDateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday):00}";
return new string[] { weekOfYear, lastWeekOfYear }; return new string[] { weekOfYear, lastWeekOfYear };
} }
@ -40,10 +39,13 @@ public class ExportRepository : IExportRepository
string[] weeks = Get(); string[] weeks = Get();
foreach (string weekYear in weeks) foreach (string weekYear in weeks)
{ {
directory = Path.Combine(_AppSettings.ApiExportPath, weekYear, $"-{headerCommon.PSN}", $"-{headerCommon.Reactor}", $"-{headerCommon.RDS}", $"-{headerCommon.ID}"); if (headerCommon.ID < 1)
directory = Path.Combine(_AppSettings.ApiExportPath, weekYear, $"-{headerCommon.PSN}", $"-{headerCommon.Reactor}", $"-{headerCommon.RDS}");
else
directory = Path.Combine(_AppSettings.ApiExportPath, weekYear, $"-{headerCommon.PSN}", $"-{headerCommon.Reactor}", $"-{headerCommon.RDS}", $"-{headerCommon.ID}");
if (!Directory.Exists(directory)) if (!Directory.Exists(directory))
continue; continue;
results.AddRange(Directory.GetFiles(directory, searchPattern, SearchOption.TopDirectoryOnly)); results.AddRange(Directory.GetFiles(directory, searchPattern, SearchOption.AllDirectories));
} }
return results; return results;
} }
@ -51,99 +53,90 @@ public class ExportRepository : IExportRepository
string IExportRepository.GetExport(HeaderCommon headerCommon) string IExportRepository.GetExport(HeaderCommon headerCommon)
{ {
string result; string result;
if (!string.IsNullOrEmpty(_MockRoot)) List<string> files = GetFiles(headerCommon, "*.txt");
result = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IExportRepository.GetExport)}.txt")); if (files.Count != 1)
result = string.Empty;
else else
{ result = File.ReadAllText(files.First());
List<string> files = GetFiles(headerCommon, "*.txt");
if (files.Count != 1)
result = string.Empty;
else
result = File.ReadAllText(files.First());
}
return result; return result;
} }
Result<HeaderCommon[]> IExportRepository.GetHeaders(HeaderCommon headerCommon) Result<HeaderCommon[]> IExportRepository.GetHeaders(HeaderCommon headerCommon)
{ {
Result<HeaderCommon[]>? result; Result<HeaderCommon[]>? result;
if (!string.IsNullOrEmpty(_MockRoot)) List<HeaderCommon> results = new();
string json;
HeaderCommon? hc;
string? directory;
string directoryName;
JsonElement? jsonElement;
const string ticks = "Ticks";
JsonProperty[] jsonProperties;
List<string> files = GetFiles(headerCommon, "*.json");
foreach (string file in files)
{ {
string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IExportRepository.GetHeaders)}.json")); json = File.ReadAllText(file);
result = JsonSerializer.Deserialize<Result<HeaderCommon[]>>(json); hc = JsonSerializer.Deserialize<HeaderCommon>(json);
if (result is null) if (hc is null)
throw new NullReferenceException(nameof(result)); continue;
} if (hc.ID < 1)
else
{
List<HeaderCommon> results = new();
string json;
HeaderCommon? hc;
List<string> files = GetFiles(headerCommon, "*.json");
foreach (string file in files)
{ {
json = File.ReadAllText(file); directory = Path.GetDirectoryName(file);
hc = JsonSerializer.Deserialize<HeaderCommon>(json); if (directory is null)
if (hc is null)
continue; continue;
results.Add(hc); directoryName = Path.GetFileName(directory);
if (directoryName.Length < 1 || directoryName[0] != '-' || !long.TryParse(directoryName[1..], out long id))
continue;
hc.ID = id;
} }
result = new() jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
if (jsonElement is not null && jsonElement.Value.ValueKind == JsonValueKind.Object)
{ {
Results = results.ToArray(), jsonProperties = (from l in jsonElement.Value.EnumerateObject() where l.Name == ticks select l).ToArray();
TotalRows = results.Count, if (jsonProperties.Any() && long.TryParse(jsonProperties[0].Value.ToString(), out long ticksValue))
}; hc.Date = new(ticksValue);
}
results.Add(hc);
} }
result = new()
{
Results = results.ToArray(),
TotalRows = results.Count,
};
return result; return result;
} }
Result<HeaderCommon[]> IExportRepository.GetLogistics(HeaderCommon headerCommon) Result<HeaderCommon[]> IExportRepository.GetLogistics(HeaderCommon headerCommon)
{ {
Result<HeaderCommon[]>? result; Result<HeaderCommon[]>? result;
if (!string.IsNullOrEmpty(_MockRoot)) List<HeaderCommon> results = new();
string json;
HeaderCommon? hc;
List<string> files = GetFiles(headerCommon, "*.json");
foreach (string file in files)
{ {
string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IExportRepository.GetLogistics)}.json")); json = File.ReadAllText(file);
result = JsonSerializer.Deserialize<Result<HeaderCommon[]>>(json); hc = JsonSerializer.Deserialize<HeaderCommon>(json);
if (result is null) if (hc is null)
throw new NullReferenceException(nameof(result)); continue;
results.Add(hc);
} }
else result = new()
{ {
List<HeaderCommon> results = new(); Results = results.ToArray(),
string json; TotalRows = results.Count,
HeaderCommon? hc; };
List<string> files = GetFiles(headerCommon, "*.json");
foreach (string file in files)
{
json = File.ReadAllText(file);
hc = JsonSerializer.Deserialize<HeaderCommon>(json);
if (hc is null)
continue;
results.Add(hc);
}
result = new()
{
Results = results.ToArray(),
TotalRows = results.Count,
};
}
return result; return result;
} }
string IExportRepository.GetProcessDataStandardFormat(HeaderCommon headerCommon) string IExportRepository.GetProcessDataStandardFormat(HeaderCommon headerCommon)
{ {
string result; string result;
if (!string.IsNullOrEmpty(_MockRoot)) List<string> files = GetFiles(headerCommon, "*.pdsf");
result = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IExportRepository.GetProcessDataStandardFormat)}.pdsf")); if (files.Count != 1)
result = string.Empty;
else else
{ result = File.ReadAllText(files.First());
List<string> files = GetFiles(headerCommon, "*.pdsf");
if (files.Count != 1)
result = string.Empty;
else
result = File.ReadAllText(files.First());
}
return result; return result;
} }

View File

@ -177,6 +177,39 @@ public class InfinityQSRepository : IInfinityQSRepository
return result; return result;
} }
string IInfinityQSRepository.GetCommandText(InfinityQSBase infinityQSBase)
{
StringBuilder result = new();
if (string.IsNullOrEmpty(infinityQSBase.PR_NAME))
throw new ArgumentException(nameof(infinityQSBase.PR_NAME));
if (string.IsNullOrEmpty(infinityQSBase.PD_NAME))
throw new ArgumentException(nameof(infinityQSBase.PD_NAME));
if (infinityQSBase.SE_SGTM is null)
throw new ArgumentException(nameof(infinityQSBase.SE_SGTM));
_ = result
.AppendLine(" select ")
.AppendLine(" ev.f_evnt [ev_evnt], ")
.AppendLine(" ev.f_sgtm [ev_sgtm], ")
.AppendLine(" dateadd(HH, -7, (dateadd(SS, convert(bigint, ev.f_sgtm), '19700101'))) [ev_utc7], ")
.AppendLine(" pr.f_name [pr_name], ")
.AppendLine(" pd.f_name [pd_name], ")
.AppendLine(" td.f_test [td_test], ")
.AppendLine(" td.f_name [td_name], ")
.AppendLine(" ev.f_name [ev_name] ")
.AppendLine(" from [spcepiworld].[dbo].[evnt_inf] ev ")
.AppendLine(" join [spcepiworld].[dbo].[prcs_dat] pr ")
.AppendLine(" on ev.f_prcs = pr.f_prcs ")
.AppendLine(" join [spcepiworld].[dbo].[part_dat] pd ")
.AppendLine(" on ev.f_part = pd.f_part ")
.AppendLine(" join [spcepiworld].[dbo].[test_dat] td ")
.AppendLine(" on ev.f_test = td.f_test ")
.Append(" where pr.f_name = '").Append(infinityQSBase.PR_NAME).AppendLine("' ")
.Append(" and pd.f_name = '").Append(infinityQSBase.PD_NAME).AppendLine("' ")
.Append(" and ev.f_sgtm = ").Append(infinityQSBase.SE_SGTM).AppendLine(" ")
.AppendLine(" for json path ");
return result.ToString();
}
Result<InfinityQSEvent[]> IInfinityQSRepository.GetEvents(string subGroupId) Result<InfinityQSEvent[]> IInfinityQSRepository.GetEvents(string subGroupId)
{ {
Result<InfinityQSEvent[]>? result; Result<InfinityQSEvent[]>? result;
@ -196,7 +229,7 @@ public class InfinityQSRepository : IInfinityQSRepository
results = Array.Empty<InfinityQSEvent>(); results = Array.Empty<InfinityQSEvent>();
else else
{ {
string commandText = $"select * from [spcepiworld].[dbo].[evnt_inf] ev where ev.f_prcs = '{infinityQSBase.PR_NAME}' and ev.f_part = '{infinityQSBase.PD_NAME}' and ev.f_sgtm = {infinityQSBase.SE_SGTM} "; string commandText = infinityQSRepository.GetCommandText(infinityQSBase);
StringBuilder stringBuilder = GetForJsonPath(_DBConnectionFactory, commandText); StringBuilder stringBuilder = GetForJsonPath(_DBConnectionFactory, commandText);
results = JsonSerializer.Deserialize<InfinityQSEvent[]>(stringBuilder.ToString(), new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); results = JsonSerializer.Deserialize<InfinityQSEvent[]>(stringBuilder.ToString(), new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
if (results is null) if (results is null)

View File

@ -26,7 +26,7 @@ public class InfinityQSV2Repository : IInfinityQSV2Repository
{ {
StringBuilder result = new(); StringBuilder result = new();
if (string.IsNullOrEmpty(subGroupId)) if (string.IsNullOrEmpty(subGroupId))
throw new ArgumentException(nameof(subGroupId)); throw new ArgumentException(null, nameof(subGroupId));
_ = result _ = result
.AppendLine(" select ") .AppendLine(" select ")
.AppendLine(" sd.f_sgrp sd_sgrp, ") .AppendLine(" sd.f_sgrp sd_sgrp, ")
@ -50,7 +50,7 @@ public class InfinityQSV2Repository : IInfinityQSV2Repository
StringBuilder result = new(); StringBuilder result = new();
const string dateTimeFormat = "yyyy-MM-dd HH:mm:ss"; const string dateTimeFormat = "yyyy-MM-dd HH:mm:ss";
if (!string.IsNullOrEmpty(dateTime) && (dateTime.Contains('-') || dateTime.Contains(' ') || dateTime.Contains(':')) && dateTime.Length != dateTimeFormat.Length) if (!string.IsNullOrEmpty(dateTime) && (dateTime.Contains('-') || dateTime.Contains(' ') || dateTime.Contains(':')) && dateTime.Length != dateTimeFormat.Length)
throw new ArgumentException(nameof(dateTime)); throw new ArgumentException(null, nameof(dateTime));
_ = result _ = result
.AppendLine(" select ") .AppendLine(" select ")
.AppendLine(" se.f_sgrp se_sgrp, ") .AppendLine(" se.f_sgrp se_sgrp, ")
@ -180,6 +180,39 @@ public class InfinityQSV2Repository : IInfinityQSV2Repository
return result; return result;
} }
string IInfinityQSV2Repository.GetCommandText(InfinityQSBaseV2 infinityQSBase)
{
StringBuilder result = new();
if (string.IsNullOrEmpty(infinityQSBase.Process))
throw new ArgumentException(nameof(infinityQSBase.Process));
if (string.IsNullOrEmpty(infinityQSBase.Part))
throw new ArgumentException(nameof(infinityQSBase.Part));
if (infinityQSBase.SubGroupDateTime is null)
throw new ArgumentException(nameof(infinityQSBase.SubGroupDateTime));
_ = result
.AppendLine(" select ")
.AppendLine(" ev.f_evnt [ev_evnt], ")
.AppendLine(" ev.f_sgtm [ev_sgtm], ")
.AppendLine(" dateadd(HH, -7, (dateadd(SS, convert(bigint, ev.f_sgtm), '19700101'))) [ev_utc7], ")
.AppendLine(" pr.f_name [pr_name], ")
.AppendLine(" pd.f_name [pd_name], ")
.AppendLine(" td.f_test [td_test], ")
.AppendLine(" td.f_name [td_name], ")
.AppendLine(" ev.f_name [ev_name] ")
.AppendLine(" from [spcepiworld].[dbo].[evnt_inf] ev ")
.AppendLine(" join [spcepiworld].[dbo].[prcs_dat] pr ")
.AppendLine(" on ev.f_prcs = pr.f_prcs ")
.AppendLine(" join [spcepiworld].[dbo].[part_dat] pd ")
.AppendLine(" on ev.f_part = pd.f_part ")
.AppendLine(" join [spcepiworld].[dbo].[test_dat] td ")
.AppendLine(" on ev.f_test = td.f_test ")
.Append(" where pr.f_name = '").Append(infinityQSBase.Process).AppendLine("' ")
.Append(" and pd.f_name = '").Append(infinityQSBase.Part).AppendLine("' ")
.Append(" and ev.f_sgtm = ").Append(infinityQSBase.SubGroupDateTime).AppendLine(" ")
.AppendLine(" for json path ");
return result.ToString();
}
Result<InfinityQSEventV2[]> IInfinityQSV2Repository.GetEvents(string subGroupId) Result<InfinityQSEventV2[]> IInfinityQSV2Repository.GetEvents(string subGroupId)
{ {
Result<InfinityQSEventV2[]>? result; Result<InfinityQSEventV2[]>? result;
@ -199,7 +232,7 @@ public class InfinityQSV2Repository : IInfinityQSV2Repository
collection = Array.Empty<InfinityQSEvent>(); collection = Array.Empty<InfinityQSEvent>();
else else
{ {
string commandText = $"select * from [spcepiworld].[dbo].[evnt_inf] ev where ev.f_prcs = '{infinityQSBase.Process}' and ev.f_part = '{infinityQSBase.Part}' and ev.f_sgtm = {infinityQSBase.SubGroupDateTime} "; string commandText = infinityQSV2Repository.GetCommandText(infinityQSBase);
StringBuilder stringBuilder = GetForJsonPath(_DBConnectionFactory, commandText); StringBuilder stringBuilder = GetForJsonPath(_DBConnectionFactory, commandText);
collection = JsonSerializer.Deserialize<InfinityQSEvent[]>(stringBuilder.ToString(), new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); collection = JsonSerializer.Deserialize<InfinityQSEvent[]>(stringBuilder.ToString(), new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
if (collection is null) if (collection is null)

View File

@ -492,7 +492,7 @@ function recipeParametersButtonRunInfo() {
var gridCreated = $("#ModalBodyGrid").data("igGrid"); var gridCreated = $("#ModalBodyGrid").data("igGrid");
if (gridCreated) if (gridCreated)
$("#ModalBodyGrid").igGrid("destroy"); $("#ModalBodyGrid").igGrid("destroy");
$.getJSON('http://messa020ec.ec.local/api/oiWizard/materials/rds/' + jsonObject.RDS, function (data) { $.getJSON('https://oi-prod-ec-api.mes.infineon.com/api/oiWizard/materials/rds/' + jsonObject.RDS, function (data) {
$("#RecipeParametersButton").prop("disabled", false); $("#RecipeParametersButton").prop("disabled", false);
var text = ""; var text = "";
for (var i = 0; i < data.rds.rdsLayers.length; i++) { for (var i = 0; i < data.rds.rdsLayers.length; i++) {

View File

@ -1,27 +1,13 @@
namespace OI.Metrology.Shared.DataModels; namespace OI.Metrology.Shared.DataModels;
public record InfinityQSEvent(int F_EVNT, public record InfinityQSEvent(int EV_EVNT,
int F_CRTM, int EV_SGTM,
int F_EDTM, string EV_UTC7,
int F_TYPE, string PR_NAME,
string F_NAME, string PD_NAME,
int F_EMPL, int TD_TEST,
int F_EVTM, string TD_NAME,
int F_PRCS, string EV_NAME)
int F_PART,
int F_TEST,
int F_SGTM,
int F_ACC,
int F_ACEM,
int F_ACTM,
int F_CAC,
int F_CAEM,
int F_CATM,
int F_FLAG,
int F_USER,
int F_DSBL,
int F_RFC,
int F_TRTM)
{ {
public static InfinityQSEventV2[] Convert(InfinityQSEvent[] collection) public static InfinityQSEventV2[] Convert(InfinityQSEvent[] collection)
@ -34,53 +20,25 @@ public record InfinityQSEvent(int F_EVNT,
public static InfinityQSEventV2 Map(InfinityQSEvent item) public static InfinityQSEventV2 Map(InfinityQSEvent item)
{ {
InfinityQSEventV2 result = new(item.F_EVNT, InfinityQSEventV2 result = new(item.EV_EVNT,
item.F_CRTM, item.EV_SGTM,
item.F_EDTM, item.EV_UTC7,
item.F_TYPE, item.PR_NAME,
item.F_NAME, item.PD_NAME,
item.F_EMPL, item.TD_TEST,
item.F_EVTM, item.TD_NAME,
item.F_PRCS, item.EV_NAME);
item.F_PART,
item.F_TEST,
item.F_SGTM,
item.F_ACC,
item.F_ACEM,
item.F_ACTM,
item.F_CAC,
item.F_CAEM,
item.F_CATM,
item.F_FLAG,
item.F_USER,
item.F_DSBL,
item.F_RFC,
item.F_TRTM);
return result; return result;
} }
} }
public record InfinityQSEventV2(int Evnt, public record InfinityQSEventV2(int EventId,
int Crtm, int SubGroupDateTimeId,
int Edtm, string SubGroupDateTime,
int Type, string Process,
string Name, string Part,
int Empl, int VariableNumber,
int Evtm, string Variable,
int Prcs, string Name)
int Part,
int Test,
int Sgtm,
int Acc,
int Acem,
int Actm,
int Cac,
int Caem,
int Catm,
int Flag,
int User,
int Dsbl,
int Rfc,
int Trtm)
{ } { }

View File

@ -1,5 +1,3 @@
using OI.Metrology.Shared.DataModels;
namespace OI.Metrology.Shared.Models.Stateless; namespace OI.Metrology.Shared.Models.Stateless;
public interface IExportController<T> public interface IExportController<T>
@ -14,9 +12,13 @@ public interface IExportController<T>
} }
static string GetRouteName() => nameof(IExportController<T>)[1..^10]; static string GetRouteName() => nameof(IExportController<T>)[1..^10];
T GetExport(HeaderCommon headerCommon); T GetExport();
T GetHeaders(HeaderCommon headerCommon); T GetHeaders();
T GetLogistics(HeaderCommon headerCommon); T GetLogistics();
T GetProcessDataStandardFormat(HeaderCommon headerCommon); T GetProcessDataStandardFormat();
T PostExport();
T PostHeaders();
T PostLogistics();
T PostProcessDataStandardFormat();
} }

View File

@ -1,5 +1,3 @@
using Newtonsoft.Json.Linq;
namespace OI.Metrology.Shared.Models.Stateless; namespace OI.Metrology.Shared.Models.Stateless;
public interface IInboundController<T> public interface IInboundController<T>
@ -11,7 +9,7 @@ public interface IInboundController<T>
} }
static string GetRouteName() => nameof(IInboundController<T>)[1..^10]; static string GetRouteName() => nameof(IInboundController<T>)[1..^10];
T Post(string tooltype, JToken jsonbody); T Post(string tooltype);
T AttachFile(string tooltype, long headerid, string datauniqueid = ""); T AttachFile(string tooltype, long headerid, string datauniqueid = "");
} }

View File

@ -6,6 +6,7 @@ public interface IInfinityQSRepository
{ {
string GetCommandText(string subGroupId); string GetCommandText(string subGroupId);
string GetCommandText(InfinityQSBase infinityQSBase);
string GetCommandText(string? subGroupId, string? process, string? job, string? part, string? lot, string? dateTime); string GetCommandText(string? subGroupId, string? process, string? job, string? part, string? lot, string? dateTime);
Result<InfinityQSBase[]> GetData(string subGroupId); Result<InfinityQSBase[]> GetData(string subGroupId);
Result<InfinityQSDescriptor[]> GetDescriptors(string subGroupId); Result<InfinityQSDescriptor[]> GetDescriptors(string subGroupId);

View File

@ -6,6 +6,7 @@ public interface IInfinityQSV2Repository
{ {
string GetCommandText(string subGroupId); string GetCommandText(string subGroupId);
string GetCommandText(InfinityQSBaseV2 infinityQSBase);
string GetCommandText(string? subGroupId, string? process, string? job, string? part, string? lot, string? dateTime); string GetCommandText(string? subGroupId, string? process, string? job, string? part, string? lot, string? dateTime);
Result<InfinityQSBaseV2[]> GetData(string subGroupId); Result<InfinityQSBaseV2[]> GetData(string subGroupId);
Result<InfinityQSDescriptorV2[]> GetDescriptors(string subGroupId); Result<InfinityQSDescriptorV2[]> GetDescriptors(string subGroupId);

View File

@ -30,8 +30,8 @@
<DefineConstants>Linux</DefineConstants> <DefineConstants>Linux</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="System.Text.Json" Version="7.0.1" /> <PackageReference Include="System.Text.Json" Version="7.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -31,9 +31,9 @@
<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" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.1" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" /> <PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" /> <PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" /> <PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />

View File

@ -29,12 +29,20 @@ public class UnitTestAppSettingsController
_ControllerName = nameof(Server.ApiControllers.AppSettingsController)[..^10]; _ControllerName = nameof(Server.ApiControllers.AppSettingsController)[..^10];
} }
private static void NonThrowTryCatch()
{
try
{ throw new Exception(); }
catch (Exception) { }
}
[TestMethod] [TestMethod]
public void TestControllerName() public void TestControllerName()
{ {
_Logger.Information("Starting Web Application"); _Logger.Information("Starting Web Application");
Assert.AreEqual(IAppSettingsController<object>.GetRouteName(), _ControllerName); Assert.AreEqual(IAppSettingsController<object>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
@ -45,6 +53,7 @@ public class UnitTestAppSettingsController
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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
@ -55,6 +64,7 @@ public class UnitTestAppSettingsController
AppSettings appSettings = serviceProvider.GetRequiredService<AppSettings>(); AppSettings appSettings = serviceProvider.GetRequiredService<AppSettings>();
Assert.IsNotNull(appSettings); Assert.IsNotNull(appSettings);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
@ -66,6 +76,7 @@ public class UnitTestAppSettingsController
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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
@ -82,6 +93,7 @@ public class UnitTestAppSettingsController
Assert.IsNotNull(json); Assert.IsNotNull(json);
Assert.IsTrue(json != "[]"); Assert.IsTrue(json != "[]");
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
@ -93,6 +105,7 @@ public class UnitTestAppSettingsController
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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
@ -108,6 +121,7 @@ public class UnitTestAppSettingsController
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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
} }

View File

@ -54,8 +54,8 @@ public class UnitTestClientSettingsController
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application"); _Logger.Information("Starting Web Application");
string actionName = nameof(IClientSettingsController<object>.Action.Client);
#if DEBUG #if DEBUG
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);
Assert.AreEqual("application/json; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString()); Assert.AreEqual("application/json; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString());

View File

@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
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 Serilog;
using System.Text;
namespace OI.Metrology.Tests; namespace OI.Metrology.Tests;
@ -28,16 +29,27 @@ public class UnitTestExportController
_ControllerName = nameof(Server.ApiControllers.ExportController)[..^10]; _ControllerName = nameof(Server.ApiControllers.ExportController)[..^10];
} }
private static void NonThrowTryCatch()
{
try
{ throw new Exception(); }
catch (Exception) { }
}
[TestMethod] [TestMethod]
public void TestControllerName() public void TestControllerName()
{ {
_Logger.Information("Starting Web Application"); _Logger.Information("Starting Web Application");
Assert.AreEqual(IExportController<string>.GetRouteName(), _ControllerName); Assert.AreEqual(IExportController<string>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
private static HeaderCommon GetHeaderCommon() => private static HeaderCommon GetHeaderCommon() =>
new() { PSN = "5008", Reactor = "39", RDS = "578918", ID = 1 }; new() { PSN = "5008", Reactor = "61", RDS = "579487", ID = 1678209360 };
private static StringContent GetStringContent() =>
new(System.Text.Json.JsonSerializer.Serialize(GetHeaderCommon()), Encoding.UTF8, "application/json");
[TestMethod] [TestMethod]
public void GetExport() public void GetExport()
@ -48,6 +60,7 @@ public class UnitTestExportController
string result = exportRepository.GetExport(GetHeaderCommon()); string result = exportRepository.GetExport(GetHeaderCommon());
Assert.IsNotNull(result); Assert.IsNotNull(result);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
@ -55,10 +68,22 @@ public class UnitTestExportController
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application"); _Logger.Information("Starting Web Application");
string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/headers"); 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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
}
[TestMethod]
public async Task PostExportApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/export", GetStringContent());
Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK);
_Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
@ -70,6 +95,7 @@ public class UnitTestExportController
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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
@ -82,6 +108,18 @@ public class UnitTestExportController
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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
}
[TestMethod]
public async Task PostHeadersApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/headers", GetStringContent());
Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK);
_Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
@ -93,6 +131,7 @@ public class UnitTestExportController
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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
@ -100,11 +139,23 @@ public class UnitTestExportController
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application"); _Logger.Information("Starting Web Application");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/headers"); 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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
}
[TestMethod]
public async Task PostLogisticsApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/logistics", GetStringContent());
Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK);
_Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
@ -116,6 +167,7 @@ public class UnitTestExportController
string result = exportRepository.GetProcessDataStandardFormat(GetHeaderCommon()); string result = exportRepository.GetProcessDataStandardFormat(GetHeaderCommon());
Assert.IsNotNull(result); Assert.IsNotNull(result);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
@ -123,10 +175,22 @@ public class UnitTestExportController
{ {
HttpClient httpClient = _WebApplicationFactory.CreateClient(); HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application"); _Logger.Information("Starting Web Application");
string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/headers"); 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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
}
[TestMethod]
public async Task PostProcessDataStandardFormatApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/processDataStandardFormat", GetStringContent());
Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK);
_Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
} }

View File

@ -28,14 +28,25 @@ public class UnitTestInfinityQSController
_ControllerName = nameof(Server.ApiControllers.InfinityQSController)[..^10]; _ControllerName = nameof(Server.ApiControllers.InfinityQSController)[..^10];
} }
private static void NonThrowTryCatch()
{
try
{ throw new Exception(); }
catch (Exception) { }
}
[TestMethod] [TestMethod]
public void TestControllerName() public void TestControllerName()
{ {
_Logger.Information("Starting Web Application"); _Logger.Information("Starting Web Application");
Assert.AreEqual(IInfinityQSController<string>.GetRouteName(), _ControllerName); Assert.AreEqual(IInfinityQSController<string>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public void GetCommandText() public void GetCommandText()
{ {
@ -45,8 +56,12 @@ public class UnitTestInfinityQSController
string result = infinityQSRepository.GetCommandText("1677273357", "61", "CDE5", "5012", "575908", ""); string result = infinityQSRepository.GetCommandText("1677273357", "61", "CDE5", "5012", "575908", "");
Assert.IsNotNull(result); Assert.IsNotNull(result);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public async Task GetCommandTextApi() public async Task GetCommandTextApi()
{ {
@ -56,8 +71,12 @@ public class UnitTestInfinityQSController
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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public void GetData() public void GetData()
{ {
@ -73,8 +92,12 @@ public class UnitTestInfinityQSController
Assert.IsNotNull(result?.Results[0].TD_NAME); Assert.IsNotNull(result?.Results[0].TD_NAME);
Assert.IsNotNull(result?.Results[0].TD_TEST); Assert.IsNotNull(result?.Results[0].TD_TEST);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public async Task GetDataApi() public async Task GetDataApi()
{ {
@ -86,8 +109,12 @@ public class UnitTestInfinityQSController
Result<InfinityQSBase[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSBase[]>>(json); Result<InfinityQSBase[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSBase[]>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public void GetDescriptors() public void GetDescriptors()
{ {
@ -100,8 +127,12 @@ public class UnitTestInfinityQSController
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");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public async Task GetDescriptorsApi() public async Task GetDescriptorsApi()
{ {
@ -113,8 +144,12 @@ public class UnitTestInfinityQSController
Result<InfinityQSDescriptor[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSDescriptor[]>>(json); Result<InfinityQSDescriptor[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSDescriptor[]>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public void GetEvents() public void GetEvents()
{ {
@ -124,8 +159,12 @@ public class UnitTestInfinityQSController
Result<InfinityQSEvent[]> result = infinityQSRepository.GetEvents("1677273357"); Result<InfinityQSEvent[]> result = infinityQSRepository.GetEvents("1677273357");
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public async Task GetEventsApi() public async Task GetEventsApi()
{ {
@ -136,8 +175,12 @@ public class UnitTestInfinityQSController
Result<InfinityQSEvent[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSEvent[]>>(json); Result<InfinityQSEvent[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSEvent[]>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public void GetHeader() public void GetHeader()
{ {
@ -147,8 +190,12 @@ public class UnitTestInfinityQSController
Result<InfinityQSBase[]> result = infinityQSRepository.GetHeader("1677273357"); Result<InfinityQSBase[]> result = infinityQSRepository.GetHeader("1677273357");
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public async Task GetHeaderApi() public async Task GetHeaderApi()
{ {
@ -159,6 +206,7 @@ public class UnitTestInfinityQSController
Result<InfinityQSBase[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSBase[]>>(json); Result<InfinityQSBase[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSBase[]>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
} }

View File

@ -28,12 +28,20 @@ public class UnitTestInfinityQSV2Controller
_ControllerName = nameof(Server.ApiControllers.InfinityQSV2Controller)[..^10]; _ControllerName = nameof(Server.ApiControllers.InfinityQSV2Controller)[..^10];
} }
private static void NonThrowTryCatch()
{
try
{ throw new Exception(); }
catch (Exception) { }
}
[TestMethod] [TestMethod]
public void TestControllerName() public void TestControllerName()
{ {
_Logger.Information("Starting Web Application"); _Logger.Information("Starting Web Application");
Assert.AreEqual(IInfinityQSV2Controller<string>.GetRouteName(), _ControllerName); Assert.AreEqual(IInfinityQSV2Controller<string>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
[TestMethod] [TestMethod]
@ -45,8 +53,12 @@ public class UnitTestInfinityQSV2Controller
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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public async Task GetCommandTextApi() public async Task GetCommandTextApi()
{ {
@ -56,8 +68,12 @@ public class UnitTestInfinityQSV2Controller
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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public void GetData() public void GetData()
{ {
@ -73,8 +89,12 @@ public class UnitTestInfinityQSV2Controller
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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public async Task GetDataApi() public async Task GetDataApi()
{ {
@ -86,8 +106,12 @@ public class UnitTestInfinityQSV2Controller
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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public void GetDescriptors() public void GetDescriptors()
{ {
@ -100,8 +124,12 @@ public class UnitTestInfinityQSV2Controller
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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public async Task GetDescriptorsApi() public async Task GetDescriptorsApi()
{ {
@ -113,8 +141,12 @@ public class UnitTestInfinityQSV2Controller
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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public void GetEvents() public void GetEvents()
{ {
@ -124,8 +156,12 @@ public class UnitTestInfinityQSV2Controller
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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public async Task GetEventsApi() public async Task GetEventsApi()
{ {
@ -136,8 +172,12 @@ public class UnitTestInfinityQSV2Controller
Result<InfinityQSEvent[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSEvent[]>>(json); Result<InfinityQSEvent[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSEvent[]>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public void GetHeader() public void GetHeader()
{ {
@ -147,8 +187,12 @@ public class UnitTestInfinityQSV2Controller
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"); _Logger.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
#if !DEBUG
[Ignore]
#endif
[TestMethod] [TestMethod]
public async Task GetHeaderApi() public async Task GetHeaderApi()
{ {
@ -159,6 +203,7 @@ public class UnitTestInfinityQSV2Controller
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.Information($"{_TestContext?.TestName} completed");
NonThrowTryCatch();
} }
} }

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Razor"> <Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks> <TargetFrameworks>net7.0</TargetFrameworks>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
@ -8,14 +8,14 @@
<SupportedPlatform Include="browser" /> <SupportedPlatform Include="browser" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="MudBlazor" Version="6.1.8" /> <PackageReference Include="MudBlazor" Version="6.1.9" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.2" /> <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.4" />
<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="1.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.0" /> <PackageReference Include="System.Net.Http.Json" Version="7.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Shared\OI.Metrology.Shared.csproj" /> <ProjectReference Include="..\Shared\OI.Metrology.Shared.csproj" />

View File

@ -15,16 +15,23 @@ trigger:
- "ClientHub/*" - "ClientHub/*"
pool: pool:
name: Mesa-IIS name: Mesa-Windows-Service
demands: OI-Metrology-Server-Development demands: OI-Metrology-Server-Development
variables: variables:
# solution: '**/*.sln' # solution: '**/*.sln'
# buildPlatform: 'Any CPU' # buildPlatform: 'Any CPU'
buildConfiguration: 'Debug' buildConfiguration: "Debug"
ASPNETCORE_ENVIRONMENT: 'Development' ASPNETCORE_ENVIRONMENT: "Development"
steps: steps:
- script: |
set exeName=OI.Metrology.Server
echo %exeName%
echo ##vso[task.setvariable variable=ExeName;]%exeName%
echo $(ExeName)
displayName: ExeName
- script: | - script: |
set coreVersion=net7.0 set coreVersion=net7.0
echo %coreVersion% echo %coreVersion%
@ -79,13 +86,28 @@ steps:
workingDirectory: Server workingDirectory: Server
displayName: "Safe storage of app secrets - Server" displayName: "Safe storage of app secrets - Server"
- script: |
"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 "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 "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 "Oi2SqlConnectionString" "Data Source=MESSAD1001\TEST1,59583;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;"
workingDirectory: Server
displayName: "Safe storage of app secrets II - Server"
- script: '"C:\program files\dotnet\dotnet.exe" build --configuration $(Configuration) --source $(NugetSource)'
workingDirectory: 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
@ -110,6 +132,14 @@ steps:
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
displayName: "Publish Test Results **/coverage.cobertura.xml"
inputs:
testResultsFormat: VSTest
testResultsFiles: "**/coverage.cobertura.xml"
testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)"
searchFolder: "$(System.DefaultWorkingDirectory)/.vscode"
- task: mspremier.CreateWorkItem.CreateWorkItem-task.CreateWorkItem@1 - task: mspremier.CreateWorkItem.CreateWorkItem-task.CreateWorkItem@1
displayName: "Create work item" displayName: "Create work item"
inputs: inputs:
@ -129,16 +159,69 @@ steps:
SourceFolder: '$(Build.ArtifactStagingDirectory)\Server' SourceFolder: '$(Build.ArtifactStagingDirectory)\Server'
TargetFolder: 'D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server' TargetFolder: 'D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server'
- script: 'sc stop "$(Build.Repository.Name)-$(Configuration)"'
workingDirectory: Server
displayName: "Service Control - Stop"
continueOnError: true
- script: 'sc delete "$(Build.Repository.Name)-$(Configuration)"'
workingDirectory: Server
displayName: "Service Control - Delete"
continueOnError: true
- task: DownloadSecureFile@1
name: downloadSecureFileKDBX
displayName: "Download secure file"
inputs:
secureFile: "Infineon-NA.kdbx"
- script: echo "<$(downloadSecureFileKDBX.secureFilePath)>"
displayName: "Echo Path"
- powershell: |
$data = @('$(downloadSecureFileKDBX.secureFilePath)', '-c:GetEntryString', '-Field:Password', '-refx-UUID:A6302662940458499454E35D28FCC9F7', '-pw-enc:AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAtBhT01pNnUGaN/uPLxZGvAAAAAACAAAAAAADZgAAwAAAABAAAAAM4xlYguhv7jzchU8dq9pVAAAAAASAAACgAAAAEAAAANS9rIoaYfNq5TwCmTrqElsgAAAA7O4J52FqCctXlCxYB2J5b/W4T+pZCN2zwFj7XCAFW6IUAAAAhQsBDOERAUZJdtSy8AfxwOAZflo=')
$data.count
$processStartInfo = New-Object System.Diagnostics.ProcessStartInfo
$processStartInfo.FileName = "C:\Users\meseafsvc\AppData\Local\IFXApps\KeePass-2.51.1---KPScript-2.51.1\KPScript.exe"
$processStartInfo.RedirectStandardError = $true
$processStartInfo.RedirectStandardOutput = $true
$processStartInfo.UseShellExecute = $false
$processStartInfo.Arguments = $data
$process = New-Object System.Diagnostics.Process
$process.StartInfo = $processStartInfo
$process.Start() | Out-Null
$process.WaitForExit()
$stdout = $process.StandardOutput.ReadToEnd()
$stderr = $process.StandardError.ReadToEnd()
Write-Host "stderr: $stderr"
Write-Host "exit code: " + $process.ExitCode
Write-Host "##vso[task.setvariable variable=pipelinePassword;]$stdout"
displayName: pipelinePassword
- script: 'sc create "$(Build.Repository.Name)-$(Configuration)" start= delayed-auto DisplayName= "$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)" binPath= D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server\$(ExeName).exe obj= INFINEON\meseafsvc password="$(pipelinePassword)"'
workingDirectory: Server
displayName: "Service Control - Create"
- script: 'sc start "$(Build.Repository.Name)-$(Configuration)"'
workingDirectory: Server
displayName: "Service Control - Start"
- task: PublishBuildArtifacts@1 - task: PublishBuildArtifacts@1
displayName: "Publish Artifact: drop" displayName: "Publish Artifact: drop"
enabled: false enabled: false
- script: | - script: '"C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration)'
"C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration)
workingDirectory: Tests workingDirectory: Tests
displayName: "Core Clean - Tests" displayName: "Core Clean - Tests"
- script: | - script: '"C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration)'
"C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration)
workingDirectory: Server workingDirectory: Server
displayName: "Core Clean - Server" displayName: "Core Clean - Server"
- script: '"C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration)'
workingDirectory: Server
displayName: "Core Clean - Server"
- script: 'echo $(Build.SourceVersion)-$(Build.BuildId)>bin_x_x_\Debug\$(CoreVersion)\win-x64\$(Build.Repository.Name).txt'
workingDirectory: "EAF Viewer"
displayName: "Force Fail"

View File

@ -110,6 +110,14 @@ steps:
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
displayName: "Publish Test Results **/coverage.cobertura.xml"
inputs:
testResultsFormat: VSTest
testResultsFiles: "**/coverage.cobertura.xml"
testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)"
searchFolder: "$(System.DefaultWorkingDirectory)/.vscode"
- task: mspremier.CreateWorkItem.CreateWorkItem-task.CreateWorkItem@1 - task: mspremier.CreateWorkItem.CreateWorkItem-task.CreateWorkItem@1
displayName: "Create work item" displayName: "Create work item"
inputs: inputs: