Characterization Data with Static Site

This commit is contained in:
Mike Phares 2024-09-23 10:27:36 -07:00
parent 4c2bef71ec
commit 018382e218
11 changed files with 273 additions and 130 deletions

View File

@ -2,6 +2,7 @@ using OI.Metrology.Server.Models;
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models;
using OI.Metrology.Shared.Models.Stateless;
using System.Collections.ObjectModel;
using System.Data;
using System.Globalization;
using System.Text;
@ -44,15 +45,15 @@ public class ExportRepository : IExportRepository
List<NginxFileSystemSortable> results = new();
Uri uri;
string[] weeks = Get();
List<NginxFileSystemSortable> nginxFileSystemSortableCollection;
ReadOnlyCollection<NginxFileSystemSortable> collection;
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}");
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);
collection = _FileShareRepository.GetNginxFileSystemSortableCollection(httpClient, uri, endsWith);
results.AddRange(collection);
}
return results.OrderByDescending(l => l.DateTime).ToArray();
}

View File

@ -1,5 +1,7 @@
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models;
using OI.Metrology.Shared.Models.Stateless;
using System.Collections.ObjectModel;
using System.Text.Json;
using System.Web;
@ -78,7 +80,7 @@ public class FileShareRepository : IFileShareRepository
return result;
}
List<NginxFileSystemSortable> IFileShareRepository.GetNginxFileSystemSortableCollection(HttpClient httpClient, Uri uri, string? endsWith)
ReadOnlyCollection<NginxFileSystemSortable> IFileShareRepository.GetNginxFileSystemSortableCollection(HttpClient httpClient, Uri uri, string? endsWith)
{
List<NginxFileSystemSortable> results = new();
Task<HttpResponseMessage> httpResponseMessage = httpClient.GetAsync(uri);
@ -97,10 +99,13 @@ public class FileShareRepository : IFileShareRepository
results.Add(nginxFileSystemSortable);
}
}
return results;
return new(results);
}
List<CharacterizationInfo> IFileShareRepository.GetArchiveData(CharacterizationParameters archiveParameters) =>
ReadOnlyCollection<CharacterizationInfo> IFileShareRepository.GetArchiveData(CharacterizationParameters archiveParameters) =>
throw new NotImplementedException();
ReadOnlyCollection<ToolTypeNameId> IFileShareRepository.GetEquipmentIds() =>
throw new NotImplementedException();
}

View File

@ -0,0 +1,28 @@
namespace OI.Metrology.Shared.DataModels;
public class WaferCounterArchive
{
public long ID { get; set; }
public DateTime InsertDate { get; set; }
public Guid AttachmentID { get; set; }
public string? Title { get; set; }
public DateTime Date { get; set; }
public long ToolTypeID { get; set; }
public string? ToolTypeName { get; set; }
public string? MesEntity { get; set; }
public string? Employee { get; set; }
public string? Layer { get; set; }
public string? PSN { get; set; }
public string? RDS { get; set; }
public string? Reactor { get; set; }
public string? Recipe { get; set; }
public string? Zone { get; set; }
public string? SlotMap { get; set; }
public string? Text { get; set; }
public int? Total { get; set; }
}

View File

@ -1,3 +1,6 @@
using OI.Metrology.Shared.DataModels;
using System.Collections.ObjectModel;
namespace OI.Metrology.Shared.Models.Stateless;
public interface IFileShareRepository
@ -7,9 +10,10 @@ public interface IFileShareRepository
void MoveFile(string from, string to);
Uri Append(Uri uri, params string[] paths);
void FileWrite(string path, string contents);
ReadOnlyCollection<ToolTypeNameId> GetEquipmentIds();
HttpResponseMessage ReadFile(HttpClient httpClient, Uri uri);
void CopyFile(HttpClient httpClient, string from, string to);
void MoveFile(HttpClient httpClient, string from, string to);
List<CharacterizationInfo> GetArchiveData(CharacterizationParameters characterizationParameters);
List<NginxFileSystemSortable> GetNginxFileSystemSortableCollection(HttpClient httpClient, Uri uri, string? endsWith);
ReadOnlyCollection<CharacterizationInfo> GetArchiveData(CharacterizationParameters characterizationParameters);
ReadOnlyCollection<NginxFileSystemSortable> GetNginxFileSystemSortableCollection(HttpClient httpClient, Uri uri, string? endsWith);
}

