Match TFS Changeset 303331

This commit is contained in:
2022-02-01 16:17:10 -07:00
parent b8bc6a8443
commit 9c042d3871
118 changed files with 12361 additions and 13 deletions

View File

@ -0,0 +1,20 @@
namespace Adaptation.Helpers
{
public partial class ConfigData
{
public enum Level
{
IsXToIQS,
IsXToOpenInsight,
IsXToAPC,
IsXToSPaCe,
IsXToSPaCeVillach,
IsXToArchive,
IsArchive,
IsDummy
}
}
}

View File

@ -0,0 +1,711 @@
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
using Adaptation.Shared;
using Adaptation.Shared.Metrology;
using Infineon.Monitoring.MonA;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text.Json;
using System.Threading;
namespace Adaptation.Helpers
{
public partial class ConfigData : ConfigDataBase
{
internal class Reactor
{
public string Name { get; internal set; }
public string FilePrefix { get; internal set; }
}
internal const object NullData = null;
internal const int MinFileLength = 100;
public bool EC { get; private set; }
public string ApcPath { get; private set; }
public string EdaPath { get; private set; }
public string IqsFile { get; private set; }
public string IqsPath { get; private set; }
public string TracePath { get; private set; }
public Level? Duplicator { get; private set; }
public string IfxChannel { get; private set; }
public string IfxSubject { get; private set; }
public string IqsTempPath { get; private set; }
public string VillachPath { get; private set; }
public string LogisticPath { get; private set; }
public string ProgressPath { get; private set; }
public string IqsQueryFilter { get; private set; }
public string IfxSubjectPrefix { get; private set; }
public List<string> MappedParts { get; private set; }
public string OpenInsightSiViewer { get; internal set; }
public string ArchiveSourceDirectory { get; private set; }
public string ConnectionStringIrmnSpc { get; private set; }
public string ConnectionStringG4Wafers { get; private set; }
public string IfxConfigurationLocation { get; private set; }
public List<string> TransportSetupMessages { get; private set; }
public string IfxConfigurationLocationLocalCopy { get; private set; }
public static Dictionary<string, List<long>> DummyRuns { get; private set; }
private Timer _Timer;
private int _LastDummyRunIndex;
private readonly Calendar _Calendar;
private readonly string _ReportFullPath;
public ConfigData(ILogic logic, string cellName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, IList<ModelObjectParameterDefinition> modelObjectParameterDefinitions, string parameterizedModelObjectDefinitionType, bool isEAFHosted) :
base(cellName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, isEAFHosted)
{
_LastDummyRunIndex = -1;
TransportSetupMessages = new List<string>();
CultureInfo cultureInfo = new CultureInfo("en-US");
_Calendar = cultureInfo.Calendar;
string firstSourceFileFilter = fileConnectorConfiguration.SourceFileFilter.Split('|')[0];
IsSourceTimer = (fileConnectorConfiguration.SourceFileFilter == "*Timer.txt");
if (DummyRuns is null)
DummyRuns = new Dictionary<string, List<long>>();
bool isDuplicator = cellInstanceConnectionName.StartsWith(cellName);
if (!isDuplicator)
Duplicator = null;
else
{
CellNames.Add(cellName, cellName);
MesEntities.Add(cellName, cellName);
int level = (cellInstanceConnectionName.Length - cellInstanceConnectionName.Replace("-", string.Empty).Length);
Duplicator = (Level)level;
}
if (isDuplicator)
ProcessDataDescription = new Duplicator.Description();
else
ProcessDataDescription = new ProcessData.FileRead.Description();
if (!isDuplicator)
{
//Verify(fileConnectorConfiguration, cellInstanceConnectionName);
if (!EafHosted)
VerifyProcessDataDescription(logic);
else
WriteExportAliases(logic, cellName, cellInstanceConnectionName);
}
MappedParts = new List<string>();
System.Net.NetworkInformation.IPGlobalProperties ipGlobalProperties = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties();
EC = (ipGlobalProperties.DomainName.ToLower().Contains("ec.local"));
bool isMET08PRFUSB4000Villach = (equipmentElementName == string.Concat(EquipmentType.MET08PRFUSB4000, "_Villach"));
if (!modelObjectParameterDefinitions.Any())
{
CellNames.Add(cellName, "****"); MesEntities.Add(cellName, "****");
IfxChannel = string.Empty;
IfxSubjectPrefix = string.Empty;
IfxConfigurationLocation = string.Empty;
IfxConfigurationLocationLocalCopy = string.Empty;
IfxSubject = string.Empty;
ArchiveSourceDirectory = string.Empty;
ConnectionStringG4Wafers = string.Empty;
ConnectionStringIrmnSpc = string.Empty;
}
else
{
int index;
string key;
string variable = string.Empty;
Dictionary<string, string> iqsSection = new Dictionary<string, string>();
Dictionary<string, string> pathSection = new Dictionary<string, string>();
Dictionary<string, string> tibcoSection = new Dictionary<string, string>();
Dictionary<string, string> commonSection = new Dictionary<string, string>();
List<Tuple<string, string>> reactorTuples = new List<Tuple<string, string>>();
Dictionary<string, string> openInsightSection = new Dictionary<string, string>();
Dictionary<string, string> connectionStringsSection = new Dictionary<string, string>();
Dictionary<string, Dictionary<string, string>> reactorSection = new Dictionary<string, Dictionary<string, string>>();
foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in modelObjectParameterDefinitions)
{
if (!modelObjectParameterDefinition.Name.Contains('.'))
continue;
else if (modelObjectParameterDefinition.Name.StartsWith("Description.") && (modelObjectParameterDefinition.Name.EndsWith(".EventName") || modelObjectParameterDefinition.Name.EndsWith(".EquipmentType")))
continue;
index = modelObjectParameterDefinition.Name.IndexOf(".");
if (index <= -1)
continue;
key = modelObjectParameterDefinition.Name.Substring(0, index);
variable = modelObjectParameterDefinition.Name.Substring(index + 1);
if (key == "COMMON")
commonSection.Add(variable, modelObjectParameterDefinition.Value);
else if (key == "CONNECTION STRINGS")
connectionStringsSection.Add(variable, modelObjectParameterDefinition.Value);
else if (key == "IQS")
iqsSection.Add(variable, modelObjectParameterDefinition.Value);
else if (key == "PATH")
pathSection.Add(variable, modelObjectParameterDefinition.Value);
else if (key == "REACTOR")
reactorTuples.Add(new Tuple<string, string>(variable, modelObjectParameterDefinition.Value));
else if (key == "TIBCO")
tibcoSection.Add(variable, modelObjectParameterDefinition.Value);
else if (key == "OpenInsight")
openInsightSection.Add(variable, modelObjectParameterDefinition.Value);
else
throw new Exception();
}
foreach (Tuple<string, string> tuple in reactorTuples)
{
if (!tuple.Item1.Contains('.'))
continue;
index = tuple.Item1.IndexOf(".");
if (index <= -1)
continue;
key = tuple.Item1.Substring(0, index);
variable = tuple.Item1.Substring(index + 1);
if (!reactorSection.ContainsKey(key))
reactorSection.Add(key, new Dictionary<string, string>() { { "NAME", key } });
reactorSection[key].Add(variable, tuple.Item2);
}
if (!iqsSection.Any())
throw new Exception("IQS section is missing from configuration");
else
{
key = "PATH";
if (iqsSection.ContainsKey(key))
IqsPath = iqsSection[key];
else
throw new Exception(string.Concat("Missing IQS Configuration entry for ", key));
if (string.IsNullOrEmpty(IqsPath))
throw new Exception(string.Format("IQS key {0} is empty", key));
key = "FILE";
if (iqsSection.ContainsKey(key))
IqsFile = iqsSection[key];
else
throw new Exception(string.Concat("Missing IQS Configuration entry for ", key));
if (eventName.HasValue && eventName.Value == EventName.FileRead && string.IsNullOrEmpty(IqsFile))
throw new Exception(string.Format("IQS key {0} is empty", key));
key = "QUERY";
if (iqsSection.ContainsKey(key))
IqsQueryFilter = iqsSection[key];
else
throw new Exception(string.Concat("Missing IQS Configuration entry for ", key));
if (eventName.HasValue && eventName.Value == EventName.FileRead && string.IsNullOrEmpty(IqsQueryFilter))
throw new Exception(string.Format("IQS key {0} is empty", key));
}
if (!pathSection.Any())
throw new Exception("Path section is missing from configuration");
else
{
key = "TRACE";
if (pathSection.ContainsKey(key) && pathSection[key].StartsWith(@"\\"))
TracePath = pathSection[key];
if (!string.IsNullOrEmpty(TracePath) && !Directory.Exists(TracePath))
Directory.CreateDirectory(TracePath);
key = "LOGISTIC";
if (pathSection.ContainsKey(key) && pathSection[key].StartsWith(@"\\"))
LogisticPath = pathSection[key];
if (!string.IsNullOrEmpty(LogisticPath) && !Directory.Exists(LogisticPath))
Directory.CreateDirectory(LogisticPath);
key = "VILLACH";
if (pathSection.ContainsKey(key) && pathSection[key].StartsWith(@"\\"))
VillachPath = pathSection[key];
if (!string.IsNullOrEmpty(VillachPath) && !Directory.Exists(VillachPath))
Directory.CreateDirectory(VillachPath);
key = "IQS";
if (pathSection.ContainsKey(key) && pathSection[key].StartsWith(@"\\"))
IqsTempPath = pathSection[key];
if (!string.IsNullOrEmpty(IqsTempPath) && !Directory.Exists(IqsTempPath))
Directory.CreateDirectory(IqsTempPath);
key = "Progress";
if (pathSection.ContainsKey(key) && pathSection[key].StartsWith(@"\\"))
ProgressPath = pathSection[key];
if (!string.IsNullOrEmpty(ProgressPath) && Directory.Exists(Path.GetPathRoot(ProgressPath)) && !Directory.Exists(ProgressPath))
Directory.CreateDirectory(ProgressPath);
key = "EDA";
if (pathSection.ContainsKey(key) && pathSection[key].StartsWith(@"\\"))
EdaPath = pathSection[key];
if (!string.IsNullOrEmpty(EdaPath) && !Directory.Exists(EdaPath))
Directory.CreateDirectory(EdaPath);
key = "APC";
if (pathSection.ContainsKey(key) && pathSection[key].StartsWith(@"\\"))
ApcPath = pathSection[key];
if (!string.IsNullOrEmpty(ApcPath) && !Directory.Exists(ApcPath))
Directory.CreateDirectory(ApcPath);
}
if (!commonSection.Any())
throw new Exception("Common section is missing from configuration");
else
{
if (isMET08PRFUSB4000Villach)
{
key = "MAPPED_PARTS";
if (!commonSection.ContainsKey(key))
throw new Exception("Mapped Parts KEY is missing from Equipment Type Configuration");
else
{
string mappedParts = commonSection[key];
if (mappedParts.Contains(','))
MappedParts = mappedParts.Split(',').ToList();
else
MappedParts = new string[] { mappedParts }.ToList();
}
if (!MappedParts.Any())
throw new Exception(string.Format("Common section key {0} is empty", key));
key = "ARCHIVE_SOURCE_DIRECTORY";
if (commonSection.ContainsKey(key))
ArchiveSourceDirectory = commonSection[key];
}
key = "CELL_NAMES";
if (!commonSection.ContainsKey(key) || !commonSection[key].Contains(';') || !commonSection[key].Contains(':'))
throw new Exception();
else
{
string[] segments;
string[] cellNames = commonSection[key].Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
foreach (string item in cellNames)
{
segments = item.Split(':');
CellNames.Add(segments[0].Trim(), segments[1].Trim());
}
}
if (!string.IsNullOrEmpty(cellName) && !CellNames.ContainsKey(cellName))
throw new Exception();
key = "MES_ENTITIES";
if (!commonSection.ContainsKey(key) || !commonSection[key].Contains(';') || !commonSection[key].Contains(':')) throw new Exception();
else
{
string[] segments;
string[] mesEntity = commonSection[key].Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
foreach (string item in mesEntity)
{
segments = item.Split(':');
MesEntities.Add(segments[0].Trim(), segments[1].Trim());
}
}
if (!string.IsNullOrEmpty(cellName) && !MesEntities.ContainsKey(cellName))
throw new Exception();
}
if (isMET08PRFUSB4000Villach)
{
if (!tibcoSection.Any())
throw new Exception("TIBCO section is missing from configuration");
else
{
key = "IFX_CHANNEL";
if (tibcoSection.ContainsKey(key))
IfxChannel = tibcoSection[key];
else
throw new Exception("IFX_CHANNEL is missing from Equipment Type Configuration");
if (string.IsNullOrEmpty(IfxChannel))
throw new Exception(string.Format("TIBCO section key {0} is empty", key));
key = "IFX_SUBJECT_PREFIX";
if (tibcoSection.ContainsKey(key))
IfxSubjectPrefix = tibcoSection[key];
else
throw new Exception("IFX_SUBJECT_PREFIX is missing from Equipment Type Configuration");
if (string.IsNullOrEmpty(IfxSubjectPrefix))
throw new Exception(string.Format("TIBCO section key {0} is empty", key));
key = "IFX_CONFIGURATION_LOCATION";
if (tibcoSection.ContainsKey(key))
IfxConfigurationLocation = tibcoSection[key];
else
throw new Exception("IFX_CONFIGURATION_LOCATION is missing from Equipment Type Configuration");
if (string.IsNullOrEmpty(IfxConfigurationLocation))
throw new Exception(string.Format("TIBCO section key {0} is empty", key));
key = "IFX_CONFIGURATION_LOCATION_LOCAL_COPY";
if (tibcoSection.ContainsKey(key))
IfxConfigurationLocationLocalCopy = tibcoSection[key];
else
throw new Exception("IFX_CONFIGURATION_LOCATION_LOCAL_COPY is missing from Equipment Type Configuration");
if (string.IsNullOrEmpty(IfxConfigurationLocationLocalCopy))
throw new Exception(string.Format("TIBCO section key {0} is empty", key));
key = "IFX_SUBJECT";
if (tibcoSection.ContainsKey(key))
IfxSubject = tibcoSection[key];
else
throw new Exception("IFX_SUBJECT KEY is missing from Equipment Type Configuration");
if (string.IsNullOrEmpty(IfxSubject))
throw new Exception(string.Format("TIBCO section key {0} is empty", key));
}
}
if (IsDatabaseExportToIPDSF || isMET08PRFUSB4000Villach)
{
if (!connectionStringsSection.Any())
throw new Exception("Connection Strings section is missing from configuration");
else
{
key = "G4WAFERS";
if (connectionStringsSection.ContainsKey(key))
ConnectionStringG4Wafers = connectionStringsSection[key];
else
throw new Exception("G4WAFERS is missing from Equipment Type Configuration");
if (string.IsNullOrEmpty(ConnectionStringG4Wafers))
throw new Exception(string.Format("Connection String key {0} is empty", key));
key = "IRMNSPC";
if (connectionStringsSection.ContainsKey(key))
ConnectionStringIrmnSpc = connectionStringsSection[key];
else
throw new Exception("IRMNSPC is missing from Equipment Type Configuration");
if (string.IsNullOrEmpty(ConnectionStringIrmnSpc))
throw new Exception(string.Format("IRMNSPC key {0} is empty", key));
//
Si.SQLDatabase.SetConnectionStringIrmnSpc(ConnectionStringIrmnSpc);
Si.SQLDatabase.SetConnectionStringG4Wafers(ConnectionStringG4Wafers);
Si.EpiControlPlan.CPGet.Parameters.SetConnectionStringIrmnSpc(ConnectionStringIrmnSpc);
Si.EpiControlPlan.CPGet.Parameters.SetConnectionStringG4Wafers(ConnectionStringG4Wafers);
Si.EpiControlPlan.CPGet.PartHistory.SetConnectionStringIrmnSpc(ConnectionStringIrmnSpc);
Si.EpiControlPlan.CPGet.PartHistory.SetConnectionStringG4Wafers(ConnectionStringG4Wafers);
Si.EpiControlPlan.CPGet.PartParameters.SetConnectionStringIrmnSpc(ConnectionStringIrmnSpc);
Si.EpiControlPlan.CPGet.PartParameters.SetConnectionStringG4Wafers(ConnectionStringG4Wafers);
}
}
if (!openInsightSection.Any())
throw new Exception("OpenInsight section is missing from configuration");
else
{
key = "SiViewer";
if (openInsightSection.ContainsKey(key))
OpenInsightSiViewer = openInsightSection[key];
if (string.IsNullOrEmpty(OpenInsightSiViewer))
throw new Exception(string.Format("OpenInsight key {0} is empty", key));
if (!OpenInsightSiViewer.Contains(":") || !OpenInsightSiViewer.Contains("."))
throw new Exception(string.Format("OpenInsight key {0} is invalid", key));
}
if (!MesEntities.Any())
throw new Exception();
if (isMET08PRFUSB4000Villach)
{
Si.Transport.Initialize(this);
if (!string.IsNullOrEmpty(fileConnectorConfiguration.SourceFileLocation))
TransportSetupMessages = Si.Transport.Setup(useSleep: true, setIfxTransport: true, setParameters: true);
else
TransportSetupMessages = Si.Transport.Setup(useSleep: false, setIfxTransport: false, setParameters: false);
}
if (IsSourceTimer || IsDatabaseExportToIPDSF || (Duplicator.HasValue && Duplicator.Value == Level.IsDummy))
{
if (!Directory.Exists(fileConnectorConfiguration.SourceFileLocation))
Directory.CreateDirectory(fileConnectorConfiguration.SourceFileLocation);
_ReportFullPath = string.Concat(fileConnectorConfiguration.SourceFileLocation, firstSourceFileFilter.Replace("*", @"\"));
if (Debugger.IsAttached || fileConnectorConfiguration.PreProcessingMode == FileConnectorConfiguration.PreProcessingModeEnum.Process)
Callback(null);
else
{
int milliSeconds;
milliSeconds = (int)((fileConnectorConfiguration.FileScanningIntervalInSeconds * 1000) / 2);
_Timer = new Timer(Callback, null, milliSeconds, Timeout.Infinite); milliSeconds += 2000;
}
}
}
}
public void CheckProcessDataDescription(Dictionary<Test, List<Duplicator.Description>> results, bool extra)
{
foreach (Test test in results.Keys)
{
if (test == Test)
{
if (!(ProcessDataDescription is ProcessData.FileRead.Description))
ProcessDataDescription = new ProcessData.FileRead.Description();
}
else
throw new Exception();
}
}
private void CallbackIsDummy(string traceDummyFile, List<Tuple<string, string, string, string, int>> tuples, bool fileConnectorConfigurationIncludeSubDirectories, bool includeSubDirectoriesExtra)
{
int fileCount;
string[] files;
string monARessource;
string checkDirectory;
string sourceArchiveFile;
string inProcessDirectory;
const string site = "sjc";
const string monInURL = "http://moninhttp.sjc.infineon.com/input/text";
MonIn monIn = MonIn.GetInstance(monInURL);
string stateName = string.Concat("Dummy_", _EventName);
foreach (Tuple<string, string, string, string, int> item in tuples)
{
monARessource = item.Item1;
sourceArchiveFile = item.Item2;
inProcessDirectory = item.Item3;
checkDirectory = item.Item4;
fileCount = item.Item5;
try
{
if (fileCount > 0 || string.IsNullOrEmpty(checkDirectory))
{
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Warning.ToString() });
monIn.SendStatus(site, monARessource, stateName, State.Warning);
for (int i = 1; i < 12; i++)
Thread.Sleep(500);
}
else if (inProcessDirectory == checkDirectory)
continue;
if (!EafHosted)
continue;
if (!File.Exists(sourceArchiveFile))
continue;
if (!long.TryParse(Path.GetFileNameWithoutExtension(sourceArchiveFile).Replace("x", string.Empty), out long sequence))
continue;
ZipFile.ExtractToDirectory(sourceArchiveFile, inProcessDirectory);
if (fileConnectorConfigurationIncludeSubDirectories && includeSubDirectoriesExtra)
{
if (_EventName == EventName.FileRead)
checkDirectory = string.Concat(checkDirectory, @"\", sequence);
else if (_EventName == EventName.FileReadDaily)
checkDirectory = string.Concat(checkDirectory, @"\Source\", sequence);
else
throw new Exception();
}
if (fileConnectorConfigurationIncludeSubDirectories)
files = Directory.GetFiles(inProcessDirectory, "*", SearchOption.AllDirectories);
else
files = Directory.GetFiles(inProcessDirectory, "*", SearchOption.TopDirectoryOnly);
if (files.Length > 250)
throw new Exception("Safety net!");
foreach (string file in files)
File.SetLastWriteTime(file, new DateTime(sequence));
if (!fileConnectorConfigurationIncludeSubDirectories)
{
foreach (string file in files)
File.Move(file, string.Concat(checkDirectory, @"\", Path.GetFileName(file)));
}
else
{
string[] directories = Directory.GetDirectories(inProcessDirectory, "*", SearchOption.AllDirectories);
foreach (string directory in directories)
Directory.CreateDirectory(string.Concat(checkDirectory, directory.Substring(inProcessDirectory.Length)));
foreach (string file in files)
File.Move(file, string.Concat(checkDirectory, file.Substring(inProcessDirectory.Length)));
}
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Ok.ToString() });
monIn.SendStatus(site, monARessource, stateName, State.Ok);
}
catch (Exception exception)
{
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Critical.ToString(), exception.Message, exception.StackTrace });
monIn.SendStatus(site, monARessource, stateName, State.Critical);
try
{
Eaf.Core.Smtp.ISmtp smtp = Eaf.Core.Backbone.Instance.GetBackboneComponentsOfType<Eaf.Core.Smtp.ISmtp>().SingleOrDefault();
Eaf.Core.Smtp.EmailMessage emailMessage = new Eaf.Core.Smtp.EmailMessage(string.Concat("Exception:", EquipmentElementName), string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace), Eaf.Core.Smtp.MailPriority.High);
smtp.Send(emailMessage);
}
catch (Exception) { }
}
}
}
private void CallbackIsDummy()
{
DateTime dateTime = DateTime.Now;
bool check = (dateTime.Hour > 7 && dateTime.Hour < 18 && dateTime.DayOfWeek != DayOfWeek.Sunday && dateTime.DayOfWeek != DayOfWeek.Saturday);
if (check)
{
int fileCount;
string[] files;
string monARessource;
string checkDirectory;
string sourceArchiveFile;
string sourceFileLocation;
string inProcessDirectory;
string weekOfYear = _Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
string traceDummyDirectory = string.Concat(Path.GetPathRoot(TracePath), @"\TracesDummy\", CellName, @"\Source\", dateTime.ToString("yyyy"), "___Week_", weekOfYear);
if (!Directory.Exists(traceDummyDirectory))
Directory.CreateDirectory(traceDummyDirectory);
string traceDummyFile = string.Concat(traceDummyDirectory, @"\", dateTime.Ticks, " - ", CellName, ".txt");
File.AppendAllText(traceDummyFile, string.Empty);
List<Tuple<string, string, string, string, int>> tuples = new List<Tuple<string, string, string, string, int>>();
string progressDirectory = Path.GetFullPath(string.Concat(FileConnectorConfiguration.SourceFileLocation, @"\_ Progress"));
if (progressDirectory != ProgressPath || !Directory.Exists(progressDirectory))
throw new Exception("Invalid progress path");
foreach (var keyValuePair in CellNames)
{
monARessource = keyValuePair.Key;
if (!keyValuePair.Value.Contains(@"\"))
continue;
foreach (string sourceFileFilter in FileConnectorConfiguration.SourceFileFilter.Split('|'))
{
if (sourceFileFilter.ToLower().StartsWith(keyValuePair.Value.Replace(@"\", string.Empty)))
sourceFileLocation = Path.GetFullPath(FileConnectorConfiguration.SourceFileLocation);
else if (FileConnectorConfiguration.SourceFileLocation.ToLower().EndsWith(keyValuePair.Value))
sourceFileLocation = Path.GetFullPath(FileConnectorConfiguration.SourceFileLocation);
else
sourceFileLocation = Path.GetFullPath(string.Concat(FileConnectorConfiguration.SourceFileLocation, @"\", keyValuePair.Value));
sourceArchiveFile = Path.GetFullPath(string.Concat(sourceFileLocation, @"\", sourceFileFilter));
if (!File.Exists(sourceArchiveFile))
continue;
if (!DummyRuns.ContainsKey(monARessource))
DummyRuns.Add(monARessource, new List<long>());
tuples.Add(new Tuple<string, string, string, string, int>(monARessource, sourceFileFilter, sourceFileLocation, sourceArchiveFile, 0));
}
}
File.AppendAllLines(traceDummyFile, from l in tuples select l.Item4);
if (tuples.Any())
{
_LastDummyRunIndex += 1;
if (_LastDummyRunIndex >= tuples.Count)
_LastDummyRunIndex = 0;
monARessource = tuples[_LastDummyRunIndex].Item1;
string sourceFileFilter = tuples[_LastDummyRunIndex].Item2;
sourceFileLocation = tuples[_LastDummyRunIndex].Item3;
sourceArchiveFile = tuples[_LastDummyRunIndex].Item4;
//fileCount = tuples[_LastDummyRunIndex].Item5;
tuples.Clear();
if (long.TryParse(Path.GetFileNameWithoutExtension(sourceArchiveFile).Replace("x", string.Empty), out long sequence))
{
if (!DummyRuns[monARessource].Contains(sequence))
DummyRuns[monARessource].Add(sequence);
inProcessDirectory = string.Concat(progressDirectory, @"\Dummy_in process\", sequence);
checkDirectory = inProcessDirectory;
if (!Directory.Exists(checkDirectory))
Directory.CreateDirectory(checkDirectory);
files = Directory.GetFiles(checkDirectory, "*", SearchOption.AllDirectories);
fileCount = files.Length;
if (files.Any())
{
if (files.Length > 250)
throw new Exception("Safety net!");
try
{
foreach (string file in files)
File.Delete(file);
}
catch (Exception) { }
}
tuples.Add(new Tuple<string, string, string, string, int>(monARessource, sourceArchiveFile, inProcessDirectory, checkDirectory, fileCount));
checkDirectory = sourceFileLocation;
files = Directory.GetFiles(checkDirectory, string.Concat("*", sequence, "*"), SearchOption.TopDirectoryOnly);
fileCount = files.Length;
tuples.Add(new Tuple<string, string, string, string, int>(monARessource, sourceArchiveFile, inProcessDirectory, checkDirectory, fileCount));
}
}
if (tuples.Any())
CallbackIsDummy(traceDummyFile, tuples, FileConnectorConfiguration.IncludeSubDirectories.Value, includeSubDirectoriesExtra: false);
}
}
private void Callback(object state)
{
try
{
if (Duplicator is null)
{
if (File.Exists(_ReportFullPath))
File.Delete(_ReportFullPath);
File.WriteAllText(_ReportFullPath, string.Empty);
}
else if (Duplicator.Value == Level.IsDummy)
CallbackIsDummy();
else
throw new Exception();
}
catch (Exception exception)
{
try
{
Eaf.Core.Smtp.ISmtp smtp = Eaf.Core.Backbone.Instance.GetBackboneComponentsOfType<Eaf.Core.Smtp.ISmtp>().SingleOrDefault();
Eaf.Core.Smtp.EmailMessage emailMessage = new Eaf.Core.Smtp.EmailMessage(string.Concat("Exception:", EquipmentElementName), string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace), Eaf.Core.Smtp.MailPriority.High);
smtp.Send(emailMessage);
}
catch (Exception) { }
}
try
{
TimeSpan timeSpan;
if (IsDatabaseExportToIPDSF)
timeSpan = new TimeSpan(DateTime.Now.AddMinutes(1).Ticks - DateTime.Now.Ticks);
else if (IsSourceTimer)
timeSpan = new TimeSpan(DateTime.Now.AddMinutes(15).Ticks - DateTime.Now.Ticks);
else if (Duplicator.HasValue && Duplicator.Value == Level.IsDummy)
timeSpan = new TimeSpan(DateTime.Now.AddSeconds(FileConnectorConfiguration.FileScanningIntervalInSeconds.Value).Ticks - DateTime.Now.Ticks);
else if (Duplicator.HasValue)
timeSpan = new TimeSpan(DateTime.Now.AddSeconds(30).Ticks - DateTime.Now.Ticks);
else
timeSpan = new TimeSpan(DateTime.Now.AddDays(.5).Ticks - DateTime.Now.Ticks);
if (!(_Timer is null))
_Timer.Change((long)timeSpan.TotalMilliseconds, Timeout.Infinite);
else
_Timer = new Timer(Callback, null, (long)timeSpan.TotalMilliseconds, Timeout.Infinite);
}
catch (Exception exception)
{
try
{
Eaf.Core.Smtp.ISmtp smtp = Eaf.Core.Backbone.Instance.GetBackboneComponentsOfType<Eaf.Core.Smtp.ISmtp>().SingleOrDefault();
Eaf.Core.Smtp.EmailMessage emailMessage = new Eaf.Core.Smtp.EmailMessage(string.Concat("Exception:", EquipmentElementName), string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace), Eaf.Core.Smtp.MailPriority.High);
smtp.Send(emailMessage);
}
catch (Exception) { }
}
}
public Tuple<string, JsonElement?, List<FileInfo>> IsManualOIEntry(string reportFullPath)
{
Tuple<string, JsonElement?, List<FileInfo>> results;
string monARessource;
const string site = "sjc";
string equipment = string.Empty;
string description = string.Empty;
string stateName = "MANUAL_OI_ENTRY";
string json = File.ReadAllText(reportFullPath);
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
results = new Tuple<string, JsonElement?, List<FileInfo>>(string.Empty, jsonElement, new List<FileInfo>());
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
{
if (jsonProperty.Name == "Equipment")
equipment = jsonProperty.Value.ToString();
else if (jsonProperty.Name == "Description")
description = jsonProperty.Value.ToString();
}
if (string.IsNullOrEmpty(equipment))
monARessource = CellName;
else
monARessource = equipment;
const string monInURL = "http://moninhttp.sjc.infineon.com/input/text";
MonIn monIn = MonIn.GetInstance(monInURL);
if (EafHosted)
monIn.SendStatus(site, monARessource, stateName, State.Warning, description);
return results;
}
private void Archive(string sourceFileLocation, string sourceFileFilter, Calendar calendar, string directoryName, string newDirectoryName, int minFiles)
{
string newDirectroyRoot = sourceFileLocation.Replace(directoryName, newDirectoryName);
if (!Directory.Exists(newDirectroyRoot))
Directory.CreateDirectory(newDirectroyRoot);
if (Directory.Exists(sourceFileLocation))
{
string[] files = Directory.GetFiles(sourceFileLocation, sourceFileFilter, SearchOption.TopDirectoryOnly);
if (files.Length > minFiles)
{
string newFile;
string weekOfYear;
DateTime dateTime;
string newDirectroy;
DateTime creationTime;
DateTime lastWriteTime;
for (int i = 1; i < 50; i++)
Thread.Sleep(500);
foreach (var file in files)
{
creationTime = new FileInfo(file).CreationTime;
lastWriteTime = new FileInfo(file).LastWriteTime;
if (creationTime < lastWriteTime)
dateTime = creationTime;
else
dateTime = lastWriteTime;
weekOfYear = calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
newDirectroy = string.Concat(newDirectroyRoot, @"\", dateTime.ToString("yyyy"), "___Week_", weekOfYear);
if (!Directory.Exists(newDirectroy))
Directory.CreateDirectory(newDirectroy);
newFile = string.Concat(newDirectroy, @"\", Path.GetFileName(file));
if (File.Exists(newFile))
File.Delete(newFile);
try { File.Move(file, string.Concat(newDirectroy, @"\", Path.GetFileName(file))); } catch (Exception e) { Print(string.Concat(e.Message, Environment.NewLine, Environment.NewLine, e.StackTrace)); }
try { Directory.SetLastWriteTime(newDirectroy, dateTime); } catch (Exception e) { Print(string.Concat(e.Message, Environment.NewLine, Environment.NewLine, e.StackTrace)); }
}
try { Directory.SetLastWriteTime(sourceFileLocation, DateTime.Now); } catch (Exception e) { Print(string.Concat(e.Message, Environment.NewLine, Environment.NewLine, e.StackTrace)); }
}
}
}
}
}

View File

@ -0,0 +1,147 @@
using Adaptation.Shared;
using Adaptation.Shared.Metrology;
using log4net;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
namespace Adaptation.Helpers
{
public partial class ProcessData : IProcessData
{
public class DiffusionLengthDetail
{
public string Reactor { get; set; }
public string Employee { get; set; }
public string Recipe { get; set; }
public string Slot { get; set; }
public string DiffusionLength { get; set; }
public string DiffusionLengthStandardDeviation { get; set; }
}
private readonly ILog _Log;
public List<DiffusionLengthDetail> Details { get; private set; }
public ProcessData(ILogic logic, ConfigData configData, List<FileInfo> fileInfoCollection, string lot, string pocketNumber)
{
_Log = LogManager.GetLogger(typeof(ProcessData));
Details = new List<DiffusionLengthDetail>();
DiffusionLengthDetail diffusionLengthDetail;
var data = ProcessDataStandardFormat.GetProcessDataStandardFormat(logic.Logistics.ReportFullPath);
Dictionary<Test, Dictionary<string, List<string>>> item2 = data.Item2;
if (item2.Any())
{
Dictionary<string, List<string>> keyValuePairs = item2.ElementAt(0).Value;
int count = keyValuePairs[Column.Time.ToString()].Count;
if (count > 0)
{
string key;
string carrier;
string[] segments;
string logistics = data.Item1;
key = "CARRIER=";
if (!logistics.Contains(key))
carrier = string.Empty;
else
{
segments = logistics.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
carrier = segments[1].Split(';')[0];
}
string mid;
key = "MID=";
if (!logistics.Contains(key))
mid = string.Empty;
else
{
segments = logistics.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
mid = segments[1].Split(';')[0];
}
string ppid;
key = "PPID=";
if (!logistics.Contains(key))
ppid = string.Empty;
else
{
segments = logistics.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
ppid = segments[1].Split(';')[0];
}
for (int i = 0; i < count; i++)
{
diffusionLengthDetail = new DiffusionLengthDetail
{
Reactor = string.Empty,
Employee = "AUTO",
Recipe = ppid,
Slot = keyValuePairs["SlotNumber"][i],
DiffusionLength = keyValuePairs["WW_SPV_DL_LBEF_AVG"][i],
DiffusionLengthStandardDeviation = keyValuePairs["WW_SPV_DL_LBEF_STD"][i]
};
if (!string.IsNullOrEmpty(mid))
diffusionLengthDetail.Reactor = mid.Substring(0, 3);
Details.Add(diffusionLengthDetail);
}
}
}
}
public Tuple<string, JsonElement?, List<FileInfo>> GetResults(ILogic logic, ConfigDataBase configDataBase, List<FileInfo> fileInfoCollection)
{
Tuple<string, JsonElement?, List<FileInfo>> results;
if (!(configDataBase is ConfigData configData))
throw new Exception();
List<Test> tests = new List<Test>();
List<IProcessDataDescription> descriptions;
EventName eventName = configData.GetEventNameValue();
if (eventName == EventName.FileRead && Details.Any())
{
foreach (var item in Details)
tests.Add(Test);
descriptions = configData.GetDescription(logic, tests, this);
}
else
throw new Exception();
if (!configData.EafHosted)
new FileRead.Description().GetDescription(logic, configData, tests, this);
if (tests.Count != descriptions.Count)
throw new Exception();
for (int i = 0; i < tests.Count; i++)
{
if (descriptions[i].Test != (int)tests[i])
throw new Exception();
}
string json;
if (descriptions[0] is Duplicator.Description)
{
List<Duplicator.Description> duplicatorDescriptions = (from l in descriptions select (Duplicator.Description)l).ToList();
json = JsonSerializer.Serialize(duplicatorDescriptions, duplicatorDescriptions.GetType());
}
else if (descriptions[0] is FileRead.Description)
{
List<FileRead.Description> fileReadDescriptions = (from l in descriptions select (FileRead.Description)l).ToList();
json = JsonSerializer.Serialize(fileReadDescriptions, fileReadDescriptions.GetType());
}
else
throw new Exception();
object @object = JsonSerializer.Deserialize<object>(json);
if (!(@object is JsonElement jsonElement))
throw new Exception();
results = new Tuple<string, JsonElement?, List<FileInfo>>(logic.Logistics.Logistics1[0], jsonElement, fileInfoCollection);
return results;
}
public static Dictionary<Test, List<Duplicator.Description>> GetKeyValuePairs(ConfigData configData, JsonElement jsonElement, List<Duplicator.Description> processDataDescriptions, bool extra = false)
{
Dictionary<Test, List<Duplicator.Description>> results = configData.GetKeyValuePairs(processDataDescriptions);
configData.CheckProcessDataDescription(results, extra);
return results;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,218 @@
using Infineon.Yoda;
using System;
using System.Collections.Generic;
using System.Linq;
using TIBCO.Rendezvous;
namespace Adaptation.Si
{
public class LDS2559Reply
{
public enum FieldName
{
ETC,
ETX,
IFX_ECD,
IFX_ETX,
PARAMETER,
ACCEPTED,
EXCLUDE,
HIT,
CALCULATED,
CHANNEL,
CKC,
OOB,
VIOLATION,
MEAN,
OFFLINE,
PARAMETERNAME,
SAMPID_64,
REPLY,
UNACCEPTED,
VIOLATIONS
}
public class HIT
{
public object CALCULATED { get; set; } //bool
public object CHANNEL { get; set; } //Int32
public object CKC { get; set; } //Int32
public object OOB { get; set; } //bool
public object VIOLATION { get; set; } //Int32
public HIT(Message value)
{
MessageField messageField;
for (uint i = 0; i < value.FieldCount; i++)
{
messageField = value.GetFieldByIndex(i);
if (messageField.Name == FieldName.CALCULATED.ToString())
CALCULATED = messageField.Value;
else if (messageField.Name == FieldName.CHANNEL.ToString())
CHANNEL = messageField.Value;
else if (messageField.Name == FieldName.CKC.ToString())
CKC = messageField.Value;
else if (messageField.Name == FieldName.OOB.ToString())
OOB = messageField.Value;
else if (messageField.Name == FieldName.VIOLATION.ToString())
VIOLATION = messageField.Value;
else
throw new Exception();
}
}
public override string ToString()
{
return string.Concat(CALCULATED, '\t', CHANNEL, '\t', CKC, '\t', OOB, '\t', VIOLATION);
}
}
public class PARAMETER
{
public object ACCEPTED { get; set; } //bool
public object EXCLUDE { get; set; } //Int32
public List<HIT> HIT { get; set; }
public object MEAN { get; set; } //double
public object OFFLINE { get; set; } //bool
public object PARAMETERNAME { get; set; } //string
public object SAMPID_64 { get; set; } //Int64
public PARAMETER(Message value)
{
HIT hit;
Message message;
HIT = new List<HIT>();
object objectFieldValue;
MessageField messageField;
for (uint i = 0; i < value.FieldCount; i++)
{
messageField = value.GetFieldByIndex(i);
if (messageField.Name == FieldName.ACCEPTED.ToString())
ACCEPTED = messageField.Value;
else if (messageField.Name == FieldName.EXCLUDE.ToString())
EXCLUDE = messageField.Value;
else if (messageField.Name == FieldName.HIT.ToString())
{
if (!(messageField.Value is null) && messageField.Value is Message)
{
message = (Message)messageField.Value;
{
for (uint j = 0; j < message.FieldCount; j++)
{
objectFieldValue = message.GetFieldByIndex(j).Value;
if (!(objectFieldValue is null) && objectFieldValue is Message)
{
hit = new HIT((Message)objectFieldValue);
HIT.Add(hit);
}
}
}
}
}
else if (messageField.Name == FieldName.MEAN.ToString())
MEAN = messageField.Value;
else if (messageField.Name == FieldName.OFFLINE.ToString())
OFFLINE = messageField.Value;
else if (messageField.Name == FieldName.PARAMETERNAME.ToString())
PARAMETERNAME = messageField.Value;
else if (messageField.Name == FieldName.SAMPID_64.ToString())
SAMPID_64 = messageField.Value;
else
throw new Exception();
}
}
public override string ToString()
{
string result;
if (!HIT.Any())
result = string.Concat(ACCEPTED, '\t', EXCLUDE, '\t', "HIT = 0", '\t', MEAN, '\t', OFFLINE, '\t', PARAMETERNAME, '\t', SAMPID_64);
else
result = string.Concat(ACCEPTED, '\t', EXCLUDE, '\t', "[Count ", HIT.Count, " - 0 {", HIT[0], "}]", '\t', MEAN, '\t', OFFLINE, '\t', PARAMETERNAME, '\t', SAMPID_64);
return result;
}
}
public class DATA
{
public object ETC { get; set; } //Int32
public object ETX { get; set; }
public object IFX_ECD { get; set; } //Int32
public object IFX_ETX { get; set; } //string
public List<PARAMETER> PARAMETER { get; set; }
public object REPLY { get; set; } //Int32
public object UNACCEPTED { get; set; } //Int32
public object VIOLATIONS { get; set; } //Int32
public DATA(IfxDoc ifxDoc = null)
{
PARAMETER = new List<PARAMETER>();
if (!(ifxDoc is null))
{
Message message;
PARAMETER parameter;
object objectFieldValue;
MessageField messageField;
for (uint i = 0; i < ifxDoc.msg.FieldCount; i++)
{
messageField = ifxDoc.msg.GetFieldByIndex(i);
if (messageField.Name == FieldName.ETC.ToString())
ETC = messageField.Value;
else if (messageField.Name == FieldName.ETX.ToString())
ETX = messageField.Value;
else if (messageField.Name == FieldName.IFX_ECD.ToString())
IFX_ECD = messageField.Value;
else if (messageField.Name == FieldName.IFX_ETX.ToString())
IFX_ETX = messageField.Value;
else if (messageField.Name == FieldName.PARAMETER.ToString())
{
if (!(messageField.Value is null) && messageField.Value is Message)
{
message = (Message)messageField.Value;
{
for (uint j = 0; j < message.FieldCount; j++)
{
objectFieldValue = message.GetFieldByIndex(j).Value;
if (!(objectFieldValue is null) && objectFieldValue is Message)
{
parameter = new PARAMETER((Message)objectFieldValue);
PARAMETER.Add(parameter);
}
}
}
}
}
else if (messageField.Name == FieldName.REPLY.ToString())
REPLY = messageField.Value;
else if (messageField.Name == FieldName.UNACCEPTED.ToString())
UNACCEPTED = messageField.Value;
else if (messageField.Name == FieldName.VIOLATIONS.ToString())
VIOLATIONS = messageField.Value;
else
throw new Exception();
}
}
}
public override string ToString()
{
string result;
if (!PARAMETER.Any())
result = string.Concat(IFX_ECD, '\t', IFX_ETX, '\t', "PARAMETER = 0", '\t', REPLY, '\t', UNACCEPTED, '\t', VIOLATIONS);
else
result = string.Concat(IFX_ECD, '\t', IFX_ETX, '\t', "[Count ", PARAMETER.Count, " - 0 {", PARAMETER[0], "}]", '\t', REPLY, '\t', UNACCEPTED, '\t', VIOLATIONS);
return result;
}
}
}
}

View File

@ -0,0 +1,317 @@
using Adaptation.Shared;
using Infineon.Yoda;
using System;
using System.Collections.Generic;
namespace Adaptation.Si
{
public class LDS2559Send
{
public enum FieldName
{
IFX_SERVICE,
KEYS,
PARAMETER,
SETTINGS,
PARAMETERNAME,
VALUE
}
public class Settings
{
public string MODE { get; set; }
public int COMTIMEOUT { get; set; }
public string DATE { get; private set; }
public int KEY { get; set; }
public int LDS { get; set; }
public string SENDER { get; set; }
public Settings(string ifxSubjectPrefix, Logistics logistics)
{
MODE = "FULL";
COMTIMEOUT = 10;
KEY = 0;
switch (ifxSubjectPrefix)
{
case "VIH_D": LDS = 2599; break;
case "VIH_P": LDS = 2500; break;
default: LDS = -1; break;
}
SENDER = Environment.MachineName;
DATE = logistics.DateTimeFromSequence.ToString("yyyyMMddHHmmss");
}
}
public class Value
{
public DataKeys DataKeys { get; set; }
public string VALUE { get; set; }
public Value(Logistics logistics)
{
DataKeys = new DataKeys(logistics);
}
}
public class Parameter
{
public ExtractorKeys ExtractorKeys { get; set; }
public DataKeys DataKeys { get; set; }
public string COMMENT { get; set; }
public double? LSL { get; set; }
public string PARAMETERNAME { get; set; }
public double? TSL { get; set; }
public string UNIT { get; set; }
public double? USL { get; set; }
public string VALUE { get; set; }
public Parameter(Logistics logistics)
{
ExtractorKeys = new ExtractorKeys(logistics);
DataKeys = new DataKeys(logistics);
}
public Parameter(Logistics logistics, string parameterName, string value)
{
ExtractorKeys = new ExtractorKeys(logistics);
DataKeys = new DataKeys(logistics);
PARAMETERNAME = parameterName;
VALUE = value;
}
public Parameter(Logistics logistics, ExtendedParameter extendedParameter)
{
ExtractorKeys = new ExtractorKeys(logistics);
DataKeys = new DataKeys(logistics);
PARAMETERNAME = extendedParameter.DiplayName;
LSL = extendedParameter.LSL;
TSL = extendedParameter.TSL;
UNIT = extendedParameter.Unit;
USL = extendedParameter.USL;
VALUE = extendedParameter.Value;
}
}
public class DataKeys
{
public string Employee { get; set; } //1
public string SID { get; set; } //2
public string WaferRegion { get; set; } //3
public string WaferScribe { get; set; } //4
public string WaferPosition { get; set; } //5
public string X { get; set; } //6
public string Y { get; set; } //7
public string EAFCellInstance { get; set; } //8
public string EAFReference { get; set; } //9
public string IQSReference { get; set; } //10
public DataKeys(Logistics logistics, IScopeInfo scopeInfo = null, string sID = null)
{
if (scopeInfo is null)
{
SID = null;
EAFReference = null;
IQSReference = null;
EAFCellInstance = null;
}
else
{
if (string.IsNullOrEmpty(sID))
SID = "-";
else
SID = sID;
EAFReference = scopeInfo.EquipmentType.ToString();
if (string.IsNullOrEmpty(scopeInfo.QueryFilter))
IQSReference = null;
else
IQSReference = scopeInfo.QueryFilter;
if (logistics is null)
EAFCellInstance = null;
else
EAFCellInstance = logistics.JobID;
}
}
}
public class ExtractorKeys
{
public string Lot { get; set; } //1
public string ToolID { get; set; } //2
public string Process { get; set; } //3
public string WaferID { get; set; } //4
public string Part { get; set; } //5
public string Recipe { get; set; } //6
public string ProcessFlow { get; set; } //7
public ExtractorKeys(Logistics logistics, IScopeInfo scopeInfo = null)
{
if (scopeInfo is null)
{
ToolID = null;
Lot = null;
Part = null;
}
else
{
ToolID = logistics.MesEntity;
Lot = "-";
Part = "-";
}
}
}
public class DATA
{
public string IFX_SERVICE { get; set; }
public ExtractorKeys ExtractorKeys { get; set; }
public DataKeys DataKeys { get; set; }
public Parameter Parameter { get; set; }
public Settings Settings { get; set; }
public DATA(string ifxSubjectPrefix, Logistics logistics, IScopeInfo scopeInfo, string sID)
{
ExtractorKeys = new ExtractorKeys(logistics, scopeInfo);
DataKeys = new DataKeys(logistics, scopeInfo, sID);
Parameter = new Parameter(logistics);
Settings = new Settings(ifxSubjectPrefix, logistics);
}
internal static IfxDoc GetIfxDoc(string service, string value, DataKeys dataKeys, ExtractorKeys extractorKeys, Settings settings)
{
IfxDoc result = new IfxDoc();
if (!string.IsNullOrEmpty(service))
result.Add(string.Concat(FieldName.IFX_SERVICE), service);
if (!(value is null))
{
if (string.IsNullOrEmpty(value))
result.Add(string.Concat(FieldName.VALUE), "-");
else
result.Add(string.Concat(FieldName.VALUE), value);
}
if (!(dataKeys is null))
{
if (!string.IsNullOrEmpty(dataKeys.EAFCellInstance))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.EAFCellInstance)), dataKeys.EAFCellInstance);
if (!string.IsNullOrEmpty(dataKeys.EAFReference))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.EAFReference)), dataKeys.EAFReference);
if (!string.IsNullOrEmpty(dataKeys.Employee))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.Employee)), dataKeys.Employee);
if (!string.IsNullOrEmpty(dataKeys.IQSReference))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.IQSReference)), dataKeys.IQSReference);
if (!string.IsNullOrEmpty(dataKeys.SID))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.SID)), dataKeys.SID);
if (!string.IsNullOrEmpty(dataKeys.WaferPosition))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.WaferPosition)), dataKeys.WaferPosition);
if (!string.IsNullOrEmpty(dataKeys.WaferRegion))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.WaferRegion)), dataKeys.WaferRegion);
if (!string.IsNullOrEmpty(dataKeys.WaferScribe))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.WaferScribe)), dataKeys.WaferScribe);
if (!string.IsNullOrEmpty(dataKeys.X))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.X)), dataKeys.X);
if (!string.IsNullOrEmpty(dataKeys.Y))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.DataKeys.Y)), dataKeys.Y);
}
if (!(extractorKeys is null))
{
if (!string.IsNullOrEmpty(extractorKeys.Lot))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.ExtractorKeys.Lot)), extractorKeys.Lot);
if (!string.IsNullOrEmpty(extractorKeys.Part))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.ExtractorKeys.Part)), extractorKeys.Part);
if (!string.IsNullOrEmpty(extractorKeys.Process))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.ExtractorKeys.Process)), extractorKeys.Process);
if (!string.IsNullOrEmpty(extractorKeys.ProcessFlow))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.ExtractorKeys.ProcessFlow)), extractorKeys.ProcessFlow);
if (!string.IsNullOrEmpty(extractorKeys.Recipe))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.ExtractorKeys.Recipe)), extractorKeys.Recipe);
if (!string.IsNullOrEmpty(extractorKeys.ToolID))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.ExtractorKeys.ToolID)), extractorKeys.ToolID);
if (!string.IsNullOrEmpty(extractorKeys.WaferID))
result.Add(string.Concat(FieldName.KEYS, "/", nameof(LDS2559Send.ExtractorKeys.WaferID)), extractorKeys.WaferID);
}
if (!(settings is null))
{
result.Add(string.Concat(FieldName.SETTINGS, "/", nameof(LDS2559Send.Settings.MODE)), settings.MODE);
result.Add(string.Concat(FieldName.SETTINGS, "/", nameof(LDS2559Send.Settings.COMTIMEOUT)), settings.COMTIMEOUT);
result.Add(string.Concat(FieldName.SETTINGS, "/", nameof(LDS2559Send.Settings.DATE)), settings.DATE);
result.Add(string.Concat(FieldName.SETTINGS, "/", nameof(LDS2559Send.Settings.KEY)), settings.KEY);
result.Add(string.Concat(FieldName.SETTINGS, "/", nameof(LDS2559Send.Settings.LDS)), settings.LDS);
result.Add(string.Concat(FieldName.SETTINGS, "/", nameof(LDS2559Send.Settings.SENDER)), settings.SENDER);
}
return result;
}
public IfxDoc GetIfxDoc(List<IfxDoc> parameters)
{
IfxDoc result = GetIfxDoc("EVALUATESPCDATA", value: null, dataKeys: DataKeys, extractorKeys: ExtractorKeys, settings: Settings);
result.Add(string.Concat(FieldName.PARAMETER), parameters.ToArray());
return result;
}
}
public class ParameterCollection
{
public List<Parameter> Collection { get; set; }
public ParameterCollection()
{
Collection = new List<Parameter>();
}
public IfxDoc GetIfxDoc()
{
IfxDoc value;
IfxDoc result = new IfxDoc();
Parameter parameter;
List<IfxDoc> values = new List<IfxDoc>();
for (int i = 0; i < Collection.Count; i++)
{
parameter = Collection[i];
if (i == 0)
{
if (parameter.TSL.HasValue & parameter.USL.HasValue && parameter.TSL.Value > parameter.USL.Value)
parameter.USL = parameter.TSL.Value;
if (parameter.TSL.HasValue & parameter.LSL.HasValue && parameter.TSL.Value < parameter.LSL.Value)
parameter.LSL = parameter.TSL.Value;
//
if (parameter.LSL.HasValue & parameter.USL.HasValue && parameter.LSL.Value > parameter.USL.Value && parameter.USL.Value == 0)
parameter.USL = null;
//
if (parameter.USL.HasValue & parameter.LSL.HasValue && parameter.USL.Value < parameter.LSL.Value)
throw new Exception();
if (parameter.LSL.HasValue & parameter.USL.HasValue && parameter.LSL.Value > parameter.USL.Value)
throw new Exception();
//
if (parameter.LSL.HasValue)
result.Add(nameof(Parameter.LSL), parameter.LSL);
if (!string.IsNullOrEmpty(parameter.PARAMETERNAME))
result.Add(string.Concat(FieldName.PARAMETERNAME), parameter.PARAMETERNAME);
if (parameter.TSL.HasValue)
result.Add(nameof(Parameter.TSL), parameter.TSL.Value);
if (!string.IsNullOrEmpty(parameter.UNIT))
result.Add(nameof(Parameter.UNIT), parameter.UNIT);
if (parameter.USL.HasValue)
result.Add(nameof(Parameter.USL), parameter.USL.Value);
}
value = DATA.GetIfxDoc(service: string.Empty, value: parameter.VALUE, dataKeys: parameter.DataKeys, extractorKeys: parameter.ExtractorKeys, settings: null);
values.Add(value);
}
result.Add(string.Concat(FieldName.VALUE), values.ToArray());
return result;
}
}
}
}

