diff --git a/Adaptation/FileHandlers/OpenInsight/FileRead.cs b/Adaptation/FileHandlers/OpenInsight/FileRead.cs index 90931a6..c522028 100644 --- a/Adaptation/FileHandlers/OpenInsight/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsight/FileRead.cs @@ -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)); } diff --git a/Adaptation/FileHandlers/OpenInsight/FromIQS.cs b/Adaptation/FileHandlers/OpenInsight/FromIQS.cs index 85fbdb7..6c6c3b1 100644 --- a/Adaptation/FileHandlers/OpenInsight/FromIQS.cs +++ b/Adaptation/FileHandlers/OpenInsight/FromIQS.cs @@ -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; diff --git a/Adaptation/FileHandlers/QS408M/Description.cs b/Adaptation/FileHandlers/QS408M/Description.cs index 95f6f1b..d43bfcb 100644 --- a/Adaptation/FileHandlers/QS408M/Description.cs +++ b/Adaptation/FileHandlers/QS408M/Description.cs @@ -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"; + } \ No newline at end of file diff --git a/Adaptation/FileHandlers/QS408M/FileRead.cs b/Adaptation/FileHandlers/QS408M/FileRead.cs index 08d2538..4f0088e 100644 --- a/Adaptation/FileHandlers/QS408M/FileRead.cs +++ b/Adaptation/FileHandlers/QS408M/FileRead.cs @@ -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> GetExtractResult(string reportFullPath, DateTime dateTime) { Tuple> results = new(string.Empty, null, null, new List()); - _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; diff --git a/Adaptation/FileHandlers/QS408M/ProcessData.cs b/Adaptation/FileHandlers/QS408M/ProcessData.cs index c056208..f04837c 100644 --- a/Adaptation/FileHandlers/QS408M/ProcessData.cs +++ b/Adaptation/FileHandlers/QS408M/ProcessData.cs @@ -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 fileInfoCollection, string originalDataBioRad, ProcessData lastProcessData) + public ProcessData(IFileRead fileRead, Logistics logistics, List fileInfoCollection, string originalDataBioRad, ProcessData lastProcessData, long tickOffset) { JobID = logistics.JobID; fileInfoCollection.Clear(); _Details = new List(); 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 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 fileInfoCollection, string originalDataBioRad, ProcessData lastProcessData) + private void Parse(IFileRead fileRead, Logistics logistics, List 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) diff --git a/Adaptation/Shared/Duplicator/Description.cs b/Adaptation/Shared/Duplicator/Description.cs index b48872b..ee456bf 100644 --- a/Adaptation/Shared/Duplicator/Description.cs +++ b/Adaptation/Shared/Duplicator/Description.cs @@ -140,4 +140,6 @@ public class Description : IDescription, Properties.IDescription return result; } + internal static string GetDateFormat() => "MM/dd/yyyy hh:mm:ss tt"; + } \ No newline at end of file diff --git a/Adaptation/Shared/Logistics.cs b/Adaptation/Shared/Logistics.cs index 38ed83c..a6ca882 100644 --- a/Adaptation/Shared/Logistics.cs +++ b/Adaptation/Shared/Logistics.cs @@ -51,7 +51,7 @@ public class Logistics : ILogistics _Logistics2 = new List(); } - 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; diff --git a/Adaptation/_Tests/Extract/Staging/v2.36.3/BIORAD3.cs b/Adaptation/_Tests/Extract/Staging/v2.36.3/BIORAD3.cs index ecdd9b9..d021704 100644 --- a/Adaptation/_Tests/Extract/Staging/v2.36.3/BIORAD3.cs +++ b/Adaptation/_Tests/Extract/Staging/v2.36.3/BIORAD3.cs @@ -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); } diff --git a/Adaptation/_Tests/Extract/Staging/v2.39.0/BIORAD3.cs b/Adaptation/_Tests/Extract/Staging/v2.39.0/BIORAD3.cs index c568349..078953f 100644 --- a/Adaptation/_Tests/Extract/Staging/v2.39.0/BIORAD3.cs +++ b/Adaptation/_Tests/Extract/Staging/v2.39.0/BIORAD3.cs @@ -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); } diff --git a/Adaptation/_Tests/Extract/Staging/v2.43.0/BIORAD3.cs b/Adaptation/_Tests/Extract/Staging/v2.43.0/BIORAD3.cs index 527023f..5c6ff16 100644 --- a/Adaptation/_Tests/Extract/Staging/v2.43.0/BIORAD3.cs +++ b/Adaptation/_Tests/Extract/Staging/v2.43.0/BIORAD3.cs @@ -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); } diff --git a/Adaptation/_Tests/Extract/Staging/v2.47.1/BIORAD3.cs b/Adaptation/_Tests/Extract/Staging/v2.47.1/BIORAD3.cs index ff73dae..fd3e219 100644 --- a/Adaptation/_Tests/Extract/Staging/v2.47.1/BIORAD3.cs +++ b/Adaptation/_Tests/Extract/Staging/v2.47.1/BIORAD3.cs @@ -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); } diff --git a/Adaptation/_Tests/Extract/Staging/v2.47.1/MET08THFTIRQS408M.cs b/Adaptation/_Tests/Extract/Staging/v2.47.1/MET08THFTIRQS408M.cs index 58b86fa..1af6c69 100644 --- a/Adaptation/_Tests/Extract/Staging/v2.47.1/MET08THFTIRQS408M.cs +++ b/Adaptation/_Tests/Extract/Staging/v2.47.1/MET08THFTIRQS408M.cs @@ -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); } diff --git a/Adaptation/_Tests/Static/QS408M.cs b/Adaptation/_Tests/Static/QS408M.cs index 4629222..ba2182b 100644 --- a/Adaptation/_Tests/Static/QS408M.cs +++ b/Adaptation/_Tests/Static/QS408M.cs @@ -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() {