NginxFileSystem

Remove Reactors and Working Directory
AppSettings
This commit is contained in:
Mike Phares 2024-03-18 12:59:15 -07:00
parent 127634f5ab
commit 811f45a7df
33 changed files with 499 additions and 530 deletions

View File

@ -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.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.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.IDE0002.severity = warning # Simplify (member access) - System.Version.Equals("1", "2"); Version.Equals("1", "2");
dotnet_diagnostic.IDE0004.severity = warning # IDE0004: Cast is redundant.

View File

@ -29,6 +29,23 @@ public class AppSettings
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)
{
Models.AppSettings result;
@ -73,20 +90,7 @@ public class AppSettings
#pragma warning disable IL3050, IL2026
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
#pragma warning restore IL3050, IL2026
if (appSettings?.ApiLoggingContentTypes is null)
{
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
{
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
continue;
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
continue;
if (!physicalFileProvider.Root.Contains("UserSecrets"))
continue;
throw new NotSupportedException(physicalFileProvider.Root);
}
throw new NotSupportedException("Not found!");
}
PreVerify(configurationRoot, appSettings);
result = Get(appSettings);
return result;
}

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

View File

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

View File

@ -100,7 +100,7 @@ public class ToolTypesController : Controller, IToolTypesController<IActionResul
[Route("{toolTypeId}/headers/{headerid}/oiexport")]
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)
return Ok(new { Message = "OK" });
else

View File

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

View File

@ -3,14 +3,17 @@ using System.Text.Json;
namespace OI.Metrology.Server.Models;
public record AppSettings(string ApiExportPath,
string ApiFileShare,
string ApiLoggingContentTypes,
string ApiLoggingPathPrefixes,
string ApiLogPath,
string ApiUrl,
string AttachmentPath,
string BuildNumber,
string Company,
string ConnectionString,
string EcCharacterizationSi,
string EcMesaFileShareCharacterizationSi,
string EcMesaFileShareMetrologySi,
string GitCommitSeven,
string InboundApiAllowedIPList,
string IqsColumns,
@ -27,7 +30,6 @@ public record AppSettings(string ApiExportPath,
Dictionary<string, string> TableToPath,
string URLs,
string WaferCounterDestinationDirectory,
string WaferCounterRootDirectory,
string WorkingDirectoryName)
{

View File

@ -7,14 +7,17 @@ public class AppSettings
{
public string? ApiExportPath { get; set; }
public string? ApiFileShare { get; set; }
public string? ApiLoggingContentTypes { get; set; }
public string? ApiLoggingPathPrefixes { get; set; }
public string? ApiLogPath { get; set; }
public string? ApiUrl { get; set; }
public string? AttachmentPath { get; set; }
public string? BuildNumber { get; set; }
public string? Company { 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? InboundApiAllowedIPList { get; set; }
public string? IqsColumns { get; set; }
@ -31,7 +34,6 @@ public class AppSettings
public Dictionary<string, string>? TableToPath { get; set; }
public string? URLs { get; set; }
public string? WaferCounterDestinationDirectory { get; set; }
public string? WaferCounterRootDirectory { get; set; }
public string? WorkingDirectoryName { get; set; }
public override string ToString()
@ -40,19 +42,39 @@ public class AppSettings
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)
{
Models.AppSettings result;
if (appSettings is null) throw new NullReferenceException(nameof(appSettings));
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.ApiLoggingPathPrefixes is null) throw new NullReferenceException(nameof(ApiLoggingPathPrefixes));
if (appSettings.ApiLogPath is null) throw new NullReferenceException(nameof(ApiLogPath));
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.Company is null) throw new NullReferenceException(nameof(Company));
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.InboundApiAllowedIPList is null) throw new NullReferenceException(nameof(InboundApiAllowedIPList));
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.TableToPath is null) throw new NullReferenceException(nameof(TableToPath));
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));
result = new(
appSettings.ApiExportPath,
appSettings.ApiFileShare,
appSettings.ApiLoggingContentTypes,
appSettings.ApiLoggingPathPrefixes,
appSettings.ApiLogPath,
appSettings.ApiUrl,
appSettings.AttachmentPath,
appSettings.BuildNumber,
appSettings.Company,
appSettings.ConnectionString,
appSettings.EcCharacterizationSi,
appSettings.EcMesaFileShareCharacterizationSi,
appSettings.EcMesaFileShareMetrologySi,
appSettings.GitCommitSeven,
appSettings.InboundApiAllowedIPList,
appSettings.IqsColumns,
@ -97,7 +121,6 @@ public class AppSettings
appSettings.TableToPath,
appSettings.URLs,
appSettings.WaferCounterDestinationDirectory,
appSettings.WaferCounterRootDirectory,
appSettings.WorkingDirectoryName);
return result;
}
@ -108,22 +131,7 @@ public class AppSettings
#pragma warning disable IL3050, IL2026
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
#pragma warning restore IL3050, IL2026
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);
if (!physicalFileProvider.Root.Contains("UserSecrets"))
continue;
throw new NotSupportedException(physicalFileProvider.Root);
}
throw new NotSupportedException($"Not found!{Environment.NewLine}{string.Join(Environment.NewLine, paths)}");
}
PreVerify(configurationRoot, appSettings);
result = Get(appSettings);
return result;
}

