v2.47.0 - Read to test IQS query - better date

This commit is contained in:
Mike Phares 2022-11-30 12:45:35 -07:00
parent 68bbb18ce8
commit 4a04737d4a
13 changed files with 53 additions and 31 deletions

View File

@ -148,7 +148,7 @@ public class FileRead : Shared.FileRead, IFileRead
if (!string.IsNullOrEmpty(lines))
collection.Add(new(new ScopeInfo(tests[0], _OpenInsightFilePattern), lines));
_ = FromIQS.GetCommandText(_IqsConnectionString, _Logistics, descriptions[0]);
// // string commandText = FromIQS.GetCommandText(_IqsConnectionString, _Logistics, descriptions[0]);
// string commandText = FromIQS.GetCommandText(_IqsConnectionString, _Logistics, descriptions[0]);
// if (!string.IsNullOrEmpty(commandText))
// collection.Add(new(new ScopeInfo(tests[0], _OpenInsightFilePattern, extraExtension: "sql"), commandText));
}

View File

@ -1,5 +1,7 @@
using Adaptation.Shared;
using System;
using System.Data.SqlClient;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.Json;
@ -11,7 +13,7 @@ public class FromIQS
#nullable enable
private static string GetCommandText(Logistics logistics, QS408M.Description description, string? sid)
private static string GetCommandText(Logistics logistics, QS408M.Description description, string dateTime, string? sid)
{
StringBuilder result = new();
_ = result
@ -46,7 +48,7 @@ public class FromIQS
.AppendLine(" and jd.f_name in ('BIORAD2', 'BIORAD3', 'BIORAD4', 'BIORAD5') ")
.Append(" and jd.f_name = '").Append(logistics.MesEntity).AppendLine("' ")
.Append(" and pl.f_name = '").Append(description.RDS).AppendLine("' ")
.Append(" and dateadd(HH, -7, (dateadd(SS, convert(bigint, se.f_sgtm), '19700101'))) = '").Append(logistics.DateTimeFromSequence.ToString("yyyy-MM-dd HH:mm:ss")).AppendLine("' ")
.Append(" and dateadd(HH, -7, (dateadd(SS, convert(bigint, se.f_sgtm), '19700101'))) = '").Append(dateTime).AppendLine("' ")
.AppendLine(" for json path ");
return result.ToString();
}
@ -68,7 +70,15 @@ public class FromIQS
internal static string GetCommandText(string connectionString, Logistics logistics, QS408M.Description description)
{
string result;
string commandText = GetCommandText(logistics, description, sid: null);
string dateTime;
string dateFormat = QS408M.Description.GetDateFormat();
if (DateTime.TryParseExact(description.Date, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTimeParsed))
dateTime = dateTimeParsed.ToString("yyyy-MM-dd HH:mm:ss");
else if (DateTime.TryParse(description.Date, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTimeParsed))
dateTime = dateTimeParsed.ToString("yyyy-MM-dd HH:mm:ss");
else
dateTime = logistics.DateTimeFromSequence.ToString("yyyy-MM-dd HH:mm:ss");
string commandText = GetCommandText(logistics, description, dateTime, sid: null);
StringBuilder stringBuilder = GetForJsonPath(connectionString, commandText);
if (stringBuilder.Length == 0)
result = commandText;
@ -83,7 +93,7 @@ public class FromIQS
if (!jsonProperties.Any() || jsonProperties[0].Name != "se_sgrp")
result = commandText;
else
result = GetCommandText(logistics, description, sid: jsonProperties[0].Value.ToString());
result = GetCommandText(logistics, description, dateTime, sid: jsonProperties[0].Value.ToString());
}
}
return result;

View File

@ -188,7 +188,7 @@ public class Description : IDescription, Shared.Properties.IDescription
ProcessJobID = logistics.ProcessJobID,
MID = logistics.MID,
//
Date = processData.Date,
Date = processData.Date.ToString(GetDateFormat()),
Employee = processData.Employee,
Lot = processData.Batch,
PSN = processData.PSN,
@ -266,4 +266,6 @@ public class Description : IDescription, Shared.Properties.IDescription
return result;
}
internal static string GetDateFormat() => "MM/dd/yyyy hh:mm:ss tt";
}

View File

@ -14,6 +14,7 @@ namespace Adaptation.FileHandlers.QS408M;
public class FileRead : Shared.FileRead, IFileRead
{
private long? _TickOffset;
private readonly string _OriginalDataBioRad;
private readonly ProcessData _LastProcessData;
@ -101,13 +102,14 @@ public class FileRead : Shared.FileRead, IFileRead
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>());
_Logistics = new Logistics(this, reportFullPath, useSplitForMID: true);
_TickOffset ??= new FileInfo(reportFullPath).LastWriteTime.Ticks - dateTime.Ticks;
_Logistics = new Logistics(this, _TickOffset.Value, reportFullPath, useSplitForMID: true);
SetFileParameterLotIDToLogisticsMID();
if (_Logistics.FileInfo.Length < _MinFileLength)
results.Item4.Add(_Logistics.FileInfo);
else
{
IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, _OriginalDataBioRad, lastProcessData: _LastProcessData);
IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, _OriginalDataBioRad, lastProcessData: _LastProcessData, tickOffset: _TickOffset.Value);
if (iProcessData is not ProcessData processData)
throw new Exception(string.Concat("A) No Data - ", dateTime.Ticks));
string mid;

