1 Commits

Author SHA1 Message Date
37f6a68cd9 WinForms and Console 2024-03-14 15:30:40 -07:00
56 changed files with 1405 additions and 599 deletions

View File

@ -101,7 +101,6 @@ 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,23 +29,6 @@ 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;
@ -90,7 +73,20 @@ public class AppSettings
#pragma warning disable IL3050, IL2026
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
#pragma warning restore IL3050, IL2026
PreVerify(configurationRoot, appSettings);
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!");
}
result = Get(appSettings);
return result;
}

1
Console/.vscode/format-report.json vendored Normal file
View File

@ -0,0 +1 @@
[]

30
Console/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,30 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/OI.Metrology.Console.dll",
"args": [
"s",
"M",
"L:/Git/Notes-EC-Documentation/.EC-Documentation",
"-s",
"L:/Git/Notes-EC-Documentation/.EC-Documentation/port"
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}

4
Console/.vscode/mklink.md vendored Normal file
View File

@ -0,0 +1,4 @@
# mklink
```bash
```

37
Console/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,37 @@
{
"[markdown]": {
"editor.wordWrap": "off"
},
"files.exclude": {
"**/.git": false,
"**/node_modules": true
},
"files.watcherExclude": {
"**/node_modules": true
},
"cSpell.words": [
"ASPNETCORE",
"BIRT",
"CHIL",
"DEAT",
"endianness",
"FAMC",
"FAMS",
"GIVN",
"HUSB",
"INDI",
"Infineon",
"Kanban",
"kanbn",
"Kofax",
"NSFX",
"OBJE",
"onenote",
"pged",
"Phares",
"Serilog",
"SUBM",
"SURN",
"SYSLIB"
]
}

99
Console/.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,99 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "User Secrets Init",
"command": "dotnet",
"type": "process",
"args": [
"user-secrets",
"-p",
"${workspaceFolder}/OI.Metrology.Console.csproj",
"init"
],
"problemMatcher": "$msCompile"
},
{
"label": "User Secrets Set",
"command": "dotnet",
"type": "process",
"args": [
"user-secrets",
"-p",
"${workspaceFolder}/OI.Metrology.Console.csproj",
"set",
"asdf",
"123"
],
"problemMatcher": "$msCompile"
},
{
"label": "Format",
"command": "dotnet",
"type": "process",
"args": [
"format",
"--report",
".vscode",
"--verbosity",
"detailed",
"--severity",
"warn"
],
"problemMatcher": "$msCompile"
},
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/OI.Metrology.Console.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/OI.Metrology.Console.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/OI.Metrology.Console.csproj"
],
"problemMatcher": "$msCompile"
},
{
"label": "Publish AOT",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"-r",
"win-x64",
"-c",
"Release",
"-p:PublishAot=true",
"${workspaceFolder}/OI.Metrology.Console.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}

View File

@ -0,0 +1,21 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace OI.Metrology.Console.Models;
public record AppSettings(string Company)
{
public override string ToString()
{
string result = JsonSerializer.Serialize(this, AppSettingsSourceGenerationContext.Default.AppSettings);
return result;
}
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(AppSettings))]
internal partial class AppSettingsSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -0,0 +1,2 @@
[*.cs]
csharp_preserve_single_line_statements = true

View File

@ -0,0 +1,61 @@
using Microsoft.Extensions.Configuration;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace OI.Metrology.Console.Models.Binder;
public class AppSettings
{
public string? Company { get; set; }
public override string ToString()
{
string result = JsonSerializer.Serialize(this, BinderAppSettingsSourceGenerationContext.Default.AppSettings);
return result;
}
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
{
if (appSettings?.Company 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;
if (appSettings is null) throw new NullReferenceException(nameof(appSettings));
if (appSettings.Company is null) throw new NullReferenceException(nameof(Company));
result = new(appSettings.Company);
return result;
}
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;
}
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(AppSettings))]
internal partial class BinderAppSettingsSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -0,0 +1,50 @@
namespace OI.Metrology.Console.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 = [];
Environment.SpecialFolder[] specialFolders =
[
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

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<TargetFramework>net8.0</TargetFramework>
<UserSecretsId>d9488860-fd41-4dd8-9448-19f1dde7a0f7</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="8.0.3" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
</ItemGroup>
</Project>

29
Console/Program.cs Normal file
View File

@ -0,0 +1,29 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using OI.Metrology.Console.Models;
namespace OI.Metrology.Console;
internal class Program
{
public static void Main(string[] args)
{
#pragma warning disable IL3050
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
#pragma warning restore IL3050
_ = builder.Configuration.AddEnvironmentVariables();
_ = builder.Configuration.AddUserSecrets<Program>();
_ = builder.Services.AddSingleton(args.ToList());
AppSettings appSettings = Models.Binder.AppSettings.Get(builder.Configuration);
_ = builder.Services.AddSingleton(appSettings);
_ = builder.Services.AddHostedService<Worker>();
using IHost host = builder.Build();
ILogger<Program> logger = host.Services.GetRequiredService<ILogger<Program>>();
logger.LogCritical("{appSettings.Company}", appSettings.Company);
host.Run();
}
}

67
Console/Worker.cs Normal file
View File

@ -0,0 +1,67 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using OI.Metrology.Console.Models;
using System.Diagnostics;
namespace OI.Metrology.Console;
public class Worker : BackgroundService
{
private readonly List<string> _Args;
private readonly ILogger<Worker> _Logger;
private readonly AppSettings _AppSettings;
private readonly IHostApplicationLifetime _Lifetime;
public Worker(ILogger<Worker> logger, IHostApplicationLifetime lifetime, List<string> args, AppSettings appSettings)
{
_Args = args;
_Logger = logger;
_Lifetime = lifetime;
_AppSettings = appSettings;
}
public override Task StartAsync(CancellationToken cancellationToken) =>
base.StartAsync(cancellationToken);
public override Task StopAsync(CancellationToken cancellationToken) =>
base.StopAsync(cancellationToken);
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
if (!stoppingToken.IsCancellationRequested)
await Task.Delay(500, stoppingToken);
if (_AppSettings is null)
throw new NullReferenceException(nameof(_AppSettings));
try
{
_Logger.LogInformation("BaseDirectory: <{BaseDirectory}>", AppContext.BaseDirectory);
_Logger.LogInformation("CurrentDirectory: <{CurrentDirectory}>", Environment.CurrentDirectory);
_Logger.LogInformation("Press Escape key to get -1, Enter key to get 0, y key to get 1 and n key to get 2 exit code");
ConsoleKeyInfo consoleKeyInfo = System.Console.ReadKey();
if (consoleKeyInfo.Key == ConsoleKey.W)
{
Process process = Process.Start("L:/DevOps/Mesa_FI/OI-Metrology/WinForms/bin/Debug/net8.0-windows/win-x64/OI.Metrology.WinForms.exe", "Mike");
process.WaitForExit();
_Logger.LogInformation("ExitCode: <{ExitCode}>", process.ExitCode);
}
else
{
Environment.ExitCode = consoleKeyInfo.Key switch
{
ConsoleKey.Escape => -1,
ConsoleKey.Enter => 0,
ConsoleKey.Y => 1,
ConsoleKey.N => 2,
_ => 9
};
}
}
catch (Exception ex)
{ _Logger.LogError("{Message}{NewLine}{StackTrace}", ex.Message, Environment.NewLine, ex.StackTrace); }
_Logger.LogInformation("Done. Press 'Enter' to end");
_ = System.Console.ReadLine();
_Lifetime.StopApplication();
}
}

