Infineon.EAF.Runtime 2.49.0

net6.0 to net7.0
Removed hasRDS that was added for P2-LOW-RR
This commit is contained in:
2023-04-18 13:48:58 -07:00
parent 3c30da0bb1
commit 025ec077f5
19 changed files with 340 additions and 108 deletions

View File

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
@ -61,7 +62,7 @@ public class Job
(int? workOrderNumber, int? _, int? workOrderCassette, int? slotNumber, bool isWorkOrder) = GetWorkOrder(input);
if (isWorkOrder || reactorNumber.HasValue)
(layer, psn, rdsNumber, zone) = (string.Empty, string.Empty, null, string.Empty);
else if (!string.IsNullOrEmpty(input.MID) && input.MID.Length is not 2 and not 3)
else if (!string.IsNullOrEmpty(input.MID) && input.MID.Length is not 2 and not 3 and not 5)
(layer, psn, rdsNumber, reactorNumber, zone) = Get(input);
else
(layer, psn, rdsNumber, reactorNumber, zone) = Get(metrologyFileShare, input);
@ -157,7 +158,7 @@ public class Job
reactor = defaultReactor;
else
reactor = segments[0];
if (segments.Length <= 1 || !int.TryParse(segments[1], out int rdsValue) || rdsValue < 99)
if (segments.Length <= 1 || !int.TryParse(segments[1].Replace("QP", string.Empty), out int rdsValue) || rdsValue < 99)
rds = defaultRDS;
else
rds = segments[1];
@ -222,7 +223,7 @@ public class Job
string defaultLayer = string.Empty;
string defaultReactor = string.Empty;
string[] segments = input.MID.Split(new char[] { '-' });
bool hasRDS = Regex.IsMatch(input.MID, "[-]?[0-9]{5,}[-]?");
bool hasRDS = Regex.IsMatch(input.MID, "[-]?([QP][0-9]{4,}|[0-9]{5,})[-]?");
string formattedText = Regex.Replace(input.MID, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
(reactor, rds) = GetReactorAndRDS(defaultReactor, defaultRDS, input.MID, formattedText, segments, hasRDS);
if (string.IsNullOrEmpty(rds))
@ -245,50 +246,66 @@ public class Job
return new(layer, psn, rdsNumber, reactorNumber, zone);
}
private static string[] GetDirectories(string metrologyFileShare)
{
DateTime dateTime = DateTime.Now;
DateTime before = dateTime.AddHours(-1);
Calendar calendar = new CultureInfo("en-US").Calendar;
string weekOfYear = $"{dateTime:yyyy}_Week_{calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday):00}";
string weekOfYearForBefore = $"{before:yyyy}_Week_{calendar.GetWeekOfYear(before, CalendarWeekRule.FirstDay, DayOfWeek.Sunday):00}";
return new string[]
{
Path.Combine(metrologyFileShare, weekOfYear, dateTime.ToString("yyyy-MM-dd_HH")),
Path.Combine(metrologyFileShare, weekOfYearForBefore, before.ToString("yyyy-MM-dd_HH"))
};
}
#nullable enable
private static (string, string, int?, int?, string) Get(string metrologyFileShare, Input input)
{
string[] files;
string[] lines;
string moveFile;
string lines;
int? reactor = null;
int? rdsNumber = null;
string psn = string.Empty;
List<string> files = new();
string zone = string.Empty;
string layer = string.Empty;
string usedDirectory = Path.Combine(metrologyFileShare, "Used");
WorkMaterialOut? workMaterialOut;
if (!Directory.Exists(metrologyFileShare))
throw new Exception($"Unable to access file-share <{metrologyFileShare}>");
if (!Directory.Exists(usedDirectory))
_ = Directory.CreateDirectory(usedDirectory);
if (string.IsNullOrEmpty(input.MID))
files = Array.Empty<string>();
else
files = Directory.GetFiles(metrologyFileShare, $"*-{input.MID}.rsv", SearchOption.TopDirectoryOnly);
if (!string.IsNullOrEmpty(input.MID))
{
string[] checkDirectories = GetDirectories(metrologyFileShare);
foreach (string checkDirectory in checkDirectories)
{
if (!Directory.Exists(checkDirectory))
_ = Directory.CreateDirectory(checkDirectory);
files.AddRange(Directory.GetFiles(checkDirectory, $"WMO-{input.MID}.json", SearchOption.TopDirectoryOnly));
}
}
foreach (string file in files.OrderByDescending(l => new FileInfo(l).LastWriteTime))
{
lines = File.ReadAllLines(file);
foreach (string line in lines)
{
if (string.IsNullOrEmpty(line))
continue;
if (!int.TryParse(line, out int rds) || IsInvalid(rds))
continue;
lines = File.ReadAllText(file);
workMaterialOut = JsonSerializer.Deserialize<WorkMaterialOut>(lines, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
if (workMaterialOut is null)
continue;
if (!string.IsNullOrEmpty(workMaterialOut.Layer))
layer = workMaterialOut.Layer;
if (!string.IsNullOrEmpty(workMaterialOut.PSN))
psn = workMaterialOut.PSN;
if (!string.IsNullOrEmpty(workMaterialOut.RunDataSheet) && int.TryParse(workMaterialOut.RunDataSheet, out int rds))
rdsNumber = rds;
break;
}
if (rdsNumber is not null)
{
moveFile = Path.Combine(usedDirectory, Path.GetFileName(file));
if (File.Exists(moveFile))
File.Delete(file);
else
File.Move(file, moveFile);
break;
}
reactor = workMaterialOut.Reactor;
if (!string.IsNullOrEmpty(workMaterialOut.Zone))
zone = workMaterialOut.Zone;
break;
}
return new(layer, psn, rdsNumber, reactor, zone);
}
#nullable disable
private static string GetRunJson(string lsl2SQLConnectionString, int? rds, int? workOrderNumber, int? workOrderCassette, int? slot, int? reactor)
{
StringBuilder result = new();