View File

@ -0,0 +1,35 @@
using Adaptation.Shared;
using Adaptation.Shared.Metrology;
using System.Collections.Generic;
using System.Linq;
namespace Adaptation.Metrology
{
internal class MET08ANLYSDIFAAST230
{
internal static Dictionary<int, List<object>> GetPreRunInfo(Logistics logistics, EventName eventName)
{
Dictionary<int, List<object>> results = new Dictionary<int, List<object>>();
return results;
}
internal static List<PreRunInfo> Verify(EventName eventName, List<PreRunInfo> results)
{
return results;
}
internal static string GetSid(List<PreRunInfo> preRunInfo, bool isMappedPart, IScopeInfo scopeInfo, List<string> tags)
{
string result = string.Empty;
if (preRunInfo.Any())
{
result = tags[0];
}
return result;
}
}
}

View File

@ -0,0 +1,104 @@
using Adaptation.Shared;
using Adaptation.Shared.Metrology;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Adaptation.Metrology
{
internal class MET08DDUPSFS6420
{
internal static Dictionary<int, List<object>> GetPreRunInfo(Logistics logistics, EventName eventName)
{
//2019-12-27 - 001
Dictionary<int, List<object>> results;
StringBuilder sql = new StringBuilder();
sql.Append(" SELECT ").
Append(" wafer_id, [run number], recipe, [part number], date, pocket_number, wafer_lot, [satellite group], ISNULL(( ").
Append(" SELECT max(startstamp) ").
Append(" FROM G4Wafers_01.dbo.ToolTimeInfo ").
Append(" WHERE (lot = @mid OR lot = @midSubstring) ").
Append(" ), date) startstamp ").
Append(" FROM G4Wafers_01.dbo.[prerun info] ").
Append(" WHERE (wafer_id = @mid OR [run number] = @mid) ").
Append(" ORDER by date ");
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>
{
new Tuple<string, string>("@midSubstring", string.Concat("'", logistics.MID.Substring(0, logistics.MID.Length - 2), "'")),
new Tuple<string, string>("@mid", string.Concat("'", logistics.MID, "'"))
};
results = SQLDatabase.ExecuteReader(sql, parameters, columns: 9, isG4Wafers: true, isIrmnSpc: false);
return results;
}
internal static List<PreRunInfo> Verify(EventName eventName, List<PreRunInfo> results)
{
//2019-12-28 - 004
if (results.Any())
{
string partFromRecipe;
Dictionary<int, List<object>> check;
StringBuilder sql = new StringBuilder();
string lastPartFromRecipe = string.Empty;
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>();
for (int i = 0; i < results.Count; i++)
{
partFromRecipe = results[i].Recipe;
if (string.IsNullOrEmpty(lastPartFromRecipe) || partFromRecipe != lastPartFromRecipe)
{
// re-format recipe name by extracting middle part of it
if ((!partFromRecipe.ToUpper().StartsWith("PROD")) &&
(!partFromRecipe.ToUpper().StartsWith("MAMD")) &&
(!partFromRecipe.ToUpper().StartsWith("QUAL")) &&
(!partFromRecipe.ToUpper().StartsWith("ENGR")) &&
(!partFromRecipe.ToUpper().StartsWith("ANKO")) &&
(!partFromRecipe.ToUpper().StartsWith("U")))
partFromRecipe = "ENG";
else if (partFromRecipe.Split('-').Length == 3) // recipe name has 3 parts
partFromRecipe = partFromRecipe.Split('-')[0].Trim() + "-" + partFromRecipe.Split('-')[1].Trim(); // middle part of recipe name
else if (partFromRecipe.Split('-').Length == 2) // recipe name has 2 parts
partFromRecipe = partFromRecipe.Split('-')[0].Trim(); // first part of recipe name
else if (partFromRecipe.Split('_').Length == 3)
partFromRecipe = partFromRecipe.Split('_')[1].Trim(); // middle part of recipe name
else if (partFromRecipe.Split('_').Length == 2) // recipe name has 2 parts
partFromRecipe = partFromRecipe.Split('_')[0].Trim(); // first part of recipe name
if (results[i].PartNumber != partFromRecipe)
results[i].PartNumber = partFromRecipe;
if (partFromRecipe != "ENG")
{
sql.Append(" SELECT ").
Append(" count(*) AS my_count ").
Append(" FROM IRMNSPC.dbo.part_dat ").
Append(" WHERE f_name = @part ");
parameters.Clear();
parameters.Add(new Tuple<string, string>("@part", string.Concat("'", partFromRecipe, "'")));
check = SQLDatabase.ExecuteReader(sql, parameters, columns: 1, isG4Wafers: true, isIrmnSpc: false);
if (check.ElementAt(0).Value[0].ToString() == "0")
{
partFromRecipe = "ENG";
results[i].PartNumber = partFromRecipe;
}
}
}
lastPartFromRecipe = partFromRecipe;
}
}
return results;
}
internal static string GetSid(List<PreRunInfo> preRunInfo, bool isMappedPart, IScopeInfo scopeInfo, List<string> tags)
{
string result = string.Empty;
if (preRunInfo.Any())
{
result = tags[0];
}
return result;
}
}
}