3
Console/secrets.json Normal file
View File

@ -0,0 +1,3 @@
{
"Company": "Infineon Technologies Americas Corp."
}

View File

@ -1,36 +0,0 @@
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

@ -0,0 +1,24 @@
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, toolTypeId, headerid);
string? message = _ToolTypesRepository.OIExport(_MetrologyRepo, _AttachmentsService, _AppSettings.AttachmentPath, _AppSettings.TableToPath, toolTypeId, headerid);
if (message is null)
return Ok(new { Message = "OK" });
else

View File

@ -0,0 +1,82 @@
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

@ -2,21 +2,19 @@ using System.Text.Json;
namespace OI.Metrology.Server.Models;
public record AppSettings(string ApiFileShare,
public record AppSettings(string ApiExportPath,
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,
string[] IqsFileSegments,
string IqsFile,
string IqsKey,
string IqsRed,
string IqsYellow,
@ -29,7 +27,7 @@ public record AppSettings(string ApiFileShare,
Dictionary<string, string> TableToPath,
string URLs,
string WaferCounterDestinationDirectory,
int WaferCounterTwoFileSecondsWait,
string WaferCounterRootDirectory,
string WorkingDirectoryName)
{

View File

@ -6,21 +6,19 @@ namespace OI.Metrology.Server.Models.Binder;
public class AppSettings
{
public string? ApiFileShare { get; set; }
public string? ApiExportPath { 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; }
public string[]? IqsFileSegments { get; set; }
public string? IqsFile { get; set; }
public string? IqsKey { get; set; }
public string? IqsRed { get; set; }
public string? IqsYellow { get; set; }
@ -33,7 +31,7 @@ public class AppSettings
public Dictionary<string, string>? TableToPath { get; set; }
public string? URLs { get; set; }
public string? WaferCounterDestinationDirectory { get; set; }
public int? WaferCounterTwoFileSecondsWait { get; set; }
public string? WaferCounterRootDirectory { get; set; }
public string? WorkingDirectoryName { get; set; }
public override string ToString()
@ -42,42 +40,23 @@ public class AppSettings
return result;
}
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
{
if (appSettings?.ApiFileShare 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.ApiFileShare is null) throw new NullReferenceException(nameof(ApiFileShare));
if (appSettings.ApiExportPath is null) throw new NullReferenceException(nameof(ApiExportPath));
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));
if (appSettings.IqsFileSegments is null) throw new NullReferenceException(nameof(IqsFileSegments));
if (appSettings.IqsFile is null) throw new NullReferenceException(nameof(IqsFile));
if (appSettings.IqsKey is null) throw new NullReferenceException(nameof(IqsKey));
if (appSettings.IqsRed is null) throw new NullReferenceException(nameof(IqsRed));
if (appSettings.IqsYellow is null) throw new NullReferenceException(nameof(IqsYellow));
@ -90,24 +69,22 @@ 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.WaferCounterTwoFileSecondsWait is null) throw new NullReferenceException(nameof(WaferCounterTwoFileSecondsWait));
if (appSettings.WaferCounterRootDirectory is null) throw new NullReferenceException(nameof(WaferCounterRootDirectory));
if (appSettings.WorkingDirectoryName is null) throw new NullReferenceException(nameof(WorkingDirectoryName));
result = new(
appSettings.ApiFileShare,
appSettings.ApiExportPath,
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,
appSettings.IqsFileSegments,
appSettings.IqsFile,
appSettings.IqsKey,
appSettings.IqsRed,
appSettings.IqsYellow,
@ -120,7 +97,7 @@ public class AppSettings
appSettings.TableToPath,
appSettings.URLs,
appSettings.WaferCounterDestinationDirectory,
appSettings.WaferCounterTwoFileSecondsWait.Value,
appSettings.WaferCounterRootDirectory,
appSettings.WorkingDirectoryName);
return result;
}
@ -131,7 +108,22 @@ public class AppSettings
#pragma warning disable IL3050, IL2026
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
#pragma warning restore IL3050, IL2026
PreVerify(configurationRoot, 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);
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);
return result;
}

