SelfHost conditional compile
This commit is contained in:
parent
97d1a1c6a7
commit
cae44abfee
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
@ -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
|
||||
|
@ -312,15 +312,18 @@ public class Job
|
||||
{
|
||||
string text;
|
||||
int? rds = null;
|
||||
FileInfo fileInfo;
|
||||
long sequence = 0;
|
||||
string psn = string.Empty;
|
||||
List<string> 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;
|
||||
|
@ -179,12 +179,6 @@
|
||||
<PackageReference Include="Infineon.EAF.Runtime">
|
||||
<Version>2.49.2</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.SelfHost">
|
||||
<Version>5.2.7</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.Core">
|
||||
<Version>5.2.7</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Text.Json">
|
||||
<Version>6.0.3</Version>
|
||||
</PackageReference>
|
||||
|
Loading…
x
Reference in New Issue
Block a user