PDSF (Process Data Standard Format) to use EAF for
pushing to OI
This commit is contained in:
parent
6668806432
commit
4cc5219409
28
.kanbn/board.css
Normal file
28
.kanbn/board.css
Normal file
@ -0,0 +1,28 @@
|
||||
.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;
|
||||
}
|
19
.kanbn/index.md
Normal file
19
.kanbn/index.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
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
|
16
.kanbn/tasks/change-eaf-to-save-and-info-pdsf.md
Normal file
16
.kanbn/tasks/change-eaf-to-save-and-info-pdsf.md
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
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~~
|
30
.vscode/tasks.json
vendored
30
.vscode/tasks.json
vendored
@ -1,13 +1,8 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"options": {
|
||||
"env": {
|
||||
"serverUserSecretsId": "6501aa0f-8499-4be5-96a9-e99b11323eeb"
|
||||
}
|
||||
},
|
||||
"tasks": [
|
||||
{
|
||||
"label": "userSecretsInit",
|
||||
"label": "User Secrets Init",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
@ -19,7 +14,7 @@
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "userSecretsSet",
|
||||
"label": "User Secrets Set",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
@ -32,19 +27,6 @@
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "userSecretsMkLink",
|
||||
"command": "cmd",
|
||||
"type": "shell",
|
||||
"args": [
|
||||
"/c",
|
||||
"mklink",
|
||||
"/J",
|
||||
".vscode\\UserSecrets",
|
||||
"${userHome}\\AppData\\Roaming\\Microsoft\\UserSecrets\\$env:serverUserSecretsId"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "buildServer",
|
||||
"command": "dotnet",
|
||||
@ -94,7 +76,7 @@
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "format",
|
||||
"label": "Format",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
@ -211,6 +193,12 @@
|
||||
"endsPattern": "^.*Application started.*"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "File-Folder-Helper AOT s M Self .Kanbn Tasks",
|
||||
"type": "shell",
|
||||
"command": "& L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net7.0/win-x64/publish/File-Folder-Helper.exe s M '.kanbn/tasks'",
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
@ -27,13 +27,13 @@
|
||||
<Content Remove="compilerconfig.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" Version="2.0.123" />
|
||||
<PackageReference Include="Dapper" Version="2.0.143" />
|
||||
<PackageReference Include="EntityFramework" Version="6.4.4" />
|
||||
<PackageReference Include="jQuery" Version="3.6.4" />
|
||||
<PackageReference Include="jQuery" Version="3.7.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" 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.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00032" />
|
||||
|
@ -308,13 +308,9 @@ public class MetrologyRepository : IMetrologyRepository
|
||||
|
||||
public DataTable GetHeaders(int toolTypeId, DateTime? startTime, DateTime? endTime, int? pageNo, int? pageSize, long? headerId, out long totalRecords)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
ToolType tt = GetToolTypeByID(toolTypeId) ?? throw new Exception("Invalid tool type ID");
|
||||
|
||||
IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId);
|
||||
if (md is null)
|
||||
throw new Exception("Invalid tool type metadata");
|
||||
IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId) ?? throw new Exception("Invalid tool type metadata");
|
||||
|
||||
DataTable dt = new();
|
||||
|
||||
@ -404,13 +400,9 @@ public class MetrologyRepository : IMetrologyRepository
|
||||
// Go Here Next
|
||||
public DataTable GetData(int toolTypeId, long headerid)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
ToolType tt = GetToolTypeByID(toolTypeId) ?? throw new Exception("Invalid tool type ID");
|
||||
|
||||
IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId);
|
||||
if (md is null)
|
||||
throw new Exception("Invalid tool type metadata");
|
||||
IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId) ?? throw new Exception("Invalid tool type metadata");
|
||||
|
||||
DataTable dt = new();
|
||||
|
||||
@ -515,13 +507,9 @@ public class MetrologyRepository : IMetrologyRepository
|
||||
}
|
||||
public DataTable GetDataSharePoint(int toolTypeId, string headerid)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
ToolType tt = GetToolTypeByID(toolTypeId) ?? throw new Exception("Invalid tool type ID");
|
||||
|
||||
IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId);
|
||||
if (md is null)
|
||||
throw new Exception("Invalid tool type metadata");
|
||||
IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId) ?? throw new Exception("Invalid tool type metadata");
|
||||
|
||||
DataTable dt = new();
|
||||
|
||||
@ -610,9 +598,7 @@ public class MetrologyRepository : IMetrologyRepository
|
||||
}
|
||||
public Guid GetHeaderAttachmentID(int toolTypeId, long headerId)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
ToolType tt = GetToolTypeByID(toolTypeId) ?? throw new Exception("Invalid tool type ID");
|
||||
|
||||
using DbConnection conn = GetDbConnection();
|
||||
string sql =
|
||||
@ -623,9 +609,7 @@ public class MetrologyRepository : IMetrologyRepository
|
||||
|
||||
public Guid GetDataAttachmentID(int toolTypeId, long headerId, string title)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
ToolType tt = GetToolTypeByID(toolTypeId) ?? throw new Exception("Invalid tool type ID");
|
||||
|
||||
using DbConnection conn = GetDbConnection();
|
||||
string sql =
|
||||
@ -642,9 +626,7 @@ public class MetrologyRepository : IMetrologyRepository
|
||||
|
||||
public DataSet GetOIExportData(int toolTypeId, long headerid)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
ToolType tt = GetToolTypeByID(toolTypeId) ?? throw new Exception("Invalid tool type ID");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(tt.OIExportSPName))
|
||||
throw new Exception("OpenInsight export not available for " + tt.ToolTypeName);
|
||||
@ -674,9 +656,7 @@ public class MetrologyRepository : IMetrologyRepository
|
||||
if (toolTypeId is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
|
||||
ToolType tt = GetToolTypeByID(toolTypeId.Value);
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
ToolType tt = GetToolTypeByID(toolTypeId.Value) ?? throw new Exception("Invalid tool type ID");
|
||||
|
||||
DbConnection conn = GetDbConnection();
|
||||
using (conn)
|
||||
@ -706,13 +686,9 @@ public class MetrologyRepository : IMetrologyRepository
|
||||
|
||||
public IEnumerable<KeyValuePair<string, string>> GetHeaderFields(int toolTypeId, long headerid)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
ToolType tt = GetToolTypeByID(toolTypeId) ?? throw new Exception("Invalid tool type ID");
|
||||
|
||||
IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId);
|
||||
if (md is null)
|
||||
throw new Exception("Invalid tool type metadata");
|
||||
IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId) ?? throw new Exception("Invalid tool type metadata");
|
||||
|
||||
List<KeyValuePair<string, string>> r = new();
|
||||
|
||||
@ -760,9 +736,7 @@ public class MetrologyRepository : IMetrologyRepository
|
||||
// Jonathan changed this to remove the reviewDate update on the database.
|
||||
public int UpdateReviewDate(int toolTypeId, long headerId, bool clearDate)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
ToolType tt = GetToolTypeByID(toolTypeId) ?? throw new Exception("Invalid tool type ID");
|
||||
|
||||
using DbConnection conn = GetDbConnection();
|
||||
if (clearDate)
|
||||
@ -781,9 +755,7 @@ public class MetrologyRepository : IMetrologyRepository
|
||||
|
||||
public Guid GetHeaderAttachmentIDByTitle(int toolTypeId, string title)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
ToolType tt = GetToolTypeByID(toolTypeId) ?? throw new Exception("Invalid tool type ID");
|
||||
|
||||
using DbConnection conn = GetDbConnection();
|
||||
string sql =
|
||||
@ -793,9 +765,7 @@ public class MetrologyRepository : IMetrologyRepository
|
||||
|
||||
public Guid GetDataAttachmentIDByTitle(int toolTypeId, string title)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
ToolType tt = GetToolTypeByID(toolTypeId) ?? throw new Exception("Invalid tool type ID");
|
||||
|
||||
using DbConnection conn = GetDbConnection();
|
||||
string sql =
|
||||
|
@ -175,4 +175,7 @@ public class AttachmentsService : IAttachmentsService
|
||||
SaveAttachment(toolType, headerId, dataUniqueId, filename, formFile);
|
||||
}
|
||||
|
||||
string IAttachmentsService.GetProcessDataStandardFormat(IMetrologyRepository metrologyRepository, string attachmentPath, int toolTypeId, long headerId) =>
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OI.Metrology.Server.Models;
|
||||
using OI.Metrology.Shared.Models;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
@ -43,13 +42,6 @@ public partial class InboundController : ControllerBase, IInboundController<IAct
|
||||
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]
|
||||
[Route("{tooltype}")]
|
||||
public IActionResult Post(string tooltype)
|
||||
@ -62,8 +54,8 @@ public partial class InboundController : ControllerBase, IInboundController<IAct
|
||||
}
|
||||
else
|
||||
{
|
||||
JToken jsonbody = GetJToken(Request.Body);
|
||||
DataResponse dataResponse = _InboundRepository.Data(_MetrologyRepository, _InboundDataService, tooltype, jsonbody);
|
||||
string? json = GetJson(Request.Body);
|
||||
DataResponse dataResponse = _InboundRepository.Data(_MetrologyRepository, _InboundDataService, tooltype, json);
|
||||
if (!dataResponse.Errors.Any())
|
||||
return Ok(dataResponse);
|
||||
else
|
||||
|
@ -100,11 +100,11 @@ public class ToolTypesController : Controller, IToolTypesController<IActionResul
|
||||
[Route("{toolTypeId}/headers/{headerid}/oiexport")]
|
||||
public IActionResult OIExport(int toolTypeId, long headerid)
|
||||
{
|
||||
Exception? exception = _ToolTypesRepository.OIExport(_MetrologyRepo, _AppSettings.OIExportPath, toolTypeId, headerid);
|
||||
if (exception is null)
|
||||
string? message = _ToolTypesRepository.OIExport(_MetrologyRepo, _AttachmentsService, _AppSettings.AttachmentPath, _AppSettings.TableToPath, toolTypeId, headerid);
|
||||
if (message is null)
|
||||
return Ok(new { Message = "OK" });
|
||||
else
|
||||
return BadRequest(JsonConvert.SerializeObject(new { exception.Message }));
|
||||
return BadRequest(JsonConvert.SerializeObject(new { message }));
|
||||
}
|
||||
|
||||
}
|
@ -19,7 +19,7 @@ public record AppSettings(string ApiExportPath,
|
||||
string MonAResource,
|
||||
string MonASite,
|
||||
string OI2SqlConnectionString,
|
||||
string OIExportPath,
|
||||
Dictionary<string, string> TableToPath,
|
||||
string URLs,
|
||||
string WorkingDirectoryName)
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ public class AppSettings
|
||||
[Display(Name = "MonA Resource"), Required] public string MonAResource { get; set; }
|
||||
[Display(Name = "MonA Site"), Required] public string MonASite { get; set; }
|
||||
[Display(Name = "Oi 2 Sql Connection String"), Required] public string Oi2SqlConnectionString { get; set; }
|
||||
[Display(Name = "OI Export Path"), Required] public string OIExportPath { get; set; }
|
||||
[Display(Name = "Table to Path"), Required] public Dictionary<string, string> TableToPath { get; set; }
|
||||
[Display(Name = "URLs"), Required] public string URLs { get; set; }
|
||||
[Display(Name = "Working Directory Name"), Required] public string WorkingDirectoryName { get; set; }
|
||||
|
||||
@ -76,10 +76,10 @@ public class AppSettings
|
||||
throw new NullReferenceException(nameof(MonASite));
|
||||
if (appSettings.Oi2SqlConnectionString is null)
|
||||
throw new NullReferenceException(nameof(Oi2SqlConnectionString));
|
||||
if (appSettings.OIExportPath is null)
|
||||
throw new NullReferenceException(nameof(OIExportPath));
|
||||
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(
|
||||
@ -100,7 +100,7 @@ public class AppSettings
|
||||
appSettings.MonAResource,
|
||||
appSettings.MonASite,
|
||||
appSettings.Oi2SqlConnectionString,
|
||||
appSettings.OIExportPath,
|
||||
appSettings.TableToPath,
|
||||
appSettings.URLs,
|
||||
appSettings.WorkingDirectoryName);
|
||||
return result;
|
||||
|
@ -25,15 +25,15 @@
|
||||
<Content Remove="compilerconfig.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" Version="2.0.123" />
|
||||
<PackageReference Include="Dapper" Version="2.0.143" />
|
||||
<PackageReference Include="EntityFramework" Version="6.4.4" />
|
||||
<PackageReference Include="jQuery" Version="3.6.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="7.0.5" />
|
||||
<PackageReference Include="jQuery" Version="3.7.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="7.0.9" />
|
||||
<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.UserSecrets" 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.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00032" />
|
||||
|
@ -4,16 +4,13 @@ using OI.Metrology.Shared.Models;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using OI.Metrology.Shared.Services;
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace OI.Metrology.Server.Repository;
|
||||
|
||||
public class InboundRepository : IInboundRepository
|
||||
{
|
||||
|
||||
private readonly Serilog.ILogger _Log;
|
||||
|
||||
public InboundRepository() => _Log = Serilog.Log.ForContext<InboundRepository>();
|
||||
|
||||
bool IInboundRepository.IsIPAddressAllowed(string inboundApiAllowedIPList, IPAddress? remoteIP)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(inboundApiAllowedIPList))
|
||||
@ -38,31 +35,52 @@ public class InboundRepository : IInboundRepository
|
||||
// tooltype is the ToolTypeName column from the ToolType table
|
||||
// JToken is how you can accept a JSON message without deserialization.
|
||||
// Using "string" doesn't work because ASP.NET Core will expect a json encoded string, not give you the actual string.
|
||||
DataResponse IInboundRepository.Data(IMetrologyRepository metrologyRepository, IInboundDataService inboundDataService, string tooltype, JToken jsonbody)
|
||||
DataResponse IInboundRepository.Data(IMetrologyRepository metrologyRepository, IInboundDataService inboundDataService, string tooltype, string? json)
|
||||
{
|
||||
DataResponse result = new();
|
||||
ToolType? toolType = metrologyRepository.GetToolTypeByName(tooltype);
|
||||
if (toolType is null)
|
||||
result.Errors.Add("Invalid tool type: " + tooltype);
|
||||
result.Errors.Add($"Invalid tool type: {tooltype}");
|
||||
else
|
||||
{
|
||||
InboundCommon? inboundCommon = string.IsNullOrEmpty(json) ? null : JsonSerializer.Deserialize<InboundCommon>(json);
|
||||
if (inboundCommon is null || string.IsNullOrEmpty(inboundCommon.ProcessDataStandardFormat))
|
||||
result.Errors.Add($"Invalid body: {json}");
|
||||
else
|
||||
{
|
||||
string? sourceDirectory = Path.GetDirectoryName(inboundCommon.ProcessDataStandardFormat);
|
||||
string? parentDirectory = Path.GetDirectoryName(sourceDirectory);
|
||||
if (string.IsNullOrEmpty(sourceDirectory) || string.IsNullOrEmpty(parentDirectory) || !Directory.Exists(parentDirectory))
|
||||
result.Errors.Add($"Invalid body:path: <{inboundCommon.ProcessDataStandardFormat}>");
|
||||
else
|
||||
{
|
||||
JToken jToken = string.IsNullOrEmpty(json) ? JToken.Parse("{}") : JToken.Parse(json);
|
||||
if (jToken is null)
|
||||
result.Errors.Add($"Invalid body: {json}");
|
||||
else
|
||||
{
|
||||
List<ToolTypeMetadata> metaData = metrologyRepository.GetToolTypeMetadataByToolTypeID(toolType.ID).ToList();
|
||||
if (metaData is null)
|
||||
result.Errors.Add("Invalid metadata for tool type: " + tooltype);
|
||||
else if (jsonbody is null)
|
||||
result.Errors.Add("Invalid json");
|
||||
result.Errors.Add($"Invalid metadata for tool type: {tooltype}");
|
||||
else
|
||||
inboundDataService.ValidateJSONFields(jsonbody, 0, metaData, result.Errors, result.Warnings);
|
||||
if (metaData is not null && jsonbody is not null && !result.Errors.Any())
|
||||
{
|
||||
inboundDataService.ValidateJSONFields(jToken, 0, metaData, result.Errors, result.Warnings);
|
||||
if (!result.Errors.Any())
|
||||
{
|
||||
try
|
||||
{
|
||||
result.HeaderID = inboundDataService.DoSQLInsert(jsonbody, toolType, metaData);
|
||||
result.HeaderID = inboundDataService.DoSQLInsert(jToken, toolType, metaData);
|
||||
result.Success = result.HeaderID > 0;
|
||||
string? destinationDirectory = Path.Combine(parentDirectory, result.HeaderID.ToString());
|
||||
Directory.Move(sourceDirectory, destinationDirectory);
|
||||
}
|
||||
catch (Exception ex) { result.Errors.Add(ex.Message); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -204,50 +204,29 @@ public class ToolTypesRepository : IToolTypesRepository
|
||||
return new(message, contentType, stream);
|
||||
}
|
||||
|
||||
// This endpoint triggers writing of the OI Export file
|
||||
Exception? IToolTypesRepository.OIExport(IMetrologyRepository metrologyRepository, string oiExportPath, int toolTypeId, long headerid)
|
||||
string? IToolTypesRepository.OIExport(IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService, string attachmentPath, Dictionary<string, string> tableToPath, int toolTypeId, long headerid)
|
||||
{
|
||||
string? result;
|
||||
ToolType toolType = metrologyRepository.GetToolTypeByID(toolTypeId);
|
||||
if (toolType?.HeaderTableName is null)
|
||||
result = $"Invalid tool id [{toolTypeId}] [{headerid}]!";
|
||||
else
|
||||
{
|
||||
string? processDataStandardFormat = attachmentsService.GetProcessDataStandardFormat(metrologyRepository, attachmentPath, toolTypeId, headerid);
|
||||
if (processDataStandardFormat is null)
|
||||
result = $"Export file doesn't exist for [{toolTypeId}] [{headerid}] at <{attachmentPath}>!";
|
||||
else if (!tableToPath.TryGetValue(toolType.HeaderTableName, out string? directly))
|
||||
result = $"Export file doesn't exist for [{toolTypeId}] [{headerid}] at <{attachmentPath}>!";
|
||||
else
|
||||
{
|
||||
Exception? result = null;
|
||||
// Call the export stored procedure
|
||||
_Log.Debug($"Exporting to <{oiExportPath}>");
|
||||
DataSet ds = metrologyRepository.GetOIExportData(toolTypeId, headerid);
|
||||
try
|
||||
{
|
||||
// The SP must return 3 result tables
|
||||
if (ds.Tables.Count != 3)
|
||||
throw new Exception("Error exporting, invalid results");
|
||||
// The first table has just one row, which is the export filename
|
||||
if (ds.Tables[0].Rows.Count != 1)
|
||||
throw new Exception("Error exporting, invalid filename");
|
||||
string? filename = Convert.ToString(ds.Tables[0].Rows[0][0]);
|
||||
// The second table has the header data
|
||||
if (ds.Tables[1].Rows.Count != 1)
|
||||
throw new Exception("Error exporting, invalid header data");
|
||||
StringBuilder sb = new();
|
||||
foreach (object? o in ds.Tables[1].Rows[0].ItemArray)
|
||||
{
|
||||
if ((o is not null) && (!Convert.IsDBNull(o)))
|
||||
_ = sb.Append(Convert.ToString(o));
|
||||
_ = sb.Append('\t');
|
||||
File.Copy(processDataStandardFormat, Path.Combine(directly, $"Viewer_{Path.GetFileName(processDataStandardFormat)}"));
|
||||
result = null;
|
||||
}
|
||||
// The third table has the detail data
|
||||
foreach (DataRow dr in ds.Tables[2].Rows)
|
||||
{
|
||||
foreach (object? o in dr.ItemArray)
|
||||
{
|
||||
if ((o is not null) && (!Convert.IsDBNull(o)))
|
||||
_ = sb.Append(Convert.ToString(o));
|
||||
_ = sb.Append('\t');
|
||||
catch (Exception ex) { result = ex.Message; }
|
||||
}
|
||||
}
|
||||
_ = sb.AppendLine();
|
||||
// The output file will only have one line, the header columns are output first
|
||||
// Then each detail rows has it's columns appended
|
||||
// H1, H2, H3, D1.1, D1.2, D1.3, D2.1, D2.2, D2.3, etc
|
||||
// Write the file
|
||||
File.WriteAllText(Path.Join(oiExportPath, filename), sb.ToString());
|
||||
}
|
||||
catch (Exception ex) { result = ex; }
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -27,14 +27,12 @@ public class AttachmentsService : IAttachmentsService
|
||||
throw new NullReferenceException(nameof(tableName));
|
||||
|
||||
DateTime insertDate = Convert.ToDateTime(_MetrologyRepository.GetAttachmentInsertDateByGUID(tableName, attachmentId));
|
||||
int year = insertDate.Year;
|
||||
DateTime d = insertDate;
|
||||
CultureInfo cul = CultureInfo.CurrentCulture;
|
||||
int weekNum = cul.Calendar.GetWeekOfYear(d, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
|
||||
string workWeek = "WW" + weekNum.ToString("00");
|
||||
string dateDir = year + @"\" + workWeek;
|
||||
|
||||
string fullPath = Path.Combine(_AppSettings.AttachmentPath, tableName + "_", dateDir, attachmentId.ToString(), filename);
|
||||
string year = insertDate.Year.ToString();
|
||||
int weekNum = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(insertDate, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
|
||||
string directory = Path.Combine(_AppSettings.AttachmentPath, tableName + "_", year, $"WW{weekNum:00}", attachmentId.ToString());
|
||||
if (!Directory.Exists(directory))
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
string fullPath = Path.Combine(directory, filename);
|
||||
|
||||
// Check to see if file exists in the "New" directory structure, if not change the path back to the old. and check there
|
||||
if (!File.Exists(fullPath))
|
||||
@ -48,7 +46,7 @@ public class AttachmentsService : IAttachmentsService
|
||||
return new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
}
|
||||
|
||||
public Stream GetAttachmentStreamByTitle(ToolType toolType, bool header, string title, string filename)
|
||||
Stream IAttachmentsService.GetAttachmentStreamByTitle(ToolType toolType, bool header, string title, string filename)
|
||||
{
|
||||
if (toolType is null)
|
||||
throw new Exception("Invalid tool type");
|
||||
@ -67,7 +65,7 @@ public class AttachmentsService : IAttachmentsService
|
||||
return GetAttachmentStream(tableName, attachmentId, filename);
|
||||
}
|
||||
|
||||
public Stream GetAttachmentStreamByAttachmentId(ToolType toolType, bool header, Guid attachmentId, string filename)
|
||||
Stream IAttachmentsService.GetAttachmentStreamByAttachmentId(ToolType toolType, bool header, Guid attachmentId, string filename)
|
||||
{
|
||||
if (toolType is null)
|
||||
throw new Exception("Invalid tool type");
|
||||
@ -94,7 +92,6 @@ public class AttachmentsService : IAttachmentsService
|
||||
attachmentId = _MetrologyRepository.GetHeaderAttachmentID(toolType.ID, headerId);
|
||||
insertDate = Convert.ToDateTime(_MetrologyRepository.GetHeaderInsertDate(toolType.ID, headerId));
|
||||
tableName = toolType.HeaderTableName;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -102,37 +99,55 @@ public class AttachmentsService : IAttachmentsService
|
||||
insertDate = Convert.ToDateTime(_MetrologyRepository.GetDataInsertDate(toolType.ID, headerId, dataUniqueId));
|
||||
// Get Date for new directory name
|
||||
tableName = toolType.DataTableName;
|
||||
|
||||
}
|
||||
|
||||
int year = insertDate.Year;
|
||||
DateTime d = insertDate;
|
||||
CultureInfo cul = CultureInfo.CurrentCulture;
|
||||
|
||||
int weekNum = cul.Calendar.GetWeekOfYear(d, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
|
||||
|
||||
string workWeek = "WW" + weekNum.ToString("00");
|
||||
string dateDir = year + @"\" + workWeek;
|
||||
|
||||
if (Equals(attachmentId, Guid.Empty))
|
||||
throw new Exception("Invalid attachment ID");
|
||||
string directoryPathSecondary = Path.Combine(_AppSettings.AttachmentPath, tableName + "_", dateDir, attachmentId.ToString());
|
||||
if (!Directory.Exists(directoryPathSecondary))
|
||||
_ = Directory.CreateDirectory(directoryPathSecondary);
|
||||
|
||||
string fullPathSecondary = Path.Combine(directoryPathSecondary, filename);
|
||||
string year = insertDate.Year.ToString();
|
||||
int weekNum = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(insertDate, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
|
||||
string directory = Path.Combine(_AppSettings.AttachmentPath, $"{tableName}_", year, $"WW{weekNum:00}", attachmentId.ToString());
|
||||
if (!Directory.Exists(directory))
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
|
||||
using (FileStream s = new(fullPathSecondary, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
|
||||
{
|
||||
uploadedFile.CopyTo(s);
|
||||
}
|
||||
string fullPath = Path.Combine(directory, filename);
|
||||
|
||||
using (FileStream fileStream = new(fullPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
|
||||
uploadedFile.CopyTo(fileStream);
|
||||
trans.Complete();
|
||||
}
|
||||
|
||||
public void SaveAttachment(ToolType toolType, long headerId, string dataUniqueId, string filename, object uploadedFile)
|
||||
void IAttachmentsService.SaveAttachment(ToolType toolType, long headerId, string dataUniqueId, string filename, object uploadedFile)
|
||||
{
|
||||
IFormFile formFile = (IFormFile)uploadedFile;
|
||||
SaveAttachment(toolType, headerId, dataUniqueId, filename, formFile);
|
||||
}
|
||||
|
||||
string? IAttachmentsService.GetProcessDataStandardFormat(IMetrologyRepository metrologyRepository, string attachmentPath, int toolTypeId, long headerId)
|
||||
{
|
||||
string? result;
|
||||
string year;
|
||||
int weekNum;
|
||||
string directory;
|
||||
string checkDirectory;
|
||||
List<string> files = new();
|
||||
DateTime[] dateTimes = new DateTime[] { DateTime.Now, DateTime.Now.AddDays(-6.66) };
|
||||
ToolType toolType = metrologyRepository.GetToolTypeByID(toolTypeId) ?? throw new Exception("Invalid tool type ID");
|
||||
foreach (DateTime dateTime in dateTimes)
|
||||
{
|
||||
year = dateTime.Year.ToString();
|
||||
weekNum = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
|
||||
directory = Path.Combine(_AppSettings.AttachmentPath, $"{toolType.HeaderTableName}_", year, $"WW{weekNum:00}");
|
||||
if (!Directory.Exists(directory))
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
checkDirectory = Path.Combine(directory, headerId.ToString());
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
continue;
|
||||
files.AddRange(Directory.GetFiles(checkDirectory));
|
||||
if (files.Any())
|
||||
break;
|
||||
}
|
||||
result = !files.Any() ? null : files.First();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -25,7 +25,6 @@
|
||||
"MonAResource": "OI_Metrology_Viewer_EC",
|
||||
"MonASite": "auc",
|
||||
"Oi2SqlConnectionString": "Data Source=messv01ec.ec.local\\PROD1,53959;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;",
|
||||
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
||||
"Serilog": {
|
||||
"Using": [
|
||||
"Serilog.Sinks.Console",
|
||||
@ -63,6 +62,16 @@
|
||||
"Application": "Sample"
|
||||
}
|
||||
},
|
||||
"TableToPath": {
|
||||
"SPVRunHeader": "\\\\messa01ec.ec.local\\apps\\Metrology\\MET08ANLYSDIFAAST230\\Source",
|
||||
"TencorRunHeader": "\\\\messa01ec.ec.local\\apps\\Metrology\\MET08DDUPSFS6420\\Source",
|
||||
"SP1RunHeader": "\\\\messa01ec.ec.local\\apps\\Metrology\\MET08DDUPSP1TBI\\Source",
|
||||
"MercuryProbeRunHeader": "\\\\messa01ec.ec.local\\apps\\Metrology\\MET08RESIHGCV\\Source",
|
||||
"CDERunHeader": "\\\\messa01ec.ec.local\\apps\\Metrology\\MET08RESIMAPCDE\\Source",
|
||||
"SRPRunHeader": "\\\\messa01ec.ec.local\\apps\\Metrology\\MET08RESISRP2100\\Source",
|
||||
"BioRadRunHeader": "\\\\messa01ec.ec.local\\apps\\Metrology\\MET08THFTIRQS408M\\Source",
|
||||
"StratusBioRadRunHeader": "\\\\messa01ec.ec.local\\apps\\Metrology\\MET08THFTIRSTRATUS\\Source"
|
||||
},
|
||||
"URLs": "http://localhost:5002;",
|
||||
"WorkingDirectoryName": "IFXApps"
|
||||
}
|
15
Shared/DataModels/InboundCommon.cs
Normal file
15
Shared/DataModels/InboundCommon.cs
Normal file
@ -0,0 +1,15 @@
|
||||
namespace OI.Metrology.Shared.DataModels;
|
||||
|
||||
public class InboundCommon
|
||||
{
|
||||
|
||||
public string? CellName { get; set; }
|
||||
public int? Id { get; set; }
|
||||
public string? PSN { get; set; }
|
||||
public string? ProcessDataStandardFormat { get; set; }
|
||||
public string? RDS { get; set; }
|
||||
public string? Reactor { get; set; }
|
||||
public string? Recipe { get; set; }
|
||||
public string? Zone { get; set; }
|
||||
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OI.Metrology.Shared.Services;
|
||||
using System.Net;
|
||||
|
||||
@ -8,7 +7,7 @@ public interface IInboundRepository
|
||||
{
|
||||
|
||||
bool IsIPAddressAllowed(string inboundApiAllowedIPList, IPAddress? remoteIP);
|
||||
DataResponse Data(IMetrologyRepository metrologyRepository, IInboundDataService inboundDataService, string tooltype, JToken jsonbody);
|
||||
string? AttachFile(IMetrologyRepository metrologyRepository, IAttachmentsService _AttachmentsService, string tooltype, long headerid, string datauniqueid, string fileName, object uploadedFile);
|
||||
DataResponse Data(IMetrologyRepository metrologyRepository, IInboundDataService inboundDataService, string tooltype, string? json);
|
||||
string? AttachFile(IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService, string tooltype, long headerid, string datauniqueid, string fileName, object uploadedFile);
|
||||
|
||||
}
|
@ -14,7 +14,7 @@ public interface IToolTypesRepository
|
||||
Result<ColumnValue[]> GetHeaderFields(IMetrologyRepository metrologyRepository, int id, long headerid);
|
||||
Result<DataTable> GetData(IMetrologyRepository metrologyRepository, int id, long headerid);
|
||||
(string?, string?, Stream?) GetAttachment(IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService, int toolTypeId, string tabletype, string attachmentId, string filename);
|
||||
Exception? OIExport(IMetrologyRepository metrologyRepository, string oiExportPath, int toolTypeId, long headerid);
|
||||
string? OIExport(IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService, string attachmentPath, Dictionary<string, string> tableToPath, int toolTypeId, long headerid);
|
||||
Result<DataTable> GetExportData(IMetrologyRepository metrologyRepository, int toolTypeId, DateTime? datebegin, DateTime? dateend);
|
||||
byte[] GetCSVExport(IMetrologyRepository metrologyRepository, int toolTypeId, DateTime? datebegin, DateTime? dateend);
|
||||
}
|
@ -30,7 +30,7 @@
|
||||
<DefineConstants>Linux</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Text.Json" Version="7.0.2" />
|
||||
<PackageReference Include="System.Text.Json" Version="7.0.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
@ -1,10 +1,12 @@
|
||||
namespace OI.Metrology.Shared.Services;
|
||||
|
||||
using DataModels;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
|
||||
public interface IAttachmentsService
|
||||
{
|
||||
Stream GetAttachmentStreamByTitle(ToolType toolType, bool header, string title, string filename);
|
||||
Stream GetAttachmentStreamByAttachmentId(ToolType toolType, bool header, Guid attachmentId, string filename);
|
||||
void SaveAttachment(ToolType toolType, long headerId, string dataUniqueId, string filename, object uploadedFile);
|
||||
string? GetProcessDataStandardFormat(IMetrologyRepository metrologyRepository, string attachmentPath, int toolTypeId, long headerId);
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace OI.Metrology.Tests.Models;
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
public string ApiLoggingContentTypes { init; get; }
|
||||
public string ApiLoggingPathPrefixes { init; get; }
|
||||
public string ApiLogPath { init; get; }
|
||||
public string AttachmentPath { init; get; }
|
||||
public string BuildNumber { init; get; }
|
||||
public string Company { init; get; }
|
||||
public string ConnectionString { init; get; }
|
||||
public string GitCommitSeven { init; get; }
|
||||
public string InboundApiAllowedIPList { init; get; }
|
||||
public string MonAResource { init; get; }
|
||||
public string MonASite { init; get; }
|
||||
public string Oi2SqlConnectionString { init; get; }
|
||||
public string OIExportPath { init; get; }
|
||||
public string URLs { init; get; }
|
||||
public string WorkingDirectoryName { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public AppSettings(string apiLoggingContentTypes,
|
||||
string apiLoggingPathPrefixes,
|
||||
string apiLogPath,
|
||||
string attachmentPath,
|
||||
string buildNumber,
|
||||
string company,
|
||||
string connectionString,
|
||||
string gitCommitSeven,
|
||||
string inboundApiAllowedIPList,
|
||||
string monAResource,
|
||||
string monASite,
|
||||
string oi2SqlConnectionString,
|
||||
string oiExportPath,
|
||||
string urls,
|
||||
string workingDirectoryName)
|
||||
{
|
||||
ApiLoggingContentTypes = apiLoggingContentTypes;
|
||||
ApiLoggingPathPrefixes = apiLoggingPathPrefixes;
|
||||
ApiLogPath = apiLogPath;
|
||||
AttachmentPath = attachmentPath;
|
||||
BuildNumber = buildNumber;
|
||||
Company = company;
|
||||
ConnectionString = connectionString;
|
||||
GitCommitSeven = gitCommitSeven;
|
||||
InboundApiAllowedIPList = inboundApiAllowedIPList;
|
||||
MonAResource = monAResource;
|
||||
MonASite = monASite;
|
||||
Oi2SqlConnectionString = oi2SqlConnectionString;
|
||||
OIExportPath = oiExportPath;
|
||||
URLs = urls;
|
||||
WorkingDirectoryName = workingDirectoryName;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace OI.Metrology.Tests.Models.Binder;
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
#nullable disable
|
||||
|
||||
[Display(Name = "Api Logging Content Types"), Required] public string ApiLoggingContentTypes { get; set; }
|
||||
[Display(Name = "Api Logging Path Prefixes"), Required] public string ApiLoggingPathPrefixes { get; set; }
|
||||
[Display(Name = "Api Log Path"), Required] public string ApiLogPath { get; set; }
|
||||
[Display(Name = "Attachment Path"), Required] public string AttachmentPath { get; set; }
|
||||
[Display(Name = "Build Number"), Required] public string BuildNumber { get; set; }
|
||||
[Display(Name = "Company"), Required] public string Company { get; set; }
|
||||
[Display(Name = "Connection String"), Required] public string ConnectionString { get; set; }
|
||||
[Display(Name = "Git Commit Seven"), Required] public string GitCommitSeven { get; set; }
|
||||
[Display(Name = "Inbound Api Allowed IP List"), Required] public string InboundApiAllowedIPList { get; set; }
|
||||
[Display(Name = "MonA Resource"), Required] public string MonAResource { get; set; }
|
||||
[Display(Name = "MonA Site"), Required] public string MonASite { get; set; }
|
||||
[Display(Name = "Oi 2 Sql Connection String"), Required] public string Oi2SqlConnectionString { get; set; }
|
||||
[Display(Name = "OI Export Path"), Required] public string OIExportPath { 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()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Models.AppSettings Get(AppSettings appSettings)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
result = new(
|
||||
appSettings.ApiLoggingContentTypes,
|
||||
appSettings.ApiLoggingPathPrefixes,
|
||||
appSettings.ApiLogPath,
|
||||
appSettings.AttachmentPath,
|
||||
appSettings.BuildNumber,
|
||||
appSettings.Company,
|
||||
appSettings.ConnectionString,
|
||||
appSettings.GitCommitSeven,
|
||||
appSettings.InboundApiAllowedIPList,
|
||||
appSettings.MonAResource,
|
||||
appSettings.MonASite,
|
||||
appSettings.Oi2SqlConnectionString,
|
||||
appSettings.OIExportPath,
|
||||
appSettings.URLs,
|
||||
appSettings.WorkingDirectoryName);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||
if (appSettings is null)
|
||||
throw new NullReferenceException(nameof(appSettings));
|
||||
result = Get(appSettings);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -27,19 +27,19 @@
|
||||
<DefineConstants>Linux</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="3.2.0" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.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.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.5" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.9" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
|
||||
<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="Serilog" Version="2.12.0" />
|
||||
<PackageReference Include="Serilog" Version="3.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\OI.Metrology.Shared.csproj" />
|
||||
|
@ -1,6 +1,8 @@
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using OI.Metrology.Shared.DataModels;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using Serilog;
|
||||
using System.Text;
|
||||
|
||||
namespace OI.Metrology.Tests;
|
||||
|
||||
@ -26,22 +28,37 @@ public class UnitInboundController
|
||||
_ControllerName = nameof(Server.ApiControllers.InboundController)[..^10];
|
||||
}
|
||||
|
||||
private static void NonThrowTryCatch()
|
||||
{
|
||||
try
|
||||
{ throw new Exception(); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestControllerName()
|
||||
{
|
||||
_Logger.Information("Starting Web Application");
|
||||
Assert.AreEqual(IInboundController<string>.GetRouteName(), _ControllerName);
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
private static InboundCommon GetInboundCommon() =>
|
||||
new() { PSN = "5008", Reactor = "61", RDS = "579487", Id = 1678209360, ProcessDataStandardFormat = @"\\server\share\file.ext" };
|
||||
|
||||
private static StringContent GetStringContent() =>
|
||||
new(System.Text.Json.JsonSerializer.Serialize(GetInboundCommon()), Encoding.UTF8, "application/json");
|
||||
|
||||
[Ignore]
|
||||
[TestMethod]
|
||||
public async Task DataApi()
|
||||
{
|
||||
HttpClient httpClient = _WebApplicationFactory.CreateClient();
|
||||
_Logger.Information("Starting Web Application");
|
||||
_ = await httpClient.PostAsync($"api/{_ControllerName}/a", null);
|
||||
_ = await httpClient.PostAsync($"api/{_ControllerName}/BioRad", GetStringContent());
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[Ignore]
|
||||
@ -50,8 +67,9 @@ public class UnitInboundController
|
||||
{
|
||||
HttpClient httpClient = _WebApplicationFactory.CreateClient();
|
||||
_Logger.Information("Starting Web Application");
|
||||
_ = await httpClient.PostAsync($"api/{_ControllerName}/a/attachment", null);
|
||||
_ = await httpClient.PostAsync($"api/{_ControllerName}/BioRad/attachment", GetStringContent());
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
}
|
@ -270,11 +270,12 @@ public class UnitTestToolTypesController
|
||||
{
|
||||
_Logger.Information("Starting Web Application");
|
||||
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
|
||||
IAttachmentsService attachmentsService = serviceProvider.GetRequiredService<IAttachmentsService>();
|
||||
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>();
|
||||
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>();
|
||||
Server.Models.AppSettings appSettings = serviceProvider.GetRequiredService<Server.Models.AppSettings>();
|
||||
Exception? exception = toolTypesRepository.OIExport(metrologyRepository, appSettings.OIExportPath, toolTypeId: 1, headerid: 1);
|
||||
Assert.IsTrue(exception is null);
|
||||
string? message = toolTypesRepository.OIExport(metrologyRepository, attachmentsService, appSettings.AttachmentPath, appSettings.TableToPath, toolTypeId: 1, headerid: 1);
|
||||
Assert.IsTrue(message is null);
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,8 @@
|
||||
<SupportedPlatform Include="browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MudBlazor" Version="6.2.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.5" />
|
||||
<PackageReference Include="MudBlazor" Version="6.7.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.9" />
|
||||
<PackageReference Include="IgniteUI.Blazor" Version="22.2.24" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user