View File

@ -4,6 +4,7 @@ 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;
@ -48,6 +49,8 @@ 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();
@ -67,7 +70,7 @@ public class Program
_ = webApplicationBuilder.Services.AddScoped<IInboundDataService, InboundDataService>();
_ = webApplicationBuilder.Services.AddSingleton<IInboundRepository, InboundRepository>();
_ = webApplicationBuilder.Services.AddScoped<IMetrologyRepository, MetrologyRepository>();
_ = webApplicationBuilder.Services.AddSingleton<IFileShareRepository, FileShareRepository>();
_ = webApplicationBuilder.Services.AddSingleton<IReactorsRepository, ReactorsRepository>();
_ = webApplicationBuilder.Services.AddSingleton<IToolTypesRepository, ToolTypesRepository>();
_ = webApplicationBuilder.Services.AddSingleton<IInfinityQSRepository, InfinityQSRepository>();
_ = webApplicationBuilder.Services.AddScoped<IOpenInsightV1Repository, OpenInsightV1Repository>();

View File

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

View File

@ -1,105 +0,0 @@
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,16 +22,14 @@ 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, IFileShareRepository fileShareRepository)
public InfinityQSV4Repository(AppSettings appSettings, IDbConnectionFactory dbConnectionFactory, IHttpClientFactory httpClientFactory)
{
_AppSettings = appSettings;
_MockRoot = appSettings.MockRoot;
_HttpClientFactory = httpClientFactory;
_DBConnectionFactory = dbConnectionFactory;
_FileShareRepository = fileShareRepository;
_RepositoryName = nameof(InfinityQSV4Repository)[..^10];
_OpenInsightApplicationProgrammingInterface = appSettings.OpenInsightApplicationProgrammingInterface;
}
@ -593,10 +591,7 @@ 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);
}
}
@ -677,11 +672,12 @@ public class InfinityQSV4Repository : IInfinityQSV4Repository
return result;
}
private static ReadOnlyCollection<Record> GetRecords(AppSettings appSettings, string[] lines)
private static ReadOnlyCollection<Record> GetRecords(AppSettings appSettings, string file)
{
Record? record;
List<Record> results = new();
List<string> checkColumns = new();
string[] lines = File.ReadAllLines(file);
foreach (string line in lines)
{
if (line.StartsWith("<th"))
@ -746,25 +742,12 @@ public class InfinityQSV4Repository : IInfinityQSV4Repository
return results;
}
private void FileFindReplaceAndSave(FileInfo fileInfo, string value)
private static void FileFindReplaceAndSave(AppSettings appSettings, string iqsFile, FileInfo fileInfo)
{
string lines = value.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);
}
private static string GetWwwRootDirectory()
{
string result;
Assembly assembly = Assembly.GetExecutingAssembly();
string? assemblyName = assembly.GetName()?.Name;
if (string.IsNullOrEmpty(assemblyName))
throw new Exception();
result = Path.Combine(AppContext.BaseDirectory, "wwwroot");
if (!Directory.Exists(result))
_ = Directory.CreateDirectory(result);
return result;
}
Dictionary<string, List<string>> IInfinityQSV4Repository.GetEngineeringSpcReview()
{
Dictionary<string, List<string>>? results;
@ -777,27 +760,19 @@ public class InfinityQSV4Repository : IInfinityQSV4Repository
}
else
{
string wwwRootDirectory = GetWwwRootDirectory();
HttpClient httpClient = _HttpClientFactory.CreateClient();
FileInfo localFileInfo = new(Path.Combine(wwwRootDirectory, _AppSettings.IqsFileSegments.Last()));
Uri uri = _FileShareRepository.Append(new Uri(_AppSettings.EcMesaFileShareCharacterizationSi), _AppSettings.IqsFileSegments[0..^1]);
List<NginxFileSystemSortable> nginxFileSystemSortableCollection = _FileShareRepository.GetNginxFileSystemSortableCollection(httpClient, uri, ".html");
if (!localFileInfo.Exists && nginxFileSystemSortableCollection.Count == 0)
FileInfo iqsFileInfo = new(_AppSettings.IqsFile);
Assembly assembly = Assembly.GetExecutingAssembly();
string? assemblyName = assembly.GetName()?.Name;
if (string.IsNullOrEmpty(assemblyName))
throw new Exception();
FileInfo localFileInfo = new(Path.Combine(AppContext.BaseDirectory, "wwwroot", iqsFileInfo.Name));
if (!localFileInfo.Exists && (!iqsFileInfo.Exists || iqsFileInfo.Length == 0))
results = new();
else
{
string[] lines;
HttpResponseMessage httpResponseMessage = _FileShareRepository.ReadFile(httpClient, nginxFileSystemSortableCollection[0].Uri);
Task<string> value = httpResponseMessage.Content.ReadAsStringAsync();
value.Wait();
if (localFileInfo.Exists && localFileInfo.LastWriteTime == nginxFileSystemSortableCollection[0].DateTime)
lines = File.ReadAllLines(localFileInfo.FullName);
else
{
FileFindReplaceAndSave(localFileInfo, value.Result);
lines = value.Result.Split("\r\n");
}
ReadOnlyCollection<Record> records = GetRecords(_AppSettings, lines);
if (!localFileInfo.Exists || localFileInfo.LastWriteTime != iqsFileInfo.LastWriteTime)
FileFindReplaceAndSave(_AppSettings, 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

@ -0,0 +1,146 @@
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,16 +13,10 @@ 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, IHttpClientFactory httpClientFactory, IFileShareRepository fileShareRepository)
public ToolTypesRepository(AppSettings appSettings)
{
_AppSettings = appSettings;
_MockRoot = appSettings.MockRoot;
_HttpClientFactory = httpClientFactory;
_FileShareRepository = fileShareRepository;
_RepositoryName = nameof(ToolTypesRepository)[..^10];
}
@ -209,7 +203,7 @@ public class ToolTypesRepository : IToolTypesRepository
return new(message, contentType, stream);
}
string? IToolTypesRepository.OIExport(IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService, int toolTypeId, long headerid)
string? IToolTypesRepository.OIExport(IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService, string attachmentPath, Dictionary<string, string> tableToPath, int toolTypeId, long headerid)
{
string? result;
ToolType toolType = metrologyRepository.GetToolTypeByID(toolTypeId);
@ -217,18 +211,16 @@ public class ToolTypesRepository : IToolTypesRepository
result = $"Invalid tool id [{toolTypeId}] [{headerid}]!";
else
{
string? processDataStandardFormat = attachmentsService.GetProcessDataStandardFormat(metrologyRepository, toolTypeId, headerid);
string? processDataStandardFormat = attachmentsService.GetProcessDataStandardFormat(metrologyRepository, attachmentPath, toolTypeId, headerid);
if (processDataStandardFormat is null)
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}>!";
result = $"Export file doesn't exist for [{toolTypeId}] [{headerid}] at <{attachmentPath}>!";
else if (!tableToPath.TryGetValue(toolType.HeaderTableName, out string? directly))
result = $"Export file doesn't exist for [{toolTypeId}] [{headerid}] at <{attachmentPath}>!";
else
{
try
{
HttpClient httpClient = _HttpClientFactory.CreateClient();
httpClient.BaseAddress = new(_AppSettings.ApiFileShare);
_FileShareRepository.CopyFile(httpClient, processDataStandardFormat, Path.Combine(directly, $"Viewer_{Path.GetFileName(processDataStandardFormat)}"));
File.Copy(processDataStandardFormat, Path.Combine(directly, $"Viewer_{Path.GetFileName(processDataStandardFormat)}"));
result = null;
}
catch (Exception ex) { result = ex.Message; }

View File

@ -1,9 +1,9 @@
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;
using System.Text.Json;
namespace OI.Metrology.Server.Repository;
@ -19,27 +19,28 @@ 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, IFileShareRepository fileShareRepository)
public WaferCounterRepository(AppSettings appSettings, IDbConnectionFactory dbConnectionFactory, IHttpClientFactory httpClientFactory)
{
_AppSettings = appSettings;
_MockRoot = appSettings.MockRoot;
_HttpClientFactory = httpClientFactory;
_DBConnectionFactory = dbConnectionFactory;
_FileShareRepository = fileShareRepository;
_RepositoryName = nameof(WaferCounterRepository)[..^10];
_OpenInsightApplicationProgrammingInterface = appSettings.OpenInsightApplicationProgrammingInterface;
}
private void MoveFile(string waferSizeDirectory, NginxFileSystemSortable nginxFileSystemSortable)
private static void MoveFile(string waferSizeDirectory, FileInfo fileInfo)
{
Calendar calendar = new CultureInfo("en-US").Calendar;
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);
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);
}
private static Record GetRecord(string line1, string line2)
@ -125,86 +126,102 @@ 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.EcCharacterizationSi, "WaferCounter", area, waferSize);
destination ? Path.Combine(_AppSettings.WaferCounterDestinationDirectory, area, waferSize) : Path.Combine(_AppSettings.WaferCounterRootDirectory, area, waferSize);
string? IWaferCounterRepository.GetSlotMap(string line1, string line2) =>
GetRecord(line1, line2).SlotMap;
private List<NginxFileSystemSortable> GetNginxFileSystemSortableCollection(HttpClient httpClient, Uri waferSizeUri, string waferSizeDirectory)
private static FileInfo[] GetFileInfoCollection(string waferSizeDirectory)
{
List<NginxFileSystemSortable> results = new();
DateTime dateTime = DateTime.Now;
long ticks = dateTime.AddSeconds(_AppSettings.WaferCounterTwoFileSecondsWait).Ticks;
for (int i = 0; i < int.MaxValue; i++)
{
results = _FileShareRepository.GetNginxFileSystemSortableCollection(httpClient, waferSizeUri, ".wc");
if (results.Count > 1 || DateTime.Now.Ticks > ticks)
break;
Thread.Sleep(250);
}
for (int i = 1; i < results.Count; i++)
MoveFile(waferSizeDirectory, results[i]);
return results;
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;
}
private static WaferCounter GetLastQuantityAndSlotMapWithText(string waferSize, string text, HttpClient httpClient, NginxFileSystemSortable nginxFileSystemSortable)
private static WaferCounter? GetLastQuantityAndSlotMapWithText(string waferSize, string text, FileInfo fileInfo)
{
WaferCounter result;
Task<string> value = httpClient.GetStringAsync(nginxFileSystemSortable.Uri);
value.Wait();
string[] lines = value.Result.Split("\r\n");
if (lines.Length <= 1)
throw new Exception("Incomplete file length!");
string[] segments = nginxFileSystemSortable.Name.Split('-');
WaferCounter? result;
string[] lines = File.ReadAllLines(fileInfo.FullName);
if (lines.Length < 2)
result = null;
else
{
string[] segments = fileInfo.Name.Split('-');
Record record = GetRecord(lines[0], lines[1]);
string equipmentId = segments.Length <= 1 ? nginxFileSystemSortable.Name : segments[1].Split('.')[0];
string equipmentId = segments.Length < 2 ? fileInfo.Name : segments[1].Split('.')[0];
if (string.IsNullOrEmpty(record.SlotMap) || record.SlotMap.Length != 25)
throw new Exception("Wrong length!");
if (record.Total != record.Check)
throw new Exception("Invalid!");
result = new(nginxFileSystemSortable.DateTime, nginxFileSystemSortable.DateTime.ToString("yyyy-MM-dd hh:mm tt"), $"WC{waferSize}{equipmentId}", text, record.Total, record.SlotMap);
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);
}
return result;
}
WaferCounter IWaferCounterRepository.GetLastQuantityAndSlotMap(string area, string waferSize)
WaferCounter? IWaferCounterRepository.GetLastQuantityAndSlotMap(string area, string waferSize)
{
WaferCounter? result;
if (!string.IsNullOrEmpty(_MockRoot))
{
string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IWaferCounterRepository.GetLastQuantityAndSlotMap)}.json"));
result = JsonSerializer.Deserialize<WaferCounter>(json);
if (result is null)
throw new NullReferenceException(nameof(result));
}
else
{
WaferCounter result;
Uri waferSizeUri = GetWaferSizeUri(area, waferSize);
HttpClient httpClient = _HttpClientFactory.CreateClient();
string waferSizeDirectory = GetWaferSizeDirectory(area, waferSize, destination: false);
List<NginxFileSystemSortable> nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(httpClient, waferSizeUri, waferSizeDirectory);
if (nginxFileSystemSortableCollection.Count < 1)
throw new Exception("No files!");
FileInfo[] fileInfoCollection = GetFileInfoCollection(waferSizeDirectory);
if (fileInfoCollection.Length == 0)
result = null;
else
{
string text = string.Empty;
result = GetLastQuantityAndSlotMapWithText(waferSize, text, httpClient, nginxFileSystemSortableCollection[0]);
result = GetLastQuantityAndSlotMapWithText(waferSize, text, fileInfoCollection[0]);
}
}
return result;
}
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} ");
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} ");
WaferCounter IWaferCounterRepository.GetLastQuantityAndSlotMapWithText(string area, string waferSize, string text)
WaferCounter? IWaferCounterRepository.GetLastQuantityAndSlotMapWithText(string area, string waferSize, string text)
{
WaferCounter? result;
if (!string.IsNullOrEmpty(_MockRoot))
{
string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IWaferCounterRepository.GetLastQuantityAndSlotMapWithText)}.json"));
result = JsonSerializer.Deserialize<WaferCounter>(json);
if (result is null)
throw new NullReferenceException(nameof(result));
}
else
{
WaferCounter result;
Uri waferSizeUri = GetWaferSizeUri(area, waferSize);
HttpClient httpClient = _HttpClientFactory.CreateClient();
string waferSizeDirectory = GetWaferSizeDirectory(area, waferSize, destination: false);
List<NginxFileSystemSortable> nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(httpClient, waferSizeUri, waferSizeDirectory);
if (nginxFileSystemSortableCollection.Count < 1)
throw new Exception("No files!");
result = GetLastQuantityAndSlotMapWithText(waferSize, text, httpClient, nginxFileSystemSortableCollection[0]);
FileInfo[] fileInfoCollection = GetFileInfoCollection(waferSizeDirectory);
if (fileInfoCollection.Length == 0)
result = null;
else
{
result = GetLastQuantityAndSlotMapWithText(waferSize, text, fileInfoCollection[0]);
if (result is not null)
{
string waferSizeDestinationDirectory = _AppSettings.WaferCounterDestinationDirectory;
// string waferSizeDestinationDirectory = GetWaferSizeUri(area, waferSize, destination: true);
Save(waferSizeDestinationDirectory, area, waferSize, text, nginxFileSystemSortableCollection[0], result);
// string waferSizeDestinationDirectory = GetWaferSizeDirectory(area, waferSize, destination: true);
Save(waferSizeDestinationDirectory, area, waferSize, text, fileInfoCollection[0], result);
}
}
}
if (result is null)
throw new NullReferenceException(nameof(result));
return result;
}