View File

@ -0,0 +1,104 @@
using Adaptation.Shared;
using Adaptation.Shared.Metrology;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Adaptation.Metrology
{
internal class MET08DDUPSP1TBI
{
internal static Dictionary<int, List<object>> GetPreRunInfo(Logistics logistics, EventName eventName)
{
//2019-12-27 - 001
Dictionary<int, List<object>> results;
StringBuilder sql = new StringBuilder();
sql.Append(" SELECT ").
Append(" wafer_id, [run number], recipe, [part number], date, pocket_number, wafer_lot, [satellite group], ISNULL(( ").
Append(" SELECT max(startstamp) ").
Append(" FROM G4Wafers_01.dbo.ToolTimeInfo ").
Append(" WHERE (lot = @mid OR lot = @midSubstring) ").
Append(" ), date) startstamp ").
Append(" FROM G4Wafers_01.dbo.[prerun info] ").
Append(" WHERE (wafer_id = @mid OR [run number] = @mid) ").
Append(" ORDER by date ");
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>
{
new Tuple<string, string>("@midSubstring", string.Concat("'", logistics.MID.Substring(0, logistics.MID.Length - 2), "'")),
new Tuple<string, string>("@mid", string.Concat("'", logistics.MID, "'"))
};
results = SQLDatabase.ExecuteReader(sql, parameters, columns: 9, isG4Wafers: true, isIrmnSpc: false);
return results;
}
internal static List<PreRunInfo> Verify(EventName eventName, List<PreRunInfo> results)
{
//2019-12-28 - 004
if (results.Any())
{
string partFromRecipe;
Dictionary<int, List<object>> check;
StringBuilder sql = new StringBuilder();
string lastPartFromRecipe = string.Empty;
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>();
for (int i = 0; i < results.Count; i++)
{
partFromRecipe = results[i].Recipe;
if (string.IsNullOrEmpty(lastPartFromRecipe) || partFromRecipe != lastPartFromRecipe)
{
// re-format recipe name by extracting middle part of it
if ((!partFromRecipe.ToUpper().StartsWith("PROD")) &&
(!partFromRecipe.ToUpper().StartsWith("MAMD")) &&
(!partFromRecipe.ToUpper().StartsWith("QUAL")) &&
(!partFromRecipe.ToUpper().StartsWith("ENGR")) &&
(!partFromRecipe.ToUpper().StartsWith("ANKO")) &&
(!partFromRecipe.ToUpper().StartsWith("U")))
partFromRecipe = "ENG";
else if (partFromRecipe.Split('-').Length == 3) // recipe name has 3 parts
partFromRecipe = partFromRecipe.Split('-')[0].Trim() + "-" + partFromRecipe.Split('-')[1].Trim(); // middle part of recipe name
else if (partFromRecipe.Split('-').Length == 2) // recipe name has 2 parts
partFromRecipe = partFromRecipe.Split('-')[0].Trim(); // first part of recipe name
else if (partFromRecipe.Split('_').Length == 3)
partFromRecipe = partFromRecipe.Split('_')[1].Trim(); // middle part of recipe name
else if (partFromRecipe.Split('_').Length == 2) // recipe name has 2 parts
partFromRecipe = partFromRecipe.Split('_')[0].Trim(); // first part of recipe name
if (results[i].PartNumber != partFromRecipe)
results[i].PartNumber = partFromRecipe;
if (partFromRecipe != "ENG")
{
sql.Append(" SELECT ").
Append(" count(*) AS my_count ").
Append(" FROM IRMNSPC.dbo.part_dat ").
Append(" WHERE f_name = @part ");
parameters.Clear();
parameters.Add(new Tuple<string, string>("@part", string.Concat("'", partFromRecipe, "'")));
check = SQLDatabase.ExecuteReader(sql, parameters, columns: 1, isG4Wafers: true, isIrmnSpc: false);
if (check.ElementAt(0).Value[0].ToString() == "0")
{
partFromRecipe = "ENG";
results[i].PartNumber = partFromRecipe;
}
}
}
lastPartFromRecipe = partFromRecipe;
}
}
return results;
}
internal static string GetSid(List<PreRunInfo> preRunInfo, bool isMappedPart, IScopeInfo scopeInfo, List<string> tags)
{
string result = string.Empty;
if (preRunInfo.Any())
{
result = tags[0];
}
return result;
}
}
}

