MET08DDUPSFS6420 - v2.43.4 - MethodBaseName

This commit is contained in:
2022-08-08 16:27:52 -07:00
parent b5244f1166
commit f8ca86e5a0
50 changed files with 1334 additions and 354 deletions

View File

@ -0,0 +1,34 @@
using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.OpenInsightMetrologyViewer;
public class BarcodeDevice : IBarcodeDevice
{
protected string _Name;
protected string _Path;
protected string _ProductId;
protected string _VendorId;
public string Name => _Name;
public string Path => _Path;
public string ProductId => _ProductId;
public string VendorId => _VendorId;
public BarcodeDevice()
{
_Name = string.Empty;
_Path = string.Empty;
_ProductId = string.Empty;
_VendorId = string.Empty;
}
[JsonConstructor]
public BarcodeDevice(string name, string path, string productId, string vendorId)
{
_Name = name;
_Path = path;
_ProductId = productId;
_VendorId = vendorId;
}
}

View File

@ -0,0 +1,38 @@
using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.OpenInsightMetrologyViewer;
public class BarcodeRecord : IBarcodeRecord
{
protected string _Barcode;
protected string _Date;
protected BarcodeDevice _Device;
protected string _Id;
protected string _ServerId;
public string Barcode => _Barcode;
public string Date => _Date;
public BarcodeDevice Device => _Device;
public string Id => _Id;
public string ServerId => _ServerId;
public BarcodeRecord()
{
_Barcode = string.Empty;
_Date = string.Empty;
_Device = new BarcodeDevice();
_Id = string.Empty;
_ServerId = string.Empty;
}
[JsonConstructor]
public BarcodeRecord(string barcode, string date, BarcodeDevice device, string id, string serverId)
{
_Barcode = barcode;
_Date = date;
_Device = device;
_Id = id;
_ServerId = serverId;
}
}

View File

@ -30,6 +30,9 @@ public class FileRead : Shared.FileRead, IFileRead
if (!_IsDuplicator)
throw new Exception(cellInstanceConnectionName);
_OpenInsightMetrologyViewerAPI = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.MetrologyViewerAPI");
string barcode = TestMe.GetBarcode("192.168.0.121");
if (string.IsNullOrEmpty(barcode))
{ }
}
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception)

View File

@ -0,0 +1,11 @@
namespace Adaptation.FileHandlers.OpenInsightMetrologyViewer;
public interface IBarcodeDevice
{
public string Name { get; }
public string Path { get; }
public string VendorId { get; }
public string ProductId { get; }
}

View File

@ -0,0 +1,12 @@
namespace Adaptation.FileHandlers.OpenInsightMetrologyViewer;
public interface IBarcodeRecord
{
public string Barcode { get; }
public string Date { get; }
public BarcodeDevice Device { get; }
public string Id { get; }
public string ServerId { get; }
}

View File

@ -0,0 +1,11 @@
namespace Adaptation.FileHandlers.OpenInsightMetrologyViewer;
internal class NginxFileSystem
{
public string Name { get; set; }
public string Type { get; set; }
public string MTime { get; set; }
public float Size { get; set; }
}

View File

@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net.Http;
using System.Text.Json;
namespace Adaptation.FileHandlers.OpenInsightMetrologyViewer;
public class TestMe
{
private static List<string> GetURLCollection(string barcodeServerIP)
{
List<string> results = new();
int weekOfYear;
string checkURL;
DateTime dateTime;
string weekDirectory;
string weekOfYearPadded;
string lastURL = string.Empty;
Calendar calendar = new CultureInfo("en-US").Calendar;
for (int i = 1; i < 3; i++)
{
if (i == 1)
dateTime = DateTime.Now;
else
dateTime = DateTime.Now.AddHours(-4);
weekOfYear = calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday) - 1;
weekOfYearPadded = weekOfYear.ToString("00");
weekDirectory = $"{dateTime:yyyy}_Week_{weekOfYearPadded}/{dateTime:yyyy-MM-dd}";
checkURL = string.Concat("http://", barcodeServerIP, '/', weekDirectory);
if (i == 1 || checkURL != lastURL)
{
results.Add(string.Concat(checkURL, "/A"));
results.Add(string.Concat(checkURL, "/B"));
}
lastURL = checkURL;
}
return results;
}
private static List<string> GetURLPossible(HttpClient httpClient, List<string> urlCollection, JsonSerializerOptions propertyNameCaseInsensitiveJsonSerializerOptions)
{
List<string> results = new();
string json;
NginxFileSystem[] nginxFileSystemCollection;
DateTime minimumDateTime = DateTime.Now.AddHours(-4);
string nginxFormat = "ddd, dd MMM yyyy HH:mm:ss zzz";
foreach (string url in urlCollection)
{
try
{
json = httpClient.GetStringAsync(url).Result;
nginxFileSystemCollection = JsonSerializer.Deserialize<NginxFileSystem[]>(json, propertyNameCaseInsensitiveJsonSerializerOptions);
foreach (NginxFileSystem nginxFileSystem in nginxFileSystemCollection)
{
if (!DateTime.TryParseExact(nginxFileSystem.MTime.Replace("GMT", "+00:00"), nginxFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTime))
continue;
if (dateTime < minimumDateTime)
continue;
results.Add(string.Concat(url, '/', nginxFileSystem.Name));
}
}
catch
{ }
}
return results;
}
private static List<(string, BarcodeRecord)> GetBarcodePossible(HttpClient httpClient, JsonSerializerOptions propertyNameCaseInsensitiveJsonSerializerOptions, List<string> possibleURLCollection)
{
List<(string, BarcodeRecord)> results = new();
string json;
BarcodeRecord barcodeRecord;
foreach (string possibleURL in possibleURLCollection)
{
try
{
json = httpClient.GetStringAsync(possibleURL).Result;
barcodeRecord = JsonSerializer.Deserialize<BarcodeRecord>(json, propertyNameCaseInsensitiveJsonSerializerOptions);
results.Add(new(possibleURL, barcodeRecord));
}
catch
{ }
}
return results;
}
public static string GetBarcode(string barcodeServerIP)
{
string result = string.Empty;
using HttpClient httpClient = new();
List<string> urlCollection = GetURLCollection(barcodeServerIP);
JsonSerializerOptions propertyNameCaseInsensitiveJsonSerializerOptions = new() { PropertyNameCaseInsensitive = true };
List<string> possibleURLCollection = GetURLPossible(httpClient, urlCollection, propertyNameCaseInsensitiveJsonSerializerOptions);
List<(string, BarcodeRecord)> possibleBarcodeCollection = GetBarcodePossible(httpClient, propertyNameCaseInsensitiveJsonSerializerOptions, possibleURLCollection);
foreach ((string url, BarcodeRecord barcodeRecord) in possibleBarcodeCollection)
{
if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(barcodeRecord.Barcode))
continue;
}
return result;
}
}

View File

@ -117,6 +117,7 @@ public class WSRequest
RDS = x.RDS;
Reactor = x.Reactor;
Recipe = x.Recipe;
Operator = x.Employee;
ScratchCountAvg = x.ScratchCountAvg;
ScratchCountMax = x.ScratchCountMax;
ScratchCountMin = x.ScratchCountMin;