View File

@ -4,24 +4,17 @@ 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, IHttpClientFactory httpClientFactory, IFileShareRepository fileShareRepository, IMetrologyRepository metrologyRepository)
public AttachmentsService(AppSettings appSettings, IMetrologyRepository metrologyRepository)
{
_AppSettings = appSettings;
_HttpClientFactory = httpClientFactory;
_FileShareRepository = fileShareRepository;
_MetrologyRepository = metrologyRepository;
}
@ -34,16 +27,23 @@ 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);
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();
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);
}
Stream IAttachmentsService.GetAttachmentStreamByTitle(ToolType toolType, bool header, string title, string filename)
@ -86,6 +86,7 @@ public class AttachmentsService : IAttachmentsService
Guid attachmentId = Guid.Empty;
DateTime insertDate = new();
string? tableName = "";
if (string.IsNullOrWhiteSpace(dataUniqueId))
{
attachmentId = _MetrologyRepository.GetHeaderAttachmentID(toolType.ID, headerId);
@ -100,22 +101,18 @@ public class AttachmentsService : IAttachmentsService
tableName = toolType.DataTableName;
}
if (Equals(attachmentId, Guid.Empty))
{
trans.Dispose();
throw new Exception("Invalid attachment ID!");
}
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);
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());
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);
trans.Complete();
}
@ -125,38 +122,27 @@ public class AttachmentsService : IAttachmentsService
SaveAttachment(toolType, headerId, dataUniqueId, filename, formFile);
}
string? IAttachmentsService.GetProcessDataStandardFormat(IMetrologyRepository metrologyRepository, int toolTypeId, long headerId)
string? IAttachmentsService.GetProcessDataStandardFormat(IMetrologyRepository metrologyRepository, string attachmentPath, int toolTypeId, long headerId)
{
string? result;
int weekNum;
string year;
Task<string> json;
Uri weekDirectory;
Uri checkDirectory;
int weekNum;
string directory;
string 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);
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)
directory = Path.Combine(_AppSettings.AttachmentPath, $"{toolType.HeaderTableName}_", year, $"WW{weekNum:00}");
if (!Directory.Exists(directory))
_ = Directory.CreateDirectory(directory);
checkDirectory = Path.Combine(directory, headerId.ToString());
if (!Directory.Exists(checkDirectory))
continue;
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);
files.AddRange(Directory.GetFiles(checkDirectory));
if (files.Count != 0)
break;
}