View File

@ -0,0 +1,104 @@
using Adaptation.Shared;
using Adaptation.Shared.Metrology;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Adaptation.Metrology
{
internal class MET08RESIHGCV
{
internal static Dictionary<int, List<object>> GetPreRunInfo(Logistics logistics, EventName eventName)
{
//2019-12-27 - 001
Dictionary<int, List<object>> results;
StringBuilder sql = new StringBuilder();
sql.Append(" SELECT ").
Append(" wafer_id, [run number], recipe, [part number], date, pocket_number, wafer_lot, [satellite group], ISNULL(( ").
Append(" SELECT max(startstamp) ").
Append(" FROM G4Wafers_01.dbo.ToolTimeInfo ").
Append(" WHERE (lot = @mid OR lot = @midSubstring) ").
Append(" ), date) startstamp ").
Append(" FROM G4Wafers_01.dbo.[prerun info] ").
Append(" WHERE (wafer_id = @mid OR [run number] = @mid) ").
Append(" ORDER by date ");
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>
{
new Tuple<string, string>("@midSubstring", string.Concat("'", logistics.MID.Substring(0, logistics.MID.Length - 2), "'")),
new Tuple<string, string>("@mid", string.Concat("'", logistics.MID, "'"))
};
results = SQLDatabase.ExecuteReader(sql, parameters, columns: 9, isG4Wafers: true, isIrmnSpc: false);
return results;
}
internal static List<PreRunInfo> Verify(EventName eventName, List<PreRunInfo> results)
{
//2019-12-28 - 004
if (results.Any())
{
string partFromRecipe;
Dictionary<int, List<object>> check;
StringBuilder sql = new StringBuilder();
string lastPartFromRecipe = string.Empty;
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>();
for (int i = 0; i < results.Count; i++)
{
partFromRecipe = results[i].Recipe;
if (string.IsNullOrEmpty(lastPartFromRecipe) || partFromRecipe != lastPartFromRecipe)
{
// re-format recipe name by extracting middle part of it
if ((!partFromRecipe.ToUpper().StartsWith("PROD")) &&
(!partFromRecipe.ToUpper().StartsWith("MAMD")) &&
(!partFromRecipe.ToUpper().StartsWith("QUAL")) &&
(!partFromRecipe.ToUpper().StartsWith("ENGR")) &&
(!partFromRecipe.ToUpper().StartsWith("ANKO")) &&
(!partFromRecipe.ToUpper().StartsWith("U")))
partFromRecipe = "ENG";
else if (partFromRecipe.Split('-').Length == 3) // recipe name has 3 parts
partFromRecipe = partFromRecipe.Split('-')[0].Trim() + "-" + partFromRecipe.Split('-')[1].Trim(); // middle part of recipe name
else if (partFromRecipe.Split('-').Length == 2) // recipe name has 2 parts
partFromRecipe = partFromRecipe.Split('-')[0].Trim(); // first part of recipe name
else if (partFromRecipe.Split('_').Length == 3)
partFromRecipe = partFromRecipe.Split('_')[1].Trim(); // middle part of recipe name
else if (partFromRecipe.Split('_').Length == 2) // recipe name has 2 parts
partFromRecipe = partFromRecipe.Split('_')[0].Trim(); // first part of recipe name
if (results[i].PartNumber != partFromRecipe)
results[i].PartNumber = partFromRecipe;
if (partFromRecipe != "ENG")
{
sql.Append(" SELECT ").
Append(" count(*) AS my_count ").
Append(" FROM IRMNSPC.dbo.part_dat ").
Append(" WHERE f_name = @part ");
parameters.Clear();
parameters.Add(new Tuple<string, string>("@part", string.Concat("'", partFromRecipe, "'")));
check = SQLDatabase.ExecuteReader(sql, parameters, columns: 1, isG4Wafers: true, isIrmnSpc: false);
if (check.ElementAt(0).Value[0].ToString() == "0")
{
partFromRecipe = "ENG";
results[i].PartNumber = partFromRecipe;
}
}
}
lastPartFromRecipe = partFromRecipe;
}
}
return results;
}
internal static string GetSid(List<PreRunInfo> preRunInfo, bool isMappedPart, IScopeInfo scopeInfo, List<string> tags)
{
string result = string.Empty;
if (preRunInfo.Any())
{
result = tags[0];
}
return result;
}
}
}

