From 0bd984057ffa31811bb54bf1ffe323e38dfa6a38 Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Tue, 4 Jun 2024 14:07:11 -0700 Subject: [PATCH] Ready to test --- .../ConvertExcelToJson/ProcessData.cs | 8 ++-- Adaptation/FileHandlers/json/FileRead.cs | 4 +- Adaptation/FileHandlers/json/ProcessData.cs | 46 +++++++++++++++---- 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/Adaptation/FileHandlers/ConvertExcelToJson/ProcessData.cs b/Adaptation/FileHandlers/ConvertExcelToJson/ProcessData.cs index 6fd5e28..31f822d 100644 --- a/Adaptation/FileHandlers/ConvertExcelToJson/ProcessData.cs +++ b/Adaptation/FileHandlers/ConvertExcelToJson/ProcessData.cs @@ -25,11 +25,11 @@ public class ProcessData : IProcessData Parse(fileRead, logistics, fileInfoCollection, sheetName); } - string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary reactors) - => throw new Exception(string.Concat("See ", nameof(Parse))); + string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary reactors) => + throw new Exception(string.Concat("See ", nameof(Parse))); - Tuple> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List fileInfoCollection) - => new(logistics.Logistics1[0], Array.Empty(), Array.Empty(), fileInfoCollection); + Tuple> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List fileInfoCollection) => + new(logistics.Logistics1[0], Array.Empty(), Array.Empty(), fileInfoCollection); #nullable enable diff --git a/Adaptation/FileHandlers/json/FileRead.cs b/Adaptation/FileHandlers/json/FileRead.cs index 62a02e1..f18367b 100644 --- a/Adaptation/FileHandlers/json/FileRead.cs +++ b/Adaptation/FileHandlers/json/FileRead.cs @@ -158,10 +158,10 @@ public class FileRead : Shared.FileRead, IFileRead else { string formattedDateTime = dateTime.ToString("yyyy-MM-dd"); - bool forceUpdatedBy = !_IsEAFHosted || (dateTime.DayOfWeek == DayOfWeek.Thursday && dateTime.Hour == 12 && _LastDateForcedUpdatedBy != formattedDateTime); + bool forceUpdatedBy = false; // !_IsEAFHosted || (dateTime.DayOfWeek == DayOfWeek.Thursday && dateTime.Hour == 12 && _LastDateForcedUpdatedBy != formattedDateTime); if (forceUpdatedBy) _LastDateForcedUpdatedBy = formattedDateTime; - bool forceDeleteUpdatedBy = !_IsEAFHosted || (dateTime.DayOfWeek == DayOfWeek.Thursday && dateTime.Hour == 18 && _LastDateDeleteForcedUpdatedBy != formattedDateTime); + bool forceDeleteUpdatedBy = false; // !_IsEAFHosted || (dateTime.DayOfWeek == DayOfWeek.Thursday && dateTime.Hour == 18 && _LastDateDeleteForcedUpdatedBy != formattedDateTime); if (forceDeleteUpdatedBy) _LastDateDeleteForcedUpdatedBy = formattedDateTime; IProcessData iProcessData = new ProcessData(this, diff --git a/Adaptation/FileHandlers/json/ProcessData.cs b/Adaptation/FileHandlers/json/ProcessData.cs index 17fc8b1..142cb42 100644 --- a/Adaptation/FileHandlers/json/ProcessData.cs +++ b/Adaptation/FileHandlers/json/ProcessData.cs @@ -17,6 +17,7 @@ using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Text.Json; +using System.Threading; using System.Threading.Tasks; namespace Adaptation.FileHandlers.json; @@ -63,17 +64,25 @@ public class ProcessData : IProcessData forceDeleteUpdatedBy); } - string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary reactors) - => throw new Exception(string.Concat("See ", nameof(Parse))); + string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary reactors) => + throw new Exception(string.Concat("See ", nameof(Parse))); - Tuple> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List fileInfoCollection) - => new(logistics.Logistics1[0], Array.Empty(), Array.Empty(), fileInfoCollection); + Tuple> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List fileInfoCollection) => + new(logistics.Logistics1[0], Array.Empty(), Array.Empty(), fileInfoCollection); - internal static List GetDescriptions(JsonElement[] jsonElements) => throw new NotImplementedException(); + internal static List GetDescriptions(JsonElement[] jsonElements) => + throw new NotImplementedException(); #nullable enable - private static void AddPatch(JsonPatchDocument document, string path, object value) => document.Add(new JsonPatchOperation { From = null, Operation = Operation.Add, Path = path, Value = value }); + private static void KillTime(int loops) + { + for (int i = 1; i < loops; i++) + Thread.Sleep(500); + } + + private static void AddPatch(JsonPatchDocument document, string path, object value) => + document.Add(new JsonPatchOperation { From = null, Operation = Operation.Add, Path = path, Value = value }); private static Dictionary GetFIBacklogMesaCollection(string json) { @@ -182,10 +191,28 @@ public class ProcessData : IProcessData private static DateTime? GetCommitDate(FIBacklogMesa fiBacklogMesa) { DateTime? result; - if (!DateTime.TryParseExact(fiBacklogMesa.CommitDate.Split(' ').First(), "MM/dd/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTime) && dateTime != DateTime.MinValue) + DateTime dateTime; + DateTime minDateTime = DateTime.MinValue.AddYears(10); + string commitDate = fiBacklogMesa.CommitDate.Split(' ')[0]; + if (string.IsNullOrEmpty(commitDate)) result = null; else - result = dateTime.AddHours(12).ToUniversalTime(); + { + if (DateTime.TryParseExact(commitDate, "MM/dd/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime) && dateTime >= minDateTime) + result = dateTime.AddHours(12).ToUniversalTime(); + else + { + if (DateTime.TryParseExact(commitDate, "dd-MMM-yy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime) && dateTime >= minDateTime) + result = dateTime.AddHours(12).ToUniversalTime(); + else + { + if (DateTime.TryParse(commitDate, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime) && dateTime >= minDateTime) + result = dateTime.AddHours(12).ToUniversalTime(); + else + result = null; + } + } + } return result; } @@ -378,6 +405,7 @@ public class ProcessData : IProcessData throw new Exception(httpResponseMessageTask.Result.StatusCode.ToString()); Task stringTask = httpResponseMessageTask.Result.Content.ReadAsStringAsync(); stringTask.Wait(); + KillTime(30); } private static void ForceUpdatedBy(HttpClient httpClient, string basePage, string project, string api, string forceUpdatedByComment, ReadOnlyDictionary> updateCollection) @@ -409,6 +437,7 @@ public class ProcessData : IProcessData throw new Exception(httpResponseMessageTask.Result.StatusCode.ToString()); Task stringTask = httpResponseMessageTask.Result.Content.ReadAsStringAsync(); stringTask.Wait(); + KillTime(30); } private static void ForceUpdatedByDelete(HttpClient httpClient, string basePage, string project, string api, ReadOnlyDictionary> deleteCollection) @@ -443,6 +472,7 @@ public class ProcessData : IProcessData Task stringTask = httpResponseMessageTask.Result.Content.ReadAsStringAsync(); stringTask.Wait(); #endif + KillTime(30); } private static void UpdateIds(HttpClient httpClient, string basePage, string api, string[] checkFiles)