View File

@ -6,25 +6,25 @@
<meta name="viewport" content="width=device-width" />
<title>File(s)</title>
<script src="/js/modernizr-3.6.0-custom.js?no-cache=2024-06-18-10-54" type="text/javascript"></script>
<script src="/js/modernizr-3.6.0-custom.js?no-cache=2024-09-23-09-09" type="text/javascript"></script>
<link href="/styles/bootstrap.min.css?no-cache=2024-06-18-10-54" rel="stylesheet" />
<link href="/igniteui/css/themes/bootstrap3/default/infragistics.theme.css?no-cache=2024-06-18-10-54"
<link href="/styles/bootstrap.min.css?no-cache=2024-09-23-09-09" rel="stylesheet" />
<link href="/igniteui/css/themes/bootstrap3/default/infragistics.theme.css?no-cache=2024-09-23-09-09"
rel="stylesheet" />
<link href="/igniteui/css/structure/infragistics.css?no-cache=2024-06-18-10-54" rel="stylesheet" />
<link href="/styles/site-server.css?no-cache=2024-06-18-10-54" rel="stylesheet" />
<link href="/styles/index.css?no-cache=2024-06-18-10-54" rel="stylesheet" />
<link href="/igniteui/css/structure/infragistics.css?no-cache=2024-09-23-09-09" rel="stylesheet" />
<link href="/styles/site-server.css?no-cache=2024-09-23-09-09" rel="stylesheet" />
<link href="/styles/index.css?no-cache=2024-09-23-09-09" rel="stylesheet" />
<script src="/js/jquery-3.6.0.min.js?no-cache=2024-06-18-10-54" type="text/javascript"></script>
<script src="/js/jquery-ui.min.js?no-cache=2024-06-18-10-54" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.core.js?no-cache=2024-06-18-10-54" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.lob.js?no-cache=2024-06-18-10-54" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.dv.js?no-cache=2024-06-18-10-54" type="text/javascript"></script>
<script src="/js/jquery-3.6.0.min.js?no-cache=2024-09-23-09-09" type="text/javascript"></script>
<script src="/js/jquery-ui.min.js?no-cache=2024-09-23-09-09" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.core.js?no-cache=2024-09-23-09-09" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.lob.js?no-cache=2024-09-23-09-09" type="text/javascript"></script>
<script src="/igniteui/js/infragistics.dv.js?no-cache=2024-09-23-09-09" type="text/javascript"></script>
<script src="/js/chart-4.3.0.min.js" type="module"></script>
<script src="/js/common.js?no-cache=2024-06-18-10-54" type="text/javascript"></script>
<script src="/js/site-server.js?no-cache=2024-06-18-10-54" type="text/javascript"></script>
<script src="/js/common.js?no-cache=2024-09-23-09-09" type="text/javascript"></script>
<script src="/js/site-server.js?no-cache=2024-09-23-09-09" type="text/javascript"></script>
</head>
<body>
@ -99,52 +99,6 @@
<table id="HeaderGrid"></table>
</div>
<div class="row" style="margin-top: 10px; margin-bottom: 20px;">
<div class="col-xs-1">
<input type="button" class="btn" id="GetDataButton" value="Get Data" disabled />
</div>
<div class="col-xs-1">
<input type="button" class="btn" id="ReviewButton" value="Review" disabled />
</div>
<div class="col-xs-1">
<input type="button" class="btn" id="RecipeParametersButton" value="Parameters" disabled />
</div>
<div class="col-xs-1">
<input type="button" class="btn" id="ViewButton" value="View" disabled />
</div>
<div class="col-xs-1">
<input type="button" class="btn" id="PinButton" value="Pin" disabled />
</div>
</div>
<div id="DetailsDiv" hidden>
<span id="HeaderId" hidden></span>
<span id="HeaderAttachmentId" hidden></span>
<div style="padding-bottom: 20px;" id="DetailsGridDiv">
<table id="DetailsGrid"></table>
</div>
<div id="ExportDiv" style="margin-top: 10px;" hidden>
<input type="button" value="Send to OpenInsight" id="OIExportButton" />
<span id="OIExportResult" style="margin-left: 10px; font-weight: bold; color: #366b02;"></span>
</div>
<p style="margin-top: 20px;">
<iframe id="DataAttachmentFrame" style="height:900px; border-width:thin; margin-right: 10px;"
hidden></iframe>
<iframe id="HeaderAttachmentFrame" style="height:900px; border-width:thin;" hidden></iframe>
&nbsp;
<div id="DataAttachmentDiv" hidden>
<canvas id="DataAttachmentCanvas"></canvas>
</div>
<div id="HeaderAttachmentDiv" hidden>
<canvas id="HeaderAttachmentCanvas"></canvas>
</div>
</p>
</div>
<hr />
<footer>
<p>&copy; 2024 - Infineon Technologies</p>
@ -153,9 +107,9 @@
<div id="MessageModal"></div>
<script src="/js/bootstrap.min.js?no-cache=2024-06-18-10-54" type="text/javascript"></script>
<script src="/js/respond.min.js?no-cache=2024-06-18-10-54" type="text/javascript"></script>
<script src="/js/files.js?no-cache=2024-06-18-10-54" type="text/javascript"></script>
<script src="/js/bootstrap.min.js?no-cache=2024-09-23-09-09" type="text/javascript"></script>
<script src="/js/respond.min.js?no-cache=2024-09-23-09-09" type="text/javascript"></script>
<script src="/js/files.js?no-cache=2024-09-23-09-09" type="text/javascript"></script>
</body>
</html>