View File

@ -0,0 +1,104 @@
using Adaptation.Shared;
using Adaptation.Shared.Metrology;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Adaptation.Metrology
{
internal class MET08RESIMAPCDE
{
internal static Dictionary<int, List<object>> GetPreRunInfo(Logistics logistics, EventName eventName)
{
//2019-12-27 - 001
Dictionary<int, List<object>> results;
StringBuilder sql = new StringBuilder();
sql.Append(" SELECT ").
Append(" wafer_id, [run number], recipe, [part number], date, pocket_number, wafer_lot, [satellite group], ISNULL(( ").
Append(" SELECT max(startstamp) ").
Append(" FROM G4Wafers_01.dbo.ToolTimeInfo ").
Append(" WHERE (lot = @mid OR lot = @midSubstring) ").
Append(" ), date) startstamp ").
Append(" FROM G4Wafers_01.dbo.[prerun info] ").
Append(" WHERE (wafer_id = @mid OR [run number] = @mid) ").
Append(" ORDER by date ");
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>
{
new Tuple<string, string>("@midSubstring", string.Concat("'", logistics.MID.Substring(0, logistics.MID.Length - 2), "'")),
new Tuple<string, string>("@mid", string.Concat("'", logistics.MID, "'"))
};
results = SQLDatabase.ExecuteReader(sql, parameters, columns: 9, isG4Wafers: true, isIrmnSpc: false);
return results;
}
internal static List<PreRunInfo> Verify(EventName eventName, List<PreRunInfo> results)
{
//2019-12-28 - 004
if (results.Any())
{
string partFromRecipe;
Dictionary<int, List<object>> check;
StringBuilder sql = new StringBuilder();
string lastPartFromRecipe = string.Empty;
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>();
for (int i = 0; i < results.Count; i++)
{
partFromRecipe = results[i].Recipe;
if (string.IsNullOrEmpty(lastPartFromRecipe) || partFromRecipe != lastPartFromRecipe)
{
// re-format recipe name by extracting middle part of it
if ((!partFromRecipe.ToUpper().StartsWith("PROD")) &&
(!partFromRecipe.ToUpper().StartsWith("MAMD")) &&
(!partFromRecipe.ToUpper().StartsWith("QUAL")) &&
(!partFromRecipe.ToUpper().StartsWith("ENGR")) &&
(!partFromRecipe.ToUpper().StartsWith("ANKO")) &&
(!partFromRecipe.ToUpper().StartsWith("U")))
partFromRecipe = "ENG";
else if (partFromRecipe.Split('-').Length == 3) // recipe name has 3 parts
partFromRecipe = partFromRecipe.Split('-')[0].Trim() + "-" + partFromRecipe.Split('-')[1].Trim(); // middle part of recipe name
else if (partFromRecipe.Split('-').Length == 2) // recipe name has 2 parts
partFromRecipe = partFromRecipe.Split('-')[0].Trim(); // first part of recipe name
else if (partFromRecipe.Split('_').Length == 3)
partFromRecipe = partFromRecipe.Split('_')[1].Trim(); // middle part of recipe name
else if (partFromRecipe.Split('_').Length == 2) // recipe name has 2 parts
partFromRecipe = partFromRecipe.Split('_')[0].Trim(); // first part of recipe name
if (results[i].PartNumber != partFromRecipe)
results[i].PartNumber = partFromRecipe;
if (partFromRecipe != "ENG")
{
sql.Append(" SELECT ").
Append(" count(*) AS my_count ").
Append(" FROM IRMNSPC.dbo.part_dat ").
Append(" WHERE f_name = @part ");
parameters.Clear();
parameters.Add(new Tuple<string, string>("@part", string.Concat("'", partFromRecipe, "'")));
check = SQLDatabase.ExecuteReader(sql, parameters, columns: 1, isG4Wafers: true, isIrmnSpc: false);
if (check.ElementAt(0).Value[0].ToString() == "0")
{
partFromRecipe = "ENG";
results[i].PartNumber = partFromRecipe;
}
}
}
lastPartFromRecipe = partFromRecipe;
}
}
return results;
}
internal static string GetSid(List<PreRunInfo> preRunInfo, bool isMappedPart, IScopeInfo scopeInfo, List<string> tags)
{
string result = string.Empty;
if (preRunInfo.Any())
{
result = tags[0];
}
return result;
}
}
}

View File

@ -0,0 +1,104 @@
using Adaptation.Shared;
using Adaptation.Shared.Metrology;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Adaptation.Metrology
{
internal class MET08THFTIRQS408M
{
internal static Dictionary<int, List<object>> GetPreRunInfo(Logistics logistics, EventName eventName)
{
//2019-12-27 - 001
Dictionary<int, List<object>> results;
StringBuilder sql = new StringBuilder();
sql.Append(" SELECT ").
Append(" wafer_id, [run number], recipe, [part number], date, pocket_number, wafer_lot, [satellite group], ISNULL(( ").
Append(" SELECT max(startstamp) ").
Append(" FROM G4Wafers_01.dbo.ToolTimeInfo ").
Append(" WHERE (lot = @mid OR lot = @midSubstring) ").
Append(" ), date) startstamp ").
Append(" FROM G4Wafers_01.dbo.[prerun info] ").
Append(" WHERE (wafer_id = @mid OR [run number] = @mid) ").
Append(" ORDER by date ");
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>
{
new Tuple<string, string>("@midSubstring", string.Concat("'", logistics.MID.Substring(0, logistics.MID.Length - 2), "'")),
new Tuple<string, string>("@mid", string.Concat("'", logistics.MID, "'"))
};
results = SQLDatabase.ExecuteReader(sql, parameters, columns: 9, isG4Wafers: true, isIrmnSpc: false);
return results;
}
internal static List<PreRunInfo> Verify(EventName eventName, List<PreRunInfo> results)
{
//2019-12-28 - 004
if (results.Any())
{
string partFromRecipe;
Dictionary<int, List<object>> check;
StringBuilder sql = new StringBuilder();
string lastPartFromRecipe = string.Empty;
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>();
for (int i = 0; i < results.Count; i++)
{
partFromRecipe = results[i].Recipe;
if (string.IsNullOrEmpty(lastPartFromRecipe) || partFromRecipe != lastPartFromRecipe)
{
// re-format recipe name by extracting middle part of it
if ((!partFromRecipe.ToUpper().StartsWith("PROD")) &&
(!partFromRecipe.ToUpper().StartsWith("MAMD")) &&
(!partFromRecipe.ToUpper().StartsWith("QUAL")) &&
(!partFromRecipe.ToUpper().StartsWith("ENGR")) &&
(!partFromRecipe.ToUpper().StartsWith("ANKO")) &&
(!partFromRecipe.ToUpper().StartsWith("U")))
partFromRecipe = "ENG";
else if (partFromRecipe.Split('-').Length == 3) // recipe name has 3 parts
partFromRecipe = partFromRecipe.Split('-')[0].Trim() + "-" + partFromRecipe.Split('-')[1].Trim(); // middle part of recipe name
else if (partFromRecipe.Split('-').Length == 2) // recipe name has 2 parts
partFromRecipe = partFromRecipe.Split('-')[0].Trim(); // first part of recipe name
else if (partFromRecipe.Split('_').Length == 3)
partFromRecipe = partFromRecipe.Split('_')[1].Trim(); // middle part of recipe name
else if (partFromRecipe.Split('_').Length == 2) // recipe name has 2 parts
partFromRecipe = partFromRecipe.Split('_')[0].Trim(); // first part of recipe name
if (results[i].PartNumber != partFromRecipe)
results[i].PartNumber = partFromRecipe;
if (partFromRecipe != "ENG")
{
sql.Append(" SELECT ").
Append(" count(*) AS my_count ").
Append(" FROM IRMNSPC.dbo.part_dat ").
Append(" WHERE f_name = @part ");
parameters.Clear();
parameters.Add(new Tuple<string, string>("@part", string.Concat("'", partFromRecipe, "'")));
check = SQLDatabase.ExecuteReader(sql, parameters, columns: 1, isG4Wafers: true, isIrmnSpc: false);
if (check.ElementAt(0).Value[0].ToString() == "0")
{
partFromRecipe = "ENG";
results[i].PartNumber = partFromRecipe;
}
}
}
lastPartFromRecipe = partFromRecipe;
}
}
return results;
}
internal static string GetSid(List<PreRunInfo> preRunInfo, bool isMappedPart, IScopeInfo scopeInfo, List<string> tags)
{
string result = string.Empty;
if (preRunInfo.Any())
{
result = tags[0];
}
return result;
}
}
}

View File

@ -0,0 +1,104 @@
using Adaptation.Shared;
using Adaptation.Shared.Metrology;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Adaptation.Metrology
{
internal class MET08THFTIRSTRATUS
{
internal static Dictionary<int, List<object>> GetPreRunInfo(Logistics logistics, EventName eventName)
{
//2019-12-27 - 001
Dictionary<int, List<object>> results;
StringBuilder sql = new StringBuilder();
sql.Append(" SELECT ").
Append(" wafer_id, [run number], recipe, [part number], date, pocket_number, wafer_lot, [satellite group], ISNULL(( ").
Append(" SELECT max(startstamp) ").
Append(" FROM G4Wafers_01.dbo.ToolTimeInfo ").
Append(" WHERE (lot = @mid OR lot = @midSubstring) ").
Append(" ), date) startstamp ").
Append(" FROM G4Wafers_01.dbo.[prerun info] ").
Append(" WHERE (wafer_id = @mid OR [run number] = @mid) ").
Append(" ORDER by date ");
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>
{
new Tuple<string, string>("@midSubstring", string.Concat("'", logistics.MID.Substring(0, logistics.MID.Length - 2), "'")),
new Tuple<string, string>("@mid", string.Concat("'", logistics.MID, "'"))
};
results = SQLDatabase.ExecuteReader(sql, parameters, columns: 9, isG4Wafers: true, isIrmnSpc: false);
return results;
}
internal static List<PreRunInfo> Verify(EventName eventName, List<PreRunInfo> results)
{
//2019-12-28 - 004
if (results.Any())
{
string partFromRecipe;
Dictionary<int, List<object>> check;
StringBuilder sql = new StringBuilder();
string lastPartFromRecipe = string.Empty;
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>();
for (int i = 0; i < results.Count; i++)
{
partFromRecipe = results[i].Recipe;
if (string.IsNullOrEmpty(lastPartFromRecipe) || partFromRecipe != lastPartFromRecipe)
{
// re-format recipe name by extracting middle part of it
if ((!partFromRecipe.ToUpper().StartsWith("PROD")) &&
(!partFromRecipe.ToUpper().StartsWith("MAMD")) &&
(!partFromRecipe.ToUpper().StartsWith("QUAL")) &&
(!partFromRecipe.ToUpper().StartsWith("ENGR")) &&
(!partFromRecipe.ToUpper().StartsWith("ANKO")) &&
(!partFromRecipe.ToUpper().StartsWith("U")))
partFromRecipe = "ENG";
else if (partFromRecipe.Split('-').Length == 3) // recipe name has 3 parts
partFromRecipe = partFromRecipe.Split('-')[0].Trim() + "-" + partFromRecipe.Split('-')[1].Trim(); // middle part of recipe name
else if (partFromRecipe.Split('-').Length == 2) // recipe name has 2 parts
partFromRecipe = partFromRecipe.Split('-')[0].Trim(); // first part of recipe name
else if (partFromRecipe.Split('_').Length == 3)
partFromRecipe = partFromRecipe.Split('_')[1].Trim(); // middle part of recipe name
else if (partFromRecipe.Split('_').Length == 2) // recipe name has 2 parts
partFromRecipe = partFromRecipe.Split('_')[0].Trim(); // first part of recipe name
if (results[i].PartNumber != partFromRecipe)
results[i].PartNumber = partFromRecipe;
if (partFromRecipe != "ENG")
{
sql.Append(" SELECT ").
Append(" count(*) AS my_count ").
Append(" FROM IRMNSPC.dbo.part_dat ").
Append(" WHERE f_name = @part ");
parameters.Clear();
parameters.Add(new Tuple<string, string>("@part", string.Concat("'", partFromRecipe, "'")));
check = SQLDatabase.ExecuteReader(sql, parameters, columns: 1, isG4Wafers: true, isIrmnSpc: false);
if (check.ElementAt(0).Value[0].ToString() == "0")
{
partFromRecipe = "ENG";
results[i].PartNumber = partFromRecipe;
}
}
}
lastPartFromRecipe = partFromRecipe;
}
}
return results;
}
internal static string GetSid(List<PreRunInfo> preRunInfo, bool isMappedPart, IScopeInfo scopeInfo, List<string> tags)
{
string result = string.Empty;
if (preRunInfo.Any())
{
result = tags[0];
}
return result;
}
}
}

