NginxFileSystem
Remove Reactors and Working Directory AppSettings
This commit is contained in:
parent
127634f5ab
commit
811f45a7df
@ -101,6 +101,7 @@ dotnet_diagnostic.CA1860.severity = error # CA1860: Prefer comparing 'Count' to
|
|||||||
dotnet_diagnostic.CA1862.severity = warning # CA1862: Prefer using 'string.Equals(string, StringComparison)' to perform a case-insensitive comparison, but keep in mind that this might cause subtle changes in behavior, so make sure to conduct thorough testing after applying the suggestion, or if culturally sensitive comparison is not required, consider using 'StringComparison.OrdinalIgnoreCase'
|
dotnet_diagnostic.CA1862.severity = warning # CA1862: Prefer using 'string.Equals(string, StringComparison)' to perform a case-insensitive comparison, but keep in mind that this might cause subtle changes in behavior, so make sure to conduct thorough testing after applying the suggestion, or if culturally sensitive comparison is not required, consider using 'StringComparison.OrdinalIgnoreCase'
|
||||||
dotnet_diagnostic.CA1869.severity = none # CA1869: Avoid creating a new 'JsonSerializerOptions' instance for every serialization operation. Cache and reuse instances instead.
|
dotnet_diagnostic.CA1869.severity = none # CA1869: Avoid creating a new 'JsonSerializerOptions' instance for every serialization operation. Cache and reuse instances instead.
|
||||||
dotnet_diagnostic.CA2254.severity = none # CA2254: The logging message template should not vary between calls to 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])'
|
dotnet_diagnostic.CA2254.severity = none # CA2254: The logging message template should not vary between calls to 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])'
|
||||||
|
dotnet_diagnostic.CS8936.severity = error # Feature 'collection expressions' is not available in C# 10.0. Please use language version 12.0 or greater.
|
||||||
dotnet_diagnostic.IDE0001.severity = warning # IDE0001: Simplify name
|
dotnet_diagnostic.IDE0001.severity = warning # IDE0001: Simplify name
|
||||||
dotnet_diagnostic.IDE0002.severity = warning # Simplify (member access) - System.Version.Equals("1", "2"); Version.Equals("1", "2");
|
dotnet_diagnostic.IDE0002.severity = warning # Simplify (member access) - System.Version.Equals("1", "2"); Version.Equals("1", "2");
|
||||||
dotnet_diagnostic.IDE0004.severity = warning # IDE0004: Cast is redundant.
|
dotnet_diagnostic.IDE0004.severity = warning # IDE0004: Cast is redundant.
|
||||||
|
@ -29,6 +29,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (appSettings?.ApiLoggingContentTypes is null)
|
||||||
|
{
|
||||||
|
List<string> paths = [];
|
||||||
|
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
|
||||||
|
{
|
||||||
|
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
|
||||||
|
continue;
|
||||||
|
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
|
||||||
|
continue;
|
||||||
|
paths.Add(physicalFileProvider.Root);
|
||||||
|
}
|
||||||
|
throw new NotSupportedException($"Not found!{Environment.NewLine}{string.Join(Environment.NewLine, paths.Distinct())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -73,20 +90,7 @@ public class AppSettings
|
|||||||
#pragma warning disable IL3050, IL2026
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
#pragma warning restore IL3050, IL2026
|
#pragma warning restore IL3050, IL2026
|
||||||
if (appSettings?.ApiLoggingContentTypes is null)
|
PreVerify(configurationRoot, appSettings);
|
||||||
{
|
|
||||||
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
|
|
||||||
{
|
|
||||||
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
|
|
||||||
continue;
|
|
||||||
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
|
|
||||||
continue;
|
|
||||||
if (!physicalFileProvider.Root.Contains("UserSecrets"))
|
|
||||||
continue;
|
|
||||||
throw new NotSupportedException(physicalFileProvider.Root);
|
|
||||||
}
|
|
||||||
throw new NotSupportedException("Not found!");
|
|
||||||
}
|
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
36
Server/ApiControllers/FileShareController.cs
Normal file
36
Server/ApiControllers/FileShareController.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using OI.Metrology.Shared.Models.Stateless;
|
||||||
|
|
||||||
|
namespace OI.Metrology.Server.ApiControllers;
|
||||||
|
|
||||||
|
[Route("api/v1/file-share")]
|
||||||
|
public class FileShareController : Controller, IFileShareController<IResult>
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly IFileShareRepository _FileShareRepository;
|
||||||
|
|
||||||
|
public FileShareController(IFileShareRepository fileShareRepository) =>
|
||||||
|
_FileShareRepository = fileShareRepository;
|
||||||
|
|
||||||
|
[HttpGet("copy-file")]
|
||||||
|
public IResult CopyFile(string from, string to)
|
||||||
|
{
|
||||||
|
_FileShareRepository.CopyFile(from, to);
|
||||||
|
return Results.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("move-file")]
|
||||||
|
public IResult MoveFile(string from, string to)
|
||||||
|
{
|
||||||
|
_FileShareRepository.CopyFile(from, to);
|
||||||
|
return Results.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("file-write")]
|
||||||
|
public IResult FileWrite(string path, string contents)
|
||||||
|
{
|
||||||
|
_FileShareRepository.FileWrite(path, contents);
|
||||||
|
return Results.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,24 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using OI.Metrology.Shared.Models.Stateless;
|
|
||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
namespace OI.Metrology.Server.ApiControllers;
|
|
||||||
|
|
||||||
[Route("api/[controller]")]
|
|
||||||
public class ReactorsController : Controller, IReactorsController<IActionResult>
|
|
||||||
{
|
|
||||||
|
|
||||||
private readonly IReactorsRepository _ReactorsRepository;
|
|
||||||
|
|
||||||
public ReactorsController(IReactorsRepository reactorsRepository) =>
|
|
||||||
_ReactorsRepository = reactorsRepository;
|
|
||||||
|
|
||||||
[HttpGet("{even}")]
|
|
||||||
public IActionResult Get(bool even) =>
|
|
||||||
Json(even ? _ReactorsRepository.EvenReactors() : _ReactorsRepository.OddReactors(), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true });
|
|
||||||
|
|
||||||
[HttpPost()]
|
|
||||||
public IActionResult Post(Shared.DataModels.WorkMaterialOut workMaterialOut) =>
|
|
||||||
Ok(_ReactorsRepository.GetKey(workMaterialOut, save: true));
|
|
||||||
|
|
||||||
}
|
|
@ -100,7 +100,7 @@ public class ToolTypesController : Controller, IToolTypesController<IActionResul
|
|||||||
[Route("{toolTypeId}/headers/{headerid}/oiexport")]
|
[Route("{toolTypeId}/headers/{headerid}/oiexport")]
|
||||||
public IActionResult OIExport(int toolTypeId, long headerid)
|
public IActionResult OIExport(int toolTypeId, long headerid)
|
||||||
{
|
{
|
||||||
string? message = _ToolTypesRepository.OIExport(_MetrologyRepo, _AttachmentsService, _AppSettings.AttachmentPath, _AppSettings.TableToPath, toolTypeId, headerid);
|
string? message = _ToolTypesRepository.OIExport(_MetrologyRepo, _AttachmentsService, toolTypeId, headerid);
|
||||||
if (message is null)
|
if (message is null)
|
||||||
return Ok(new { Message = "OK" });
|
return Ok(new { Message = "OK" });
|
||||||
else
|
else
|
||||||
|
@ -1,82 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
|
||||||
using OI.Metrology.Server.Models;
|
|
||||||
using OI.Metrology.Shared.ViewModels;
|
|
||||||
|
|
||||||
namespace OI.Metrology.Server.Controllers;
|
|
||||||
|
|
||||||
public class ReactorsController : Controller
|
|
||||||
{
|
|
||||||
|
|
||||||
private readonly bool _IsTestDatabase;
|
|
||||||
private readonly AppSettings _AppSettings;
|
|
||||||
|
|
||||||
public ReactorsController(AppSettings appSettings)
|
|
||||||
{
|
|
||||||
_AppSettings = appSettings;
|
|
||||||
_IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnActionExecuted(ActionExecutedContext context)
|
|
||||||
{
|
|
||||||
base.OnActionExecuted(context);
|
|
||||||
ViewBag.IsTestDatabase = _IsTestDatabase;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetApiUrl() => string.IsNullOrEmpty(_AppSettings.ApiUrl) ? Url.Content("~/") : _AppSettings.ApiUrl[0] == '~' ? Url.Content(_AppSettings.ApiUrl) : _AppSettings.ApiUrl;
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[Route("/Step1")]
|
|
||||||
[Route("/Metrology/Step1")]
|
|
||||||
public IActionResult Step1(string mod = "", string equipment = "", string layer = "", string zone = "", string rds = "", string initials = "")
|
|
||||||
{
|
|
||||||
string directory = "D:/Tmp/Metrology";
|
|
||||||
if (!Directory.Exists(directory))
|
|
||||||
_ = Directory.CreateDirectory(directory);
|
|
||||||
string[] model = new string[] { mod, equipment, layer, zone, rds, initials };
|
|
||||||
if (!string.IsNullOrEmpty(initials))
|
|
||||||
System.IO.File.WriteAllLines(Path.Combine(directory, $"{DateTime.Now.Ticks}-{initials}.rsv"), model);
|
|
||||||
return View(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[Route("/Step2")]
|
|
||||||
[Route("/Metrology/Step2")]
|
|
||||||
public IActionResult Step2(string mod) =>
|
|
||||||
View(new string[] { mod });
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[Route("/Step3")]
|
|
||||||
[Route("/Metrology/Step3")]
|
|
||||||
public IActionResult Step3(string mod, string equipment) =>
|
|
||||||
View(new string[] { mod, equipment });
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[Route("/Step4")]
|
|
||||||
[Route("/Metrology/Step4")]
|
|
||||||
public IActionResult Step4(string mod, string equipment, string layer) =>
|
|
||||||
View(new string[] { mod, equipment, layer });
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[Route("/Step5")]
|
|
||||||
[Route("/Metrology/Step5")]
|
|
||||||
public IActionResult Step5(string mod, string equipment, string layer, string zone) =>
|
|
||||||
View(new string[] { mod, equipment, layer, zone });
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[Route("/Step6")]
|
|
||||||
[Route("/Metrology/Step6")]
|
|
||||||
public IActionResult Step6(string mod, string equipment, string layer, string zone, string rds) =>
|
|
||||||
View(new string[] { mod, equipment, layer, zone, rds });
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[Route("/Reactor")]
|
|
||||||
[Route("/Metrology/Reactor")]
|
|
||||||
public IActionResult Reactor() => View(new RunInfo());
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[Route("/WorkMaterial")]
|
|
||||||
[Route("/Metrology/WorkMaterial")]
|
|
||||||
public IActionResult WorkMaterial() => View();
|
|
||||||
|
|
||||||
}
|
|
@ -3,14 +3,17 @@ using System.Text.Json;
|
|||||||
namespace OI.Metrology.Server.Models;
|
namespace OI.Metrology.Server.Models;
|
||||||
|
|
||||||
public record AppSettings(string ApiExportPath,
|
public record AppSettings(string ApiExportPath,
|
||||||
|
string ApiFileShare,
|
||||||
string ApiLoggingContentTypes,
|
string ApiLoggingContentTypes,
|
||||||
string ApiLoggingPathPrefixes,
|
string ApiLoggingPathPrefixes,
|
||||||
string ApiLogPath,
|
string ApiLogPath,
|
||||||
string ApiUrl,
|
string ApiUrl,
|
||||||
string AttachmentPath,
|
|
||||||
string BuildNumber,
|
string BuildNumber,
|
||||||
string Company,
|
string Company,
|
||||||
string ConnectionString,
|
string ConnectionString,
|
||||||
|
string EcCharacterizationSi,
|
||||||
|
string EcMesaFileShareCharacterizationSi,
|
||||||
|
string EcMesaFileShareMetrologySi,
|
||||||
string GitCommitSeven,
|
string GitCommitSeven,
|
||||||
string InboundApiAllowedIPList,
|
string InboundApiAllowedIPList,
|
||||||
string IqsColumns,
|
string IqsColumns,
|
||||||
@ -27,7 +30,6 @@ public record AppSettings(string ApiExportPath,
|
|||||||
Dictionary<string, string> TableToPath,
|
Dictionary<string, string> TableToPath,
|
||||||
string URLs,
|
string URLs,
|
||||||
string WaferCounterDestinationDirectory,
|
string WaferCounterDestinationDirectory,
|
||||||
string WaferCounterRootDirectory,
|
|
||||||
string WorkingDirectoryName)
|
string WorkingDirectoryName)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -7,14 +7,17 @@ public class AppSettings
|
|||||||
{
|
{
|
||||||
|
|
||||||
public string? ApiExportPath { get; set; }
|
public string? ApiExportPath { get; set; }
|
||||||
|
public string? ApiFileShare { get; set; }
|
||||||
public string? ApiLoggingContentTypes { get; set; }
|
public string? ApiLoggingContentTypes { get; set; }
|
||||||
public string? ApiLoggingPathPrefixes { get; set; }
|
public string? ApiLoggingPathPrefixes { get; set; }
|
||||||
public string? ApiLogPath { get; set; }
|
public string? ApiLogPath { get; set; }
|
||||||
public string? ApiUrl { get; set; }
|
public string? ApiUrl { get; set; }
|
||||||
public string? AttachmentPath { get; set; }
|
|
||||||
public string? BuildNumber { get; set; }
|
public string? BuildNumber { get; set; }
|
||||||
public string? Company { get; set; }
|
public string? Company { get; set; }
|
||||||
public string? ConnectionString { get; set; }
|
public string? ConnectionString { get; set; }
|
||||||
|
public string? EcCharacterizationSi { get; set; }
|
||||||
|
public string? EcMesaFileShareCharacterizationSi { get; set; }
|
||||||
|
public string? EcMesaFileShareMetrologySi { get; set; }
|
||||||
public string? GitCommitSeven { get; set; }
|
public string? GitCommitSeven { get; set; }
|
||||||
public string? InboundApiAllowedIPList { get; set; }
|
public string? InboundApiAllowedIPList { get; set; }
|
||||||
public string? IqsColumns { get; set; }
|
public string? IqsColumns { get; set; }
|
||||||
@ -31,7 +34,6 @@ public class AppSettings
|
|||||||
public Dictionary<string, string>? TableToPath { get; set; }
|
public Dictionary<string, string>? TableToPath { get; set; }
|
||||||
public string? URLs { get; set; }
|
public string? URLs { get; set; }
|
||||||
public string? WaferCounterDestinationDirectory { get; set; }
|
public string? WaferCounterDestinationDirectory { get; set; }
|
||||||
public string? WaferCounterRootDirectory { get; set; }
|
|
||||||
public string? WorkingDirectoryName { get; set; }
|
public string? WorkingDirectoryName { get; set; }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
@ -40,19 +42,39 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (appSettings?.ApiExportPath is null)
|
||||||
|
{
|
||||||
|
List<string> paths = new();
|
||||||
|
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
|
||||||
|
{
|
||||||
|
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
|
||||||
|
continue;
|
||||||
|
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
|
||||||
|
continue;
|
||||||
|
paths.Add(physicalFileProvider.Root);
|
||||||
|
}
|
||||||
|
throw new NotSupportedException($"Not found!{Environment.NewLine}{string.Join(Environment.NewLine, paths.Distinct())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
if (appSettings is null) throw new NullReferenceException(nameof(appSettings));
|
if (appSettings is null) throw new NullReferenceException(nameof(appSettings));
|
||||||
if (appSettings.ApiExportPath is null) throw new NullReferenceException(nameof(ApiExportPath));
|
if (appSettings.ApiExportPath is null) throw new NullReferenceException(nameof(ApiExportPath));
|
||||||
|
if (appSettings.ApiFileShare is null) throw new NullReferenceException(nameof(ApiFileShare));
|
||||||
if (appSettings.ApiLoggingContentTypes is null) throw new NullReferenceException(nameof(ApiLoggingContentTypes));
|
if (appSettings.ApiLoggingContentTypes is null) throw new NullReferenceException(nameof(ApiLoggingContentTypes));
|
||||||
if (appSettings.ApiLoggingPathPrefixes is null) throw new NullReferenceException(nameof(ApiLoggingPathPrefixes));
|
if (appSettings.ApiLoggingPathPrefixes is null) throw new NullReferenceException(nameof(ApiLoggingPathPrefixes));
|
||||||
if (appSettings.ApiLogPath is null) throw new NullReferenceException(nameof(ApiLogPath));
|
if (appSettings.ApiLogPath is null) throw new NullReferenceException(nameof(ApiLogPath));
|
||||||
if (appSettings.ApiUrl is null) throw new NullReferenceException(nameof(ApiUrl));
|
if (appSettings.ApiUrl is null) throw new NullReferenceException(nameof(ApiUrl));
|
||||||
if (appSettings.AttachmentPath is null) throw new NullReferenceException(nameof(AttachmentPath));
|
|
||||||
if (appSettings.BuildNumber is null) throw new NullReferenceException(nameof(BuildNumber));
|
if (appSettings.BuildNumber is null) throw new NullReferenceException(nameof(BuildNumber));
|
||||||
if (appSettings.Company is null) throw new NullReferenceException(nameof(Company));
|
if (appSettings.Company is null) throw new NullReferenceException(nameof(Company));
|
||||||
if (appSettings.ConnectionString is null) throw new NullReferenceException(nameof(ConnectionString));
|
if (appSettings.ConnectionString is null) throw new NullReferenceException(nameof(ConnectionString));
|
||||||
|
if (appSettings.EcCharacterizationSi is null) throw new NullReferenceException(nameof(EcCharacterizationSi));
|
||||||
|
if (appSettings.EcMesaFileShareCharacterizationSi is null) throw new NullReferenceException(nameof(EcMesaFileShareCharacterizationSi));
|
||||||
|
if (appSettings.EcMesaFileShareMetrologySi is null) throw new NullReferenceException(nameof(EcMesaFileShareMetrologySi));
|
||||||
if (appSettings.GitCommitSeven is null) throw new NullReferenceException(nameof(GitCommitSeven));
|
if (appSettings.GitCommitSeven is null) throw new NullReferenceException(nameof(GitCommitSeven));
|
||||||
if (appSettings.InboundApiAllowedIPList is null) throw new NullReferenceException(nameof(InboundApiAllowedIPList));
|
if (appSettings.InboundApiAllowedIPList is null) throw new NullReferenceException(nameof(InboundApiAllowedIPList));
|
||||||
if (appSettings.IqsColumns is null) throw new NullReferenceException(nameof(IqsColumns));
|
if (appSettings.IqsColumns is null) throw new NullReferenceException(nameof(IqsColumns));
|
||||||
@ -69,18 +91,20 @@ public class AppSettings
|
|||||||
if (appSettings.URLs is null) throw new NullReferenceException(nameof(URLs));
|
if (appSettings.URLs is null) throw new NullReferenceException(nameof(URLs));
|
||||||
if (appSettings.TableToPath is null) throw new NullReferenceException(nameof(TableToPath));
|
if (appSettings.TableToPath is null) throw new NullReferenceException(nameof(TableToPath));
|
||||||
if (appSettings.WaferCounterDestinationDirectory is null) throw new NullReferenceException(nameof(WaferCounterDestinationDirectory));
|
if (appSettings.WaferCounterDestinationDirectory is null) throw new NullReferenceException(nameof(WaferCounterDestinationDirectory));
|
||||||
if (appSettings.WaferCounterRootDirectory is null) throw new NullReferenceException(nameof(WaferCounterRootDirectory));
|
|
||||||
if (appSettings.WorkingDirectoryName is null) throw new NullReferenceException(nameof(WorkingDirectoryName));
|
if (appSettings.WorkingDirectoryName is null) throw new NullReferenceException(nameof(WorkingDirectoryName));
|
||||||
result = new(
|
result = new(
|
||||||
appSettings.ApiExportPath,
|
appSettings.ApiExportPath,
|
||||||
|
appSettings.ApiFileShare,
|
||||||
appSettings.ApiLoggingContentTypes,
|
appSettings.ApiLoggingContentTypes,
|
||||||
appSettings.ApiLoggingPathPrefixes,
|
appSettings.ApiLoggingPathPrefixes,
|
||||||
appSettings.ApiLogPath,
|
appSettings.ApiLogPath,
|
||||||
appSettings.ApiUrl,
|
appSettings.ApiUrl,
|
||||||
appSettings.AttachmentPath,
|
|
||||||
appSettings.BuildNumber,
|
appSettings.BuildNumber,
|
||||||
appSettings.Company,
|
appSettings.Company,
|
||||||
appSettings.ConnectionString,
|
appSettings.ConnectionString,
|
||||||
|
appSettings.EcCharacterizationSi,
|
||||||
|
appSettings.EcMesaFileShareCharacterizationSi,
|
||||||
|
appSettings.EcMesaFileShareMetrologySi,
|
||||||
appSettings.GitCommitSeven,
|
appSettings.GitCommitSeven,
|
||||||
appSettings.InboundApiAllowedIPList,
|
appSettings.InboundApiAllowedIPList,
|
||||||
appSettings.IqsColumns,
|
appSettings.IqsColumns,
|
||||||
@ -97,7 +121,6 @@ public class AppSettings
|
|||||||
appSettings.TableToPath,
|
appSettings.TableToPath,
|
||||||
appSettings.URLs,
|
appSettings.URLs,
|
||||||
appSettings.WaferCounterDestinationDirectory,
|
appSettings.WaferCounterDestinationDirectory,
|
||||||
appSettings.WaferCounterRootDirectory,
|
|
||||||
appSettings.WorkingDirectoryName);
|
appSettings.WorkingDirectoryName);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -108,22 +131,7 @@ public class AppSettings
|
|||||||
#pragma warning disable IL3050, IL2026
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
#pragma warning restore IL3050, IL2026
|
#pragma warning restore IL3050, IL2026
|
||||||
if (appSettings?.ApiExportPath is null)
|
PreVerify(configurationRoot, appSettings);
|
||||||
{
|
|
||||||
List<string> paths = new();
|
|
||||||
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
|
|
||||||
{
|
|
||||||
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
|
|
||||||
continue;
|
|
||||||
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
|
|
||||||
continue;
|
|
||||||
paths.Add(physicalFileProvider.Root);
|
|
||||||
if (!physicalFileProvider.Root.Contains("UserSecrets"))
|
|
||||||
continue;
|
|
||||||
throw new NotSupportedException(physicalFileProvider.Root);
|
|
||||||
}
|
|
||||||
throw new NotSupportedException($"Not found!{Environment.NewLine}{string.Join(Environment.NewLine, paths)}");
|
|
||||||
}
|
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ using OI.Metrology.Server.Models;
|
|||||||
using OI.Metrology.Server.Repositories;
|
using OI.Metrology.Server.Repositories;
|
||||||
using OI.Metrology.Server.Repository;
|
using OI.Metrology.Server.Repository;
|
||||||
using OI.Metrology.Server.Services;
|
using OI.Metrology.Server.Services;
|
||||||
using OI.Metrology.Shared.Models;
|
|
||||||
using OI.Metrology.Shared.Models.Stateless;
|
using OI.Metrology.Shared.Models.Stateless;
|
||||||
using OI.Metrology.Shared.Repositories;
|
using OI.Metrology.Shared.Repositories;
|
||||||
using OI.Metrology.Shared.Services;
|
using OI.Metrology.Shared.Services;
|
||||||
@ -49,8 +48,6 @@ public class Program
|
|||||||
throw new Exception("Company name must have a value!");
|
throw new Exception("Company name must have a value!");
|
||||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
||||||
throw new Exception("Working directory name must have a value!");
|
throw new Exception("Working directory name must have a value!");
|
||||||
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assemblyName, appSettings.WorkingDirectoryName);
|
|
||||||
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_ = webApplicationBuilder.Services.AddMemoryCache();
|
_ = webApplicationBuilder.Services.AddMemoryCache();
|
||||||
@ -70,7 +67,7 @@ public class Program
|
|||||||
_ = webApplicationBuilder.Services.AddScoped<IInboundDataService, InboundDataService>();
|
_ = webApplicationBuilder.Services.AddScoped<IInboundDataService, InboundDataService>();
|
||||||
_ = webApplicationBuilder.Services.AddSingleton<IInboundRepository, InboundRepository>();
|
_ = webApplicationBuilder.Services.AddSingleton<IInboundRepository, InboundRepository>();
|
||||||
_ = webApplicationBuilder.Services.AddScoped<IMetrologyRepository, MetrologyRepository>();
|
_ = webApplicationBuilder.Services.AddScoped<IMetrologyRepository, MetrologyRepository>();
|
||||||
_ = webApplicationBuilder.Services.AddSingleton<IReactorsRepository, ReactorsRepository>();
|
_ = webApplicationBuilder.Services.AddSingleton<IFileShareRepository, FileShareRepository>();
|
||||||
_ = webApplicationBuilder.Services.AddSingleton<IToolTypesRepository, ToolTypesRepository>();
|
_ = webApplicationBuilder.Services.AddSingleton<IToolTypesRepository, ToolTypesRepository>();
|
||||||
_ = webApplicationBuilder.Services.AddSingleton<IInfinityQSRepository, InfinityQSRepository>();
|
_ = webApplicationBuilder.Services.AddSingleton<IInfinityQSRepository, InfinityQSRepository>();
|
||||||
_ = webApplicationBuilder.Services.AddScoped<IOpenInsightV1Repository, OpenInsightV1Repository>();
|
_ = webApplicationBuilder.Services.AddScoped<IOpenInsightV1Repository, OpenInsightV1Repository>();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using OI.Metrology.Server.Models;
|
using OI.Metrology.Server.Models;
|
||||||
using OI.Metrology.Shared.DataModels;
|
using OI.Metrology.Shared.DataModels;
|
||||||
|
using OI.Metrology.Shared.Models;
|
||||||
using OI.Metrology.Shared.Models.Stateless;
|
using OI.Metrology.Shared.Models.Stateless;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
@ -12,13 +13,17 @@ public class ExportRepository : IExportRepository
|
|||||||
private readonly string _RepositoryName;
|
private readonly string _RepositoryName;
|
||||||
private readonly AppSettings _AppSettings;
|
private readonly AppSettings _AppSettings;
|
||||||
private readonly ILogger<ExportRepository> _Logger;
|
private readonly ILogger<ExportRepository> _Logger;
|
||||||
|
private readonly IHttpClientFactory _HttpClientFactory;
|
||||||
|
private readonly IFileShareRepository _FileShareRepository;
|
||||||
private readonly Dictionary<string, Dictionary<long, HeaderCommon>> _RdsToHeaderCommonCollection;
|
private readonly Dictionary<string, Dictionary<long, HeaderCommon>> _RdsToHeaderCommonCollection;
|
||||||
|
|
||||||
public ExportRepository(ILogger<ExportRepository> logger, AppSettings appSettings)
|
public ExportRepository(ILogger<ExportRepository> logger, AppSettings appSettings, IHttpClientFactory httpClientFactory, IFileShareRepository fileShareRepository)
|
||||||
{
|
{
|
||||||
_Logger = logger;
|
_Logger = logger;
|
||||||
_AppSettings = appSettings;
|
_AppSettings = appSettings;
|
||||||
_RdsToHeaderCommonCollection = new();
|
_RdsToHeaderCommonCollection = new();
|
||||||
|
_HttpClientFactory = httpClientFactory;
|
||||||
|
_FileShareRepository = fileShareRepository;
|
||||||
_RepositoryName = nameof(ExportRepository)[..^10];
|
_RepositoryName = nameof(ExportRepository)[..^10];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,32 +37,47 @@ public class ExportRepository : IExportRepository
|
|||||||
return new string[] { weekOfYear, lastWeekOfYear };
|
return new string[] { weekOfYear, lastWeekOfYear };
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<string> GetFiles(HeaderCommon headerCommon, string searchPattern)
|
private NginxFileSystemSortable[] GetNginxFileSystemSortableCollection(HeaderCommon headerCommon, HttpClient httpClient, string endsWith)
|
||||||
{
|
{
|
||||||
List<string> results = new();
|
List<NginxFileSystemSortable> results = new();
|
||||||
string directory;
|
Uri uri;
|
||||||
string[] weeks = Get();
|
string[] weeks = Get();
|
||||||
|
List<NginxFileSystemSortable> nginxFileSystemSortableCollection;
|
||||||
foreach (string weekYear in weeks)
|
foreach (string weekYear in weeks)
|
||||||
{
|
{
|
||||||
if (headerCommon.ID < 1)
|
if (headerCommon.ID < 1)
|
||||||
directory = Path.Combine(_AppSettings.ApiExportPath, "Archive", "API", weekYear, $"-{headerCommon.PSN}", $"-{headerCommon.Reactor}", $"-{headerCommon.RDS}");
|
uri = _FileShareRepository.Append(new Uri(_AppSettings.EcMesaFileShareMetrologySi), "Archive", "API", weekYear, $"-{headerCommon.PSN}", $"-{headerCommon.Reactor}", $"-{headerCommon.RDS}");
|
||||||
else
|
else
|
||||||
directory = Path.Combine(_AppSettings.ApiExportPath, "Archive", "API", weekYear, $"-{headerCommon.PSN}", $"-{headerCommon.Reactor}", $"-{headerCommon.RDS}", $"-{headerCommon.ID}");
|
uri = _FileShareRepository.Append(new Uri(_AppSettings.EcMesaFileShareMetrologySi), "Archive", "API", weekYear, $"-{headerCommon.PSN}", $"-{headerCommon.Reactor}", $"-{headerCommon.RDS}", $"-{headerCommon.ID}");
|
||||||
if (!Directory.Exists(directory))
|
nginxFileSystemSortableCollection = _FileShareRepository.GetNginxFileSystemSortableCollection(httpClient, uri, endsWith);
|
||||||
continue;
|
results.AddRange(nginxFileSystemSortableCollection);
|
||||||
results.AddRange(Directory.GetFiles(directory, searchPattern, SearchOption.AllDirectories));
|
|
||||||
}
|
}
|
||||||
return results;
|
return results.OrderByDescending(l => l.DateTime).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetLines(HttpClient httpClient, NginxFileSystemSortable[] nginxFileSystemSortableCollection)
|
||||||
|
{
|
||||||
|
string result;
|
||||||
|
if (nginxFileSystemSortableCollection.Length != 1)
|
||||||
|
result = string.Empty;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HttpResponseMessage httpResponseMessage = _FileShareRepository.ReadFile(httpClient, nginxFileSystemSortableCollection.First().Uri);
|
||||||
|
if (httpResponseMessage.StatusCode != System.Net.HttpStatusCode.OK)
|
||||||
|
throw new Exception("File not found!");
|
||||||
|
Task<string> lines = httpResponseMessage.Content.ReadAsStringAsync();
|
||||||
|
lines.Wait();
|
||||||
|
result = lines.Result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
string IExportRepository.GetExport(HeaderCommon headerCommon)
|
string IExportRepository.GetExport(HeaderCommon headerCommon)
|
||||||
{
|
{
|
||||||
string result;
|
string result;
|
||||||
List<string> files = GetFiles(headerCommon, "*.txt");
|
HttpClient httpClient = _HttpClientFactory.CreateClient();
|
||||||
if (files.Count != 1)
|
NginxFileSystemSortable[] nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(headerCommon, httpClient, ".txt");
|
||||||
result = string.Empty;
|
result = GetLines(httpClient, nginxFileSystemSortableCollection);
|
||||||
else
|
|
||||||
result = File.ReadAllText(files.First());
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,16 +92,17 @@ public class ExportRepository : IExportRepository
|
|||||||
JsonElement? jsonElement;
|
JsonElement? jsonElement;
|
||||||
const string ticks = "Ticks";
|
const string ticks = "Ticks";
|
||||||
JsonProperty[] jsonProperties;
|
JsonProperty[] jsonProperties;
|
||||||
List<string> files = GetFiles(headerCommon, "*.json");
|
HttpClient httpClient = _HttpClientFactory.CreateClient();
|
||||||
foreach (string file in files)
|
NginxFileSystemSortable[] nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(headerCommon, httpClient, ".json");
|
||||||
|
foreach (NginxFileSystemSortable nginxFileSystemSortable in nginxFileSystemSortableCollection)
|
||||||
{
|
{
|
||||||
json = File.ReadAllText(file);
|
json = GetLines(httpClient, nginxFileSystemSortableCollection);
|
||||||
hc = JsonSerializer.Deserialize<HeaderCommon>(json);
|
hc = JsonSerializer.Deserialize<HeaderCommon>(json);
|
||||||
if (hc is null)
|
if (hc is null)
|
||||||
continue;
|
continue;
|
||||||
if (hc.ID < 1)
|
if (hc.ID < 1)
|
||||||
{
|
{
|
||||||
directory = Path.GetDirectoryName(file);
|
directory = Path.GetDirectoryName(nginxFileSystemSortable.Uri.OriginalString);
|
||||||
if (directory is null)
|
if (directory is null)
|
||||||
continue;
|
continue;
|
||||||
directoryName = Path.GetFileName(directory);
|
directoryName = Path.GetFileName(directory);
|
||||||
@ -112,10 +133,11 @@ public class ExportRepository : IExportRepository
|
|||||||
List<HeaderCommon> results = new();
|
List<HeaderCommon> results = new();
|
||||||
string json;
|
string json;
|
||||||
HeaderCommon? hc;
|
HeaderCommon? hc;
|
||||||
List<string> files = GetFiles(headerCommon, "*.json");
|
HttpClient httpClient = _HttpClientFactory.CreateClient();
|
||||||
foreach (string file in files)
|
NginxFileSystemSortable[] nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(headerCommon, httpClient, ".json");
|
||||||
|
foreach (NginxFileSystemSortable nginxFileSystemSortable in nginxFileSystemSortableCollection)
|
||||||
{
|
{
|
||||||
json = File.ReadAllText(file);
|
json = GetLines(httpClient, nginxFileSystemSortableCollection);
|
||||||
hc = JsonSerializer.Deserialize<HeaderCommon>(json);
|
hc = JsonSerializer.Deserialize<HeaderCommon>(json);
|
||||||
if (hc is null)
|
if (hc is null)
|
||||||
continue;
|
continue;
|
||||||
@ -132,11 +154,9 @@ public class ExportRepository : IExportRepository
|
|||||||
string IExportRepository.GetProcessDataStandardFormat(HeaderCommon headerCommon)
|
string IExportRepository.GetProcessDataStandardFormat(HeaderCommon headerCommon)
|
||||||
{
|
{
|
||||||
string result;
|
string result;
|
||||||
List<string> files = GetFiles(headerCommon, "*.pdsf");
|
HttpClient httpClient = _HttpClientFactory.CreateClient();
|
||||||
if (files.Count != 1)
|
NginxFileSystemSortable[] nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(headerCommon, httpClient, ".pdsf");
|
||||||
result = string.Empty;
|
result = GetLines(httpClient, nginxFileSystemSortableCollection);
|
||||||
else
|
|
||||||
result = File.ReadAllText(files.First());
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
105
Server/Repositories/FileShareRepository.cs
Normal file
105
Server/Repositories/FileShareRepository.cs
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
using OI.Metrology.Shared.Models;
|
||||||
|
using OI.Metrology.Shared.Models.Stateless;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace OI.Metrology.Server.Repository;
|
||||||
|
|
||||||
|
public class FileShareRepository : IFileShareRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
Uri IFileShareRepository.Append(Uri uri, params string[] paths) =>
|
||||||
|
new(paths.Aggregate(uri.AbsoluteUri, (current, path) => string.Format("{0}/{1}", current.TrimEnd('/'), path.TrimStart('/'))));
|
||||||
|
|
||||||
|
private Uri GetEndPoint(HttpClient httpClient, string method)
|
||||||
|
{
|
||||||
|
Uri result;
|
||||||
|
if (httpClient.BaseAddress is null)
|
||||||
|
throw new NullReferenceException(nameof(httpClient.BaseAddress));
|
||||||
|
IFileShareRepository fileShareRepository = this;
|
||||||
|
result = fileShareRepository.Append(httpClient.BaseAddress, "api", "v1", "file-share", method);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IFileShareRepository.CopyFile(string from, string to)
|
||||||
|
{
|
||||||
|
string directory = Path.GetDirectoryName(to) ?? throw new NullReferenceException();
|
||||||
|
if (!Directory.Exists(directory))
|
||||||
|
_ = Directory.CreateDirectory(directory);
|
||||||
|
File.Copy(from, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IFileShareRepository.MoveFile(string from, string to)
|
||||||
|
{
|
||||||
|
string directory = Path.GetDirectoryName(to) ?? throw new NullReferenceException();
|
||||||
|
if (!Directory.Exists(directory))
|
||||||
|
_ = Directory.CreateDirectory(directory);
|
||||||
|
File.Move(from, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IFileShareRepository.FileWrite(string path, string contents)
|
||||||
|
{
|
||||||
|
string directory = Path.GetDirectoryName(path) ?? throw new NullReferenceException();
|
||||||
|
if (!Directory.Exists(directory))
|
||||||
|
_ = Directory.CreateDirectory(directory);
|
||||||
|
File.WriteAllText(path, contents);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IFileShareRepository.CopyFile(HttpClient httpClient, string from, string to)
|
||||||
|
{
|
||||||
|
Uri uri = GetEndPoint(httpClient, "copy-file");
|
||||||
|
Task<HttpResponseMessage> httpResponseMessage = httpClient.GetAsync(uri);
|
||||||
|
httpResponseMessage.Wait();
|
||||||
|
if (httpResponseMessage.Result.StatusCode != System.Net.HttpStatusCode.OK)
|
||||||
|
throw new Exception(httpResponseMessage.Result.StatusCode.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void IFileShareRepository.MoveFile(HttpClient httpClient, string from, string to)
|
||||||
|
{
|
||||||
|
Uri uri = GetEndPoint(httpClient, "move-file");
|
||||||
|
Task<HttpResponseMessage> httpResponseMessage = httpClient.GetAsync(uri);
|
||||||
|
httpResponseMessage.Wait();
|
||||||
|
if (httpResponseMessage.Result.StatusCode != System.Net.HttpStatusCode.OK)
|
||||||
|
throw new Exception(httpResponseMessage.Result.StatusCode.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void IFileShareRepository.FileWrite(HttpClient httpClient, string path, string contents)
|
||||||
|
{
|
||||||
|
Uri uri = GetEndPoint(httpClient, "file-write");
|
||||||
|
Task<HttpResponseMessage> httpResponseMessage = httpClient.GetAsync(uri);
|
||||||
|
httpResponseMessage.Wait();
|
||||||
|
if (httpResponseMessage.Result.StatusCode != System.Net.HttpStatusCode.OK)
|
||||||
|
throw new Exception(httpResponseMessage.Result.StatusCode.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpResponseMessage IFileShareRepository.ReadFile(HttpClient httpClient, Uri uri)
|
||||||
|
{
|
||||||
|
HttpResponseMessage result;
|
||||||
|
Task<HttpResponseMessage> httpResponseMessage = httpClient.GetAsync(uri);
|
||||||
|
httpResponseMessage.Wait();
|
||||||
|
result = httpResponseMessage.Result;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<NginxFileSystemSortable> IFileShareRepository.GetNginxFileSystemSortableCollection(HttpClient httpClient, Uri uri, string? endsWith)
|
||||||
|
{
|
||||||
|
List<NginxFileSystemSortable> results = new();
|
||||||
|
Task<HttpResponseMessage> httpResponseMessage = httpClient.GetAsync(uri);
|
||||||
|
httpResponseMessage.Wait();
|
||||||
|
if (httpResponseMessage.Result.StatusCode == System.Net.HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
FileShareRepository fileShareRepository = this;
|
||||||
|
Task<string> json = httpResponseMessage.Result.Content.ReadAsStringAsync();
|
||||||
|
json.Wait();
|
||||||
|
NginxFileSystem[]? nginxFileSystemCollection = JsonSerializer.Deserialize(json.Result, NginxFileSystemCollectionSourceGenerationContext.Default.NginxFileSystemArray);
|
||||||
|
List<NginxFileSystemSortable> nginxFileSystemSortableCollection = NginxFileSystemSortable.Convert(fileShareRepository, uri, nginxFileSystemCollection);
|
||||||
|
foreach (NginxFileSystemSortable nginxFileSystemSortable in nginxFileSystemSortableCollection.OrderByDescending(l => l.DateTime))
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(endsWith) && !nginxFileSystemSortable.Name.EndsWith(endsWith))
|
||||||
|
continue;
|
||||||
|
results.Add(nginxFileSystemSortable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -22,14 +22,16 @@ public class InfinityQSV4Repository : IInfinityQSV4Repository
|
|||||||
private readonly AppSettings _AppSettings;
|
private readonly AppSettings _AppSettings;
|
||||||
private readonly IHttpClientFactory _HttpClientFactory;
|
private readonly IHttpClientFactory _HttpClientFactory;
|
||||||
private readonly IDbConnectionFactory _DBConnectionFactory;
|
private readonly IDbConnectionFactory _DBConnectionFactory;
|
||||||
|
private readonly IFileShareRepository _FileShareRepository;
|
||||||
private readonly string _OpenInsightApplicationProgrammingInterface;
|
private readonly string _OpenInsightApplicationProgrammingInterface;
|
||||||
|
|
||||||
public InfinityQSV4Repository(AppSettings appSettings, IDbConnectionFactory dbConnectionFactory, IHttpClientFactory httpClientFactory)
|
public InfinityQSV4Repository(AppSettings appSettings, IDbConnectionFactory dbConnectionFactory, IHttpClientFactory httpClientFactory, IFileShareRepository fileShareRepository)
|
||||||
{
|
{
|
||||||
_AppSettings = appSettings;
|
_AppSettings = appSettings;
|
||||||
_MockRoot = appSettings.MockRoot;
|
_MockRoot = appSettings.MockRoot;
|
||||||
_HttpClientFactory = httpClientFactory;
|
_HttpClientFactory = httpClientFactory;
|
||||||
_DBConnectionFactory = dbConnectionFactory;
|
_DBConnectionFactory = dbConnectionFactory;
|
||||||
|
_FileShareRepository = fileShareRepository;
|
||||||
_RepositoryName = nameof(InfinityQSV4Repository)[..^10];
|
_RepositoryName = nameof(InfinityQSV4Repository)[..^10];
|
||||||
_OpenInsightApplicationProgrammingInterface = appSettings.OpenInsightApplicationProgrammingInterface;
|
_OpenInsightApplicationProgrammingInterface = appSettings.OpenInsightApplicationProgrammingInterface;
|
||||||
}
|
}
|
||||||
@ -591,7 +593,10 @@ public class InfinityQSV4Repository : IInfinityQSV4Repository
|
|||||||
{
|
{
|
||||||
List<string> lines = new();
|
List<string> lines = new();
|
||||||
foreach (char ch in runDataSheetRoot.RunDataSheet.PSN)
|
foreach (char ch in runDataSheetRoot.RunDataSheet.PSN)
|
||||||
{ }
|
{
|
||||||
|
if (ch is '1')
|
||||||
|
continue;
|
||||||
|
}
|
||||||
result = string.Join(Environment.NewLine, lines);
|
result = string.Join(Environment.NewLine, lines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -742,10 +747,10 @@ public class InfinityQSV4Repository : IInfinityQSV4Repository
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void FileFindReplaceAndSave(AppSettings appSettings, string iqsFile, FileInfo fileInfo)
|
private void FileFindReplaceAndSave(string iqsFile, FileInfo fileInfo)
|
||||||
{
|
{
|
||||||
string lines = File.ReadAllText(iqsFile).Replace(appSettings.IqsRed, "red").Replace(appSettings.IqsYellow, "Yellow");
|
string lines = File.ReadAllText(iqsFile).Replace(_AppSettings.IqsRed, "red").Replace(_AppSettings.IqsYellow, "Yellow");
|
||||||
File.WriteAllText(fileInfo.FullName, lines);
|
_FileShareRepository.FileWrite(fileInfo.FullName, lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<string, List<string>> IInfinityQSV4Repository.GetEngineeringSpcReview()
|
Dictionary<string, List<string>> IInfinityQSV4Repository.GetEngineeringSpcReview()
|
||||||
@ -771,7 +776,7 @@ public class InfinityQSV4Repository : IInfinityQSV4Repository
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!localFileInfo.Exists || localFileInfo.LastWriteTime != iqsFileInfo.LastWriteTime)
|
if (!localFileInfo.Exists || localFileInfo.LastWriteTime != iqsFileInfo.LastWriteTime)
|
||||||
FileFindReplaceAndSave(_AppSettings, iqsFileInfo.FullName, localFileInfo);
|
FileFindReplaceAndSave(iqsFileInfo.FullName, localFileInfo);
|
||||||
ReadOnlyCollection<Record> records = !iqsFileInfo.Exists || iqsFileInfo.Length == 0 ? GetRecords(_AppSettings, localFileInfo.FullName) : GetRecords(_AppSettings, iqsFileInfo.FullName);
|
ReadOnlyCollection<Record> records = !iqsFileInfo.Exists || iqsFileInfo.Length == 0 ? GetRecords(_AppSettings, localFileInfo.FullName) : GetRecords(_AppSettings, iqsFileInfo.FullName);
|
||||||
List<Dictionary<string, Record>> collection = GetCollection(_AppSettings.IqsColumns, records);
|
List<Dictionary<string, Record>> collection = GetCollection(_AppSettings.IqsColumns, records);
|
||||||
results = GetResults(_AppSettings, collection);
|
results = GetResults(_AppSettings, collection);
|
||||||
|
@ -1,146 +0,0 @@
|
|||||||
using OI.Metrology.Server.Models;
|
|
||||||
using OI.Metrology.Shared.DataModels;
|
|
||||||
using OI.Metrology.Shared.Models.Stateless;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
namespace OI.Metrology.Server.Repository;
|
|
||||||
|
|
||||||
public class ReactorsRepository : IReactorsRepository
|
|
||||||
{
|
|
||||||
|
|
||||||
private readonly AppSettings _AppSettings;
|
|
||||||
private readonly Dictionary<int, char> _SecondsToAlpha;
|
|
||||||
|
|
||||||
public ReactorsRepository(AppSettings appSettings)
|
|
||||||
{
|
|
||||||
_AppSettings = appSettings;
|
|
||||||
_SecondsToAlpha = new();
|
|
||||||
for (int i = 65; i < 91; i++)
|
|
||||||
{
|
|
||||||
if (i is 73 or 79)
|
|
||||||
continue;
|
|
||||||
_SecondsToAlpha.Add(i - 65, (char)i);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Result<int[]> IReactorsRepository.EvenReactors()
|
|
||||||
{
|
|
||||||
Result<int[]> results;
|
|
||||||
int[] collection = new int[] {
|
|
||||||
20,
|
|
||||||
22,
|
|
||||||
24,
|
|
||||||
26,
|
|
||||||
28,
|
|
||||||
30,
|
|
||||||
32,
|
|
||||||
34,
|
|
||||||
36,
|
|
||||||
38,
|
|
||||||
40,
|
|
||||||
42,
|
|
||||||
44,
|
|
||||||
46,
|
|
||||||
48,
|
|
||||||
50,
|
|
||||||
52,
|
|
||||||
54,
|
|
||||||
56,
|
|
||||||
58,
|
|
||||||
60,
|
|
||||||
62,
|
|
||||||
64,
|
|
||||||
66,
|
|
||||||
68,
|
|
||||||
70,
|
|
||||||
72,
|
|
||||||
74
|
|
||||||
};
|
|
||||||
results = new()
|
|
||||||
{
|
|
||||||
Results = collection,
|
|
||||||
TotalRows = collection.Length,
|
|
||||||
};
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result<int[]> IReactorsRepository.OddReactors()
|
|
||||||
{
|
|
||||||
Result<int[]> results;
|
|
||||||
int[] collection = new int[] {
|
|
||||||
21,
|
|
||||||
23,
|
|
||||||
25,
|
|
||||||
27,
|
|
||||||
29,
|
|
||||||
31,
|
|
||||||
33,
|
|
||||||
35,
|
|
||||||
37,
|
|
||||||
39,
|
|
||||||
41,
|
|
||||||
43,
|
|
||||||
45,
|
|
||||||
47,
|
|
||||||
49,
|
|
||||||
51,
|
|
||||||
53,
|
|
||||||
55,
|
|
||||||
57,
|
|
||||||
59,
|
|
||||||
61,
|
|
||||||
63,
|
|
||||||
65,
|
|
||||||
73,
|
|
||||||
75,
|
|
||||||
77,
|
|
||||||
79
|
|
||||||
};
|
|
||||||
results = new()
|
|
||||||
{
|
|
||||||
Results = collection,
|
|
||||||
TotalRows = collection.Length,
|
|
||||||
};
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
string? IReactorsRepository.GetKey(WorkMaterialOut workMaterialOut, bool save)
|
|
||||||
{
|
|
||||||
if (workMaterialOut is null)
|
|
||||||
throw new Exception();
|
|
||||||
if (workMaterialOut.Username is null || workMaterialOut.Username.Length < 2)
|
|
||||||
throw new ArgumentException(nameof(workMaterialOut.Username));
|
|
||||||
if (workMaterialOut.RunDataSheet is null || workMaterialOut.RunDataSheet.Length < 2)
|
|
||||||
throw new ArgumentException(nameof(workMaterialOut.RunDataSheet));
|
|
||||||
string? result = null;
|
|
||||||
char c;
|
|
||||||
string? fileName = null;
|
|
||||||
DateTime dateTime = DateTime.Now;
|
|
||||||
Calendar calendar = new CultureInfo("en-US").Calendar;
|
|
||||||
string json = JsonSerializer.Serialize(workMaterialOut, new JsonSerializerOptions { WriteIndented = true });
|
|
||||||
string weekOfYear = $"{dateTime:yyyy}_Week_{calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday):00}";
|
|
||||||
string directory = Path.Combine(_AppSettings.ApiExportPath, "WorkMaterialOut", "API", weekOfYear, dateTime.ToString("yyyy-MM-dd_HH"));
|
|
||||||
if (!Directory.Exists(directory))
|
|
||||||
_ = Directory.CreateDirectory(directory);
|
|
||||||
for (int i = 0; i < int.MaxValue; i++)
|
|
||||||
{
|
|
||||||
dateTime = dateTime.AddSeconds(i);
|
|
||||||
if (!_SecondsToAlpha.TryGetValue(dateTime.Second, out c))
|
|
||||||
continue;
|
|
||||||
fileName = Path.Combine(directory, $"WMO-{dateTime:mm}{c}.json");
|
|
||||||
if (!File.Exists(fileName))
|
|
||||||
{
|
|
||||||
result = $"{c}{dateTime:mm}";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fileName is null)
|
|
||||||
throw new Exception();
|
|
||||||
if (save)
|
|
||||||
File.WriteAllText(fileName, json);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -13,10 +13,16 @@ public class ToolTypesRepository : IToolTypesRepository
|
|||||||
|
|
||||||
private readonly string _MockRoot;
|
private readonly string _MockRoot;
|
||||||
private readonly string _RepositoryName;
|
private readonly string _RepositoryName;
|
||||||
|
private readonly AppSettings _AppSettings;
|
||||||
|
private readonly IHttpClientFactory _HttpClientFactory;
|
||||||
|
private readonly IFileShareRepository _FileShareRepository;
|
||||||
|
|
||||||
public ToolTypesRepository(AppSettings appSettings)
|
public ToolTypesRepository(AppSettings appSettings, IHttpClientFactory httpClientFactory, IFileShareRepository fileShareRepository)
|
||||||
{
|
{
|
||||||
|
_AppSettings = appSettings;
|
||||||
_MockRoot = appSettings.MockRoot;
|
_MockRoot = appSettings.MockRoot;
|
||||||
|
_HttpClientFactory = httpClientFactory;
|
||||||
|
_FileShareRepository = fileShareRepository;
|
||||||
_RepositoryName = nameof(ToolTypesRepository)[..^10];
|
_RepositoryName = nameof(ToolTypesRepository)[..^10];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +209,7 @@ public class ToolTypesRepository : IToolTypesRepository
|
|||||||
return new(message, contentType, stream);
|
return new(message, contentType, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
string? IToolTypesRepository.OIExport(IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService, string attachmentPath, Dictionary<string, string> tableToPath, int toolTypeId, long headerid)
|
string? IToolTypesRepository.OIExport(IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService, int toolTypeId, long headerid)
|
||||||
{
|
{
|
||||||
string? result;
|
string? result;
|
||||||
ToolType toolType = metrologyRepository.GetToolTypeByID(toolTypeId);
|
ToolType toolType = metrologyRepository.GetToolTypeByID(toolTypeId);
|
||||||
@ -211,16 +217,18 @@ public class ToolTypesRepository : IToolTypesRepository
|
|||||||
result = $"Invalid tool id [{toolTypeId}] [{headerid}]!";
|
result = $"Invalid tool id [{toolTypeId}] [{headerid}]!";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string? processDataStandardFormat = attachmentsService.GetProcessDataStandardFormat(metrologyRepository, attachmentPath, toolTypeId, headerid);
|
string? processDataStandardFormat = attachmentsService.GetProcessDataStandardFormat(metrologyRepository, toolTypeId, headerid);
|
||||||
if (processDataStandardFormat is null)
|
if (processDataStandardFormat is null)
|
||||||
result = $"Export file doesn't exist for [{toolTypeId}] [{headerid}] at <{attachmentPath}>!";
|
result = $"Export file doesn't exist for [{toolTypeId}] [{headerid}] at <{_AppSettings.EcMesaFileShareMetrologySi}>!";
|
||||||
else if (!tableToPath.TryGetValue(toolType.HeaderTableName, out string? directly))
|
else if (!_AppSettings.TableToPath.TryGetValue(toolType.HeaderTableName, out string? directly))
|
||||||
result = $"Export file doesn't exist for [{toolTypeId}] [{headerid}] at <{attachmentPath}>!";
|
result = $"Export file doesn't exist for [{toolTypeId}] [{headerid}] at <{_AppSettings.EcMesaFileShareMetrologySi}>!";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.Copy(processDataStandardFormat, Path.Combine(directly, $"Viewer_{Path.GetFileName(processDataStandardFormat)}"));
|
HttpClient httpClient = _HttpClientFactory.CreateClient();
|
||||||
|
httpClient.BaseAddress = new(_AppSettings.ApiFileShare);
|
||||||
|
_FileShareRepository.CopyFile(httpClient, processDataStandardFormat, Path.Combine(directly, $"Viewer_{Path.GetFileName(processDataStandardFormat)}"));
|
||||||
result = null;
|
result = null;
|
||||||
}
|
}
|
||||||
catch (Exception ex) { result = ex.Message; }
|
catch (Exception ex) { result = ex.Message; }
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using OI.Metrology.Server.Models;
|
using OI.Metrology.Server.Models;
|
||||||
using OI.Metrology.Shared.DataModels;
|
using OI.Metrology.Shared.DataModels;
|
||||||
|
using OI.Metrology.Shared.Models;
|
||||||
using OI.Metrology.Shared.Models.Stateless;
|
using OI.Metrology.Shared.Models.Stateless;
|
||||||
using OI.Metrology.Shared.Repositories;
|
using OI.Metrology.Shared.Repositories;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
@ -19,28 +20,27 @@ public class WaferCounterRepository : IWaferCounterRepository
|
|||||||
private readonly AppSettings _AppSettings;
|
private readonly AppSettings _AppSettings;
|
||||||
private readonly IHttpClientFactory _HttpClientFactory;
|
private readonly IHttpClientFactory _HttpClientFactory;
|
||||||
private readonly IDbConnectionFactory _DBConnectionFactory;
|
private readonly IDbConnectionFactory _DBConnectionFactory;
|
||||||
|
private readonly IFileShareRepository _FileShareRepository;
|
||||||
private readonly string _OpenInsightApplicationProgrammingInterface;
|
private readonly string _OpenInsightApplicationProgrammingInterface;
|
||||||
|
|
||||||
public WaferCounterRepository(AppSettings appSettings, IDbConnectionFactory dbConnectionFactory, IHttpClientFactory httpClientFactory)
|
public WaferCounterRepository(AppSettings appSettings, IDbConnectionFactory dbConnectionFactory, IHttpClientFactory httpClientFactory, IFileShareRepository fileShareRepository)
|
||||||
{
|
{
|
||||||
_AppSettings = appSettings;
|
_AppSettings = appSettings;
|
||||||
_MockRoot = appSettings.MockRoot;
|
_MockRoot = appSettings.MockRoot;
|
||||||
_HttpClientFactory = httpClientFactory;
|
_HttpClientFactory = httpClientFactory;
|
||||||
_DBConnectionFactory = dbConnectionFactory;
|
_DBConnectionFactory = dbConnectionFactory;
|
||||||
|
_FileShareRepository = fileShareRepository;
|
||||||
_RepositoryName = nameof(WaferCounterRepository)[..^10];
|
_RepositoryName = nameof(WaferCounterRepository)[..^10];
|
||||||
_OpenInsightApplicationProgrammingInterface = appSettings.OpenInsightApplicationProgrammingInterface;
|
_OpenInsightApplicationProgrammingInterface = appSettings.OpenInsightApplicationProgrammingInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MoveFile(string waferSizeDirectory, FileInfo fileInfo)
|
private void MoveFile(string waferSizeDirectory, NginxFileSystemSortable nginxFileSystemSortable)
|
||||||
{
|
{
|
||||||
Calendar calendar = new CultureInfo("en-US").Calendar;
|
Calendar calendar = new CultureInfo("en-US").Calendar;
|
||||||
string weekOfYear = $"{fileInfo.LastWriteTime:yyyy}_Week_{calendar.GetWeekOfYear(fileInfo.LastWriteTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday):00}";
|
string from = Path.Combine(waferSizeDirectory, nginxFileSystemSortable.Name);
|
||||||
string checkDirectory = Path.Combine(waferSizeDirectory, "Archive", weekOfYear);
|
string weekOfYear = $"{nginxFileSystemSortable.DateTime:yyyy}_Week_{calendar.GetWeekOfYear(nginxFileSystemSortable.DateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday):00}";
|
||||||
if (!Directory.Exists(checkDirectory))
|
string to = Path.Combine(waferSizeDirectory, "Archive", weekOfYear, nginxFileSystemSortable.Name);
|
||||||
_ = Directory.CreateDirectory(checkDirectory);
|
_FileShareRepository.MoveFile(from, to);
|
||||||
string checkFile = Path.Combine(checkDirectory, fileInfo.Name);
|
|
||||||
if (!File.Exists(checkFile))
|
|
||||||
File.Move(fileInfo.FullName, checkFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Record GetRecord(string line1, string line2)
|
private static Record GetRecord(string line1, string line2)
|
||||||
@ -126,43 +126,42 @@ public class WaferCounterRepository : IWaferCounterRepository
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Uri GetWaferSizeUri(string area, string waferSize) =>
|
||||||
|
_FileShareRepository.Append(new Uri(_AppSettings.EcMesaFileShareCharacterizationSi), "WaferCounter", area, waferSize);
|
||||||
|
|
||||||
private string GetWaferSizeDirectory(string area, string waferSize, bool destination) =>
|
private string GetWaferSizeDirectory(string area, string waferSize, bool destination) =>
|
||||||
destination ? Path.Combine(_AppSettings.WaferCounterDestinationDirectory, area, waferSize) : Path.Combine(_AppSettings.WaferCounterRootDirectory, area, waferSize);
|
destination ? Path.Combine(_AppSettings.WaferCounterDestinationDirectory, area, waferSize) : Path.Combine(_AppSettings.EcCharacterizationSi, "WaferCounter", area, waferSize);
|
||||||
|
|
||||||
string? IWaferCounterRepository.GetSlotMap(string line1, string line2) =>
|
string? IWaferCounterRepository.GetSlotMap(string line1, string line2) =>
|
||||||
GetRecord(line1, line2).SlotMap;
|
GetRecord(line1, line2).SlotMap;
|
||||||
|
|
||||||
private static FileInfo[] GetFileInfoCollection(string waferSizeDirectory)
|
private List<NginxFileSystemSortable> GetNginxFileSystemSortableCollection(HttpClient httpClient, Uri waferSizeUri, string waferSizeDirectory)
|
||||||
{
|
{
|
||||||
List<FileInfo> results = new();
|
List<NginxFileSystemSortable> results = _FileShareRepository.GetNginxFileSystemSortableCollection(httpClient, waferSizeUri, ".wc");
|
||||||
FileInfo[] fileInfoCollection;
|
for (int i = 1; i < results.Count; i++)
|
||||||
string[] files = !Directory.Exists(waferSizeDirectory) ? Array.Empty<string>() : Directory.GetFiles(waferSizeDirectory, "*.wc", SearchOption.TopDirectoryOnly);
|
MoveFile(waferSizeDirectory, results[i]);
|
||||||
fileInfoCollection = (from l in files select new FileInfo(l)).OrderByDescending(l => l.LastWriteTime).ToArray();
|
return results;
|
||||||
if (fileInfoCollection.Length > 0)
|
|
||||||
results.Add(fileInfoCollection[0]);
|
|
||||||
|
|
||||||
for (int i = 1; i < fileInfoCollection.Length; i++)
|
|
||||||
MoveFile(waferSizeDirectory, fileInfoCollection[i]);
|
|
||||||
return fileInfoCollection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static WaferCounter? GetLastQuantityAndSlotMapWithText(string waferSize, string text, FileInfo fileInfo)
|
private static WaferCounter? GetLastQuantityAndSlotMapWithText(string waferSize, string text, HttpClient httpClient, NginxFileSystemSortable nginxFileSystemSortable)
|
||||||
{
|
{
|
||||||
WaferCounter? result;
|
WaferCounter? result;
|
||||||
string[] lines = File.ReadAllLines(fileInfo.FullName);
|
Task<string> value = httpClient.GetStringAsync(nginxFileSystemSortable.Uri);
|
||||||
|
value.Wait();
|
||||||
|
string[] lines = value.Result.Split(Environment.NewLine);
|
||||||
if (lines.Length < 2)
|
if (lines.Length < 2)
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string[] segments = fileInfo.Name.Split('-');
|
string[] segments = nginxFileSystemSortable.Name.Split('-');
|
||||||
Record record = GetRecord(lines[0], lines[1]);
|
Record record = GetRecord(lines[0], lines[1]);
|
||||||
string equipmentId = segments.Length < 2 ? fileInfo.Name : segments[1].Split('.')[0];
|
string equipmentId = segments.Length < 2 ? nginxFileSystemSortable.Name : segments[1].Split('.')[0];
|
||||||
if (string.IsNullOrEmpty(record.SlotMap) || record.SlotMap.Length != 25)
|
if (string.IsNullOrEmpty(record.SlotMap) || record.SlotMap.Length != 25)
|
||||||
result = null; // Wrong length!
|
result = null; // Wrong length!
|
||||||
else if (record.Total != record.Check)
|
else if (record.Total != record.Check)
|
||||||
result = null; // Invalid!
|
result = null; // Invalid!
|
||||||
else
|
else
|
||||||
result = new(fileInfo.LastWriteTime, fileInfo.LastWriteTime.ToString("yyyy-MM-dd hh:mm tt"), $"WC{waferSize}{equipmentId}", text, record.Total, record.SlotMap);
|
result = new(nginxFileSystemSortable.DateTime, nginxFileSystemSortable.DateTime.ToString("yyyy-MM-dd hh:mm tt"), $"WC{waferSize}{equipmentId}", text, record.Total, record.SlotMap);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -179,21 +178,23 @@ public class WaferCounterRepository : IWaferCounterRepository
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Uri waferSizeUri = GetWaferSizeUri(area, waferSize);
|
||||||
|
HttpClient httpClient = _HttpClientFactory.CreateClient();
|
||||||
string waferSizeDirectory = GetWaferSizeDirectory(area, waferSize, destination: false);
|
string waferSizeDirectory = GetWaferSizeDirectory(area, waferSize, destination: false);
|
||||||
FileInfo[] fileInfoCollection = GetFileInfoCollection(waferSizeDirectory);
|
List<NginxFileSystemSortable> nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(httpClient, waferSizeUri, waferSizeDirectory);
|
||||||
if (fileInfoCollection.Length == 0)
|
if (nginxFileSystemSortableCollection.Count == 0)
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string text = string.Empty;
|
string text = string.Empty;
|
||||||
result = GetLastQuantityAndSlotMapWithText(waferSize, text, fileInfoCollection[0]);
|
result = GetLastQuantityAndSlotMapWithText(waferSize, text, httpClient, nginxFileSystemSortableCollection[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Save(string waferSizeDestinationDirectory, string area, string waferSize, string text, FileInfo fileInfo, WaferCounter result) =>
|
private void Save(string waferSizeDestinationDirectory, string area, string waferSize, string text, NginxFileSystemSortable nginxFileSystemSortable, WaferCounter result) =>
|
||||||
File.WriteAllText(Path.Combine(waferSizeDestinationDirectory, $"{fileInfo.Name}.csv"), $"100,{waferSize},{area},{fileInfo.LastWriteTime},{text},{result.Total:00},{result.SlotMap} ");
|
_FileShareRepository.FileWrite(Path.Combine(waferSizeDestinationDirectory, $"{nginxFileSystemSortable.Name}.csv"), $"100,{waferSize},{area},{nginxFileSystemSortable.DateTime},{text},{result.Total:00},{result.SlotMap} ");
|
||||||
|
|
||||||
WaferCounter? IWaferCounterRepository.GetLastQuantityAndSlotMapWithText(string area, string waferSize, string text)
|
WaferCounter? IWaferCounterRepository.GetLastQuantityAndSlotMapWithText(string area, string waferSize, string text)
|
||||||
{
|
{
|
||||||
@ -207,18 +208,20 @@ public class WaferCounterRepository : IWaferCounterRepository
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Uri waferSizeUri = GetWaferSizeUri(area, waferSize);
|
||||||
|
HttpClient httpClient = _HttpClientFactory.CreateClient();
|
||||||
string waferSizeDirectory = GetWaferSizeDirectory(area, waferSize, destination: false);
|
string waferSizeDirectory = GetWaferSizeDirectory(area, waferSize, destination: false);
|
||||||
FileInfo[] fileInfoCollection = GetFileInfoCollection(waferSizeDirectory);
|
List<NginxFileSystemSortable> nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(httpClient, waferSizeUri, waferSizeDirectory);
|
||||||
if (fileInfoCollection.Length == 0)
|
if (nginxFileSystemSortableCollection.Count == 0)
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = GetLastQuantityAndSlotMapWithText(waferSize, text, fileInfoCollection[0]);
|
result = GetLastQuantityAndSlotMapWithText(waferSize, text, httpClient, nginxFileSystemSortableCollection[0]);
|
||||||
if (result is not null)
|
if (result is not null)
|
||||||
{
|
{
|
||||||
string waferSizeDestinationDirectory = _AppSettings.WaferCounterDestinationDirectory;
|
string waferSizeDestinationDirectory = _AppSettings.WaferCounterDestinationDirectory;
|
||||||
// string waferSizeDestinationDirectory = GetWaferSizeDirectory(area, waferSize, destination: true);
|
// string waferSizeDestinationDirectory = GetWaferSizeUri(area, waferSize, destination: true);
|
||||||
Save(waferSizeDestinationDirectory, area, waferSize, text, fileInfoCollection[0], result);
|
Save(waferSizeDestinationDirectory, area, waferSize, text, nginxFileSystemSortableCollection[0], result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,17 +4,24 @@ namespace OI.Metrology.Server.Services;
|
|||||||
|
|
||||||
using OI.Metrology.Server.Models;
|
using OI.Metrology.Server.Models;
|
||||||
using OI.Metrology.Shared.DataModels;
|
using OI.Metrology.Shared.DataModels;
|
||||||
|
using OI.Metrology.Shared.Models;
|
||||||
using OI.Metrology.Shared.Models.Stateless;
|
using OI.Metrology.Shared.Models.Stateless;
|
||||||
using OI.Metrology.Shared.Services;
|
using OI.Metrology.Shared.Services;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
public class AttachmentsService : IAttachmentsService
|
public class AttachmentsService : IAttachmentsService
|
||||||
{
|
{
|
||||||
|
|
||||||
private readonly AppSettings _AppSettings;
|
private readonly AppSettings _AppSettings;
|
||||||
|
private readonly IHttpClientFactory _HttpClientFactory;
|
||||||
|
private readonly IFileShareRepository _FileShareRepository;
|
||||||
private readonly IMetrologyRepository _MetrologyRepository;
|
private readonly IMetrologyRepository _MetrologyRepository;
|
||||||
|
|
||||||
public AttachmentsService(AppSettings appSettings, IMetrologyRepository metrologyRepository)
|
public AttachmentsService(AppSettings appSettings, IHttpClientFactory httpClientFactory, IFileShareRepository fileShareRepository, IMetrologyRepository metrologyRepository)
|
||||||
{
|
{
|
||||||
_AppSettings = appSettings;
|
_AppSettings = appSettings;
|
||||||
|
_HttpClientFactory = httpClientFactory;
|
||||||
|
_FileShareRepository = fileShareRepository;
|
||||||
_MetrologyRepository = metrologyRepository;
|
_MetrologyRepository = metrologyRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,23 +34,16 @@ public class AttachmentsService : IAttachmentsService
|
|||||||
throw new NullReferenceException(nameof(tableName));
|
throw new NullReferenceException(nameof(tableName));
|
||||||
|
|
||||||
DateTime insertDate = Convert.ToDateTime(_MetrologyRepository.GetAttachmentInsertDateByGUID(tableName, attachmentId));
|
DateTime insertDate = Convert.ToDateTime(_MetrologyRepository.GetAttachmentInsertDateByGUID(tableName, attachmentId));
|
||||||
|
|
||||||
string year = insertDate.Year.ToString();
|
string year = insertDate.Year.ToString();
|
||||||
|
HttpClient httpClient = _HttpClientFactory.CreateClient();
|
||||||
|
Uri mesaFileShareMetrologySi = new(_AppSettings.EcMesaFileShareMetrologySi);
|
||||||
int weekNum = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(insertDate, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
|
int weekNum = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(insertDate, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
|
||||||
string directory = Path.Combine(_AppSettings.AttachmentPath, tableName + "_", year, $"WW{weekNum:00}", attachmentId.ToString());
|
Uri uri = _FileShareRepository.Append(mesaFileShareMetrologySi, $"{tableName}_", year, $"WW{weekNum:00}", attachmentId.ToString(), filename);
|
||||||
if (!Directory.Exists(directory))
|
HttpResponseMessage httpResponseMessage = _FileShareRepository.ReadFile(httpClient, uri);
|
||||||
_ = Directory.CreateDirectory(directory);
|
if (httpResponseMessage.StatusCode != System.Net.HttpStatusCode.OK)
|
||||||
string fullPath = Path.Combine(directory, filename);
|
throw new Exception("File not found!");
|
||||||
|
return httpResponseMessage.Content.ReadAsStream();
|
||||||
// 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))
|
|
||||||
{
|
|
||||||
fullPath = Path.Combine(_AppSettings.AttachmentPath, tableName, attachmentId.ToString(), filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!File.Exists(fullPath))
|
|
||||||
throw new Exception("File not found");
|
|
||||||
|
|
||||||
return new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream IAttachmentsService.GetAttachmentStreamByTitle(ToolType toolType, bool header, string title, string filename)
|
Stream IAttachmentsService.GetAttachmentStreamByTitle(ToolType toolType, bool header, string title, string filename)
|
||||||
@ -86,7 +86,6 @@ public class AttachmentsService : IAttachmentsService
|
|||||||
Guid attachmentId = Guid.Empty;
|
Guid attachmentId = Guid.Empty;
|
||||||
DateTime insertDate = new();
|
DateTime insertDate = new();
|
||||||
string? tableName = "";
|
string? tableName = "";
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(dataUniqueId))
|
if (string.IsNullOrWhiteSpace(dataUniqueId))
|
||||||
{
|
{
|
||||||
attachmentId = _MetrologyRepository.GetHeaderAttachmentID(toolType.ID, headerId);
|
attachmentId = _MetrologyRepository.GetHeaderAttachmentID(toolType.ID, headerId);
|
||||||
@ -101,18 +100,22 @@ public class AttachmentsService : IAttachmentsService
|
|||||||
tableName = toolType.DataTableName;
|
tableName = toolType.DataTableName;
|
||||||
}
|
}
|
||||||
if (Equals(attachmentId, Guid.Empty))
|
if (Equals(attachmentId, Guid.Empty))
|
||||||
throw new Exception("Invalid attachment ID");
|
{
|
||||||
|
trans.Dispose();
|
||||||
|
throw new Exception("Invalid attachment ID!");
|
||||||
|
}
|
||||||
string year = insertDate.Year.ToString();
|
string year = insertDate.Year.ToString();
|
||||||
|
HttpClient httpClient = _HttpClientFactory.CreateClient();
|
||||||
|
Uri mesaFileShareMetrologySi = new(_AppSettings.EcMesaFileShareMetrologySi);
|
||||||
int weekNum = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(insertDate, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
|
int weekNum = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(insertDate, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
|
||||||
string directory = Path.Combine(_AppSettings.AttachmentPath, $"{tableName}_", year, $"WW{weekNum:00}", attachmentId.ToString());
|
Uri uri = _FileShareRepository.Append(mesaFileShareMetrologySi, $"{tableName}_", year, $"WW{weekNum:00}", attachmentId.ToString(), filename);
|
||||||
if (!Directory.Exists(directory))
|
HttpResponseMessage httpResponseMessage = _FileShareRepository.ReadFile(httpClient, uri);
|
||||||
_ = Directory.CreateDirectory(directory);
|
if (httpResponseMessage.StatusCode != System.Net.HttpStatusCode.OK)
|
||||||
|
{
|
||||||
string fullPath = Path.Combine(directory, filename);
|
trans.Dispose();
|
||||||
|
throw new Exception("Invalid attachment path!");
|
||||||
using (FileStream fileStream = new(fullPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
|
}
|
||||||
uploadedFile.CopyTo(fileStream);
|
uploadedFile.CopyTo(httpResponseMessage.Content.ReadAsStream());
|
||||||
trans.Complete();
|
trans.Complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,27 +125,38 @@ public class AttachmentsService : IAttachmentsService
|
|||||||
SaveAttachment(toolType, headerId, dataUniqueId, filename, formFile);
|
SaveAttachment(toolType, headerId, dataUniqueId, filename, formFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
string? IAttachmentsService.GetProcessDataStandardFormat(IMetrologyRepository metrologyRepository, string attachmentPath, int toolTypeId, long headerId)
|
string? IAttachmentsService.GetProcessDataStandardFormat(IMetrologyRepository metrologyRepository, int toolTypeId, long headerId)
|
||||||
{
|
{
|
||||||
string? result;
|
string? result;
|
||||||
string year;
|
|
||||||
int weekNum;
|
int weekNum;
|
||||||
string directory;
|
string year;
|
||||||
string checkDirectory;
|
Task<string> json;
|
||||||
|
Uri weekDirectory;
|
||||||
|
Uri checkDirectory;
|
||||||
List<string> files = new();
|
List<string> files = new();
|
||||||
|
NginxFileSystem[]? nginxFileSystemCollection;
|
||||||
|
Task<HttpResponseMessage> httpResponseMessage;
|
||||||
|
HttpClient httpClient = _HttpClientFactory.CreateClient();
|
||||||
|
Uri mesaFileShareMetrologySi = new(_AppSettings.EcMesaFileShareMetrologySi);
|
||||||
DateTime[] dateTimes = new DateTime[] { DateTime.Now, DateTime.Now.AddDays(-6.66) };
|
DateTime[] dateTimes = new DateTime[] { DateTime.Now, DateTime.Now.AddDays(-6.66) };
|
||||||
ToolType toolType = metrologyRepository.GetToolTypeByID(toolTypeId) ?? throw new Exception("Invalid tool type ID");
|
ToolType toolType = metrologyRepository.GetToolTypeByID(toolTypeId) ?? throw new Exception("Invalid tool type ID");
|
||||||
foreach (DateTime dateTime in dateTimes)
|
foreach (DateTime dateTime in dateTimes)
|
||||||
{
|
{
|
||||||
year = dateTime.Year.ToString();
|
year = dateTime.Year.ToString();
|
||||||
weekNum = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
|
weekNum = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
|
||||||
directory = Path.Combine(_AppSettings.AttachmentPath, $"{toolType.HeaderTableName}_", year, $"WW{weekNum:00}");
|
weekDirectory = _FileShareRepository.Append(mesaFileShareMetrologySi, $"{toolType.HeaderTableName}_", year, $"WW{weekNum:00}");
|
||||||
if (!Directory.Exists(directory))
|
checkDirectory = _FileShareRepository.Append(weekDirectory, headerId.ToString());
|
||||||
_ = Directory.CreateDirectory(directory);
|
httpResponseMessage = httpClient.GetAsync(checkDirectory);
|
||||||
checkDirectory = Path.Combine(directory, headerId.ToString());
|
httpResponseMessage.Wait();
|
||||||
if (!Directory.Exists(checkDirectory))
|
if (httpResponseMessage.Result.StatusCode != System.Net.HttpStatusCode.OK)
|
||||||
continue;
|
continue;
|
||||||
files.AddRange(Directory.GetFiles(checkDirectory));
|
json = httpResponseMessage.Result.Content.ReadAsStringAsync();
|
||||||
|
json.Wait();
|
||||||
|
nginxFileSystemCollection = JsonSerializer.Deserialize(json.Result, NginxFileSystemCollectionSourceGenerationContext.Default.NginxFileSystemArray);
|
||||||
|
if (nginxFileSystemCollection is null)
|
||||||
|
continue;
|
||||||
|
foreach (NginxFileSystem nginxFileSystem in nginxFileSystemCollection)
|
||||||
|
files.Add(_FileShareRepository.Append(checkDirectory, nginxFileSystem.Name).AbsoluteUri);
|
||||||
if (files.Count != 0)
|
if (files.Count != 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@ function getUrlParameter(param) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setWafers(waferMap) {
|
function setSlots(slotMap) {
|
||||||
var slots = waferMap.split("");
|
var slots = slotMap.split("");
|
||||||
if (slots.length !== 25)
|
if (slots.length !== 25)
|
||||||
throw Error;
|
throw Error;
|
||||||
$('.slot').each(function (index) {
|
$('.slot').each(function (index) {
|
||||||
@ -36,7 +36,7 @@ function setValues(data) {
|
|||||||
clearMap();
|
clearMap();
|
||||||
else {
|
else {
|
||||||
$('#waferCount').val(data.total);
|
$('#waferCount').val(data.total);
|
||||||
setWafers(data.waferMap);
|
setSlots(data.slotMap);
|
||||||
$('#lastDateTime').text(new Date().toLocaleString());
|
$('#lastDateTime').text(new Date().toLocaleString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ function clearText() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function clearMap() {
|
function clearMap() {
|
||||||
setWafers('0000000000000000000000000');
|
setSlots('0000000000000000000000000');
|
||||||
}
|
}
|
||||||
|
|
||||||
function poll() {
|
function poll() {
|
||||||
@ -59,7 +59,7 @@ function poll() {
|
|||||||
}
|
}
|
||||||
else if (_count > -1) {
|
else if (_count > -1) {
|
||||||
_count++;
|
_count++;
|
||||||
$.get(_apiUrl + $("#toolId").val() + '/last-quantity-and-wafer-map/?area=' + $("#operation").val(), function (data) {
|
$.get(_apiUrl + $("#toolId").val() + '/last-quantity-and-slot-map/?area=' + $("#operation").val(), function (data) {
|
||||||
setValues(data);
|
setValues(data);
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
ShowErrorMessage("Error");
|
ShowErrorMessage("Error");
|
||||||
@ -68,7 +68,7 @@ function poll() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
$.get(_apiUrl + $("#toolId").val() + '/last-quantity-and-wafer-map-with-text/?area=' + $("#operation").val() + '&text=' + $("#lot").val(), function (data) {
|
$.get(_apiUrl + $("#toolId").val() + '/last-quantity-and-slot-map-with-text/?area=' + $("#operation").val() + '&text=' + $("#lot").val(), function (data) {
|
||||||
setValues(data);
|
setValues(data);
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
ShowErrorMessage("Error");
|
ShowErrorMessage("Error");
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
<meta name="viewport" content="width=device-width" />
|
<meta name="viewport" content="width=device-width" />
|
||||||
<title>Wafer Counter</title>
|
<title>Wafer Counter</title>
|
||||||
|
|
||||||
<script src="js/jquery-3.6.0.min.js?v=2024-03-09_09-00" type="text/javascript"></script>
|
<script src="js/jquery-3.6.0.min.js?v=2024-03-13_13-22" type="text/javascript"></script>
|
||||||
<script src="js/wafer-counter.js?v=2024-03-09_09-00" type="text/javascript"></script>
|
<script src="js/wafer-counter.js?v=2024-03-13_13-22" type="text/javascript"></script>
|
||||||
<script src="js/common.js?v=2024-03-09_09-00" type="text/javascript"></script>
|
<script src="js/common.js?v=2024-03-13_13-22" type="text/javascript"></script>
|
||||||
|
|
||||||
<script type="module"
|
<script type="module"
|
||||||
src="package/dist/infineon-design-system-stencil/infineon-design-system-stencil.esm.js"></script>
|
src="package/dist/infineon-design-system-stencil/infineon-design-system-stencil.esm.js"></script>
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
namespace OI.Metrology.Shared.Models;
|
|
||||||
|
|
||||||
public interface IWorkingDirectory
|
|
||||||
{
|
|
||||||
|
|
||||||
static string GetWorkingDirectory(string? executingAssemblyName, string subDirectoryName) =>
|
|
||||||
WorkingDirectory.GetWorkingDirectory(executingAssemblyName, subDirectoryName);
|
|
||||||
|
|
||||||
}
|
|
21
Shared/Models/NginxFileSystem.cs
Normal file
21
Shared/Models/NginxFileSystem.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace OI.Metrology.Shared.Models;
|
||||||
|
|
||||||
|
public record NginxFileSystem(
|
||||||
|
[property: JsonPropertyName("name")] string Name,
|
||||||
|
[property: JsonPropertyName("type")] string Type,
|
||||||
|
[property: JsonPropertyName("mtime")] string MTime,
|
||||||
|
[property: JsonPropertyName("size")] float Size);
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(NginxFileSystem))]
|
||||||
|
public partial class NginxFileSystemSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(NginxFileSystem[]))]
|
||||||
|
public partial class NginxFileSystemCollectionSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
29
Shared/Models/NginxFileSystemSortable.cs
Normal file
29
Shared/Models/NginxFileSystemSortable.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using OI.Metrology.Shared.Models.Stateless;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace OI.Metrology.Shared.Models;
|
||||||
|
|
||||||
|
public record NginxFileSystemSortable(DateTime DateTime,
|
||||||
|
Uri Uri,
|
||||||
|
string Name,
|
||||||
|
float Size,
|
||||||
|
string Type)
|
||||||
|
{
|
||||||
|
|
||||||
|
public static List<NginxFileSystemSortable> Convert(IFileShareRepository fileShareRepository, Uri waferSizeUri, NginxFileSystem[]? collection)
|
||||||
|
{
|
||||||
|
List<NginxFileSystemSortable> results = new();
|
||||||
|
NginxFileSystemSortable nginxFileSystemSortable;
|
||||||
|
string nginxFormat = "ddd, dd MMM yyyy HH:mm:ss zzz";
|
||||||
|
foreach (NginxFileSystem nginxFileSystem in collection ?? Array.Empty<NginxFileSystem>())
|
||||||
|
{
|
||||||
|
if (DateTime.TryParseExact(nginxFileSystem.MTime.Replace("GMT", "+00:00"), nginxFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTime))
|
||||||
|
nginxFileSystemSortable = new(dateTime, fileShareRepository.Append(waferSizeUri, nginxFileSystem.Name), nginxFileSystem.Name, nginxFileSystem.Size, nginxFileSystem.Type);
|
||||||
|
else
|
||||||
|
nginxFileSystemSortable = new(DateTime.MinValue, fileShareRepository.Append(waferSizeUri, nginxFileSystem.Name), nginxFileSystem.Name, nginxFileSystem.Size, nginxFileSystem.Type);
|
||||||
|
results.Add(nginxFileSystemSortable);
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
18
Shared/Models/Stateless/IFileShareController.cs
Normal file
18
Shared/Models/Stateless/IFileShareController.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
namespace OI.Metrology.Shared.Models.Stateless;
|
||||||
|
|
||||||
|
public interface IFileShareController<T>
|
||||||
|
{
|
||||||
|
|
||||||
|
enum Action : int
|
||||||
|
{
|
||||||
|
Index = 0,
|
||||||
|
MarkAsPinned = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
static string GetRouteName() => nameof(IFileShareController<T>)[1..^10];
|
||||||
|
|
||||||
|
T CopyFile(string from, string to);
|
||||||
|
T MoveFile(string from, string to);
|
||||||
|
T FileWrite(string path, string contents);
|
||||||
|
|
||||||
|
}
|
16
Shared/Models/Stateless/IFileShareRepository.cs
Normal file
16
Shared/Models/Stateless/IFileShareRepository.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
namespace OI.Metrology.Shared.Models.Stateless;
|
||||||
|
|
||||||
|
public interface IFileShareRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
void CopyFile(string from, string to);
|
||||||
|
void MoveFile(string from, string to);
|
||||||
|
Uri Append(Uri uri, params string[] paths);
|
||||||
|
void FileWrite(string path, string contents);
|
||||||
|
HttpResponseMessage ReadFile(HttpClient httpClient, Uri uri);
|
||||||
|
void CopyFile(HttpClient httpClient, string from, string to);
|
||||||
|
void MoveFile(HttpClient httpClient, string from, string to);
|
||||||
|
void FileWrite(HttpClient httpClient, string path, string contents);
|
||||||
|
List<NginxFileSystemSortable> GetNginxFileSystemSortableCollection(HttpClient httpClient, Uri uri, string? endsWith);
|
||||||
|
|
||||||
|
}
|
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
using OI.Metrology.Shared.DataModels;
|
|
||||||
|
|
||||||
namespace OI.Metrology.Shared.Models.Stateless;
|
|
||||||
|
|
||||||
public interface IReactorsRepository
|
|
||||||
{
|
|
||||||
|
|
||||||
Result<int[]> EvenReactors();
|
|
||||||
Result<int[]> OddReactors();
|
|
||||||
string? GetKey(WorkMaterialOut workMaterialOut, bool save);
|
|
||||||
|
|
||||||
}
|
|
@ -8,13 +8,14 @@ public interface IToolTypesRepository
|
|||||||
{
|
{
|
||||||
|
|
||||||
Result<ToolTypeNameId[]> Index(IMetrologyRepository metrologyRepository);
|
Result<ToolTypeNameId[]> Index(IMetrologyRepository metrologyRepository);
|
||||||
Result<ToolTypeMetadataResult> GetToolTypeMetadata(IMetrologyRepository metrologyRepository, int id, string sortby = "");
|
|
||||||
Result<DataTable> GetHeaders(IMetrologyRepository metrologyRepository, int id, string? datebegin, string? dateend, int? page, int? pagesize, long? headerid);
|
|
||||||
Result<HeaderCommon[]> GetHeaderTitles(IMetrologyRepository metrologyRepository, int id, int? page, int? pagesize);
|
|
||||||
Result<ColumnValue[]> GetHeaderFields(IMetrologyRepository metrologyRepository, int id, long headerid);
|
|
||||||
Result<DataTable> GetData(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);
|
Result<ColumnValue[]> GetHeaderFields(IMetrologyRepository metrologyRepository, int id, 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, string? datebegin, string? dateend);
|
|
||||||
byte[] GetCSVExport(IMetrologyRepository metrologyRepository, int toolTypeId, string? datebegin, string? dateend);
|
byte[] GetCSVExport(IMetrologyRepository metrologyRepository, int toolTypeId, string? datebegin, string? dateend);
|
||||||
|
Result<HeaderCommon[]> GetHeaderTitles(IMetrologyRepository metrologyRepository, int id, int? page, int? pagesize);
|
||||||
|
Result<ToolTypeMetadataResult> GetToolTypeMetadata(IMetrologyRepository metrologyRepository, int id, string sortby = "");
|
||||||
|
Result<DataTable> GetExportData(IMetrologyRepository metrologyRepository, int toolTypeId, string? datebegin, string? dateend);
|
||||||
|
string? OIExport(IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService, int toolTypeId, long headerid);
|
||||||
|
Result<DataTable> GetHeaders(IMetrologyRepository metrologyRepository, int id, string? datebegin, string? dateend, int? page, int? pagesize, long? headerid);
|
||||||
|
(string?, string?, Stream?) GetAttachment(IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService, int toolTypeId, string tabletype, string attachmentId, string filename);
|
||||||
|
|
||||||
}
|
}
|
@ -1,50 +0,0 @@
|
|||||||
namespace OI.Metrology.Shared.Models;
|
|
||||||
|
|
||||||
internal abstract class WorkingDirectory
|
|
||||||
{
|
|
||||||
|
|
||||||
internal static string GetWorkingDirectory(string? executingAssemblyName, string subDirectoryName)
|
|
||||||
{
|
|
||||||
string result = string.Empty;
|
|
||||||
if (executingAssemblyName is null)
|
|
||||||
throw new Exception();
|
|
||||||
string traceFile;
|
|
||||||
List<string> directories = new();
|
|
||||||
List<Environment.SpecialFolder> specialFolders = new()
|
|
||||||
{
|
|
||||||
Environment.SpecialFolder.LocalApplicationData,
|
|
||||||
Environment.SpecialFolder.ApplicationData,
|
|
||||||
Environment.SpecialFolder.History,
|
|
||||||
Environment.SpecialFolder.CommonApplicationData,
|
|
||||||
Environment.SpecialFolder.InternetCache
|
|
||||||
};
|
|
||||||
foreach (Environment.SpecialFolder specialFolder in specialFolders)
|
|
||||||
directories.Add(Path.Combine(Environment.GetFolderPath(specialFolder), subDirectoryName, executingAssemblyName));
|
|
||||||
foreach (string directory in directories)
|
|
||||||
{
|
|
||||||
for (int i = 1; i < 3; i++)
|
|
||||||
{
|
|
||||||
if (i == 1)
|
|
||||||
result = directory;
|
|
||||||
else
|
|
||||||
result = string.Concat("D", directory[1..]);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!Directory.Exists(result))
|
|
||||||
_ = Directory.CreateDirectory(result);
|
|
||||||
traceFile = string.Concat(result, @"\", DateTime.Now.Ticks, ".txt");
|
|
||||||
File.WriteAllText(traceFile, traceFile);
|
|
||||||
File.Delete(traceFile);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
catch (Exception) { result = string.Empty; }
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrEmpty(result))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(result))
|
|
||||||
throw new Exception("Unable to set working directory!");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -7,6 +7,6 @@ public interface IAttachmentsService
|
|||||||
{
|
{
|
||||||
Stream GetAttachmentStreamByTitle(ToolType toolType, bool header, string title, string filename);
|
Stream GetAttachmentStreamByTitle(ToolType toolType, bool header, string title, string filename);
|
||||||
Stream GetAttachmentStreamByAttachmentId(ToolType toolType, bool header, Guid attachmentId, string filename);
|
Stream GetAttachmentStreamByAttachmentId(ToolType toolType, bool header, Guid attachmentId, string filename);
|
||||||
|
string? GetProcessDataStandardFormat(IMetrologyRepository metrologyRepository, int toolTypeId, long headerId);
|
||||||
void SaveAttachment(ToolType toolType, long headerId, string dataUniqueId, string filename, object uploadedFile);
|
void SaveAttachment(ToolType toolType, long headerId, string dataUniqueId, string filename, object uploadedFile);
|
||||||
string? GetProcessDataStandardFormat(IMetrologyRepository metrologyRepository, string attachmentPath, int toolTypeId, long headerId);
|
|
||||||
}
|
}
|
@ -47,7 +47,7 @@ public class UnitTestExportController
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static HeaderCommon GetHeaderCommon() =>
|
private static HeaderCommon GetHeaderCommon() =>
|
||||||
new() { PSN = "5008", Reactor = "61", RDS = "579487", ID = 1678209360 };
|
new() { PSN = "5131", Reactor = "23", RDS = "631836", ID = 1710783849 };
|
||||||
|
|
||||||
private static StringContent GetStringContent() =>
|
private static StringContent GetStringContent() =>
|
||||||
new(System.Text.Json.JsonSerializer.Serialize(GetHeaderCommon()), Encoding.UTF8, "application/json");
|
new(System.Text.Json.JsonSerializer.Serialize(GetHeaderCommon()), Encoding.UTF8, "application/json");
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
using Microsoft.AspNetCore.Mvc.Testing;
|
using Microsoft.AspNetCore.Mvc.Testing;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using OI.Metrology.Shared.DataModels;
|
|
||||||
using OI.Metrology.Shared.Models.Stateless;
|
using OI.Metrology.Shared.Models.Stateless;
|
||||||
|
|
||||||
namespace OI.Metrology.Tests;
|
namespace OI.Metrology.Tests;
|
||||||
|
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class UnitTestReactorController
|
public class UnitTestFileShareController
|
||||||
{
|
{
|
||||||
|
|
||||||
#pragma warning disable CS8618
|
#pragma warning disable CS8618
|
||||||
@ -26,7 +25,7 @@ public class UnitTestReactorController
|
|||||||
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
|
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
|
||||||
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
|
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
|
||||||
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
|
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
|
||||||
_ControllerName = nameof(Server.ApiControllers.ReactorsController)[..^10];
|
_ControllerName = nameof(Server.ApiControllers.FileShareController)[..^10];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void NonThrowTryCatch()
|
private static void NonThrowTryCatch()
|
||||||
@ -40,46 +39,45 @@ public class UnitTestReactorController
|
|||||||
public void TestControllerName()
|
public void TestControllerName()
|
||||||
{
|
{
|
||||||
_Logger?.LogInformation("Starting Web Application");
|
_Logger?.LogInformation("Starting Web Application");
|
||||||
Assert.AreEqual(IReactorsController<string>.GetRouteName(), _ControllerName);
|
Assert.AreEqual(IFileShareController<string>.GetRouteName(), _ControllerName);
|
||||||
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Ignore]
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void GetReactors()
|
public async Task CopyFileApi()
|
||||||
{
|
|
||||||
_Logger?.LogInformation("Starting Web Application");
|
|
||||||
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
|
|
||||||
IReactorsRepository? reactorsRepository = serviceProvider?.GetRequiredService<IReactorsRepository>();
|
|
||||||
Result<int[]>? result = reactorsRepository?.EvenReactors();
|
|
||||||
Assert.IsNotNull(result?.Results);
|
|
||||||
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
|
||||||
NonThrowTryCatch();
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public async Task GetReactorsApi()
|
|
||||||
{
|
{
|
||||||
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
|
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
|
||||||
_Logger?.LogInformation("Starting Web Application");
|
_Logger?.LogInformation("Starting Web Application");
|
||||||
Assert.IsTrue(httpClient is not null);
|
Assert.IsTrue(httpClient is not null);
|
||||||
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/true/");
|
string? response = await httpClient.GetStringAsync($"api/v1/file-share/copy-file/?from=\\\\mesfs.infineon.com\\EC_Metrology_Si\\MetrologyAttachments\\CDERunHeader_\\2024\\WW11\\247233\\CDE5_240315162756858.pdsf&to=\\\\messa01ec.infineon.com\\apps\\Metrology\\MET08RESIMAPCDE\\Test\\a.pdsf");
|
||||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetReactors)}.json"), json);
|
Assert.IsNotNull(response);
|
||||||
Result<int[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<int[]>>(json);
|
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
||||||
Assert.IsNotNull(result?.Results);
|
NonThrowTryCatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Ignore]
|
||||||
|
[TestMethod]
|
||||||
|
public async Task MoveFileApi()
|
||||||
|
{
|
||||||
|
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
|
||||||
|
_Logger?.LogInformation("Starting Web Application");
|
||||||
|
Assert.IsTrue(httpClient is not null);
|
||||||
|
string? response = await httpClient.GetStringAsync($"api/v1/file-share/move-file/?from=\\\\mesfs.infineon.com\\EC_Metrology_Si\\MetrologyAttachments\\CDERunHeader_\\2024\\WW11\\247233\\CDE5_240315162756858.pdsf&to=\\\\messa01ec.infineon.com\\apps\\Metrology\\MET08RESIMAPCDE\\Test\\a.pdsf");
|
||||||
|
Assert.IsNotNull(response);
|
||||||
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void GetKey()
|
public async Task FileWriteApi()
|
||||||
{
|
{
|
||||||
|
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
|
||||||
_Logger?.LogInformation("Starting Web Application");
|
_Logger?.LogInformation("Starting Web Application");
|
||||||
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
|
Assert.IsTrue(httpClient is not null);
|
||||||
IReactorsRepository? reactorsRepository = serviceProvider?.GetRequiredService<IReactorsRepository>();
|
string? response = await httpClient.GetStringAsync($"api/v1/file-share/file-write/?path=\\\\messa01ec.infineon.com\\apps\\Metrology\\MET08RESIMAPCDE\\Test\\b.pdsf&contents=b");
|
||||||
WorkMaterialOut workMaterialOut = new() { RunDataSheet = "123456", Username = "phares" };
|
Assert.IsNotNull(response);
|
||||||
string? result = reactorsRepository?.GetKey(workMaterialOut, save: false);
|
|
||||||
Assert.IsNotNull(result);
|
|
||||||
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
@ -282,9 +282,9 @@ public class UnitTestInfinityQSV4Controller
|
|||||||
List<string> production = new();
|
List<string> production = new();
|
||||||
foreach (int rds in rdsCollection)
|
foreach (int rds in rdsCollection)
|
||||||
{
|
{
|
||||||
|
if (rds is 0)
|
||||||
|
continue;
|
||||||
production.Add("");
|
production.Add("");
|
||||||
|
|
||||||
}
|
}
|
||||||
foreach (string part in new string[] { "4992" })
|
foreach (string part in new string[] { "4992" })
|
||||||
{
|
{
|
||||||
|
@ -283,7 +283,7 @@ public class UnitTestToolTypesController
|
|||||||
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Ignore]
|
// [Ignore]
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void OIExport()
|
public void OIExport()
|
||||||
{
|
{
|
||||||
@ -296,7 +296,7 @@ public class UnitTestToolTypesController
|
|||||||
Assert.IsTrue(appSettings is not null);
|
Assert.IsTrue(appSettings is not null);
|
||||||
Assert.IsTrue(attachmentsService is not null);
|
Assert.IsTrue(attachmentsService is not null);
|
||||||
Assert.IsTrue(metrologyRepository is not null);
|
Assert.IsTrue(metrologyRepository is not null);
|
||||||
string? message = toolTypesRepository?.OIExport(metrologyRepository, attachmentsService, appSettings.AttachmentPath, appSettings.TableToPath, toolTypeId: 1, headerid: 1);
|
string? message = toolTypesRepository?.OIExport(metrologyRepository, attachmentsService, toolTypeId: 1, headerid: 1);
|
||||||
Assert.IsTrue(message is null);
|
Assert.IsTrue(message is null);
|
||||||
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,10 @@ public class UnitTestWaferCounterController
|
|||||||
Assert.AreEqual("0101010101010101010101010", result);
|
Assert.AreEqual("0101010101010101010101010", result);
|
||||||
result = waferCounterRepository?.GetSlotMap("T13", "P1555555");
|
result = waferCounterRepository?.GetSlotMap("T13", "P1555555");
|
||||||
Assert.AreEqual("1010101010101010101010101", result);
|
Assert.AreEqual("1010101010101010101010101", result);
|
||||||
|
result = waferCounterRepository?.GetSlotMap("T20", "P0EFFFF8");
|
||||||
|
Assert.AreEqual("0111011111111111111111000", result);
|
||||||
|
result = waferCounterRepository?.GetSlotMap("T20", "P07FFFF8");
|
||||||
|
Assert.AreEqual("0011111111111111111111000", result);
|
||||||
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
@ -70,7 +74,7 @@ public class UnitTestWaferCounterController
|
|||||||
_Logger?.LogInformation("Starting Web Application");
|
_Logger?.LogInformation("Starting Web Application");
|
||||||
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
|
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
|
||||||
IWaferCounterRepository? waferCounterRepository = serviceProvider?.GetRequiredService<IWaferCounterRepository>();
|
IWaferCounterRepository? waferCounterRepository = serviceProvider?.GetRequiredService<IWaferCounterRepository>();
|
||||||
WaferCounter? result = waferCounterRepository?.GetLastQuantityAndSlotMap("EPP-East", "8INCH", "123456");
|
WaferCounter? result = waferCounterRepository?.GetLastQuantityAndSlotMap("EPP-East", "8INCH");
|
||||||
Assert.IsNotNull(result);
|
Assert.IsNotNull(result);
|
||||||
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
|
@ -62,7 +62,10 @@ public class AppSettings
|
|||||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user