View File

@ -23,7 +23,7 @@ public partial class ProcessData : IProcessData
public string MesEntity { get; set; }
public string Batch { get; set; }
public string Cassette { get; set; }
public string Date { get; set; }
public DateTime Date { get; set; }
public string Employee { get; set; }
public string Layer { get; set; }
public string MeanThickness { get; set; }
@ -49,14 +49,14 @@ public partial class ProcessData : IProcessData
{
}
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string originalDataBioRad, ProcessData lastProcessData)
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string originalDataBioRad, ProcessData lastProcessData, long tickOffset)
{
JobID = logistics.JobID;
fileInfoCollection.Clear();
_Details = new List<object>();
MesEntity = logistics.MesEntity;
_Log = LogManager.GetLogger(typeof(ProcessData));
Parse(fileRead, logistics, fileInfoCollection, originalDataBioRad, lastProcessData);
Parse(fileRead, logistics, fileInfoCollection, originalDataBioRad, lastProcessData, tickOffset);
}
string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) => throw new Exception(string.Concat("See ", nameof(Parse)));
@ -232,7 +232,7 @@ public partial class ProcessData : IProcessData
}
}
internal static DateTime GetDateTime(Logistics logistics, string dateTimeText)
internal static DateTime GetDateTime(Logistics logistics, long tickOffset, string dateTimeText)
{
DateTime result;
string inputDateFormat = "ddd mmm dd HH:mm:ss yyyy";
@ -245,7 +245,7 @@ public partial class ProcessData : IProcessData
else
{
if (dateTimeParsed < logistics.DateTimeFromSequence.AddDays(1) && dateTimeParsed > logistics.DateTimeFromSequence.AddDays(-1))
result = dateTimeParsed;
result = new(dateTimeParsed.Ticks + tickOffset);
else
result = logistics.DateTimeFromSequence;
}
@ -371,16 +371,16 @@ public partial class ProcessData : IProcessData
return result;
}
private void Set(Logistics logistics, ProcessData lastProcessData, string receivedData)
private void Set(Logistics logistics, ProcessData lastProcessData, long tickOffset, string receivedData)
{
string psn;
string rds;
string date;
string zone;
string batch;
string layer;
string title;
string wafer;
DateTime date;
string recipe;
string reactor;
string cassette;
@ -390,8 +390,7 @@ public partial class ProcessData : IProcessData
string dateTimeText = GetToEOL();
if (dateTimeText.EndsWith("."))
dateTimeText = dateTimeText.Remove(dateTimeText.Length - 1, 1);
DateTime dateTime = GetDateTime(logistics, dateTimeText);
date = dateTime.ToString();
date = GetDateTime(logistics, tickOffset, dateTimeText);
ScanPast("operator:");
employee = GetBefore("batch:");
batch = GetToEOL();
@ -484,7 +483,7 @@ public partial class ProcessData : IProcessData
UniqueId = string.Concat(title, '_', wafer, '_', logistics.DateTimeFromSequence.ToString("yyyyMMddHHmmssffff"), '_', logistics.TotalSecondsSinceLastWriteTimeFromSequence);
}
private void Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string originalDataBioRad, ProcessData lastProcessData)
private void Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, string originalDataBioRad, ProcessData lastProcessData, long tickOffset)
{
if (fileRead is null)
{ }
@ -507,7 +506,7 @@ public partial class ProcessData : IProcessData
{
_I = 0;
_Data = receivedData;
Set(logistics, lastProcessData, receivedData);
Set(logistics, lastProcessData, tickOffset, receivedData);
string token = GetToken();
int counter = 1;
while (true)

View File

@ -140,4 +140,6 @@ public class Description : IDescription, Properties.IDescription
return result;
}
internal static string GetDateFormat() => "MM/dd/yyyy hh:mm:ss tt";
}

View File