View File

@ -17,8 +17,8 @@ function getUrlParameter(param) {
return false;
}
function setSlots(slotMap) {
var slots = slotMap.split("");
function setWafers(waferMap) {
var slots = waferMap.split("");
if (slots.length !== 25)
throw Error;
$('.slot').each(function (index) {
@ -36,7 +36,7 @@ function setValues(data) {
clearMap();
else {
$('#waferCount').val(data.total);
setSlots(data.slotMap);
setWafers(data.waferMap);
$('#lastDateTime').text(new Date().toLocaleString());
}
}
@ -48,7 +48,7 @@ function clearText() {
}
function clearMap() {
setSlots('0000000000000000000000000');
setWafers('0000000000000000000000000');
}
function poll() {
@ -59,7 +59,7 @@ function poll() {
}
else if (_count > -1) {
_count++;
$.get(_apiUrl + $("#toolId").val() + '/last-quantity-and-slot-map/?area=' + $("#operation").val(), function (data) {
$.get(_apiUrl + $("#toolId").val() + '/last-quantity-and-wafer-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-slot-map-with-text/?area=' + $("#operation").val() + '&text=' + $("#lot").val(), function (data) {
$.get(_apiUrl + $("#toolId").val() + '/last-quantity-and-wafer-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-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 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 type="module"
src="package/dist/infineon-design-system-stencil/infineon-design-system-stencil.esm.js"></script>

View File

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

View File

@ -1,21 +0,0 @@
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

@ -1,29 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,16 +0,0 @@
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

@ -0,0 +1,13 @@
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,14 +8,13 @@ public interface IToolTypesRepository
{
Result<ToolTypeNameId[]> Index(IMetrologyRepository metrologyRepository);
Result<DataTable> GetData(IMetrologyRepository metrologyRepository, int id, long headerid);
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);
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);
byte[] GetCSVExport(IMetrologyRepository metrologyRepository, int toolTypeId, string? datebegin, string? dateend);
}

View File

@ -4,7 +4,7 @@ public interface IWaferCounterRepository
{
string? GetSlotMap(string line1, string line2);
DataModels.WaferCounter GetLastQuantityAndSlotMap(string area, string waferSize);
DataModels.WaferCounter? GetLastQuantityAndSlotMap(string area, string waferSize);
DataModels.WaferCounter? GetLastQuantityAndSlotMapWithText(string area, string waferSize, string text);
}

View File

@ -0,0 +1,50 @@
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 = "5131", Reactor = "23", RDS = "631836", ID = 1710783849 };
new() { PSN = "5008", Reactor = "61", RDS = "579487", ID = 1678209360 };
private static StringContent GetStringContent() =>
new(System.Text.Json.JsonSerializer.Serialize(GetHeaderCommon()), Encoding.UTF8, "application/json");

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

@ -1,12 +1,13 @@
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 UnitTestFileShareController
public class UnitTestReactorController
{
#pragma warning disable CS8618
@ -25,7 +26,7 @@ public class UnitTestFileShareController
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.FileShareController)[..^10];
_ControllerName = nameof(Server.ApiControllers.ReactorsController)[..^10];
}
private static void NonThrowTryCatch()
@ -39,45 +40,46 @@ public class UnitTestFileShareController
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IFileShareController<string>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch();
}
[Ignore]
[TestMethod]
public async Task CopyFileApi()
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
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);
Assert.AreEqual(IReactorsController<string>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch();
}
[TestMethod]
public async Task FileWriteApi()
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()
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
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);
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);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch();
}
[TestMethod]
public void GetKey()
{
_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);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch();
}

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, toolTypeId: 1, headerid: 1);
string? message = toolTypesRepository?.OIExport(metrologyRepository, attachmentsService, appSettings.AttachmentPath, appSettings.TableToPath, toolTypeId: 1, headerid: 1);
Assert.IsTrue(message is null);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
}

