From cae44abfee39ed386bc772fa514e5752887f35fe Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Tue, 27 Jun 2023 11:13:29 -0700 Subject: [PATCH] SelfHost conditional compile --- .../MoveAllFiles/ApiController/BarcodeController.cs | 4 +++- Adaptation/FileHandlers/MoveAllFiles/FileRead.cs | 6 ++++++ Adaptation/FileHandlers/TIBCO/Transport/Job.cs | 8 +++++++- MET08DDUPSP1TBI.csproj | 6 ------ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Adaptation/FileHandlers/MoveAllFiles/ApiController/BarcodeController.cs b/Adaptation/FileHandlers/MoveAllFiles/ApiController/BarcodeController.cs index efa2b0e..efd26a6 100644 --- a/Adaptation/FileHandlers/MoveAllFiles/ApiController/BarcodeController.cs +++ b/Adaptation/FileHandlers/MoveAllFiles/ApiController/BarcodeController.cs @@ -1,3 +1,4 @@ +#if SelfHost using System; using System.Globalization; using System.IO; @@ -60,4 +61,5 @@ public class BarcodeController : System.Web.Http.ApiController } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Adaptation/FileHandlers/MoveAllFiles/FileRead.cs b/Adaptation/FileHandlers/MoveAllFiles/FileRead.cs index 59ad144..7dd98f1 100644 --- a/Adaptation/FileHandlers/MoveAllFiles/FileRead.cs +++ b/Adaptation/FileHandlers/MoveAllFiles/FileRead.cs @@ -7,8 +7,10 @@ using System; using System.Collections.Generic; using System.IO; using System.Text.Json; +#if SelfHost using System.Web.Http; using System.Web.Http.SelfHost; +#endif namespace Adaptation.FileHandlers.MoveAllFiles; @@ -18,7 +20,9 @@ public class FileRead : Shared.FileRead, IFileRead #nullable enable private long? _TickOffset; +#if SelfHost private readonly HttpSelfHostServer? _HttpSelfHostServer; +#endif public const string BarcodeHostFileShare = @"\\messv02ecc1.ec.local\EC_Metrology_Si\BarcodeHost\API"; // GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "BarcodeHost.FileShare"); @@ -34,6 +38,7 @@ public class FileRead : Shared.FileRead, IFileRead throw new Exception(cellInstanceConnectionName); if (_IsDuplicator) throw new Exception(cellInstanceConnectionName); +#if SelfHost if (!_IsEAFHosted) _HttpSelfHostServer = null; else @@ -46,6 +51,7 @@ public class FileRead : Shared.FileRead, IFileRead _HttpSelfHostServer = new(config); _HttpSelfHostServer.OpenAsync().Wait(); } +#endif } #nullable disable diff --git a/Adaptation/FileHandlers/TIBCO/Transport/Job.cs b/Adaptation/FileHandlers/TIBCO/Transport/Job.cs index 67e7298..5c39616 100644 --- a/Adaptation/FileHandlers/TIBCO/Transport/Job.cs +++ b/Adaptation/FileHandlers/TIBCO/Transport/Job.cs @@ -312,15 +312,18 @@ public class Job { string text; int? rds = null; + FileInfo fileInfo; + long sequence = 0; string psn = string.Empty; List files = new(); string[] segments = input.MID.Split('.'); string layer = segments[1]; string zone = segments.Length <= 2 ? string.Empty : segments[2]; int? reactor = !int.TryParse(segments[0], out int reactorNumber) ? null : reactorNumber; + bool parsed = !string.IsNullOrEmpty(input.Sequence) && long.TryParse(input.Sequence, out sequence); if (string.IsNullOrEmpty(barcodeHostFileShare) || !Directory.Exists(barcodeHostFileShare)) throw new Exception($"Unable to access file-share <{barcodeHostFileShare}>"); - if (!string.IsNullOrEmpty(input.MID)) + if (parsed && !string.IsNullOrEmpty(input.MID)) { string[] checkDirectories = GetDirectories(barcodeHostFileShare); foreach (string checkDirectory in checkDirectories) @@ -332,6 +335,9 @@ public class Job } foreach (string file in files.OrderByDescending(l => new FileInfo(l).LastWriteTime)) { + fileInfo = new FileInfo(file); + if (fileInfo.LastWriteTime.Ticks > sequence) + continue; text = File.ReadAllText(file); rds = !int.TryParse(segments[0], out int rdsNumber) ? null : rdsNumber; break; diff --git a/MET08DDUPSP1TBI.csproj b/MET08DDUPSP1TBI.csproj index cb9c55d..03e3af4 100644 --- a/MET08DDUPSP1TBI.csproj +++ b/MET08DDUPSP1TBI.csproj @@ -179,12 +179,6 @@ 2.49.2 - - 5.2.7 - - - 5.2.7 - 6.0.3