View File

@ -4,7 +4,6 @@ using OI.Metrology.Server.Models;
using OI.Metrology.Server.Repositories;
using OI.Metrology.Server.Repository;
using OI.Metrology.Server.Services;
using OI.Metrology.Shared.Models;
using OI.Metrology.Shared.Models.Stateless;
using OI.Metrology.Shared.Repositories;
using OI.Metrology.Shared.Services;
@ -49,8 +48,6 @@ public class Program
throw new Exception("Company name must have a value!");
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
throw new Exception("Working directory name must have a value!");
string workingDirectory = IWorkingDirectory.GetWorkingDirectory(assemblyName, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
try
{
_ = webApplicationBuilder.Services.AddMemoryCache();
@ -70,7 +67,7 @@ public class Program
_ = webApplicationBuilder.Services.AddScoped<IInboundDataService, InboundDataService>();
_ = webApplicationBuilder.Services.AddSingleton<IInboundRepository, InboundRepository>();
_ = webApplicationBuilder.Services.AddScoped<IMetrologyRepository, MetrologyRepository>();
_ = webApplicationBuilder.Services.AddSingleton<IReactorsRepository, ReactorsRepository>();
_ = webApplicationBuilder.Services.AddSingleton<IFileShareRepository, FileShareRepository>();
_ = webApplicationBuilder.Services.AddSingleton<IToolTypesRepository, ToolTypesRepository>();
_ = webApplicationBuilder.Services.AddSingleton<IInfinityQSRepository, InfinityQSRepository>();
_ = webApplicationBuilder.Services.AddScoped<IOpenInsightV1Repository, OpenInsightV1Repository>();

View File

@ -1,5 +1,6 @@
using OI.Metrology.Server.Models;
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models;
using OI.Metrology.Shared.Models.Stateless;
using System.Globalization;
using System.Text.Json;
@ -12,13 +13,17 @@ public class ExportRepository : IExportRepository
private readonly string _RepositoryName;
private readonly AppSettings _AppSettings;
private readonly ILogger<ExportRepository> _Logger;
private readonly IHttpClientFactory _HttpClientFactory;
private readonly IFileShareRepository _FileShareRepository;
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;
_AppSettings = appSettings;
_RdsToHeaderCommonCollection = new();
_HttpClientFactory = httpClientFactory;
_FileShareRepository = fileShareRepository;
_RepositoryName = nameof(ExportRepository)[..^10];
}
@ -32,32 +37,47 @@ public class ExportRepository : IExportRepository
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();
string directory;
List<NginxFileSystemSortable> results = new();
Uri uri;
string[] weeks = Get();
List<NginxFileSystemSortable> nginxFileSystemSortableCollection;
foreach (string weekYear in weeks)
{
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
directory = Path.Combine(_AppSettings.ApiExportPath, "Archive", "API", weekYear, $"-{headerCommon.PSN}", $"-{headerCommon.Reactor}", $"-{headerCommon.RDS}", $"-{headerCommon.ID}");
if (!Directory.Exists(directory))
continue;
results.AddRange(Directory.GetFiles(directory, searchPattern, SearchOption.AllDirectories));
uri = _FileShareRepository.Append(new Uri(_AppSettings.EcMesaFileShareMetrologySi), "Archive", "API", weekYear, $"-{headerCommon.PSN}", $"-{headerCommon.Reactor}", $"-{headerCommon.RDS}", $"-{headerCommon.ID}");
nginxFileSystemSortableCollection = _FileShareRepository.GetNginxFileSystemSortableCollection(httpClient, uri, endsWith);
results.AddRange(nginxFileSystemSortableCollection);
}
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 result;
List<string> files = GetFiles(headerCommon, "*.txt");
if (files.Count != 1)
result = string.Empty;
else
result = File.ReadAllText(files.First());
HttpClient httpClient = _HttpClientFactory.CreateClient();
NginxFileSystemSortable[] nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(headerCommon, httpClient, ".txt");
result = GetLines(httpClient, nginxFileSystemSortableCollection);
return result;
}
@ -72,16 +92,17 @@ public class ExportRepository : IExportRepository
JsonElement? jsonElement;
const string ticks = "Ticks";
JsonProperty[] jsonProperties;
List<string> files = GetFiles(headerCommon, "*.json");
foreach (string file in files)
HttpClient httpClient = _HttpClientFactory.CreateClient();
NginxFileSystemSortable[] nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(headerCommon, httpClient, ".json");
foreach (NginxFileSystemSortable nginxFileSystemSortable in nginxFileSystemSortableCollection)
{
json = File.ReadAllText(file);
json = GetLines(httpClient, nginxFileSystemSortableCollection);
hc = JsonSerializer.Deserialize<HeaderCommon>(json);
if (hc is null)
continue;
if (hc.ID < 1)
{
directory = Path.GetDirectoryName(file);
directory = Path.GetDirectoryName(nginxFileSystemSortable.Uri.OriginalString);
if (directory is null)
continue;
directoryName = Path.GetFileName(directory);
@ -112,10 +133,11 @@ public class ExportRepository : IExportRepository
List<HeaderCommon> results = new();
string json;
HeaderCommon? hc;
List<string> files = GetFiles(headerCommon, "*.json");
foreach (string file in files)
HttpClient httpClient = _HttpClientFactory.CreateClient();
NginxFileSystemSortable[] nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(headerCommon, httpClient, ".json");
foreach (NginxFileSystemSortable nginxFileSystemSortable in nginxFileSystemSortableCollection)
{
json = File.ReadAllText(file);
json = GetLines(httpClient, nginxFileSystemSortableCollection);
hc = JsonSerializer.Deserialize<HeaderCommon>(json);
if (hc is null)
continue;
@ -132,11 +154,9 @@ public class ExportRepository : IExportRepository
string IExportRepository.GetProcessDataStandardFormat(HeaderCommon headerCommon)
{
string result;
List<string> files = GetFiles(headerCommon, "*.pdsf");
if (files.Count != 1)
result = string.Empty;
else
result = File.ReadAllText(files.First());
HttpClient httpClient = _HttpClientFactory.CreateClient();
NginxFileSystemSortable[] nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(headerCommon, httpClient, ".pdsf");
result = GetLines(httpClient, nginxFileSystemSortableCollection);
return result;
}

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

View File

@ -22,14 +22,16 @@ public class InfinityQSV4Repository : IInfinityQSV4Repository
private readonly AppSettings _AppSettings;
private readonly IHttpClientFactory _HttpClientFactory;
private readonly IDbConnectionFactory _DBConnectionFactory;
private readonly IFileShareRepository _FileShareRepository;
private readonly string _OpenInsightApplicationProgrammingInterface;
public InfinityQSV4Repository(AppSettings appSettings, IDbConnectionFactory dbConnectionFactory, IHttpClientFactory httpClientFactory)
public InfinityQSV4Repository(AppSettings appSettings, IDbConnectionFactory dbConnectionFactory, IHttpClientFactory httpClientFactory, IFileShareRepository fileShareRepository)
{
_AppSettings = appSettings;
_MockRoot = appSettings.MockRoot;
_HttpClientFactory = httpClientFactory;
_DBConnectionFactory = dbConnectionFactory;
_FileShareRepository = fileShareRepository;
_RepositoryName = nameof(InfinityQSV4Repository)[..^10];
_OpenInsightApplicationProgrammingInterface = appSettings.OpenInsightApplicationProgrammingInterface;
}
@ -591,7 +593,10 @@ public class InfinityQSV4Repository : IInfinityQSV4Repository
{
List<string> lines = new();
foreach (char ch in runDataSheetRoot.RunDataSheet.PSN)
{ }
{
if (ch is '1')
continue;
}
result = string.Join(Environment.NewLine, lines);
}
}
@ -742,10 +747,10 @@ public class InfinityQSV4Repository : IInfinityQSV4Repository
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");
File.WriteAllText(fileInfo.FullName, lines);
string lines = File.ReadAllText(iqsFile).Replace(_AppSettings.IqsRed, "red").Replace(_AppSettings.IqsYellow, "Yellow");
_FileShareRepository.FileWrite(fileInfo.FullName, lines);
}
Dictionary<string, List<string>> IInfinityQSV4Repository.GetEngineeringSpcReview()
@ -771,7 +776,7 @@ public class InfinityQSV4Repository : IInfinityQSV4Repository
else
{
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);
List<Dictionary<string, Record>> collection = GetCollection(_AppSettings.IqsColumns, records);
results = GetResults(_AppSettings, collection);

View File

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

View File

@ -13,10 +13,16 @@ public class ToolTypesRepository : IToolTypesRepository
private readonly string _MockRoot;
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;
_HttpClientFactory = httpClientFactory;
_FileShareRepository = fileShareRepository;
_RepositoryName = nameof(ToolTypesRepository)[..^10];
}
@ -203,7 +209,7 @@ public class ToolTypesRepository : IToolTypesRepository
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;
ToolType toolType = metrologyRepository.GetToolTypeByID(toolTypeId);
@ -211,16 +217,18 @@ public class ToolTypesRepository : IToolTypesRepository
result = $"Invalid tool id [{toolTypeId}] [{headerid}]!";
else
{
string? processDataStandardFormat = attachmentsService.GetProcessDataStandardFormat(metrologyRepository, attachmentPath, toolTypeId, headerid);
string? processDataStandardFormat = attachmentsService.GetProcessDataStandardFormat(metrologyRepository, toolTypeId, headerid);
if (processDataStandardFormat is null)
result = $"Export file doesn't exist for [{toolTypeId}] [{headerid}] at <{attachmentPath}>!";
else if (!tableToPath.TryGetValue(toolType.HeaderTableName, out string? directly))
result = $"Export file doesn't exist for [{toolTypeId}] [{headerid}] at <{attachmentPath}>!";
result = $"Export file doesn't exist for [{toolTypeId}] [{headerid}] at <{_AppSettings.EcMesaFileShareMetrologySi}>!";
else if (!_AppSettings.TableToPath.TryGetValue(toolType.HeaderTableName, out string? directly))
result = $"Export file doesn't exist for [{toolTypeId}] [{headerid}] at <{_AppSettings.EcMesaFileShareMetrologySi}>!";
else
{
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;
}
catch (Exception ex) { result = ex.Message; }

View File

@ -1,5 +1,6 @@
using OI.Metrology.Server.Models;
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models;
using OI.Metrology.Shared.Models.Stateless;
using OI.Metrology.Shared.Repositories;
using System.Globalization;
@ -19,28 +20,27 @@ public class WaferCounterRepository : IWaferCounterRepository
private readonly AppSettings _AppSettings;
private readonly IHttpClientFactory _HttpClientFactory;
private readonly IDbConnectionFactory _DBConnectionFactory;
private readonly IFileShareRepository _FileShareRepository;
private readonly string _OpenInsightApplicationProgrammingInterface;
public WaferCounterRepository(AppSettings appSettings, IDbConnectionFactory dbConnectionFactory, IHttpClientFactory httpClientFactory)
public WaferCounterRepository(AppSettings appSettings, IDbConnectionFactory dbConnectionFactory, IHttpClientFactory httpClientFactory, IFileShareRepository fileShareRepository)
{
_AppSettings = appSettings;
_MockRoot = appSettings.MockRoot;
_HttpClientFactory = httpClientFactory;
_DBConnectionFactory = dbConnectionFactory;
_FileShareRepository = fileShareRepository;
_RepositoryName = nameof(WaferCounterRepository)[..^10];
_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;
string weekOfYear = $"{fileInfo.LastWriteTime:yyyy}_Week_{calendar.GetWeekOfYear(fileInfo.LastWriteTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday):00}";
string checkDirectory = Path.Combine(waferSizeDirectory, "Archive", weekOfYear);
if (!Directory.Exists(checkDirectory))
_ = Directory.CreateDirectory(checkDirectory);
string checkFile = Path.Combine(checkDirectory, fileInfo.Name);
if (!File.Exists(checkFile))
File.Move(fileInfo.FullName, checkFile);
string from = Path.Combine(waferSizeDirectory, nginxFileSystemSortable.Name);
string weekOfYear = $"{nginxFileSystemSortable.DateTime:yyyy}_Week_{calendar.GetWeekOfYear(nginxFileSystemSortable.DateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday):00}";
string to = Path.Combine(waferSizeDirectory, "Archive", weekOfYear, nginxFileSystemSortable.Name);
_FileShareRepository.MoveFile(from, to);
}
private static Record GetRecord(string line1, string line2)
@ -126,43 +126,42 @@ public class WaferCounterRepository : IWaferCounterRepository
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) =>
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) =>
GetRecord(line1, line2).SlotMap;
private static FileInfo[] GetFileInfoCollection(string waferSizeDirectory)
private List<NginxFileSystemSortable> GetNginxFileSystemSortableCollection(HttpClient httpClient, Uri waferSizeUri, string waferSizeDirectory)
{
List<FileInfo> results = new();
FileInfo[] fileInfoCollection;
string[] files = !Directory.Exists(waferSizeDirectory) ? Array.Empty<string>() : Directory.GetFiles(waferSizeDirectory, "*.wc", SearchOption.TopDirectoryOnly);
fileInfoCollection = (from l in files select new FileInfo(l)).OrderByDescending(l => l.LastWriteTime).ToArray();
if (fileInfoCollection.Length > 0)
results.Add(fileInfoCollection[0]);
for (int i = 1; i < fileInfoCollection.Length; i++)
MoveFile(waferSizeDirectory, fileInfoCollection[i]);
return fileInfoCollection;
List<NginxFileSystemSortable> results = _FileShareRepository.GetNginxFileSystemSortableCollection(httpClient, waferSizeUri, ".wc");
for (int i = 1; i < results.Count; i++)
MoveFile(waferSizeDirectory, results[i]);
return results;
}
private static WaferCounter? GetLastQuantityAndSlotMapWithText(string waferSize, string text, FileInfo fileInfo)
private static WaferCounter? GetLastQuantityAndSlotMapWithText(string waferSize, string text, HttpClient httpClient, NginxFileSystemSortable nginxFileSystemSortable)
{
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)
result = null;
else
{
string[] segments = fileInfo.Name.Split('-');
string[] segments = nginxFileSystemSortable.Name.Split('-');
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)
result = null; // Wrong length!
else if (record.Total != record.Check)
result = null; // Invalid!
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;
}
@ -179,21 +178,23 @@ public class WaferCounterRepository : IWaferCounterRepository
}
else
{
Uri waferSizeUri = GetWaferSizeUri(area, waferSize);
HttpClient httpClient = _HttpClientFactory.CreateClient();
string waferSizeDirectory = GetWaferSizeDirectory(area, waferSize, destination: false);
FileInfo[] fileInfoCollection = GetFileInfoCollection(waferSizeDirectory);
if (fileInfoCollection.Length == 0)
List<NginxFileSystemSortable> nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(httpClient, waferSizeUri, waferSizeDirectory);
if (nginxFileSystemSortableCollection.Count == 0)
result = null;
else
{
string text = string.Empty;
result = GetLastQuantityAndSlotMapWithText(waferSize, text, fileInfoCollection[0]);
result = GetLastQuantityAndSlotMapWithText(waferSize, text, httpClient, nginxFileSystemSortableCollection[0]);
}
}
return result;
}
private static void Save(string waferSizeDestinationDirectory, string area, string waferSize, string text, FileInfo fileInfo, WaferCounter result) =>
File.WriteAllText(Path.Combine(waferSizeDestinationDirectory, $"{fileInfo.Name}.csv"), $"100,{waferSize},{area},{fileInfo.LastWriteTime},{text},{result.Total:00},{result.SlotMap} ");
private void Save(string waferSizeDestinationDirectory, string area, string waferSize, string text, NginxFileSystemSortable nginxFileSystemSortable, WaferCounter result) =>
_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)
{
@ -207,18 +208,20 @@ public class WaferCounterRepository : IWaferCounterRepository
}
else
{
Uri waferSizeUri = GetWaferSizeUri(area, waferSize);
HttpClient httpClient = _HttpClientFactory.CreateClient();
string waferSizeDirectory = GetWaferSizeDirectory(area, waferSize, destination: false);
FileInfo[] fileInfoCollection = GetFileInfoCollection(waferSizeDirectory);
if (fileInfoCollection.Length == 0)
List<NginxFileSystemSortable> nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(httpClient, waferSizeUri, waferSizeDirectory);
if (nginxFileSystemSortableCollection.Count == 0)
result = null;
else
{
result = GetLastQuantityAndSlotMapWithText(waferSize, text, fileInfoCollection[0]);
result = GetLastQuantityAndSlotMapWithText(waferSize, text, httpClient, nginxFileSystemSortableCollection[0]);
if (result is not null)
{
string waferSizeDestinationDirectory = _AppSettings.WaferCounterDestinationDirectory;
// string waferSizeDestinationDirectory = GetWaferSizeDirectory(area, waferSize, destination: true);
Save(waferSizeDestinationDirectory, area, waferSize, text, fileInfoCollection[0], result);
// string waferSizeDestinationDirectory = GetWaferSizeUri(area, waferSize, destination: true);
Save(waferSizeDestinationDirectory, area, waferSize, text, nginxFileSystemSortableCollection[0], result);
}
}
}