View File

@ -60,49 +60,22 @@ 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);
result = waferCounterRepository?.GetSlotMap("T20", "P17FFFF0");
Assert.AreEqual("1011111111111111111110000", result);
result = waferCounterRepository?.GetSlotMap("T03", "P1002002");
Assert.AreEqual("1000000000010000000000010", result);
result = waferCounterRepository?.GetSlotMap("T02", "P1000002");
Assert.AreEqual("1000000000000000000000010", result);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch();
}
[Ignore]
[TestMethod]
public void GetLastQuantityAndSlotMap()
{
WaferCounter? result;
_Logger?.LogInformation("Starting Web Application");
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IWaferCounterRepository? waferCounterRepository = serviceProvider?.GetRequiredService<IWaferCounterRepository>();
result = waferCounterRepository?.GetLastQuantityAndSlotMap("EPP-East", "6INCH");
Assert.IsNotNull(result);
result = waferCounterRepository?.GetLastQuantityAndSlotMap("EPP-East", "8INCH");
Assert.IsNotNull(result);
result = waferCounterRepository?.GetLastQuantityAndSlotMap("EPP-West", "6INCH");
Assert.IsNotNull(result);
result = waferCounterRepository?.GetLastQuantityAndSlotMap("EPP-West", "8INCH");
Assert.IsNotNull(result);
result = waferCounterRepository?.GetLastQuantityAndSlotMap("FQA", "6INCH");
Assert.IsNotNull(result);
result = waferCounterRepository?.GetLastQuantityAndSlotMap("FQA", "8INCH");
Assert.IsNotNull(result);
result = waferCounterRepository?.GetLastQuantityAndSlotMap("MU", "6INCH");
Assert.IsNotNull(result);
result = waferCounterRepository?.GetLastQuantityAndSlotMap("MU", "8INCH");
WaferCounter? result = waferCounterRepository?.GetLastQuantityAndSlotMap("EPP-East", "8INCH", "123456");
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch();
}
[Ignore]
[TestMethod]
public async Task GetLastQuantityAndSlotMapApi()
{
@ -116,7 +89,6 @@ public class UnitTestWaferCounterController
NonThrowTryCatch();
}
[Ignore]
[TestMethod]
public void GetLastQuantityAndSlotMapWithText()
{
@ -129,7 +101,6 @@ public class UnitTestWaferCounterController
NonThrowTryCatch();
}
[Ignore]
[TestMethod]
public async Task GetLastQuantityAndSlotMapWithTextApi()
{

View File

@ -62,10 +62,7 @@ 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;
}