View File

@ -1,10 +1,5 @@
$(document).ready(function () {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const initialHeaderId = urlParams.get('headerid');
const initialToolTypeID = urlParams.get('tooltypeid');
const initialHeaderAttachmentId = urlParams.get('headerattachmentid');
initFiles("https://oi-metrology-viewer-prod.mes.infineon.com:4433/api", "https://oi-metrology-viewer-prod.mes.infineon.com", initialToolTypeID, initialHeaderId, initialHeaderAttachmentId);
initFiles("https://oi-metrology-viewer-prod.mes.infineon.com:4437/api", "https://oi-metrology-viewer-prod.mes.infineon.com", "https://eaf-prod.mes.infineon.com:4439");
});

View File

@ -8,6 +8,7 @@ var _workMaterial = {};
var _initialHeaderId = null;
var _toolTypeMetaData = null;
var _initialHeaderAttachmentId = null;
var _EcMesaFileShareCharacterizationSi = null;
async function loadRunInfoAwaitingDisposition() {
var row = $("#grid").igGrid("selectedRow");
@ -169,6 +170,31 @@ function loadHeaderGridRunInfo() {
});
}
function loadHeaderGridFiles() {
var toolTypeName = $("#ToolType").igCombo("text");
$("#HeaderId").text("");
$("#HeaderAttachmentId").text("");
var gridCreated = $("#HeaderGrid").data("igGrid");
if (gridCreated)
$("#HeaderGrid").igGrid("destroy");
$.ajax({
type: "GET",
url: _EcMesaFileShareCharacterizationSi + "/Archive/" + toolTypeName + ".json",
success: function (r) {
if ((r.Results == null) || (r.Results.ToolType == null) || (r.Results.Metadata == null))
ShowErrorMessage("Invalid tool-type: " + toolTypeName);
else {
_toolType = r.Results.ToolType;
_toolTypeMetaData = r.Results.Metadata;
requestHeaderDataFiles();
}
},
error: function (e) {
DisplayWSMessage("error", "There was an error getting tool-type info by archive.", e);
}
});
}
function disableHeaderButtonsRunInfo() {
$("#GetDataButton").prop("disabled", true);
$("#ReviewButton").prop("disabled", true);
@ -667,7 +693,7 @@ function loadDetailsRunInfo() {
}
}
$.getJSON(detailsURL, function (data) {
var gridParms = {
var gridParams = {
autoGenerateColumns: false,
primaryKey: "ID",
features: [
@ -682,9 +708,9 @@ function loadDetailsRunInfo() {
dataBound: markAsReviewedRunInfo,
};
if ((_toolType != null) && (_toolType.DataGridAttributes != null)) {
jQuery.extend(gridParms, JSON.parse(_toolType.DataGridAttributes));
jQuery.extend(gridParams, JSON.parse(_toolType.DataGridAttributes));
}
$("#DetailsGrid").igGrid(gridParms);
$("#DetailsGrid").igGrid(gridParams);
if ($("#chkCopyOnGet").is(':checked')) {
copySelected(attachmentID, title, data);
}
@ -696,7 +722,7 @@ function requestHeaderDataRunInfo() {
var startTime = $("#StartTime").igTimePicker("value");
var endDate = $("#EndDate").igDatePicker("value");
var endTime = $("#EndTime").igTimePicker("value");
var parms = {
var params = {
datebegin: new Date(
startDate.getFullYear(), startDate.getMonth(), startDate.getDate(),
startTime.getHours(), startTime.getMinutes(), startTime.getSeconds()).toISOString(),
@ -707,7 +733,7 @@ function requestHeaderDataRunInfo() {
var headerId = 0;
if (_initialHeaderId > 0) {
headerId = _initialHeaderId;
parms.headerid = headerId;
params.headerid = headerId;
$("#HeaderId").text(headerId);
$("#HeaderAttachmentId").text(_initialHeaderAttachmentId);
_initialHeaderId = -1;
@ -716,7 +742,7 @@ function requestHeaderDataRunInfo() {
$("#PinButton").hide();
else
$("#PinButton").show();
var headerURL = _apiUrl + "/tooltypes/" + _toolType.ID + "/headers?" + $.param(parms);
var headerURL = _apiUrl + "/tooltypes/" + _toolType.ID + "/headers?" + $.param(params);
var gridColumns = [
{ key: "ID", dataType: "number", hidden: true },
{ key: "AttachmentID", dataType: "string", hidden: true },
@ -741,7 +767,7 @@ function requestHeaderDataRunInfo() {
gridColumns.push(col);
}
}
var gridParms = {
var gridParams = {
autoGenerateColumns: false,
primaryKey: "ID",
height: "100%",
@ -758,14 +784,84 @@ function requestHeaderDataRunInfo() {
responseDataKey: "Results",
};
if ((_toolType != null) && (_toolType.HeaderGridAttributes != null)) {
jQuery.extend(gridParms, JSON.parse(_toolType.HeaderGridAttributes));
jQuery.extend(gridParams, JSON.parse(_toolType.HeaderGridAttributes));
}
$("#HeaderGrid").igGrid(gridParms);
$("#HeaderGrid").igGrid(gridParams);
if (headerId > 0) {
loadDetailsRunInfo();
}
}
function requestHeaderDataFiles() {
var toolTypeName = $("#ToolType").igCombo("text");
var startDate = $("#StartDate").igDatePicker("value");
var startTime = $("#StartTime").igTimePicker("value");
var endDate = $("#EndDate").igDatePicker("value");
var endTime = $("#EndTime").igTimePicker("value");
var params = {
area: null,
'end-time': new Date(
endDate.getFullYear(), endDate.getMonth(), endDate.getDate(),
endTime.getHours(), endTime.getMinutes(), endTime.getSeconds()).toISOString(),
'equipment-id': toolTypeName,
'search-pattern': null,
'start-time': new Date(
startDate.getFullYear(), startDate.getMonth(), startDate.getDate(),
startTime.getHours(), startTime.getMinutes(), startTime.getSeconds()).toISOString(),
'wafer-size': null,
}
var headerURL = _apiUrl + "/v1/file-share/archive-data/?" + $.param(params);
var gridColumns = [
{ key: "ID", dataType: "number", hidden: true },
{ key: "AttachmentID", dataType: "string", hidden: true },
{ key: "Title", dataType: "string", hidden: true },
];
for (var i = 0; i < _toolTypeMetaData.length; i++) {
var f = _toolTypeMetaData[i];
if ((f.Header == true) && (f.GridDisplayOrder > 0)) {
var col = {
key: f.ColumnName,
headerText: f.DisplayTitle,
width: "150px",
};
if (f.GridAttributes != null)
jQuery.extend(col, JSON.parse(f.GridAttributes));
if (col.formatter != null) {
if (col.formatter == "boolToYesNo")
col.formatter = boolToYesNo;
else
col.formatter = null;
}
gridColumns.push(col);
}
}
$.getJSON(headerURL, function (data) {
var collection = [];
for (var i = 0; i < data.length; i++) {
collection.push(JSON.parse(data[i].lines.join(' ')));
}
var gridParams = {
autoGenerateColumns: false,
height: "100%",
width: "100%",
features: [
{ name: "Paging", type: "local", recordCountKey: "TotalRows", pageSize: 100, pageSizeList: [50, 100, 250, 500], pageSizeUrlKey: "pageSize", "pageIndexUrlKey": "page" },
{ name: "Selection", mode: "row", rowSelectionChanged: headerSelectionChangedRunInfo },
{ name: "Filtering", type: "local" },
{ name: 'Resizing' },
{ name: "Sorting", type: "local" }
],
columns: gridColumns,
dataSource: collection,
responseDataKey: "Results",
};
if ((_toolType != null) && (_toolType.HeaderGridAttributes != null)) {
jQuery.extend(gridParams, JSON.parse(_toolType.HeaderGridAttributes));
}
$("#HeaderGrid").igGrid(gridParams);
});
}
function reviewButtonRunInfo() {
var toolTypeId = $("#ToolTypeID").text();
var headerId = parseInt($("#HeaderId").text());
@ -1274,43 +1370,27 @@ function restartButton() {
clearWorkMaterial();
};
function initFiles(apiUrl, staticUrl, initialToolTypeID, initialHeaderId, initialHeaderAttachmentId) {
function initFiles(apiUrl, staticUrl, ecMesaFileShareCharacterizationSi) {
_apiUrl = apiUrl;
_initialHeaderId = ""
_StaticUrl = staticUrl;
_initialHeaderId = initialHeaderId === null ? "" : initialHeaderId;
_initialHeaderAttachmentId = initialHeaderAttachmentId === null ? "" : initialHeaderAttachmentId;
$.getJSON(_apiUrl + '/tooltypes', function (data) {
for (var i = 0; i < data.Results.length; i++) {
if (data.Results[i].ToolTypeName === "CDE") {
_CdeId = data.Results[i].ID;
}
else if (data.Results[i].ToolTypeName === "BioRad") {
_BioRadId = data.Results[i].ID;
}
}
_initialHeaderAttachmentId = "";
_EcMesaFileShareCharacterizationSi = ecMesaFileShareCharacterizationSi;
$.getJSON(_apiUrl + '/v1/file-share/equipment-ids', function (data) {
$("#ToolType").igCombo({
dataSource: data,
responseDataKey: "Results",
textKey: "ToolTypeName",
valueKey: "ID",
textKey: "toolTypeName",
valueKey: "id",
mode: "dropdown",
width: 150,
itemsRendered: function (evt, ui) {
loadHeaderGridRunInfo();
itemsRendered: function () {
loadHeaderGridFiles();
},
selectionChanged: loadHeaderGridRunInfo,
initialSelectedItems: [{ value: initialToolTypeID === null ? 1 : initialToolTypeID }]
selectionChanged: loadHeaderGridFiles,
});
});
setInitialDateTimesRunInfo(6 * 60 * 60 * 1000);
$("#HeaderGrid").on("dblclick", "tr", loadDetailsRunInfo);
$("#LoadHeadersButton").click(loadHeaderGridRunInfo);
$("#GetDataButton").click(loadDetailsRunInfo);
$("#ReviewButton").click(reviewButtonRunInfo);
$("#RecipeParametersButton").click(recipeParametersButtonRunInfo);
$("#ViewButton").click(viewButtonRunInfo);
$("#PinButton").click(pinButtonRunInfo);
$("#OIExportButton").click(oiExportButtonRunInfo);
$("#LoadHeadersButton").click(loadHeaderGridFiles);
setInterval(function () {
if ($("#chkAutoRefresh").is(':checked')) {
setInitialDateTimesRunInfo(null);

View File

@ -1,8 +1,10 @@
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models;
using OI.Metrology.Shared.Models.Stateless;
using System.Collections.ObjectModel;
namespace OI.Metrology.Tests;
@ -88,7 +90,7 @@ public class UnitTestFileShareController
public void GetArchiveData()
{
_Logger?.LogInformation("Starting Web Application");
List<CharacterizationInfo>? result;
ReadOnlyCollection<CharacterizationInfo>? result;
CharacterizationParameters characterizationParameters;
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IFileShareRepository? fileShareRepository = serviceProvider?.GetRequiredService<IFileShareRepository>();
@ -117,4 +119,28 @@ public class UnitTestFileShareController
NonThrowTryCatch();
}
[TestMethod]
public void EquipmentIds()
{
_Logger?.LogInformation("Starting Web Application");
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IFileShareRepository? fileShareRepository = serviceProvider?.GetRequiredService<IFileShareRepository>();
ReadOnlyCollection<ToolTypeNameId>? result = fileShareRepository?.GetEquipmentIds();
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch();
}
[TestMethod]
public async Task EquipmentIdsApi()
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? response = await httpClient.GetStringAsync($"api/v1/file-share/equipment-ids");
Assert.IsNotNull(response);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch();
}
}

View File

@ -1,6 +1,8 @@
using Microsoft.AspNetCore.Mvc;
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models;
using OI.Metrology.Shared.Models.Stateless;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Text.Json;
using System.Web;
@ -65,11 +67,18 @@ public class FileShareController : Controller, IFileShareController<IResult>
[HttpGet("archive-data")]
public IActionResult ArchiveData()
{
List<CharacterizationInfo> results;
ReadOnlyCollection<CharacterizationInfo> results;
CharacterizationParameters? characterizationParameters = GetCharacterizationParameters(Request.QueryString);
ArgumentNullException.ThrowIfNull(characterizationParameters);
results = _FileShareRepository.GetArchiveData(characterizationParameters);
return Json(results);
}
[HttpGet("equipment-ids")]
public IActionResult EquipmentIds()
{
ReadOnlyCollection<ToolTypeNameId> results = _FileShareRepository.GetEquipmentIds();
return Json(results);
}
}

View File

@ -1,3 +1,4 @@
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models;
using OI.Metrology.Shared.Models.Stateless;
using OI.Metrology.Wafer.Counter.Models;
@ -82,7 +83,7 @@ public class FileShareRepository : IFileShareRepository
return result;
}
List<NginxFileSystemSortable> IFileShareRepository.GetNginxFileSystemSortableCollection(HttpClient httpClient, Uri uri, string? endsWith)
ReadOnlyCollection<NginxFileSystemSortable> IFileShareRepository.GetNginxFileSystemSortableCollection(HttpClient httpClient, Uri uri, string? endsWith)
{
List<NginxFileSystemSortable> results = new();
Task<HttpResponseMessage> httpResponseMessage = httpClient.GetAsync(uri);
@ -101,12 +102,12 @@ public class FileShareRepository : IFileShareRepository
results.Add(nginxFileSystemSortable);
}
}
return results;
return new(results);
}
private static ReadOnlyCollection<string> GetValidDirectories(string equipmentDirectory, DateTime startDateTime, DateTime endDateTime)
{
List<string> results = [equipmentDirectory];
List<string> results = [];
DateTime dateTime;
string weekOfYear;
Calendar calendar = new CultureInfo("en-US").Calendar;
@ -121,27 +122,37 @@ public class FileShareRepository : IFileShareRepository
return new(results);
}
private static ReadOnlyCollection<FileInfo> GetCollection(CharacterizationParameters characterizationParameters, string searchPattern, DateTime startDateTime, DateTime endDateTime, ReadOnlyCollection<string> validDirectories)
private static ReadOnlyCollection<string> GetFiles(CharacterizationParameters characterizationParameters, string equipmentDirectory, string searchPattern, DateTime startDateTime, DateTime endDateTime, ReadOnlyCollection<string> validDirectories)
{
FileInfo[] results;
List<string> results = [];
string[] directories;
List<FileInfo> collection = [];
string startDateTimeTicks = startDateTime.Ticks.ToString();
string delta = (endDateTime.Ticks - startDateTime.Ticks).ToString();
string ticksSearchPattern = $"{startDateTime.Ticks.ToString()[..(startDateTimeTicks.Length - delta.Length + 1)]}*";
bool check = characterizationParameters.SearchPattern is null || searchPattern == characterizationParameters.SearchPattern;
if (check)
results.AddRange(Directory.GetFiles(equipmentDirectory, searchPattern, SearchOption.AllDirectories));
foreach (string validDirectory in validDirectories)
{
if (string.IsNullOrEmpty(validDirectory) || !Directory.Exists(validDirectory))
continue;
if (characterizationParameters.SearchPattern is null || searchPattern == characterizationParameters.SearchPattern)
collection.AddRange(Directory.GetFiles(validDirectory, searchPattern, SearchOption.AllDirectories).Select(l => new FileInfo(l)));
if (check)
results.AddRange(Directory.GetFiles(validDirectory, searchPattern, SearchOption.AllDirectories));
else
{
directories = Directory.GetDirectories(validDirectory, ticksSearchPattern, SearchOption.AllDirectories);
foreach (string directory in directories)
collection.AddRange(Directory.GetFiles(directory, searchPattern, SearchOption.TopDirectoryOnly).Select(l => new FileInfo(l)));
results.AddRange(Directory.GetFiles(directory, searchPattern, SearchOption.TopDirectoryOnly));
}
}
return new(results);
}
private static ReadOnlyCollection<FileInfo> GetCollection(CharacterizationParameters characterizationParameters, string equipmentDirectory, string searchPattern, DateTime startDateTime, DateTime endDateTime, ReadOnlyCollection<string> validDirectories)
{
FileInfo[] results;
ReadOnlyCollection<string> files = GetFiles(characterizationParameters, equipmentDirectory, searchPattern, startDateTime, endDateTime, validDirectories);
FileInfo[] collection = files.Select(l => new FileInfo(l)).ToArray();
results = (from l in collection where l.LastWriteTime >= startDateTime && l.LastWriteTime <= endDateTime orderby l.LastWriteTime descending select l).ToArray();
return new(results);
}
@ -193,7 +204,7 @@ public class FileShareRepository : IFileShareRepository
DateTime endDateTime = characterizationParameters.EndTime is null ? DateTime.Now : DateTime.Parse(characterizationParameters.EndTime).ToLocalTime();
DateTime startDateTime = characterizationParameters.StartTime is null ? DateTime.Now.AddHours(-6) : DateTime.Parse(characterizationParameters.StartTime).ToLocalTime();
ReadOnlyCollection<string> validDirectories = GetValidDirectories(equipmentDirectory, startDateTime, endDateTime);
ReadOnlyCollection<FileInfo> collection = GetCollection(characterizationParameters, searchPattern, startDateTime, endDateTime, validDirectories);
ReadOnlyCollection<FileInfo> collection = GetCollection(characterizationParameters, equipmentDirectory, searchPattern, startDateTime, endDateTime, validDirectories);
foreach (FileInfo fileInfo in collection)
{
if (string.IsNullOrEmpty(fileInfo.DirectoryName))
@ -218,7 +229,7 @@ public class FileShareRepository : IFileShareRepository
return new(results);
}
List<CharacterizationInfo> IFileShareRepository.GetArchiveData(CharacterizationParameters characterizationParameters)
ReadOnlyCollection<CharacterizationInfo> IFileShareRepository.GetArchiveData(CharacterizationParameters characterizationParameters)
{
List<CharacterizationInfo> results = [];
string searchPattern;
@ -240,4 +251,23 @@ public class FileShareRepository : IFileShareRepository
return new(results);
}
ReadOnlyCollection<ToolTypeNameId> IFileShareRepository.GetEquipmentIds()
{
List<ToolTypeNameId> results = [];
string directoryName;
ToolTypeNameId toolTypeNameId;
string archiveDirectory = Path.Combine(_AppSettings.EcCharacterizationSi, "Archive");
string[] directories = Directory.GetDirectories(archiveDirectory, "*", SearchOption.TopDirectoryOnly);
string[] fileNames = Directory.GetFiles(archiveDirectory, "*.json", SearchOption.TopDirectoryOnly).Select(l => Path.GetFileNameWithoutExtension(l)).ToArray();
for (int i = 0; i < directories.Length; i++)
{
directoryName = Path.GetFileName(directories[i]);
if (!fileNames.Contains(directoryName))
continue;
toolTypeNameId = new() { ID = i, ToolTypeName = directoryName };
results.Add(toolTypeNameId);
}
return new(results);
}
}

View File

@ -2,6 +2,7 @@ using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models;
using OI.Metrology.Shared.Models.Stateless;
using OI.Metrology.Wafer.Counter.Models;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Text.Json;
using System.Text.RegularExpressions;
@ -32,17 +33,25 @@ public class WaferCounterRepository : IWaferCounterRepository
_RepositoryName = nameof(WaferCounterRepository)[..^10];
}
private void MoveFile(string area, string waferSize, string windowsFileSystemSafeText, string waferSizeDirectory, NginxFileSystemSortable nginxFileSystemSortable)
private void MoveFile(string area, string waferSize, WaferCounter? waferCounter, string windowsFileSystemSafeText, string waferSizeDirectory, NginxFileSystemSortable nginxFileSystemSortable)
{
string equipmentId = $"{area}-{waferSize}";
WaferCounterArchive waferCounterArchive = new()
{
Date = nginxFileSystemSortable.DateTime,
MesEntity = equipmentId,
RDS = windowsFileSystemSafeText,
SlotMap = waferCounter?.SlotMap,
Text = waferCounter?.Text,
Total = waferCounter?.Total,
};
Calendar calendar = new CultureInfo("en-US").Calendar;
string from = Path.Combine(waferSizeDirectory, nginxFileSystemSortable.Name);
string archive = Path.Combine(_AppSettings.EcCharacterizationSi, "Archive", equipmentId);
HeaderCommon headerCommon = new() { RDS = windowsFileSystemSafeText, MesEntity = equipmentId };
string weekOfYear = $"{nginxFileSystemSortable.DateTime:yyyy}_Week_{calendar.GetWeekOfYear(nginxFileSystemSortable.DateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday):00}";
string directory = Path.Combine(archive, weekOfYear, nginxFileSystemSortable.DateTime.ToString("yyyy-MM-dd"), windowsFileSystemSafeText);
string file = Path.Combine(directory, nginxFileSystemSortable.DateTime.Ticks.ToString(), $"{nginxFileSystemSortable.Name}.json");
string json = JsonSerializer.Serialize(headerCommon, new JsonSerializerOptions() { WriteIndented = true });
string json = JsonSerializer.Serialize(waferCounterArchive, new JsonSerializerOptions() { WriteIndented = true });
_FileShareRepository.FileWrite(file, json);
string to = Path.Combine(directory, nginxFileSystemSortable.Name);
_FileShareRepository.MoveFile(from, to);
@ -145,10 +154,12 @@ public class WaferCounterRepository : IWaferCounterRepository
{
List<NginxFileSystemSortable> results = new();
DateTime dateTime = DateTime.Now;
ReadOnlyCollection<NginxFileSystemSortable> collection;
long ticks = dateTime.AddSeconds(_AppSettings.WaferCounterTwoFileSecondsWait).Ticks;
for (int i = 0; i < int.MaxValue; i++)
{
results = _FileShareRepository.GetNginxFileSystemSortableCollection(httpClient, waferSizeUri, ".wc");
collection = _FileShareRepository.GetNginxFileSystemSortableCollection(httpClient, waferSizeUri, ".wc");
results.AddRange(collection);
if (results.Count > 0 || DateTime.Now.Ticks > ticks)
break;
Thread.Sleep(250);
@ -197,7 +208,7 @@ public class WaferCounterRepository : IWaferCounterRepository
string windowsFileSystemSafeText = _Regex.Replace(text, ".");
result = GetLastQuantityAndSlotMap(waferSize, httpClient, nginxFileSystemSortableCollection[0]);
for (int i = 0; i < nginxFileSystemSortableCollection.Count; i++)
MoveFile(area, waferSize, windowsFileSystemSafeText, waferSizeDirectory, nginxFileSystemSortableCollection[i]);
MoveFile(area, waferSize, result, windowsFileSystemSafeText, waferSizeDirectory, nginxFileSystemSortableCollection[i]);
}
return result;
}