View File

@ -4,17 +4,24 @@ namespace OI.Metrology.Server.Services;
using OI.Metrology.Server.Models;
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models;
using OI.Metrology.Shared.Models.Stateless;
using OI.Metrology.Shared.Services;
using System.Text.Json;
public class AttachmentsService : IAttachmentsService
{
private readonly AppSettings _AppSettings;
private readonly IHttpClientFactory _HttpClientFactory;
private readonly IFileShareRepository _FileShareRepository;
private readonly IMetrologyRepository _MetrologyRepository;
public AttachmentsService(AppSettings appSettings, IMetrologyRepository metrologyRepository)
public AttachmentsService(AppSettings appSettings, IHttpClientFactory httpClientFactory, IFileShareRepository fileShareRepository, IMetrologyRepository metrologyRepository)
{
_AppSettings = appSettings;
_HttpClientFactory = httpClientFactory;
_FileShareRepository = fileShareRepository;
_MetrologyRepository = metrologyRepository;
}
@ -27,23 +34,16 @@ public class AttachmentsService : IAttachmentsService
throw new NullReferenceException(nameof(tableName));
DateTime insertDate = Convert.ToDateTime(_MetrologyRepository.GetAttachmentInsertDateByGUID(tableName, attachmentId));
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);
string directory = Path.Combine(_AppSettings.AttachmentPath, tableName + "_", year, $"WW{weekNum:00}", attachmentId.ToString());
if (!Directory.Exists(directory))
_ = Directory.CreateDirectory(directory);
string fullPath = Path.Combine(directory, filename);
// Check to see if file exists in the "New" directory structure, if not change the path back to the old. and check there
if (!File.Exists(fullPath))
{
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);
Uri uri = _FileShareRepository.Append(mesaFileShareMetrologySi, $"{tableName}_", year, $"WW{weekNum:00}", attachmentId.ToString(), filename);
HttpResponseMessage httpResponseMessage = _FileShareRepository.ReadFile(httpClient, uri);
if (httpResponseMessage.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception("File not found!");
return httpResponseMessage.Content.ReadAsStream();
}
Stream IAttachmentsService.GetAttachmentStreamByTitle(ToolType toolType, bool header, string title, string filename)
@ -86,7 +86,6 @@ public class AttachmentsService : IAttachmentsService
Guid attachmentId = Guid.Empty;
DateTime insertDate = new();
string? tableName = "";
if (string.IsNullOrWhiteSpace(dataUniqueId))
{
attachmentId = _MetrologyRepository.GetHeaderAttachmentID(toolType.ID, headerId);
@ -101,18 +100,22 @@ public class AttachmentsService : IAttachmentsService
tableName = toolType.DataTableName;
}
if (Equals(attachmentId, Guid.Empty))
throw new Exception("Invalid attachment ID");
{
trans.Dispose();
throw new Exception("Invalid attachment ID!");
}
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);
string directory = Path.Combine(_AppSettings.AttachmentPath, $"{tableName}_", year, $"WW{weekNum:00}", attachmentId.ToString());
if (!Directory.Exists(directory))
_ = Directory.CreateDirectory(directory);
string fullPath = Path.Combine(directory, filename);
using (FileStream fileStream = new(fullPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
uploadedFile.CopyTo(fileStream);
Uri uri = _FileShareRepository.Append(mesaFileShareMetrologySi, $"{tableName}_", year, $"WW{weekNum:00}", attachmentId.ToString(), filename);
HttpResponseMessage httpResponseMessage = _FileShareRepository.ReadFile(httpClient, uri);
if (httpResponseMessage.StatusCode != System.Net.HttpStatusCode.OK)
{
trans.Dispose();
throw new Exception("Invalid attachment path!");
}
uploadedFile.CopyTo(httpResponseMessage.Content.ReadAsStream());
trans.Complete();
}
@ -122,27 +125,38 @@ public class AttachmentsService : IAttachmentsService
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 year;
int weekNum;
string directory;
string checkDirectory;
string year;
Task<string> json;
Uri weekDirectory;
Uri checkDirectory;
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) };
ToolType toolType = metrologyRepository.GetToolTypeByID(toolTypeId) ?? throw new Exception("Invalid tool type ID");
foreach (DateTime dateTime in dateTimes)
{
year = dateTime.Year.ToString();
weekNum = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
directory = Path.Combine(_AppSettings.AttachmentPath, $"{toolType.HeaderTableName}_", year, $"WW{weekNum:00}");
if (!Directory.Exists(directory))
_ = Directory.CreateDirectory(directory);
checkDirectory = Path.Combine(directory, headerId.ToString());
if (!Directory.Exists(checkDirectory))
weekDirectory = _FileShareRepository.Append(mesaFileShareMetrologySi, $"{toolType.HeaderTableName}_", year, $"WW{weekNum:00}");
checkDirectory = _FileShareRepository.Append(weekDirectory, headerId.ToString());
httpResponseMessage = httpClient.GetAsync(checkDirectory);
httpResponseMessage.Wait();
if (httpResponseMessage.Result.StatusCode != System.Net.HttpStatusCode.OK)
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)
break;
}