1
WinForms/.vscode/format-report.json vendored Normal file
View File

@ -0,0 +1 @@
[]

30
WinForms/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,30 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/net8.0-windows/win-x64/OI.Metrology.WinForms.dll",
"args": [
"s",
"M",
"L:/Git/Notes-EC-Documentation/.EC-Documentation",
"-s",
"L:/Git/Notes-EC-Documentation/.EC-Documentation/port"
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}

4
WinForms/.vscode/mklink.md vendored Normal file
View File

@ -0,0 +1,4 @@
# mklink
```bash
```

37
WinForms/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,37 @@
{
"[markdown]": {
"editor.wordWrap": "off"
},
"files.exclude": {
"**/.git": false,
"**/node_modules": true
},
"files.watcherExclude": {
"**/node_modules": true
},
"cSpell.words": [
"ASPNETCORE",
"BIRT",
"CHIL",
"DEAT",
"endianness",
"FAMC",
"FAMS",
"GIVN",
"HUSB",
"INDI",
"Infineon",
"Kanban",
"kanbn",
"Kofax",
"NSFX",
"OBJE",
"onenote",
"pged",
"Phares",
"Serilog",
"SUBM",
"SURN",
"SYSLIB"
]
}

83
WinForms/.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,83 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "User Secrets Init",
"command": "dotnet",
"type": "process",
"args": [
"user-secrets",
"-p",
"${workspaceFolder}/OI.Metrology.WinForms.csproj",
"init"
],
"problemMatcher": "$msCompile"
},
{
"label": "User Secrets Set",
"command": "dotnet",
"type": "process",
"args": [
"user-secrets",
"-p",
"${workspaceFolder}/OI.Metrology.WinForms.csproj",
"set",
"asdf",
"123"
],
"problemMatcher": "$msCompile"
},
{
"label": "Format",
"command": "dotnet",
"type": "process",
"args": [
"format",
"--report",
".vscode",
"--verbosity",
"detailed",
"--severity",
"warn"
],
"problemMatcher": "$msCompile"
},
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/OI.Metrology.WinForms.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/OI.Metrology.WinForms.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary",
"-p:PublishSingleFile=true"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/OI.Metrology.WinForms.csproj"
],
"problemMatcher": "$msCompile"
}
]
}

136
WinForms/Form1.Designer.cs generated Normal file
View File