@ -51,7 +51,7 @@ public class Logistics : ILogistics
_Logistics2 = new List<Logistics2>();
}
public Logistics(IFileRead fileRead, string reportFullPath, bool useSplitForMID, int? fileInfoLength = null)
public Logistics(IFileRead fileRead, long tickOffset, string reportFullPath, bool useSplitForMID, int? fileInfoLength = null)
{
if (string.IsNullOrEmpty(fileRead.CellInstanceName))
throw new Exception();
@ -59,7 +59,7 @@ public class Logistics : ILogistics
throw new Exception();
_NullData = fileRead.NullData;
_FileInfo = new(reportFullPath);
DateTime dateTime = _FileInfo.LastWriteTime;
DateTime dateTime = new(_FileInfo.LastWriteTime.Ticks + tickOffset);
if (fileInfoLength.HasValue && _FileInfo.Length < fileInfoLength.Value)
dateTime = dateTime.AddTicks(-1);
_JobID = fileRead.CellInstanceName;

View File

@ -42,9 +42,9 @@ public class BIORAD3
string[] variables = _BIORAD3.AdaptationTesting.GetVariables(methodBase, check);
IFileRead fileRead = _BIORAD3.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false);
Logistics logistics = new(fileRead);
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, string.Empty);
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, tickOffset: 0, dateTimeText: string.Empty);
Assert.IsTrue(dateTime == logistics.DateTimeFromSequence);
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, "Tue Nov 10 12:03:56 1970");
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, tickOffset: 0, dateTimeText: "Tue Nov 10 12:03:56 1970");
Assert.IsTrue(dateTime == logistics.DateTimeFromSequence);
_ = Shared.AdaptationTesting.ReExtractCompareUpdatePassDirectory(variables, fileRead, logistics);
}

View File

@ -42,9 +42,9 @@ public class BIORAD3
string[] variables = _BIORAD3.AdaptationTesting.GetVariables(methodBase, check);
IFileRead fileRead = _BIORAD3.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false);
Logistics logistics = new(fileRead);
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, string.Empty);
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, tickOffset: 0, dateTimeText: string.Empty);
Assert.IsTrue(dateTime == logistics.DateTimeFromSequence);
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, "Tue Nov 10 12:03:56 1970");
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, tickOffset: 0, dateTimeText: "Tue Nov 10 12:03:56 1970");
Assert.IsTrue(dateTime == logistics.DateTimeFromSequence);
_ = Shared.AdaptationTesting.ReExtractCompareUpdatePassDirectory(variables, fileRead, logistics);
}

View File

@ -42,9 +42,9 @@ public class BIORAD3
string[] variables = _BIORAD3.AdaptationTesting.GetVariables(methodBase, check);
IFileRead fileRead = _BIORAD3.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false);
Logistics logistics = new(fileRead);
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, string.Empty);
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, tickOffset: 0, dateTimeText: string.Empty);
Assert.IsTrue(dateTime == logistics.DateTimeFromSequence);
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, "Tue Nov 10 12:03:56 1970");
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, tickOffset: 0, dateTimeText: "Tue Nov 10 12:03:56 1970");
Assert.IsTrue(dateTime == logistics.DateTimeFromSequence);
_ = Shared.AdaptationTesting.ReExtractCompareUpdatePassDirectory(variables, fileRead, logistics);
}

View File

@ -42,9 +42,9 @@ public class BIORAD3
string[] variables = _BIORAD3.AdaptationTesting.GetVariables(methodBase, check);
IFileRead fileRead = _BIORAD3.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false);
Logistics logistics = new(fileRead);
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, string.Empty);
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, tickOffset: 0, dateTimeText: string.Empty);
Assert.IsTrue(dateTime == logistics.DateTimeFromSequence);
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, "Tue Nov 10 12:03:56 1970");
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, tickOffset: 0, dateTimeText: "Tue Nov 10 12:03:56 1970");
Assert.IsTrue(dateTime == logistics.DateTimeFromSequence);
_ = Shared.AdaptationTesting.ReExtractCompareUpdatePassDirectory(variables, fileRead, logistics);
}

View File

@ -60,9 +60,9 @@ public class MET08THFTIRQS408M
string[] variables = _MET08THFTIRQS408M.AdaptationTesting.GetVariables(methodBase, check, validatePDSF: false);
IFileRead fileRead = _MET08THFTIRQS408M.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false);
Logistics logistics = new(fileRead);
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, string.Empty);
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, tickOffset: 0, dateTimeText: string.Empty);
Assert.IsTrue(dateTime == logistics.DateTimeFromSequence);
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, "Tue Nov 10 12:03:56 1970");
dateTime = FileHandlers.QS408M.ProcessData.GetDateTime(logistics, tickOffset: 0, dateTimeText: "Tue Nov 10 12:03:56 1970");
Assert.IsTrue(dateTime == logistics.DateTimeFromSequence);
_ = Shared.AdaptationTesting.ReExtractCompareUpdatePassDirectory(variables, fileRead, logistics);
}

View File

@ -36,6 +36,13 @@ public class QS408M : LoggingUnitTesting, IDisposable
LoggingUnitTesting?.Dispose();
}
[TestMethod]
public void TestDateTime()
{
DateTime dateTime = DateTime.Now;
Assert.IsTrue(dateTime.ToString("MM/dd/yyyy hh:mm:ss tt") == dateTime.ToString());
}
[TestMethod]
public void TestDescriptor()
{