View File

@ -17,8 +17,8 @@ function getUrlParameter(param) {
return false;
}
function setWafers(waferMap) {
var slots = waferMap.split("");
function setSlots(slotMap) {
var slots = slotMap.split("");
if (slots.length !== 25)
throw Error;
$('.slot').each(function (index) {
@ -36,7 +36,7 @@ function setValues(data) {
clearMap();
else {
$('#waferCount').val(data.total);
setWafers(data.waferMap);
setSlots(data.slotMap);
$('#lastDateTime').text(new Date().toLocaleString());
}
}
@ -48,7 +48,7 @@ function clearText() {
}
function clearMap() {
setWafers('0000000000000000000000000');
setSlots('0000000000000000000000000');
}
function poll() {
@ -59,7 +59,7 @@ function poll() {
}
else if (_count > -1) {
_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);
}).fail(function () {
ShowErrorMessage("Error");
@ -68,7 +68,7 @@ function poll() {
}
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);
}).fail(function () {
ShowErrorMessage("Error");

View File

@ -6,9 +6,9 @@
<meta name="viewport" content="width=device-width" />
<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/wafer-counter.js?v=2024-03-09_09-00" type="text/javascript"></script>
<script src="js/common.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-13_13-22" type="text/javascript"></script>
<script src="js/common.js?v=2024-03-13_13-22" type="text/javascript"></script>
<script type="module"
src="package/dist/infineon-design-system-stencil/infineon-design-system-stencil.esm.js"></script>

View File

@ -1,9 +0,0 @@
namespace OI.Metrology.Shared.Models;
public interface IWorkingDirectory
{
static string GetWorkingDirectory(string? executingAssemblyName, string subDirectoryName) =>
WorkingDirectory.GetWorkingDirectory(executingAssemblyName, subDirectoryName);
}

View 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
{
}

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

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

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

View File

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

View File

@ -8,13 +8,14 @@ public interface IToolTypesRepository
{
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);
(string?, string?, Stream?) GetAttachment(IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService, int toolTypeId, string tabletype, string attachmentId, string filename);
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);
Result<ColumnValue[]> GetHeaderFields(IMetrologyRepository metrologyRepository, int id, long headerid);
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);
}

View File

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

View File

@ -7,6 +7,6 @@ public interface IAttachmentsService
{
Stream GetAttachmentStreamByTitle(ToolType toolType, bool header, string title, 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);
string? GetProcessDataStandardFormat(IMetrologyRepository metrologyRepository, string attachmentPath, int toolTypeId, long headerId);
}

View File

@ -47,7 +47,7 @@ public class UnitTestExportController
}
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() =>
new(System.Text.Json.JsonSerializer.Serialize(GetHeaderCommon()), Encoding.UTF8, "application/json");