View File

@ -0,0 +1,54 @@
using Adaptation.Shared;
namespace Adaptation.Si
{
public class PreRunInfo
{
public string MID { get; private set; }
public string RunNumber { get; private set; }
public string Recipe { get; private set; }
public string PartNumber { get; internal set; }
public string Date { get; private set; }
public string PocketNumber { get; private set; }
public string WaferLot { get; private set; }
public string SatelliteGroup { get; private set; }
public string StartStamp { get; private set; }
public Logistics Logistics { get; private set; }
public PreRunInfo(Logistics logistics, object partNumber)
{
MID = logistics.MID;
RunNumber = string.Empty;
Recipe = string.Empty;
PartNumber = partNumber.ToString();
Date = logistics.DateTimeFromSequence.ToString();
PocketNumber = "00";
WaferLot = string.Empty;
SatelliteGroup = string.Empty;
StartStamp = logistics.DateTimeFromSequence.ToString();
Logistics = logistics;
}
public PreRunInfo(Logistics logistics, object mID, object runNumber, object recipe, object partNumber, object date, object pocketNumber, object waferLot, object satelliteGroup, object startStamp)
{
MID = mID.ToString();
RunNumber = runNumber.ToString();
Recipe = recipe.ToString();
PartNumber = partNumber.ToString();
Date = date.ToString();
PocketNumber = pocketNumber.ToString();
WaferLot = waferLot.ToString();
SatelliteGroup = satelliteGroup.ToString();
StartStamp = startStamp.ToString();
Logistics = logistics;
}
public override string ToString()
{
return string.Concat(MID, " - ", RunNumber, " - ", Recipe, " - ", PartNumber, " - ", Date, " - ", PocketNumber, " - ", WaferLot, " - ", SatelliteGroup, " - ", StartStamp);
}
}
}

View File

@ -0,0 +1,208 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading;
namespace Adaptation.Si
{
public class SQLDatabase
{
private static string _ConnectionStringIrmnSpc;
private static string _ConnectionStringG4Wafers;
public static void SetConnectionStringIrmnSpc(string connectionString)
{
_ConnectionStringIrmnSpc = connectionString;
}
public static void SetConnectionStringG4Wafers(string connectionString)
{
_ConnectionStringG4Wafers = connectionString;
}
public static Dictionary<string, List<object>> ExecuteReader(StringBuilder rawSql, List<Tuple<string, string>> parameters, List<Tuple<string, int>> columns, bool isG4Wafers, bool isIrmnSpc)
{
Dictionary<string, List<object>> results = new Dictionary<string, List<object>>();
foreach (var item in parameters)
rawSql.Replace(item.Item1, item.Item2);
string sql = rawSql.ToString();
if (sql.Contains("@"))
throw new Exception("Invalid query (a parameter didn't get populated)!");
if (sql.Contains("<"))
throw new Exception("Invalid query (a parameter didn't get populated)!");
if (sql.Contains(">"))
throw new Exception("Invalid query (a parameter didn't get populated)!");
if (sql.Contains("!"))
throw new Exception("Invalid query (a parameter didn't get populated)!");
foreach (var item in columns)
results.Add(item.Item1, new List<object>());
string connectionString;
if (isG4Wafers && isIrmnSpc)
throw new Exception();
else if (isG4Wafers)
connectionString = _ConnectionStringG4Wafers;
else if (isIrmnSpc)
connectionString = _ConnectionStringIrmnSpc;
else
throw new Exception();
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
using (SqlCommand sqlComm = new SqlCommand(sql.ToString(), conn))
{
using (SqlDataReader sqlReader = sqlComm.ExecuteReader())
{
while (sqlReader.Read())
{
foreach (var item in columns)
results[item.Item1].Add(sqlReader.GetSqlValue(item.Item2));
}
}
}
}
return results;
}
public static Dictionary<int, List<object>> ExecuteReader(StringBuilder rawSql, List<Tuple<string, string>> parameters, int columns, bool isG4Wafers, bool isIrmnSpc)
{
Dictionary<int, List<object>> results = new Dictionary<int, List<object>>();
foreach (var item in parameters)
rawSql.Replace(item.Item1, item.Item2);
string sql = rawSql.ToString();
if (sql.Contains("@"))
throw new Exception("Invalid query (a parameter didn't get populated)!");
if (sql.Contains("{"))
throw new Exception("Invalid query (a parameter didn't get populated)!");
if (sql.Contains("}"))
throw new Exception("Invalid query (a parameter didn't get populated)!");
if (sql.Contains("!"))
throw new Exception("Invalid query (a parameter didn't get populated)!");
string connectionString;
if (isG4Wafers && isIrmnSpc)
throw new Exception();
else if (isG4Wafers)
connectionString = _ConnectionStringG4Wafers;
else if (isIrmnSpc)
connectionString = _ConnectionStringIrmnSpc;
else
throw new Exception();
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
using (SqlCommand sqlComm = new SqlCommand(sql.ToString(), conn))
{
using (SqlDataReader sqlReader = sqlComm.ExecuteReader())
{
while (sqlReader.Read())
{
for (int i = 0; i < columns; i++)
{
if (!results.ContainsKey(i))
results.Add(i, new List<object>());
results[i].Add(sqlReader.GetSqlValue(i));
}
}
}
}
}
return results;
}
private static int? CheckDisableHistory(string sid)
{
int? result = null;
if (sid != "1")
{
object exits;
StringBuilder sql = new StringBuilder();
sql.Append("SELECT ");
sql.Append("hs.SID [SID] ");
sql.Append("FROM [IRMNSPC].[dbo].[HIST_DISABLE] hs ");
sql.Append("WHERE hs.SID = '").Append(sid).Append("' ");
using (SqlConnection conn = new SqlConnection(_ConnectionStringIrmnSpc))
{
conn.Open();
using (SqlCommand sqlComm = new SqlCommand(sql.ToString(), conn))
exits = sqlComm.ExecuteScalar();
}
if (exits is null)
{
sql.Clear();
sql.Append("INSERT INTO HIST_DISABLE VALUES ('").Append(sid).Append("' , 0) ");
using (SqlConnection conn = new SqlConnection(_ConnectionStringIrmnSpc))
{
conn.Open();
using (SqlCommand sqlComm = new SqlCommand(sql.ToString(), conn))
result = sqlComm.ExecuteNonQuery();
}
}
}
return result;
}
public static object ExecuteScalar(string sql, bool isMappedPart, double totalSecondsSinceLastWriteTime, Tuple<string, string> replace, bool selectForSID, bool isG4Wafers, bool isIrmnSpc)
{
object result;
if (sql.Contains("@"))
throw new Exception("Invalid query (a parameter didn't get populated)!");
List<object> results = new List<object>();
for (int i = 1; i < 15; i++)
{
string connectionString;
if (isG4Wafers && isIrmnSpc)
throw new Exception();
else if (isG4Wafers)
connectionString = _ConnectionStringG4Wafers;
else if (isIrmnSpc)
connectionString = _ConnectionStringIrmnSpc;
else
throw new Exception();
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
using (SqlCommand sqlComm = new SqlCommand(sql, conn))
{
using (SqlDataReader sqlReader = sqlComm.ExecuteReader())
{
while (sqlReader.Read())
results.Add(sqlReader.GetSqlValue(0));
}
}
}
if (results.Any())
break;
if ((i > 10 && !(replace is null)) || (!isMappedPart && totalSecondsSinceLastWriteTime > 1800) || totalSecondsSinceLastWriteTime > 432000 && sql.Contains(replace.Item1)) //30 minutes and 5 days
{
sql = sql.Replace(replace.Item1, replace.Item2);
continue;
}
if (!isMappedPart)
break;
for (int j = 1; j < 60; j++)
Thread.Sleep(500);
}
if (!isMappedPart && !results.Any())
result = "-";
else if (isMappedPart && !results.Any())
throw new Exception("Didn't find a matching record!");
else if (isMappedPart && results.Count > 1)
throw new Exception("Found more than one matching record!");
else
{
result = results[0];
if (selectForSID && results.Count() == 1)
{
int? exits = CheckDisableHistory(result.ToString());
{ }
}
}
return result;
}
}
}

View File

