Update GetEngineeringSpcReview to work without FS access.
IqsFileSegments and WaferCounterTwoFileSecondsWait
This commit is contained in:
parent
811f45a7df
commit
85fe0a7823
@ -2,8 +2,7 @@ using System.Text.Json;
|
|||||||
|
|
||||||
namespace OI.Metrology.Server.Models;
|
namespace OI.Metrology.Server.Models;
|
||||||
|
|
||||||
public record AppSettings(string ApiExportPath,
|
public record AppSettings(string ApiFileShare,
|
||||||
string ApiFileShare,
|
|
||||||
string ApiLoggingContentTypes,
|
string ApiLoggingContentTypes,
|
||||||
string ApiLoggingPathPrefixes,
|
string ApiLoggingPathPrefixes,
|
||||||
string ApiLogPath,
|
string ApiLogPath,
|
||||||
@ -17,7 +16,7 @@ public record AppSettings(string ApiExportPath,
|
|||||||
string GitCommitSeven,
|
string GitCommitSeven,
|
||||||
string InboundApiAllowedIPList,
|
string InboundApiAllowedIPList,
|
||||||
string IqsColumns,
|
string IqsColumns,
|
||||||
string IqsFile,
|
string[] IqsFileSegments,
|
||||||
string IqsKey,
|
string IqsKey,
|
||||||
string IqsRed,
|
string IqsRed,
|
||||||
string IqsYellow,
|
string IqsYellow,
|
||||||
@ -30,6 +29,7 @@ public record AppSettings(string ApiExportPath,
|
|||||||
Dictionary<string, string> TableToPath,
|
Dictionary<string, string> TableToPath,
|
||||||
string URLs,
|
string URLs,
|
||||||
string WaferCounterDestinationDirectory,
|
string WaferCounterDestinationDirectory,
|
||||||
|
int WaferCounterTwoFileSecondsWait,
|
||||||
string WorkingDirectoryName)
|
string WorkingDirectoryName)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ namespace OI.Metrology.Server.Models.Binder;
|
|||||||
public class AppSettings
|
public class AppSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
public string? ApiExportPath { get; set; }
|
|
||||||
public string? ApiFileShare { get; set; }
|
public string? ApiFileShare { get; set; }
|
||||||
public string? ApiLoggingContentTypes { get; set; }
|
public string? ApiLoggingContentTypes { get; set; }
|
||||||
public string? ApiLoggingPathPrefixes { get; set; }
|
public string? ApiLoggingPathPrefixes { get; set; }
|
||||||
@ -21,7 +20,7 @@ public class AppSettings
|
|||||||
public string? GitCommitSeven { get; set; }
|
public string? GitCommitSeven { get; set; }
|
||||||
public string? InboundApiAllowedIPList { get; set; }
|
public string? InboundApiAllowedIPList { get; set; }
|
||||||
public string? IqsColumns { get; set; }
|
public string? IqsColumns { get; set; }
|
||||||
public string? IqsFile { get; set; }
|
public string[]? IqsFileSegments { get; set; }
|
||||||
public string? IqsKey { get; set; }
|
public string? IqsKey { get; set; }
|
||||||
public string? IqsRed { get; set; }
|
public string? IqsRed { get; set; }
|
||||||
public string? IqsYellow { get; set; }
|
public string? IqsYellow { get; set; }
|
||||||
@ -34,6 +33,7 @@ public class AppSettings
|
|||||||
public Dictionary<string, string>? TableToPath { get; set; }
|
public Dictionary<string, string>? TableToPath { get; set; }
|
||||||
public string? URLs { get; set; }
|
public string? URLs { get; set; }
|
||||||
public string? WaferCounterDestinationDirectory { get; set; }
|
public string? WaferCounterDestinationDirectory { get; set; }
|
||||||
|
public int? WaferCounterTwoFileSecondsWait { get; set; }
|
||||||
public string? WorkingDirectoryName { get; set; }
|
public string? WorkingDirectoryName { get; set; }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
@ -44,7 +44,7 @@ public class AppSettings
|
|||||||
|
|
||||||
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
if (appSettings?.ApiExportPath is null)
|
if (appSettings?.ApiFileShare is null)
|
||||||
{
|
{
|
||||||
List<string> paths = new();
|
List<string> paths = new();
|
||||||
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
|
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
|
||||||
@ -63,7 +63,6 @@ public class AppSettings
|
|||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
if (appSettings is null) throw new NullReferenceException(nameof(appSettings));
|
if (appSettings is null) throw new NullReferenceException(nameof(appSettings));
|
||||||
if (appSettings.ApiExportPath is null) throw new NullReferenceException(nameof(ApiExportPath));
|
|
||||||
if (appSettings.ApiFileShare is null) throw new NullReferenceException(nameof(ApiFileShare));
|
if (appSettings.ApiFileShare is null) throw new NullReferenceException(nameof(ApiFileShare));
|
||||||
if (appSettings.ApiLoggingContentTypes is null) throw new NullReferenceException(nameof(ApiLoggingContentTypes));
|
if (appSettings.ApiLoggingContentTypes is null) throw new NullReferenceException(nameof(ApiLoggingContentTypes));
|
||||||
if (appSettings.ApiLoggingPathPrefixes is null) throw new NullReferenceException(nameof(ApiLoggingPathPrefixes));
|
if (appSettings.ApiLoggingPathPrefixes is null) throw new NullReferenceException(nameof(ApiLoggingPathPrefixes));
|
||||||
@ -78,7 +77,7 @@ public class AppSettings
|
|||||||
if (appSettings.GitCommitSeven is null) throw new NullReferenceException(nameof(GitCommitSeven));
|
if (appSettings.GitCommitSeven is null) throw new NullReferenceException(nameof(GitCommitSeven));
|
||||||
if (appSettings.InboundApiAllowedIPList is null) throw new NullReferenceException(nameof(InboundApiAllowedIPList));
|
if (appSettings.InboundApiAllowedIPList is null) throw new NullReferenceException(nameof(InboundApiAllowedIPList));
|
||||||
if (appSettings.IqsColumns is null) throw new NullReferenceException(nameof(IqsColumns));
|
if (appSettings.IqsColumns is null) throw new NullReferenceException(nameof(IqsColumns));
|
||||||
if (appSettings.IqsFile is null) throw new NullReferenceException(nameof(IqsFile));
|
if (appSettings.IqsFileSegments is null) throw new NullReferenceException(nameof(IqsFileSegments));
|
||||||
if (appSettings.IqsKey is null) throw new NullReferenceException(nameof(IqsKey));
|
if (appSettings.IqsKey is null) throw new NullReferenceException(nameof(IqsKey));
|
||||||
if (appSettings.IqsRed is null) throw new NullReferenceException(nameof(IqsRed));
|
if (appSettings.IqsRed is null) throw new NullReferenceException(nameof(IqsRed));
|
||||||
if (appSettings.IqsYellow is null) throw new NullReferenceException(nameof(IqsYellow));
|
if (appSettings.IqsYellow is null) throw new NullReferenceException(nameof(IqsYellow));
|
||||||
@ -91,9 +90,9 @@ public class AppSettings
|
|||||||
if (appSettings.URLs is null) throw new NullReferenceException(nameof(URLs));
|
if (appSettings.URLs is null) throw new NullReferenceException(nameof(URLs));
|
||||||
if (appSettings.TableToPath is null) throw new NullReferenceException(nameof(TableToPath));
|
if (appSettings.TableToPath is null) throw new NullReferenceException(nameof(TableToPath));
|
||||||
if (appSettings.WaferCounterDestinationDirectory is null) throw new NullReferenceException(nameof(WaferCounterDestinationDirectory));
|
if (appSettings.WaferCounterDestinationDirectory is null) throw new NullReferenceException(nameof(WaferCounterDestinationDirectory));
|
||||||
|
if (appSettings.WaferCounterTwoFileSecondsWait is null) throw new NullReferenceException(nameof(WaferCounterTwoFileSecondsWait));
|
||||||
if (appSettings.WorkingDirectoryName is null) throw new NullReferenceException(nameof(WorkingDirectoryName));
|
if (appSettings.WorkingDirectoryName is null) throw new NullReferenceException(nameof(WorkingDirectoryName));
|
||||||
result = new(
|
result = new(
|
||||||
appSettings.ApiExportPath,
|
|
||||||
appSettings.ApiFileShare,
|
appSettings.ApiFileShare,
|
||||||
appSettings.ApiLoggingContentTypes,
|
appSettings.ApiLoggingContentTypes,
|
||||||
appSettings.ApiLoggingPathPrefixes,
|
appSettings.ApiLoggingPathPrefixes,
|
||||||
@ -108,7 +107,7 @@ public class AppSettings
|
|||||||
appSettings.GitCommitSeven,
|
appSettings.GitCommitSeven,
|
||||||
appSettings.InboundApiAllowedIPList,
|
appSettings.InboundApiAllowedIPList,
|
||||||
appSettings.IqsColumns,
|
appSettings.IqsColumns,
|
||||||
appSettings.IqsFile,
|
appSettings.IqsFileSegments,
|
||||||
appSettings.IqsKey,
|
appSettings.IqsKey,
|
||||||
appSettings.IqsRed,
|
appSettings.IqsRed,
|
||||||
appSettings.IqsYellow,
|
appSettings.IqsYellow,
|
||||||
@ -121,6 +120,7 @@ public class AppSettings
|
|||||||
appSettings.TableToPath,
|
appSettings.TableToPath,
|
||||||
appSettings.URLs,
|
appSettings.URLs,
|
||||||
appSettings.WaferCounterDestinationDirectory,
|
appSettings.WaferCounterDestinationDirectory,
|
||||||
|
appSettings.WaferCounterTwoFileSecondsWait.Value,
|
||||||
appSettings.WorkingDirectoryName);
|
appSettings.WorkingDirectoryName);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -677,12 +677,11 @@ public class InfinityQSV4Repository : IInfinityQSV4Repository
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReadOnlyCollection<Record> GetRecords(AppSettings appSettings, string file)
|
private static ReadOnlyCollection<Record> GetRecords(AppSettings appSettings, string[] lines)
|
||||||
{
|
{
|
||||||
Record? record;
|
Record? record;
|
||||||
List<Record> results = new();
|
List<Record> results = new();
|
||||||
List<string> checkColumns = new();
|
List<string> checkColumns = new();
|
||||||
string[] lines = File.ReadAllLines(file);
|
|
||||||
foreach (string line in lines)
|
foreach (string line in lines)
|
||||||
{
|
{
|
||||||
if (line.StartsWith("<th"))
|
if (line.StartsWith("<th"))
|
||||||
@ -747,10 +746,23 @@ public class InfinityQSV4Repository : IInfinityQSV4Repository
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FileFindReplaceAndSave(string iqsFile, FileInfo fileInfo)
|
private void FileFindReplaceAndSave(FileInfo fileInfo, string value)
|
||||||
{
|
{
|
||||||
string lines = File.ReadAllText(iqsFile).Replace(_AppSettings.IqsRed, "red").Replace(_AppSettings.IqsYellow, "Yellow");
|
string lines = value.Replace(_AppSettings.IqsRed, "red").Replace(_AppSettings.IqsYellow, "Yellow");
|
||||||
_FileShareRepository.FileWrite(fileInfo.FullName, lines);
|
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>> IInfinityQSV4Repository.GetEngineeringSpcReview()
|
||||||
@ -765,19 +777,27 @@ public class InfinityQSV4Repository : IInfinityQSV4Repository
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FileInfo iqsFileInfo = new(_AppSettings.IqsFile);
|
string wwwRootDirectory = GetWwwRootDirectory();
|
||||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
HttpClient httpClient = _HttpClientFactory.CreateClient();
|
||||||
string? assemblyName = assembly.GetName()?.Name;
|
FileInfo localFileInfo = new(Path.Combine(wwwRootDirectory, _AppSettings.IqsFileSegments.Last()));
|
||||||
if (string.IsNullOrEmpty(assemblyName))
|
Uri uri = _FileShareRepository.Append(new Uri(_AppSettings.EcMesaFileShareCharacterizationSi), _AppSettings.IqsFileSegments[0..^1]);
|
||||||
throw new Exception();
|
List<NginxFileSystemSortable> nginxFileSystemSortableCollection = _FileShareRepository.GetNginxFileSystemSortableCollection(httpClient, uri, ".html");
|
||||||
FileInfo localFileInfo = new(Path.Combine(AppContext.BaseDirectory, "wwwroot", iqsFileInfo.Name));
|
if (!localFileInfo.Exists && nginxFileSystemSortableCollection.Count == 0)
|
||||||
if (!localFileInfo.Exists && (!iqsFileInfo.Exists || iqsFileInfo.Length == 0))
|
|
||||||
results = new();
|
results = new();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!localFileInfo.Exists || localFileInfo.LastWriteTime != iqsFileInfo.LastWriteTime)
|
string[] lines;
|
||||||
FileFindReplaceAndSave(iqsFileInfo.FullName, localFileInfo);
|
HttpResponseMessage httpResponseMessage = _FileShareRepository.ReadFile(httpClient, nginxFileSystemSortableCollection[0].Uri);
|
||||||
ReadOnlyCollection<Record> records = !iqsFileInfo.Exists || iqsFileInfo.Length == 0 ? GetRecords(_AppSettings, localFileInfo.FullName) : GetRecords(_AppSettings, iqsFileInfo.FullName);
|
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);
|
||||||
List<Dictionary<string, Record>> collection = GetCollection(_AppSettings.IqsColumns, records);
|
List<Dictionary<string, Record>> collection = GetCollection(_AppSettings.IqsColumns, records);
|
||||||
results = GetResults(_AppSettings, collection);
|
results = GetResults(_AppSettings, collection);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ using OI.Metrology.Shared.Models;
|
|||||||
using OI.Metrology.Shared.Models.Stateless;
|
using OI.Metrology.Shared.Models.Stateless;
|
||||||
using OI.Metrology.Shared.Repositories;
|
using OI.Metrology.Shared.Repositories;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
namespace OI.Metrology.Server.Repository;
|
namespace OI.Metrology.Server.Repository;
|
||||||
|
|
||||||
@ -137,85 +136,66 @@ public class WaferCounterRepository : IWaferCounterRepository
|
|||||||
|
|
||||||
private List<NginxFileSystemSortable> GetNginxFileSystemSortableCollection(HttpClient httpClient, Uri waferSizeUri, string waferSizeDirectory)
|
private List<NginxFileSystemSortable> GetNginxFileSystemSortableCollection(HttpClient httpClient, Uri waferSizeUri, string waferSizeDirectory)
|
||||||
{
|
{
|
||||||
List<NginxFileSystemSortable> results = _FileShareRepository.GetNginxFileSystemSortableCollection(httpClient, waferSizeUri, ".wc");
|
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++)
|
for (int i = 1; i < results.Count; i++)
|
||||||
MoveFile(waferSizeDirectory, results[i]);
|
MoveFile(waferSizeDirectory, results[i]);
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static WaferCounter? GetLastQuantityAndSlotMapWithText(string waferSize, string text, HttpClient httpClient, NginxFileSystemSortable nginxFileSystemSortable)
|
private static WaferCounter GetLastQuantityAndSlotMapWithText(string waferSize, string text, HttpClient httpClient, NginxFileSystemSortable nginxFileSystemSortable)
|
||||||
{
|
{
|
||||||
WaferCounter? result;
|
WaferCounter result;
|
||||||
Task<string> value = httpClient.GetStringAsync(nginxFileSystemSortable.Uri);
|
Task<string> value = httpClient.GetStringAsync(nginxFileSystemSortable.Uri);
|
||||||
value.Wait();
|
value.Wait();
|
||||||
string[] lines = value.Result.Split(Environment.NewLine);
|
string[] lines = value.Result.Split("\r\n");
|
||||||
if (lines.Length < 2)
|
if (lines.Length <= 1)
|
||||||
result = null;
|
throw new Exception("Incomplete file length!");
|
||||||
else
|
|
||||||
{
|
|
||||||
string[] segments = nginxFileSystemSortable.Name.Split('-');
|
string[] segments = nginxFileSystemSortable.Name.Split('-');
|
||||||
Record record = GetRecord(lines[0], lines[1]);
|
Record record = GetRecord(lines[0], lines[1]);
|
||||||
string equipmentId = segments.Length < 2 ? nginxFileSystemSortable.Name : segments[1].Split('.')[0];
|
string equipmentId = segments.Length <= 1 ? nginxFileSystemSortable.Name : segments[1].Split('.')[0];
|
||||||
if (string.IsNullOrEmpty(record.SlotMap) || record.SlotMap.Length != 25)
|
if (string.IsNullOrEmpty(record.SlotMap) || record.SlotMap.Length != 25)
|
||||||
result = null; // Wrong length!
|
throw new Exception("Wrong length!");
|
||||||
else if (record.Total != record.Check)
|
if (record.Total != record.Check)
|
||||||
result = null; // Invalid!
|
throw new Exception("Invalid!");
|
||||||
else
|
|
||||||
result = new(nginxFileSystemSortable.DateTime, nginxFileSystemSortable.DateTime.ToString("yyyy-MM-dd hh:mm tt"), $"WC{waferSize}{equipmentId}", text, record.Total, record.SlotMap);
|
result = new(nginxFileSystemSortable.DateTime, nginxFileSystemSortable.DateTime.ToString("yyyy-MM-dd hh:mm tt"), $"WC{waferSize}{equipmentId}", text, record.Total, record.SlotMap);
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
Uri waferSizeUri = GetWaferSizeUri(area, waferSize);
|
||||||
HttpClient httpClient = _HttpClientFactory.CreateClient();
|
HttpClient httpClient = _HttpClientFactory.CreateClient();
|
||||||
string waferSizeDirectory = GetWaferSizeDirectory(area, waferSize, destination: false);
|
string waferSizeDirectory = GetWaferSizeDirectory(area, waferSize, destination: false);
|
||||||
List<NginxFileSystemSortable> nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(httpClient, waferSizeUri, waferSizeDirectory);
|
List<NginxFileSystemSortable> nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(httpClient, waferSizeUri, waferSizeDirectory);
|
||||||
if (nginxFileSystemSortableCollection.Count == 0)
|
if (nginxFileSystemSortableCollection.Count < 1)
|
||||||
result = null;
|
throw new Exception("No files!");
|
||||||
else
|
|
||||||
{
|
|
||||||
string text = string.Empty;
|
string text = string.Empty;
|
||||||
result = GetLastQuantityAndSlotMapWithText(waferSize, text, httpClient, nginxFileSystemSortableCollection[0]);
|
result = GetLastQuantityAndSlotMapWithText(waferSize, text, httpClient, nginxFileSystemSortableCollection[0]);
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Save(string waferSizeDestinationDirectory, string area, string waferSize, string text, NginxFileSystemSortable nginxFileSystemSortable, WaferCounter 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} ");
|
_FileShareRepository.FileWrite(Path.Combine(waferSizeDestinationDirectory, $"{nginxFileSystemSortable.Name}.csv"), $"100,{waferSize},{area},{nginxFileSystemSortable.DateTime},{text},{result.Total:00},{result.SlotMap} ");
|
||||||
|
|
||||||
WaferCounter? IWaferCounterRepository.GetLastQuantityAndSlotMapWithText(string area, string waferSize, string text)
|
WaferCounter IWaferCounterRepository.GetLastQuantityAndSlotMapWithText(string area, string waferSize, string text)
|
||||||
{
|
|
||||||
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);
|
Uri waferSizeUri = GetWaferSizeUri(area, waferSize);
|
||||||
HttpClient httpClient = _HttpClientFactory.CreateClient();
|
HttpClient httpClient = _HttpClientFactory.CreateClient();
|
||||||
string waferSizeDirectory = GetWaferSizeDirectory(area, waferSize, destination: false);
|
string waferSizeDirectory = GetWaferSizeDirectory(area, waferSize, destination: false);
|
||||||
List<NginxFileSystemSortable> nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(httpClient, waferSizeUri, waferSizeDirectory);
|
List<NginxFileSystemSortable> nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(httpClient, waferSizeUri, waferSizeDirectory);
|
||||||
if (nginxFileSystemSortableCollection.Count == 0)
|
if (nginxFileSystemSortableCollection.Count < 1)
|
||||||
result = null;
|
throw new Exception("No files!");
|
||||||
else
|
|
||||||
{
|
|
||||||
result = GetLastQuantityAndSlotMapWithText(waferSize, text, httpClient, nginxFileSystemSortableCollection[0]);
|
result = GetLastQuantityAndSlotMapWithText(waferSize, text, httpClient, nginxFileSystemSortableCollection[0]);
|
||||||
if (result is not null)
|
if (result is not null)
|
||||||
{
|
{
|
||||||
@ -223,8 +203,8 @@ public class WaferCounterRepository : IWaferCounterRepository
|
|||||||
// string waferSizeDestinationDirectory = GetWaferSizeUri(area, waferSize, destination: true);
|
// string waferSizeDestinationDirectory = GetWaferSizeUri(area, waferSize, destination: true);
|
||||||
Save(waferSizeDestinationDirectory, area, waferSize, text, nginxFileSystemSortableCollection[0], result);
|
Save(waferSizeDestinationDirectory, area, waferSize, text, nginxFileSystemSortableCollection[0], result);
|
||||||
}
|
}
|
||||||
}
|
if (result is null)
|
||||||
}
|
throw new NullReferenceException(nameof(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ public interface IWaferCounterRepository
|
|||||||
{
|
{
|
||||||
|
|
||||||
string? GetSlotMap(string line1, string line2);
|
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);
|
DataModels.WaferCounter? GetLastQuantityAndSlotMapWithText(string area, string waferSize, string text);
|
||||||
|
|
||||||
}
|
}
|
@ -64,22 +64,45 @@ public class UnitTestWaferCounterController
|
|||||||
Assert.AreEqual("0111011111111111111111000", result);
|
Assert.AreEqual("0111011111111111111111000", result);
|
||||||
result = waferCounterRepository?.GetSlotMap("T20", "P07FFFF8");
|
result = waferCounterRepository?.GetSlotMap("T20", "P07FFFF8");
|
||||||
Assert.AreEqual("0011111111111111111111000", result);
|
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);
|
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Ignore]
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void GetLastQuantityAndSlotMap()
|
public void GetLastQuantityAndSlotMap()
|
||||||
{
|
{
|
||||||
|
WaferCounter? result;
|
||||||
_Logger?.LogInformation("Starting Web Application");
|
_Logger?.LogInformation("Starting Web Application");
|
||||||
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
|
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
|
||||||
IWaferCounterRepository? waferCounterRepository = serviceProvider?.GetRequiredService<IWaferCounterRepository>();
|
IWaferCounterRepository? waferCounterRepository = serviceProvider?.GetRequiredService<IWaferCounterRepository>();
|
||||||
WaferCounter? result = waferCounterRepository?.GetLastQuantityAndSlotMap("EPP-East", "8INCH");
|
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");
|
||||||
Assert.IsNotNull(result);
|
Assert.IsNotNull(result);
|
||||||
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Ignore]
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task GetLastQuantityAndSlotMapApi()
|
public async Task GetLastQuantityAndSlotMapApi()
|
||||||
{
|
{
|
||||||
@ -93,6 +116,7 @@ public class UnitTestWaferCounterController
|
|||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Ignore]
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void GetLastQuantityAndSlotMapWithText()
|
public void GetLastQuantityAndSlotMapWithText()
|
||||||
{
|
{
|
||||||
@ -105,6 +129,7 @@ public class UnitTestWaferCounterController
|
|||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Ignore]
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task GetLastQuantityAndSlotMapWithTextApi()
|
public async Task GetLastQuantityAndSlotMapWithTextApi()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user