View File

@ -1,13 +1,12 @@
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models.Stateless;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestReactorController
public class UnitTestFileShareController
{
#pragma warning disable CS8618
@ -26,7 +25,7 @@ public class UnitTestReactorController
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.ReactorsController)[..^10];
_ControllerName = nameof(Server.ApiControllers.FileShareController)[..^10];
}
private static void NonThrowTryCatch()
@ -40,46 +39,45 @@ public class UnitTestReactorController
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IReactorsController<string>.GetRouteName(), _ControllerName);
Assert.AreEqual(IFileShareController<string>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch();
}
[Ignore]
[TestMethod]
public void GetReactors()
{
_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()
public async Task CopyFileApi()
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/true/");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetReactors)}.json"), json);
Result<int[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<int[]>>(json);
Assert.IsNotNull(result?.Results);
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");
Assert.IsNotNull(response);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
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);
NonThrowTryCatch();
}
[TestMethod]
public void GetKey()
public async Task FileWriteApi()
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IReactorsRepository? reactorsRepository = serviceProvider?.GetRequiredService<IReactorsRepository>();
WorkMaterialOut workMaterialOut = new() { RunDataSheet = "123456", Username = "phares" };
string? result = reactorsRepository?.GetKey(workMaterialOut, save: false);
Assert.IsNotNull(result);
Assert.IsTrue(httpClient is not null);
string? response = await httpClient.GetStringAsync($"api/v1/file-share/file-write/?path=\\\\messa01ec.infineon.com\\apps\\Metrology\\MET08RESIMAPCDE\\Test\\b.pdsf&contents=b");
Assert.IsNotNull(response);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch();
}