@ -0,0 +1,136 @@
namespace WinForms;
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
this._Go = new System.Windows.Forms.Button();
this._NoGo = new System.Windows.Forms.Button();
this._Cancel = new System.Windows.Forms.Button();
this._BaseDirectory = new System.Windows.Forms.Label();
this._CommandLineArgs = new System.Windows.Forms.Label();
this._WebBrowser = new System.Windows.Forms.WebBrowser();
this._CurrentDirectory = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// _Go
//
this._Go.AutoSize = true;
this._Go.Location = new System.Drawing.Point(5, 5);
this._Go.Name = "Go";
this._Go.Size = new System.Drawing.Size(68, 16);
this._Go.Text = "Go";
this._Go.ForeColor = Color.White;
this._Go.Click += new EventHandler(this.Go_Click);
//
// _NoGo
//
this._NoGo.AutoSize = true;
this._NoGo.Location = new System.Drawing.Point(105, 5);
this._NoGo.Name = "NoGo";
this._NoGo.Size = new System.Drawing.Size(68, 16);
this._NoGo.Text = "NoGo";
this._NoGo.ForeColor = Color.White;
this._NoGo.Click += new EventHandler(this.NoGo_Click);
//
// _Cancel
//
this._Cancel.AutoSize = true;
this._Cancel.Location = new System.Drawing.Point(205, 5);
this._Cancel.Name = "Cancel";
this._Cancel.Size = new System.Drawing.Size(68, 16);
this._Cancel.Text = "Cancel";
this._Cancel.ForeColor = Color.White;
this._Cancel.Click += new EventHandler(this.Cancel_Click);
//
// _BaseDirectory
//
this._BaseDirectory.AutoSize = true;
this._BaseDirectory.Location = new System.Drawing.Point(5, 55);
this._BaseDirectory.Name = "BaseDirectory";
this._BaseDirectory.Size = new System.Drawing.Size(68, 16);
this._BaseDirectory.Text = "BaseDirectory";
this._BaseDirectory.ForeColor = Color.White;
//
// _CommandLineArgs
//
this._CommandLineArgs.AutoSize = true;
this._CommandLineArgs.Location = new System.Drawing.Point(5, 105);
this._CommandLineArgs.Name = "CurrentDirectory";
this._CommandLineArgs.Size = new System.Drawing.Size(68, 16);
this._CommandLineArgs.Text = "CurrentDirectory";
this._CommandLineArgs.ForeColor = Color.White;
//
// _CurrentDirectory
//
this._CurrentDirectory.AutoSize = true;
this._CurrentDirectory.Location = new System.Drawing.Point(5, 155);
this._CurrentDirectory.Name = "CurrentDirectory";
this._CurrentDirectory.Size = new System.Drawing.Size(68, 16);
this._CurrentDirectory.Text = "CurrentDirectory";
this._CurrentDirectory.ForeColor = Color.White;
//
// _WebBrowser
//
this._WebBrowser.Location = new System.Drawing.Point(5, 205);
this._WebBrowser.MinimumSize = new System.Drawing.Size(20, 20);
this._WebBrowser.Name = "WebBrowser";
this._WebBrowser.ScriptErrorsSuppressed = true;
this._WebBrowser.Size = new System.Drawing.Size(1008, 729);
this._WebBrowser.Visible = false;
this._WebBrowser.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.WebBrowser_DocumentCompleted);
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(43)))), ((int)(((byte)(48)))));
this.ClientSize = new System.Drawing.Size(1008, 729);
this.Controls.Add(this._Go);
this.Controls.Add(this._NoGo);
this.Controls.Add(this._Cancel);
this.Controls.Add(this._WebBrowser);
this.Controls.Add(this._BaseDirectory);
this.Controls.Add(this._CommandLineArgs);
this.Controls.Add(this._CurrentDirectory);
this.Font = new System.Drawing.Font("Tahoma", 9.75F);
this.Load += new System.EventHandler(this.Form_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
internal System.Windows.Forms.Button _Go;
internal System.Windows.Forms.Button _NoGo;
internal System.Windows.Forms.Button _Cancel;
internal System.Windows.Forms.Label _BaseDirectory;
internal System.Windows.Forms.Label _CommandLineArgs;
internal System.Windows.Forms.WebBrowser _WebBrowser;
internal System.Windows.Forms.Label _CurrentDirectory;
#endregion
}

62
WinForms/Form1.cs Normal file
View File

@ -0,0 +1,62 @@
namespace WinForms;
public partial class Form1 : Form
{
public Form1() =>
InitializeComponent();
private void Form_Load(object sender, EventArgs e)
{
try
{
_BaseDirectory.Text = AppContext.BaseDirectory;
_CurrentDirectory.Text = Environment.CurrentDirectory;
_CommandLineArgs.Text = string.Join(' ', Environment.GetCommandLineArgs());
_WebBrowser.Navigate("https://oi-metrology-viewer-prod.mes.infineon.com/Export");
}
catch (Exception ex) { CatchException(ex); }
}
private static void CatchException(Exception ex) =>
_ = MessageBox.Show(ex.StackTrace, ex.Message);
private void Go_Click(object sender, EventArgs e)
{
try
{
Environment.ExitCode = 1;
Application.Exit();
}
catch (Exception ex) { CatchException(ex); }
}
private void NoGo_Click(object sender, EventArgs e)
{
try
{
Environment.ExitCode = 2;
Application.Exit();
}
catch (Exception ex) { CatchException(ex); }
}
private void Cancel_Click(object sender, EventArgs e)
{
try
{
Environment.ExitCode = -1;
Application.Exit();
}
catch (Exception ex) { CatchException(ex); }
}
private void WebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
try
{
_WebBrowser.Visible = true;
}
catch (Exception ex) { CatchException(ex); }
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>a98b14f0-fc21-4f31-a1e4-1337f6c60100</UserSecretsId>
</PropertyGroup>
</Project>

16
WinForms/Program.cs Normal file
View File

@ -0,0 +1,16 @@
namespace WinForms;
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
}