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

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

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;