@ -0,0 +1,945 @@
using Adaptation.Shared;
using Adaptation.Shared.Metrology;
using Infineon.Yoda;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Xml;
namespace Adaptation.Si
{
internal class Transport
{
private static object _IfxTransport;
private static ConfigData _ConfigData;
private static Dictionary<string, List<Parameters>> _Parameters;
internal static void Initialize(ConfigData configData)
{
_IfxTransport = null;
_ConfigData = configData;
_Parameters = new Dictionary<string, List<Parameters>>();
}
internal static List<string> Setup(bool useSleep, bool setIfxTransport, bool setParameters)
{
List<string> results = new List<string>();
if (useSleep)
{
for (int i = 1; i < 50; i++)
Thread.Sleep(500);
}
if (setIfxTransport)
{
results.Add(string.Concat("IfxTransport Subject: ", _ConfigData.IfxSubject));
IfxDoc ifxDoc = new IfxDoc();
ifxDoc.Add(IfxConst.SUBJECT_PREFIX, _ConfigData.IfxSubjectPrefix);
ifxDoc.Add(IfxConst.IFX_CHANNEL, _ConfigData.IfxChannel);
ifxDoc.Add(IfxConst.IFX_CONFIGURATION_LOCATION, _ConfigData.IfxConfigurationLocation);
ifxDoc.Add(IfxConst.IFX_CONFIGURATION_LOCATION_LOCAL_COPY, _ConfigData.IfxConfigurationLocationLocalCopy);
results.Add(string.Concat("IfxTransport Config: ", ifxDoc));
_IfxTransport = new IfxTransport();
IfxTransport ifxTransport = (IfxTransport)_IfxTransport;
ifxTransport.Create(ifxDoc);
if (useSleep)
{
for (int i = 1; i < 10; i++)
Thread.Sleep(500);
}
results.Add(string.Concat("IfxTransport Current Daemon: ", ifxTransport.CurrentDaemon));
results.Add(string.Concat("IfxTransport Current Network: ", ifxTransport.CurrentNetwork));
results.Add(string.Concat("IfxTransport Current Service: ", ifxTransport.CurrentService));
results.Add(string.Concat("IfxTransport Current PoolName: ", ifxTransport.CurrentPoolName));
}
if (setParameters)
{
try { _Parameters = GetParameters(); } catch { /* Dev doesn't have this table */ }
}
return results;
}
private static Dictionary<string, List<Parameters>> GetParameters()
{
Dictionary<string, List<Parameters>> results = new Dictionary<string, List<Parameters>>();
List<Parameters> parameters = Parameters.GetParameters();
string iqsName;
foreach (var parameter in parameters)
{
iqsName = string.Concat(parameter.Iqs_name);
if (!results.ContainsKey(iqsName))
results.Add(iqsName, new List<Parameters>());
results[iqsName].Add(parameter);
}
return results;
}
internal static bool IsMappedPart(List<string> parts)
{
List<string> check = (from l in parts where _ConfigData.MappedParts.Contains(l) select l).ToList();
return check.Any();
}
internal static List<string> GetDistinctParts(List<PreRunInfo> preRunInfo)
{
List<string> results = new List<string>();
foreach (var item in preRunInfo)
results.Add(item.PartNumber);
results = results.Distinct().ToList();
return results;
}
internal static Dictionary<Test, IScopeInfo> GetScopeInfoCollections(ILogic logic, ConfigData configData, Dictionary<Test, Dictionary<string, List<string>>> rawData, Dictionary<Test, List<int>> tests)
{
Dictionary<Test, IScopeInfo> results = new Dictionary<Test, IScopeInfo>();
int min;
int max;
IScopeInfo scopeInfo;
foreach (var element in rawData)
{
min = tests[element.Key].Min();
max = tests[element.Key].Max() + 1;
scopeInfo = new ScopeInfo(logic, configData, element.Key);
results.Add(element.Key, scopeInfo);
}
return results;
}
internal static ExtractResult MergeAndMaybeSort(ExtractResult extractResult, List<PreRunInfo> preRunInfo, Dictionary<Test, List<int>> tests)
{
if (!preRunInfo.Any())
throw new Exception();
if (tests.ElementAt(0).Key != Test.AFMRoughness && tests.ElementAt(0).Key != Test.UV)
{
int min;
int max;
List<PreRunInfo> matchingPreRunInfo;
Dictionary<Enum, List<string>> keyValuePairs;
foreach (var testKeyValuePair in tests)
{
min = testKeyValuePair.Value.Min();
max = testKeyValuePair.Value.Max() + 1;
for (int i = min; i < max; i++)
{
switch (testKeyValuePair.Key)
{
default:
if (preRunInfo.Count != 1)
throw new Exception();
else
matchingPreRunInfo = preRunInfo;
break;
}
if (matchingPreRunInfo.Count > 1)
throw new Exception();
for (int g = 1; g < 3; g++)
{
switch (g)
{
case 1: keyValuePairs = extractResult.DatabaseHeaders; break;
case 2: keyValuePairs = extractResult.DatabaseDetails; break;
default: throw new Exception();
}
foreach (var element in keyValuePairs)
{
if (matchingPreRunInfo.Count == 0)
element.Value[i] = string.Empty;
else
{
switch (element.Key)
{
case Column.SID: break;
//case "MID": element.Value[i] = matchingPreRunInfo[0].MID; break;
case Column.Lot: element.Value[i] = matchingPreRunInfo[0].RunNumber; break;
case Column.Recipe: element.Value[i] = matchingPreRunInfo[0].Recipe; break;
case Column.Part: element.Value[i] = matchingPreRunInfo[0].PartNumber; break;
case Column.Date: element.Value[i] = matchingPreRunInfo[0].Date; break;
case Column.Wafer_ID: element.Value[i] = matchingPreRunInfo[0].PocketNumber; break;
case Column.WaferPocket_Candela: element.Value[i] = matchingPreRunInfo[0].PocketNumber; break;
case Column.Wafer_Scribe: element.Value[i] = matchingPreRunInfo[0].WaferLot; break;
//case "SatelliteGroup": element.Value[i] = matchingPreRunInfo[0].SatelliteGroup; break;
//case "StartStamp": element.Value[i] = matchingPreRunInfo[0].StartStamp; break;
default: throw new Exception();
}
}
}
}
}
}
}
if (tests.ElementAt(0).Key == Test.CandelaKlarfDC || tests.ElementAt(0).Key == Test.CandelaLaser || tests.ElementAt(0).Key == Test.CandelaPSL || tests.ElementAt(0).Key == Test.CandelaVerify)
{
int min;
int max;
List<int> sortIndeices;
List<string> singleColumnSortedValues;
List<string> singleColumnBeforeSortValues;
Dictionary<Enum, List<string>> valuesCollection;
foreach (var testKeyValuePair in tests)
{
if (testKeyValuePair.Key == Test.CandelaKlarfDC || testKeyValuePair.Key == Test.CandelaLaser || testKeyValuePair.Key == Test.CandelaPSL || testKeyValuePair.Key == Test.CandelaVerify)
{
min = testKeyValuePair.Value.Min();
max = testKeyValuePair.Value.Max() + 1;
sortIndeices = new List<int>();
singleColumnBeforeSortValues = (from l in extractResult.DatabaseDetails[Column.WaferPocket_Candela] select l).ToList();
singleColumnSortedValues = (from l in extractResult.DatabaseDetails[Column.WaferPocket_Candela] orderby !string.IsNullOrEmpty(l), l select l).ToList();
for (int i = min; i < max; i++)
sortIndeices.Add(singleColumnBeforeSortValues.IndexOf(singleColumnSortedValues[i]));
valuesCollection = new Dictionary<Enum, List<string>>();
foreach (var element in extractResult.DatabaseDetails)
{
valuesCollection.Add(element.Key, new List<string>());
for (int i = min; i < max; i++)
valuesCollection[element.Key].Add(extractResult.DatabaseDetails[element.Key][i]);
element.Value.Clear();
for (int i = min; i < max; i++)
extractResult.DatabaseDetails[element.Key].Add(valuesCollection[element.Key][sortIndeices[i]]);
}
valuesCollection = new Dictionary<Enum, List<string>>();
foreach (var element in extractResult.Details)
{
valuesCollection.Add(element.Key, new List<string>());
for (int i = min; i < max; i++)
valuesCollection[element.Key].Add(extractResult.Details[element.Key][i]);
element.Value.Clear();
for (int i = min; i < max; i++)
extractResult.Details[element.Key].Add(valuesCollection[element.Key][sortIndeices[i]]);
}
valuesCollection = new Dictionary<Enum, List<string>>();
foreach (var element in extractResult.Parameters)
{
valuesCollection.Add(element.Key, new List<string>());
for (int i = min; i < max; i++)
valuesCollection[element.Key].Add(extractResult.Parameters[element.Key][i]);
element.Value.Clear();
for (int i = min; i < max; i++)
extractResult.Parameters[element.Key].Add(valuesCollection[element.Key][sortIndeices[i]]);
}
}
}
}
return extractResult;
}
private static Dictionary<Column, List<PartParameters>> GetPartParameters(string partNumber, bool isMappedPart)
{
Dictionary<Column, List<PartParameters>> results = new Dictionary<Column, List<PartParameters>>();
List<PartParameters> partParameters = PartParameters.GetPartParameters(partNumber);
foreach (var partParameter in partParameters)
{
if (Convert.IsDBNull(partParameter.Enum) || !Enum.TryParse(partParameter.Enum.ToString(), out Column column))
{
if (isMappedPart && partParameter.Crit_to_ship.ToString() == "CRIT")
throw new Exception();
else
continue;
}
else
{
if (!results.ContainsKey(column))
results.Add(column, new List<PartParameters>());
results[column].Add(partParameter);
}
}
return results;
}
private static List<PartHistory> GetPartHistory(string partNumber)
{
List<PartHistory> results = PartHistory.GetPartHistory(partNumber);
return results;
}
private static DataKeys GetDataKeys(Dictionary<Enum, List<string>> columns, Logistics logistics, Dictionary<Enum, List<int>> ignoreIndeices, DataKeys dataKeys, int r, bool forParameter)
{
DataKeys result = dataKeys;
Column key;
if (!forParameter)
{
key = Column.Employee;
if (!columns.ContainsKey(key))
result.Employee = "AUTO";
else
result.Employee = columns[key][r];
}
key = Column.WaferPosition_BV;
if (columns.ContainsKey(key) && (!ignoreIndeices.ContainsKey(key) || !ignoreIndeices[key].Contains(r)))
result.WaferPosition = columns[key][r];
key = Column.WaferPosition_CV;
if (columns.ContainsKey(key) && (!ignoreIndeices.ContainsKey(key) || !ignoreIndeices[key].Contains(r)))
result.WaferPosition = columns[key][r];
key = Column.WaferPosition_Hall;
if (columns.ContainsKey(key) && (!ignoreIndeices.ContainsKey(key) || !ignoreIndeices[key].Contains(r)))
result.WaferPosition = columns[key][r];
key = Column.WaferPosition_PR;
if (columns.ContainsKey(key) && (!ignoreIndeices.ContainsKey(key) || !ignoreIndeices[key].Contains(r)))
result.WaferPosition = columns[key][r];
//
key = Column.Wafer_Region;
if (columns.ContainsKey(key) && (!ignoreIndeices.ContainsKey(key) || !ignoreIndeices[key].Contains(r)))
result.WaferRegion = columns[key][r];
//
key = Column.Wafer_Scribe;
if (columns.ContainsKey(key) && (!ignoreIndeices.ContainsKey(key) || !ignoreIndeices[key].Contains(r)))
result.WaferScribe = columns[key][r];
//
key = Column.X_Coord;
if (columns.ContainsKey(key) && (!ignoreIndeices.ContainsKey(key) || !ignoreIndeices[key].Contains(r)))
result.X = columns[key][r];
//
key = Column.Y_Coord;
if (columns.ContainsKey(key) && (!ignoreIndeices.ContainsKey(key) || !ignoreIndeices[key].Contains(r)))
result.Y = columns[key][r];
return result;
}
private static ExtractorKeys GetExtractorKeys(Dictionary<Enum, List<string>> columns, Logistics logistics, Dictionary<Enum, List<int>> ignoreIndeices, ExtractorKeys extractorKeys, int r, bool forParameter)
{
ExtractorKeys result = extractorKeys;
Column key;
key = Column.Lot;
if (columns.ContainsKey(key) && (!ignoreIndeices.ContainsKey(key) || !ignoreIndeices[key].Contains(r)))
result.Lot = columns[key][r];
//
key = Column.Part;
if (columns.ContainsKey(key) && (!ignoreIndeices.ContainsKey(key) || !ignoreIndeices[key].Contains(r)))
result.Part = columns[key][r];
//
key = Column.Process;
if (columns.ContainsKey(key) && (!ignoreIndeices.ContainsKey(key) || !ignoreIndeices[key].Contains(r)))
result.Process = columns[key][r];
//
key = Column.Recipe;
if (columns.ContainsKey(key) && (!ignoreIndeices.ContainsKey(key) || !ignoreIndeices[key].Contains(r)))
result.Recipe = columns[key][r];
//
key = Column.Wafer_ID;
if (columns.ContainsKey(key) && (!ignoreIndeices.ContainsKey(key) || !ignoreIndeices[key].Contains(r)))
result.WaferID = columns[key][r];
key = Column.Denton_Gun_Pocket;
if (columns.ContainsKey(key) && (!ignoreIndeices.ContainsKey(key) || !ignoreIndeices[key].Contains(r)))
result.WaferID = columns[key][r];
key = Column.WaferPocket_Candela;
if (columns.ContainsKey(key) && (!ignoreIndeices.ContainsKey(key) || !ignoreIndeices[key].Contains(r)))
result.WaferID = columns[key][r];
key = Column.WaferPocket_Warp;
if (columns.ContainsKey(key) && (!ignoreIndeices.ContainsKey(key) || !ignoreIndeices[key].Contains(r)))
result.WaferID = columns[key][r];
return result;
}
private static string GetUnit(string columnDiplayName, string columnDatabaseName)
{
string result;
if (_Parameters.ContainsKey(columnDiplayName) && !(_Parameters[columnDiplayName][0].Units is null) && !string.IsNullOrEmpty(_Parameters[columnDiplayName][0].Units.ToString()))
result = _Parameters[columnDiplayName][0].Units.ToString();
else if (_Parameters.ContainsKey(columnDatabaseName) && !(_Parameters[columnDatabaseName][0].Units is null) && !string.IsNullOrEmpty(_Parameters[columnDatabaseName][0].Units.ToString()))
result = _Parameters[columnDatabaseName][0].Units.ToString();
else
result = "xx";
return result;
}
private static double? GetLsl(PartParameters partParameters)
{
if (!(partParameters.Lsl is null) && !string.IsNullOrEmpty(partParameters.Lsl.ToString()))
{
double.TryParse(partParameters.Lsl.ToString(), out double lsl);
return lsl;
}
return null;
}
private static double? GetUsl(PartParameters partParameters)
{
if (!(partParameters.Usl is null) && !string.IsNullOrEmpty(partParameters.Usl.ToString()))
{
double.TryParse(partParameters.Usl.ToString(), out double usl);
return usl;
}
return null;
}
private static double? GetTsl(PartParameters partParameters)
{
if (!(partParameters.Target is null) && !string.IsNullOrEmpty(partParameters.Target.ToString()))
{
double.TryParse(partParameters.Target.ToString(), out double tsl);
return tsl;
}
return null;
}
private static Dictionary<string, List<string>> GetKeyValuePairs(Logistics logistics, ExtractResult extractResult, string xml2Text)
{
Dictionary<string, List<string>> results = new Dictionary<string, List<string>>();
bool documentKeys = false;
bool fieldParameter = false;
bool isFirstParmeter = true;
bool documnetParameter = false;
string elementName = string.Empty;
const string elementField = "Field";
bool fieldParameterNameKeys = false;
bool fieldParameterNameValue = false;
string attributeNameValue = string.Empty;
const string elementDocument = "Document";
string parameterAttributeNameValue = string.Empty;
string keyOrSettingAttributeNameValue = string.Empty;
string parameterKeyAttributeNameValue = string.Empty;
const string attributeNameValueParameter = "PARAMETER";
const string attributeNameValueParameterName = "PARAMETERNAME";
StringReader stringReader = new StringReader(xml2Text);
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings { IgnoreWhitespace = true };
XmlReader xmlReader = XmlReader.Create(stringReader, xmlReaderSettings);
while (xmlReader.Read())
{
switch (xmlReader.NodeType)
{
case XmlNodeType.Element:
elementName = xmlReader.Name;
if (elementName == elementDocument || elementName == elementField)
{
while (xmlReader.HasAttributes && xmlReader.MoveToNextAttribute())
{
if (xmlReader.Name == "name")
{
attributeNameValue = xmlReader.Value;
if (!documentKeys && attributeNameValue == "KEYS")
documentKeys = true;
else if (documentKeys && !fieldParameter && elementName == elementField && attributeNameValue != attributeNameValueParameter)
keyOrSettingAttributeNameValue = attributeNameValue;
else if (documentKeys && !fieldParameter && elementName == elementField && attributeNameValue == attributeNameValueParameter)
fieldParameter = true;
else if (documentKeys && fieldParameter && elementName == elementDocument && attributeNameValue == attributeNameValueParameter && !documnetParameter)
documnetParameter = true;
else if (documentKeys && fieldParameter && documnetParameter && elementName == elementField && attributeNameValue == attributeNameValueParameterName && string.IsNullOrEmpty(parameterAttributeNameValue))
{
xmlReader.Read(); xmlReader.Read(); parameterAttributeNameValue = xmlReader.Value;
}
else if (documentKeys && fieldParameter && documnetParameter && !string.IsNullOrEmpty(parameterAttributeNameValue))
{
if (elementName == elementDocument && attributeNameValue == attributeNameValueParameter)
{
parameterAttributeNameValue = string.Empty;
if (isFirstParmeter)
isFirstParmeter = false;
if (fieldParameterNameValue)
fieldParameterNameValue = false;
if (fieldParameterNameKeys)
fieldParameterNameKeys = false;
if (!string.IsNullOrEmpty(parameterKeyAttributeNameValue))
parameterKeyAttributeNameValue = string.Empty;
}
else if (attributeNameValue == "VALUE")
{
if (!fieldParameterNameValue)
fieldParameterNameValue = true;
if (fieldParameterNameKeys)
fieldParameterNameKeys = false;
}
else if (!fieldParameterNameKeys && attributeNameValue == "KEYS")
fieldParameterNameKeys = true;
else if (fieldParameterNameValue && fieldParameterNameKeys)
parameterKeyAttributeNameValue = attributeNameValue;
}
}
}
}
break;
case XmlNodeType.Text:
if (documentKeys && !documnetParameter)
{
if (!results.ContainsKey(keyOrSettingAttributeNameValue))
results.Add(keyOrSettingAttributeNameValue, new List<string>());
results[keyOrSettingAttributeNameValue].Add(xmlReader.Value);
}
else if (fieldParameter && documnetParameter && !string.IsNullOrEmpty(parameterAttributeNameValue) && fieldParameterNameValue && !fieldParameterNameKeys)
{
if (!results.ContainsKey(parameterAttributeNameValue))
results.Add(parameterAttributeNameValue, new List<string>());
results[parameterAttributeNameValue].Add(xmlReader.Value);
}
else if (fieldParameter && documnetParameter && !string.IsNullOrEmpty(parameterAttributeNameValue) && fieldParameterNameValue && fieldParameterNameKeys && isFirstParmeter)
{
if (!results.ContainsKey(parameterKeyAttributeNameValue))
results.Add(parameterKeyAttributeNameValue, new List<string>());
results[parameterKeyAttributeNameValue].Add(xmlReader.Value);
}
break;
}
}
return results;
}
internal static void SaveXmlAsHtml(Logistics logistics, ExtractResult extractResult, ConfigData configData, string xml2Text, string htmlDirectory, string file)
{
StringBuilder html = new StringBuilder();
html.Clear();
html.AppendLine("<html>");
html.AppendLine("<head>");
html.Append("<title>").Append(configData.GetEquipmentType()).AppendLine("</title>");
html.AppendLine("</head>");
html.AppendLine("<body>");
int count;
string htmlFile;
List<int> counts = new List<int>();
Array array = Enum.GetValues(typeof(Column));
List<string> allDataKeyNames = new List<string>();
List<string> allSettingNames = new List<string>();
List<string> logisticsColumns = new List<string>();
List<string> presentSettingNames = new List<string>();
List<string> allLDSParameterNames = new List<string>();
List<string> allExtractorKeyNames = new List<string>();
List<string> parameterOrRowColumns = new List<string>();
Dictionary<string, List<string>> keyValuePairs = GetKeyValuePairs(logistics, extractResult, xml2Text);
foreach (var item in typeof(Settings).GetProperties())
allSettingNames.Add(item.Name);
foreach (var item in typeof(ExtractorKeys).GetProperties())
allExtractorKeyNames.Add(item.Name);
foreach (var item in typeof(DataKeys).GetProperties())
allDataKeyNames.Add(item.Name);
foreach (var item in typeof(Parameter).GetProperties())
allLDSParameterNames.Add(item.Name);
Dictionary<string, Column> columnNames = new Dictionary<string, Column>();
foreach (Column column in array)
columnNames.Add(column.GetDiplayName(), column);
foreach (KeyValuePair<string, List<string>> element in keyValuePairs)
{
counts.Add(element.Value.Count());
if (columnNames.ContainsKey(element.Key))
parameterOrRowColumns.Add(element.Key);
else
{
if (Enum.TryParse(element.Key, out Description.RowColumn rowColumnTry))
parameterOrRowColumns.Add(rowColumnTry.ToString());
else
{
if (Enum.TryParse(element.Key, out Description.LogisticsColumn logisticsColumnTry))
logisticsColumns.Add(logisticsColumnTry.ToString());
else
{
if (allSettingNames.Contains(element.Key))
presentSettingNames.Add(element.Key);
else
{
if (allExtractorKeyNames.Contains(element.Key))
parameterOrRowColumns.Add(element.Key);
else
{
if (allDataKeyNames.Contains(element.Key))
parameterOrRowColumns.Add(element.Key);
else
{
if (allLDSParameterNames.Contains(element.Key))
parameterOrRowColumns.Add(element.Key);
else
throw new Exception();
}
}
}
}
}
}
}
count = counts.Max();
html.AppendLine("<table border = '2' CellPadding = '2' ");
html.Append(" id = '").Append(configData.GetEquipmentType()).AppendLine("' ");
html.Append(" title = '").Append("Missing \"Column\"(s)").AppendLine("' ");
html.AppendLine(">");
html.AppendLine("<tr>");
foreach (var element in keyValuePairs)
{
if (element.Value.Count() == 0 && parameterOrRowColumns.Contains(element.Key))
html.Append("<th nowrap>").Append(element.Key).AppendLine("</th>");
}
html.AppendLine("</tr>");
html.AppendLine("</table>");
//
html.AppendLine("<hr>");
//
html.AppendLine("<table border = '2' CellPadding = '2' ");
html.Append(" id = '").Append(configData.GetEquipmentType()).AppendLine("' ");
html.Append(" title = '").Append("\"settingNames\"(s)").AppendLine("' ");
html.AppendLine(">");
html.AppendLine("<tr>");
foreach (var item in presentSettingNames)
html.Append("<th nowrap>").Append(item).AppendLine("</th>");
html.AppendLine("</tr>");
html.AppendLine("<tr>");
foreach (var element in keyValuePairs)
{
if (presentSettingNames.Contains(element.Key))
{
if (string.IsNullOrEmpty(element.Value[0]))
html.AppendLine("<td nowrap>&nbsp;</td>");
else
html.Append("<td nowrap>").Append(element.Value[0]).AppendLine("</td>");
}
}
html.AppendLine("</tr>");
html.AppendLine("</table>");
//
html.AppendLine("<hr>");
//
html.AppendLine("<table border = '2' CellPadding = '2' ");
html.Append(" id = '").Append(configData.GetEquipmentType()).AppendLine("' ");
html.Append(" title = '").Append("\"LogisticsColumn\"(s)").AppendLine("' ");
html.AppendLine(">");
html.AppendLine("<tr>");
foreach (var item in logisticsColumns)
html.Append("<th nowrap>").Append(item).AppendLine("</th>");
html.AppendLine("</tr>");
for (int i = 0; i < 1; i++)
{
html.AppendLine("<tr>");
foreach (var element in keyValuePairs)
{
if (logisticsColumns.Contains(element.Key))
{
if (string.IsNullOrEmpty(element.Value[i]))
html.AppendLine("<td nowrap>&nbsp;</td>");
else
html.Append("<td nowrap>").Append(element.Value[i]).AppendLine("</td>");
}
}
}
html.AppendLine("</tr>");
html.AppendLine("</table>");
//
html.AppendLine("<hr>");
//
html.AppendLine("<table border = '2' CellPadding = '2' ");
html.Append(" id = '").Append(configData.GetEquipmentType()).AppendLine("' ");
html.Append(" title = '").Append("\"Parameter\"(s) Single-row").AppendLine("' ");
html.AppendLine(">");
html.AppendLine("<tr>");
foreach (var item in parameterOrRowColumns)
html.Append("<th nowrap>").Append(item).AppendLine("</th>");
html.AppendLine("</tr>");
for (int i = 0; i < 1; i++)
{
html.AppendLine("<tr>");
foreach (var element in keyValuePairs)
{
if (parameterOrRowColumns.Contains(element.Key))
{
if (element.Value.Count() > 1 || element.Value.Count() <= i || string.IsNullOrEmpty(element.Value[i]))
html.Append("<td nowrap>&nbsp;</td>");
else
{
if (!allExtractorKeyNames.Contains(element.Key) && element.Key != "SID")
html.Append("<td nowrap>").Append(element.Value[i]).AppendLine("</td>");
else
html.Append("<td nowrap style = \"background:yellow;\">").Append(element.Value[i]).AppendLine("</td>");
}
}
}
html.AppendLine("</tr>");
}
html.AppendLine("</table>");
//
html.AppendLine("<hr>");
//
html.AppendLine("<table border = '2' CellPadding = '2' ");
html.Append(" id = '").Append(configData.GetEquipmentType()).AppendLine("' ");
html.Append(" title = '").Append("\"Parameter\"(s) Multi-row").AppendLine("' ");
html.AppendLine(">");
html.AppendLine("<tr>");
foreach (var item in parameterOrRowColumns)
html.Append("<th nowrap>").Append(item).AppendLine("</th>");
html.AppendLine("</tr>");
for (int i = 0; i < count; i++)
{
html.AppendLine("<tr>");
foreach (var element in keyValuePairs)
{
if (parameterOrRowColumns.Contains(element.Key))
{
if (element.Value.Count() == 1 || element.Value.Count() <= i || string.IsNullOrEmpty(element.Value[i]))
html.Append("<td nowrap>&nbsp;</td>");
else
{
if (!allExtractorKeyNames.Contains(element.Key))
html.Append("<td nowrap>").Append(element.Value[i]).AppendLine("</td>");
else
html.Append("<td nowrap style = \"background:yellow;\">").Append(element.Value[i]).AppendLine("</td>");
}
}
}
html.AppendLine("</tr>");
}
html.AppendLine("</table>");
//
html.AppendLine("</body>");
html.AppendLine("</html>");
htmlFile = string.Concat(htmlDirectory, @"\", Path.GetFileNameWithoutExtension(file), ".html");
File.WriteAllText(htmlFile, html.ToString());
File.SetLastWriteTime(htmlFile, logistics.DateTimeFromSequence);
try { File.SetLastWriteTime(htmlFile, logistics.DateTimeFromSequence); } catch (Exception) { }
}
internal static Dictionary<string, IfxDoc> GetIfxDocs(Logistics logistics, ExtractResult extractResult, ConfigData configData, string writePath, Dictionary<Test, List<int>> tests, List<string> distinctParts, Dictionary<Test, IScopeInfo> scopeInfoCollections, bool isMappedPart)
{
Dictionary<string, IfxDoc> results = new Dictionary<string, IfxDoc>();
int c;
int min;
int max;
DATA data;
string sid;
string file;
IfxDoc ifxDoc;
string nullData;
string xml2Text;
IScopeInfo scopeInfo;
Parameter parameter;
string testAppendage;
string htmlDirectory;
List<PartHistory> partHistory;
List<int> rowCheck = new List<int>();
if (scopeInfoCollections.Any())
{
string xmlDirectory = string.Empty;
ExtendedParameter extendedParameter;
List<ExtendedParameter> extendedParameters;
Dictionary<Enum, List<int>> ignoreIndeices;
List<IfxDoc> parameters = new List<IfxDoc>();
List<ParameterCollection> parameterCollections = new List<ParameterCollection>();
string directory = string.Concat(writePath, @"\", configData.GetEquipmentType(), @"\Target");
Dictionary<Enum, List<string>> toolHeadersAndDatabaseHeadersCollection = extractResult.GetToolHeadersAndDatabaseHeadersCollection();
Dictionary<Enum, List<string>> toolDetailsAndDatabaseDetailsCollection = extractResult.GetToolDetailsAndDatabaseDetailsCollection();
if (logistics.NullData is null)
nullData = string.Empty;
else
nullData = logistics.NullData.ToString();
if (!distinctParts.Any())
partHistory = new List<PartHistory>();
else
{
if (distinctParts.Count != 1)
throw new Exception();
partHistory = GetPartHistory(distinctParts[0]);
}
if (!string.IsNullOrEmpty(writePath))
{
xmlDirectory = string.Concat(directory, @"\xml");
if (!Directory.Exists(xmlDirectory))
Directory.CreateDirectory(xmlDirectory);
}
foreach (var testKeyValuePair in tests)
{
if (isMappedPart && !partHistory.Any())
throw new Exception();
min = testKeyValuePair.Value.Min();
max = testKeyValuePair.Value.Max() + 1;
scopeInfo = scopeInfoCollections[testKeyValuePair.Key];
ignoreIndeices = extractResult.IgnoreIndeices[testKeyValuePair.Key];
data = new DATA(_ConfigData.IfxSubjectPrefix, logistics, scopeInfo, extractResult.DatabaseHeaders[Column.SID][min]);
if (toolHeadersAndDatabaseHeadersCollection.Any())
{
data.DataKeys = GetDataKeys(toolHeadersAndDatabaseHeadersCollection, logistics, ignoreIndeices, data.DataKeys, r: min, forParameter: false);
data.ExtractorKeys = GetExtractorKeys(toolHeadersAndDatabaseHeadersCollection, logistics, ignoreIndeices, data.ExtractorKeys, r: min, forParameter: false);
}
if (partHistory.Any())
{
if (!(partHistory[0].Process_flow is null) && !string.IsNullOrEmpty(partHistory[0].Process_flow.ToString()))
data.ExtractorKeys.ProcessFlow = partHistory[0].Process_flow.ToString();
}
c = 0;
parameterCollections.Clear();
foreach (KeyValuePair<Enum, List<string>> element in extractResult.Parameters)
{
rowCheck.Clear();
for (int r = min; r < max; r++)
{
if (ignoreIndeices[element.Key].Contains(r))
rowCheck.Add(r);
}
if (rowCheck.Count != (max - min))
{
extendedParameters = extractResult.ExtendedParameters[element.Key];
parameterCollections.Add(new ParameterCollection());
for (int r = min; r < max; r++)
{
if (!ignoreIndeices[element.Key].Contains(r))
{
extendedParameter = extendedParameters[r];
if (!extendedParameter.Ignore.Value && extendedParameter.CriticalToShip.HasValue && extendedParameter.CriticalToShip.Value)
{
parameter = new Parameter(logistics, extendedParameter);
if (toolDetailsAndDatabaseDetailsCollection.Any())
{
parameter.DataKeys = GetDataKeys(toolDetailsAndDatabaseDetailsCollection, logistics, ignoreIndeices, parameter.DataKeys, r, forParameter: true);
parameter.ExtractorKeys = GetExtractorKeys(toolDetailsAndDatabaseDetailsCollection, logistics, ignoreIndeices, parameter.ExtractorKeys, r, forParameter: true);
}
parameterCollections[c].Collection.Add(parameter);
}
}
}
c += 1;
}
}
if (parameterCollections.Any())
parameterCollections = (from l in parameterCollections where l.Collection.Any() select l).ToList();
if (parameterCollections.Any())
{
parameters.Clear();
foreach (var item in parameterCollections)
parameters.Add(item.GetIfxDoc());
ifxDoc = data.GetIfxDoc(parameters);
if (ifxDoc.GetFieldCount() == 0)
throw new Exception();
else
{
xml2Text = ifxDoc.GetAsXml2();
if (!(logistics.NullData is null) && !string.IsNullOrEmpty(nullData) && xml2Text.Contains(nullData))
throw new Exception();
if (xml2Text.Contains("<Field name=\"Lot\"><String>-</String>") && !(rowCheck is null))
throw new Exception();
if (!string.IsNullOrEmpty(writePath))
{
//testAppendage = string.Concat(" - ", (int)element.Key);
testAppendage = string.Concat(" - ", scopeInfo.FileNameWithoutExtension);
file = string.Concat(xmlDirectory, @"\", logistics.JobID, "_", logistics.Sequence, testAppendage, ".xml");
ifxDoc.Save(file, IfxConst.IfxDocFileType.Xml2, Overwrite: true);
if (logistics.TotalSecondsSinceLastWriteTimeFromSequence > 600)
{
try { File.SetLastWriteTime(file, logistics.DateTimeFromSequence); } catch (Exception) { }
}
htmlDirectory = string.Concat(directory, @"\html");
if (!Directory.Exists(htmlDirectory))
Directory.CreateDirectory(htmlDirectory);
SaveXmlAsHtml(logistics, extractResult, configData, xml2Text, htmlDirectory, file);
}
sid = extractResult.DatabaseHeaders[Column.SID][min];
if (!isMappedPart && results.ContainsKey(sid))
{
sid = string.Concat(sid, " ", DateTime.Now.Ticks.ToString());
Thread.Sleep(100);
}
results.Add(sid, ifxDoc);
}
}
}
}
return results;
}
internal static List<LDS2559Reply.DATA> SendIfxDocs(ILogic logic, ConfigData configData, bool isMappedPart, Dictionary<string, IfxDoc> ifxDocs)
{
List<LDS2559Reply.DATA> results = new List<LDS2559Reply.DATA>();
IfxDoc reply;
string replyString;
LDS2559Reply.DATA lds2559Data;
if (_IfxTransport is null)
{
bool setParameters = !_Parameters.Any();
List<string> messages = Setup(useSleep: false, setIfxTransport: true, setParameters: setParameters);
foreach (string message in messages)
{
System.Diagnostics.Debug.Print(message);
}
}
if (_IfxTransport is null)
throw new Exception();
else
{
IfxTransport ifxTransport = (IfxTransport)_IfxTransport;
if (isMappedPart && !(configData.EquipmentConnection is null))
{
DateTime dateTime = new DateTime(2019, 08, 25);
if (!(logic.Logistics is null) && logic.Logistics.DateTimeFromSequence >= dateTime)
{
foreach (var element in ifxDocs)
{
if (element.Value.GetFieldCount() == 0)
throw new Exception();
else
element.Value.Save(string.Concat(@"\\MESSV02ECC1.EC.LOCAL\EC_EAFLog\Production\IFXDocs\", configData.GetEquipmentType(), @"\", element.Key.Replace("*", string.Empty), ".xml"), IfxConst.IfxDocFileType.Xml2, Overwrite: true);
}
}
}
foreach (var element in ifxDocs)
{
if (element.Value.GetFieldCount() == 0)
throw new Exception();
else
{
element.Value.SendSubject = string.Concat(ifxTransport.SubjectPrefix, ".", _ConfigData.IfxSubject);
if (ifxTransport.SubjectPrefix.StartsWith("MES_"))
{
ifxTransport.Publish(element.Value, false, 60);
lds2559Data = null;
}
else
{
if (!isMappedPart)
lds2559Data = null;
else
{
IfxEnvelope ifxEnvelope = ifxTransport.SendRequest(element.Value, false, 60, IfxConst.IfxMessageType.Yoda);
if (ifxEnvelope is null)
throw new Exception("SendRequest timeout occurred");
else
{
reply = ifxEnvelope.ExtractDocument();
replyString = reply.ToString();
try { lds2559Data = new LDS2559Reply.DATA(reply); } catch (Exception) { lds2559Data = null; }
}
}
}
}
results.Add(lds2559Data);
}
}
return results;
}
internal static string EvaluateSendResults(ILogic logic, ConfigData configData, List<string> distinctParts, bool isMappedPart, List<LDS2559Reply.DATA> transportSendResults)
{
StringBuilder result = new StringBuilder();
string mID;
if (logic is null || logic.Logistics is null || logic.Logistics.MID is null)
mID = string.Empty;
else
mID = logic.Logistics.MID;
string part;
if (!distinctParts.Any())
part = string.Empty;
else
{
if (!isMappedPart)
part = distinctParts[0];
else
part = string.Concat(distinctParts[0], " (Mapped) ");
}
if (!transportSendResults.Any())
throw new Exception(string.Concat(configData.GetEquipmentType(), " - ", mID, " - ", part, " Nothing was sent!"));
foreach (var item in transportSendResults)
{
if (item is null)
result.AppendLine(string.Concat(configData.GetEquipmentType(), " - ", mID, " - ", part, " null"));
else
{
if (item.UNACCEPTED is null || (!(item.ETC is null) && item.ETC.ToString() == "-1"))
throw new Exception(string.Concat(configData.GetEquipmentType(), " - ", mID, " - ", part, " Invalid data"));
else
{
double.TryParse(item.UNACCEPTED.ToString(), out double unaccepted);
if (unaccepted > 0)
throw new Exception("Unaccepted record present");
else
result.AppendLine(string.Concat("Reply: ", item, Environment.NewLine, Environment.NewLine));
}
}
}
return result.ToString();
}
}
}