View File

@ -282,9 +282,9 @@ public class UnitTestInfinityQSV4Controller
List<string> production = new();
foreach (int rds in rdsCollection)
{
if (rds is 0)
continue;
production.Add("");
}
foreach (string part in new string[] { "4992" })
{

View File

@ -283,7 +283,7 @@ public class UnitTestToolTypesController
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
}
[Ignore]
// [Ignore]
[TestMethod]
public void OIExport()
{
@ -296,7 +296,7 @@ public class UnitTestToolTypesController
Assert.IsTrue(appSettings is not null);
Assert.IsTrue(attachmentsService is not null);
Assert.IsTrue(metrologyRepository is not null);
string? message = toolTypesRepository?.OIExport(metrologyRepository, attachmentsService, appSettings.AttachmentPath, appSettings.TableToPath, toolTypeId: 1, headerid: 1);
string? message = toolTypesRepository?.OIExport(metrologyRepository, attachmentsService, toolTypeId: 1, headerid: 1);
Assert.IsTrue(message is null);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
}

View File

@ -60,6 +60,10 @@ public class UnitTestWaferCounterController
Assert.AreEqual("0101010101010101010101010", result);
result = waferCounterRepository?.GetSlotMap("T13", "P1555555");
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);
NonThrowTryCatch();
}
@ -70,7 +74,7 @@ public class UnitTestWaferCounterController
_Logger?.LogInformation("Starting Web Application");
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IWaferCounterRepository? waferCounterRepository = serviceProvider?.GetRequiredService<IWaferCounterRepository>();
WaferCounter? result = waferCounterRepository?.GetLastQuantityAndSlotMap("EPP-East", "8INCH", "123456");
WaferCounter? result = waferCounterRepository?.GetLastQuantityAndSlotMap("EPP-East", "8INCH");
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch();

View File

@ -62,7 +62,10 @@ public class AppSettings
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
{
Models.AppSettings result;
#pragma warning disable IL3050, IL2026
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
#pragma warning restore IL3050, IL2026
PreVerify(configurationRoot, appSettings);
result = Get(appSettings);
return result;
}