diff --git a/.kanbn/board.css b/.kanbn/board.css
new file mode 100644
index 0000000..427c0bd
--- /dev/null
+++ b/.kanbn/board.css
@@ -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;
+}
diff --git a/.kanbn/index.md b/.kanbn/index.md
new file mode 100644
index 0000000..3106b8b
--- /dev/null
+++ b/.kanbn/index.md
@@ -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
diff --git a/.kanbn/tasks/change-eaf-to-save-and-info-pdsf.md b/.kanbn/tasks/change-eaf-to-save-and-info-pdsf.md
new file mode 100644
index 0000000..f5d515e
--- /dev/null
+++ b/.kanbn/tasks/change-eaf-to-save-and-info-pdsf.md
@@ -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~~
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 710b24c..ad47041 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -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": []
}
]
}
\ No newline at end of file
diff --git a/Archive/OI.Metrology.Archive.csproj b/Archive/OI.Metrology.Archive.csproj
index d53c73f..b04f7cc 100644
--- a/Archive/OI.Metrology.Archive.csproj
+++ b/Archive/OI.Metrology.Archive.csproj
@@ -27,13 +27,13 @@
-
+
-
+
-
+
diff --git a/Archive/Repositories/MetrologyRepo.cs b/Archive/Repositories/MetrologyRepo.cs
index d043406..3d35e21 100644
--- a/Archive/Repositories/MetrologyRepo.cs
+++ b/Archive/Repositories/MetrologyRepo.cs
@@ -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 md = GetToolTypeMetadataByToolTypeID(toolTypeId);
- if (md is null)
- throw new Exception("Invalid tool type metadata");
+ IEnumerable 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 md = GetToolTypeMetadataByToolTypeID(toolTypeId);
- if (md is null)
- throw new Exception("Invalid tool type metadata");
+ IEnumerable 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 md = GetToolTypeMetadataByToolTypeID(toolTypeId);
- if (md is null)
- throw new Exception("Invalid tool type metadata");
+ IEnumerable 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> 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 md = GetToolTypeMetadataByToolTypeID(toolTypeId);
- if (md is null)
- throw new Exception("Invalid tool type metadata");
+ IEnumerable md = GetToolTypeMetadataByToolTypeID(toolTypeId) ?? throw new Exception("Invalid tool type metadata");
List> 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 =
diff --git a/Archive/Services/AttachmentsService.cs b/Archive/Services/AttachmentsService.cs
index f4113fe..b5ffed3 100644
--- a/Archive/Services/AttachmentsService.cs
+++ b/Archive/Services/AttachmentsService.cs
@@ -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();
+
}
\ No newline at end of file
diff --git a/Server/ApiControllers/InboundController.cs b/Server/ApiControllers/InboundController.cs
index cd1116e..6014b26 100644
--- a/Server/ApiControllers/InboundController.cs
+++ b/Server/ApiControllers/InboundController.cs
@@ -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 TableToPath,
string URLs,
string WorkingDirectoryName)
{
diff --git a/Server/Models/Binder/AppSettings.cs b/Server/Models/Binder/AppSettings.cs
index 5edc082..1af153b 100644
--- a/Server/Models/Binder/AppSettings.cs
+++ b/Server/Models/Binder/AppSettings.cs
@@ -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 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;
diff --git a/Server/OI.Metrology.Server.csproj b/Server/OI.Metrology.Server.csproj
index 38313fb..b0ee548 100644
--- a/Server/OI.Metrology.Server.csproj
+++ b/Server/OI.Metrology.Server.csproj
@@ -25,15 +25,15 @@
-
+
-
-
+
+
-
+
diff --git a/Server/Properties/launchSettings.json b/Server/Properties/launchSettings.json
index 96ca44f..b3bc698 100644
--- a/Server/Properties/launchSettings.json
+++ b/Server/Properties/launchSettings.json
@@ -28,4 +28,4 @@
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Server/Repositories/InboundRepository.cs b/Server/Repositories/InboundRepository.cs
index 6e36fb2..4d4b3b0 100644
--- a/Server/Repositories/InboundRepository.cs
+++ b/Server/Repositories/InboundRepository.cs
@@ -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();
-
bool IInboundRepository.IsIPAddressAllowed(string inboundApiAllowedIPList, IPAddress? remoteIP)
{
if (string.IsNullOrWhiteSpace(inboundApiAllowedIPList))
@@ -38,29 +35,50 @@ 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
{
- List 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");
+ InboundCommon? inboundCommon = string.IsNullOrEmpty(json) ? null : JsonSerializer.Deserialize(json);
+ if (inboundCommon is null || string.IsNullOrEmpty(inboundCommon.ProcessDataStandardFormat))
+ result.Errors.Add($"Invalid body: {json}");
else
- inboundDataService.ValidateJSONFields(jsonbody, 0, metaData, result.Errors, result.Warnings);
- if (metaData is not null && jsonbody is not null && !result.Errors.Any())
{
- try
+ 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
{
- result.HeaderID = inboundDataService.DoSQLInsert(jsonbody, toolType, metaData);
- result.Success = result.HeaderID > 0;
+ JToken jToken = string.IsNullOrEmpty(json) ? JToken.Parse("{}") : JToken.Parse(json);
+ if (jToken is null)
+ result.Errors.Add($"Invalid body: {json}");
+ else
+ {
+ List metaData = metrologyRepository.GetToolTypeMetadataByToolTypeID(toolType.ID).ToList();
+ if (metaData is null)
+ result.Errors.Add($"Invalid metadata for tool type: {tooltype}");
+ else
+ {
+ inboundDataService.ValidateJSONFields(jToken, 0, metaData, result.Errors, result.Warnings);
+ if (!result.Errors.Any())
+ {
+ try
+ {
+ 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); }
+ }
+ }
+ }
}
- catch (Exception ex) { result.Errors.Add(ex.Message); }
}
}
return result;
diff --git a/Server/Repositories/ToolTypesRepository.cs b/Server/Repositories/ToolTypesRepository.cs
index 57fbc9b..da15e19 100644
--- a/Server/Repositories/ToolTypesRepository.cs
+++ b/Server/Repositories/ToolTypesRepository.cs
@@ -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 tableToPath, int toolTypeId, long headerid)
{
- Exception? result = null;
- // Call the export stored procedure
- _Log.Debug($"Exporting to <{oiExportPath}>");
- DataSet ds = metrologyRepository.GetOIExportData(toolTypeId, headerid);
- try
+ string? result;
+ ToolType toolType = metrologyRepository.GetToolTypeByID(toolTypeId);
+ if (toolType?.HeaderTableName is null)
+ result = $"Invalid tool id [{toolTypeId}] [{headerid}]!";
+ else
{
- // 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)
+ 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
{
- if ((o is not null) && (!Convert.IsDBNull(o)))
- _ = sb.Append(Convert.ToString(o));
- _ = sb.Append('\t');
- }
- // The third table has the detail data
- foreach (DataRow dr in ds.Tables[2].Rows)
- {
- foreach (object? o in dr.ItemArray)
+ try
{
- 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;
}
+ 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;
}
diff --git a/Server/Services/AttachmentsService.cs b/Server/Services/AttachmentsService.cs
index e6baeff..d99e43b 100644
--- a/Server/Services/AttachmentsService.cs
+++ b/Server/Services/AttachmentsService.cs
@@ -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 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;
+ }
+
}
\ No newline at end of file
diff --git a/Server/appsettings.json b/Server/appsettings.json
index 7d2ecc8..ca10478 100644
--- a/Server/appsettings.json
+++ b/Server/appsettings.json
@@ -6,7 +6,7 @@
"ApiUrl": "~/api",
"ApiLogPath": "D:\\Metrology\\MetrologyAPILogs",
"AttachmentPath": "\\\\messv02ecc1.ec.local\\EC_Metrology_Si\\MetrologyAttachments",
- "BuildNumber": "1",
+ "BuildNumber": "1",
"Company": "Infineon Technologies Americas Corp.",
"ConnectionString": "Data Source=messv01ec.ec.local\\PROD1,53959;Integrated Security=True;Initial Catalog=Metrology;",
"GitCommitSeven": "1234567",
@@ -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"
}
\ No newline at end of file
diff --git a/Shared/DataModels/InboundCommon.cs b/Shared/DataModels/InboundCommon.cs
new file mode 100644
index 0000000..dbdca1a
--- /dev/null
+++ b/Shared/DataModels/InboundCommon.cs
@@ -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; }
+
+}
\ No newline at end of file
diff --git a/Shared/Models/Stateless/IInboundRepository.cs b/Shared/Models/Stateless/IInboundRepository.cs
index c92f9d1..7ddfdda 100644
--- a/Shared/Models/Stateless/IInboundRepository.cs
+++ b/Shared/Models/Stateless/IInboundRepository.cs
@@ -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);
}
\ No newline at end of file
diff --git a/Shared/Models/Stateless/IToolTypesRepository.cs b/Shared/Models/Stateless/IToolTypesRepository.cs
index 1f81b60..6c7b06f 100644
--- a/Shared/Models/Stateless/IToolTypesRepository.cs
+++ b/Shared/Models/Stateless/IToolTypesRepository.cs
@@ -14,7 +14,7 @@ public interface IToolTypesRepository
Result GetHeaderFields(IMetrologyRepository metrologyRepository, int id, long headerid);
Result 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 tableToPath, int toolTypeId, long headerid);
Result GetExportData(IMetrologyRepository metrologyRepository, int toolTypeId, DateTime? datebegin, DateTime? dateend);
byte[] GetCSVExport(IMetrologyRepository metrologyRepository, int toolTypeId, DateTime? datebegin, DateTime? dateend);
}
\ No newline at end of file
diff --git a/Shared/OI.Metrology.Shared.csproj b/Shared/OI.Metrology.Shared.csproj
index 9301b92..a2f26b4 100644
--- a/Shared/OI.Metrology.Shared.csproj
+++ b/Shared/OI.Metrology.Shared.csproj
@@ -30,7 +30,7 @@
Linux
-
+
diff --git a/Shared/Services/IAttachmentsService.cs b/Shared/Services/IAttachmentsService.cs
index f5a59d6..5b570f5 100644
--- a/Shared/Services/IAttachmentsService.cs
+++ b/Shared/Services/IAttachmentsService.cs
@@ -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);
}
\ No newline at end of file
diff --git a/Tests/Models/AppSettings.cs b/Tests/Models/AppSettings.cs
deleted file mode 100644
index 672e8ab..0000000
--- a/Tests/Models/AppSettings.cs
+++ /dev/null
@@ -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;
- }
-
-}
\ No newline at end of file
diff --git a/Tests/Models/Binder/AppSettings.cs b/Tests/Models/Binder/AppSettings.cs
deleted file mode 100644
index e95514c..0000000
--- a/Tests/Models/Binder/AppSettings.cs
+++ /dev/null
@@ -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();
- if (appSettings is null)
- throw new NullReferenceException(nameof(appSettings));
- result = Get(appSettings);
- return result;
- }
-
-}
\ No newline at end of file
diff --git a/Tests/OI.Metrology.Tests.csproj b/Tests/OI.Metrology.Tests.csproj
index 63cdfaf..35b79ce 100644
--- a/Tests/OI.Metrology.Tests.csproj
+++ b/Tests/OI.Metrology.Tests.csproj
@@ -27,19 +27,19 @@
Linux
-
+
-
-
-
-
+
+
+
+
-
+
diff --git a/Tests/UnitInboundController.cs b/Tests/UnitInboundController.cs
index cf19c70..fd769ea 100644
--- a/Tests/UnitInboundController.cs
+++ b/Tests/UnitInboundController.cs
@@ -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.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();
}
}
\ No newline at end of file
diff --git a/Tests/UnitTestToolTypesController.cs b/Tests/UnitTestToolTypesController.cs
index 45f06ee..d62d2e5 100644
--- a/Tests/UnitTestToolTypesController.cs
+++ b/Tests/UnitTestToolTypesController.cs
@@ -270,11 +270,12 @@ public class UnitTestToolTypesController
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
+ IAttachmentsService attachmentsService = serviceProvider.GetRequiredService();
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService();
Server.Models.AppSettings appSettings = serviceProvider.GetRequiredService();
- 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");
}
diff --git a/View/OI.Metrology.View.csproj b/View/OI.Metrology.View.csproj
index 7158809..6fd7898 100644
--- a/View/OI.Metrology.View.csproj
+++ b/View/OI.Metrology.View.csproj
@@ -8,8 +8,8 @@
-
-
+
+