PropertyGroup Condition

BarcodeController
This commit is contained in:
Mike Phares 2023-08-01 14:12:05 -07:00
parent 71753964ac
commit c6782d1cb3
9 changed files with 138 additions and 56 deletions

View File

@ -17,6 +17,7 @@
"lsid", "lsid",
"messa", "messa",
"messv", "messv",
"NETFRAMEWORK",
"NOPAUSE", "NOPAUSE",
"PDFC", "PDFC",
"PDSF", "PDSF",

View File

@ -1,10 +1,7 @@
#if SelfHost #if NETFRAMEWORK && NET48
using System; using Adaptation.FileHandlers.TIBCO.Transport;
using System.Globalization;
using System.IO;
using System.Text.Json;
using System.Threading.Tasks;
using System.Web.Http; using System.Web.Http;
using System.Web.Http.Results;
namespace Adaptation.FileHandlers.MoveAllFiles.ApiController; namespace Adaptation.FileHandlers.MoveAllFiles.ApiController;
@ -15,50 +12,20 @@ public class BarcodeController : System.Web.Http.ApiController
#nullable enable #nullable enable
#pragma warning disable CA1822 #pragma warning disable CA1822
public string Get() public OkNegotiatedContentResult<string> Get()
#pragma warning restore CA1822 #pragma warning restore CA1822
{ {
string results = "record"; string result = "record";
return results; return Ok(result);
}
private static string? GetJson(System.Net.Http.HttpContent? httpContent)
{
string? result;
if (httpContent is null)
result = null;
else
{
Task<string> task = httpContent.ReadAsStringAsync();
task.Wait();
result = task.Result;
}
return result;
}
private static void Write(string barcodeHostFileShare, string cellInstanceConnectionName, Notification notification)
{
DateTime dateTime = DateTime.Now;
Calendar calendar = new CultureInfo("en-US").Calendar;
string weekOfYear = $"{dateTime:yyyy}_Week_{calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday):00}";
string directory = Path.Combine(barcodeHostFileShare, weekOfYear, dateTime.ToString("yyyy-MM-dd_HH"));
if (!Directory.Exists(directory))
_ = Directory.CreateDirectory(directory);
File.WriteAllText(Path.Combine(directory, $"{cellInstanceConnectionName}.csv"), notification.LastScanServiceResultValue);
} }
[Route("{id}")] [Route("{id}")]
#pragma warning disable CA1822 #pragma warning disable CA1822
public void Post(string id) public JsonResult<PostReplay?> Post(string id)
#pragma warning restore CA1822 #pragma warning restore CA1822
{ {
string? json = GetJson(Request.Content); PostReplay? postReplay = BarcodeHelper.Post(id, Request.Content);
if (json is not null) return Json(postReplay);
{
Notification? notification = JsonSerializer.Deserialize<Notification>(json);
if (notification is not null)
Write(FileRead.BarcodeHostFileShare, id, notification.Value);
}
} }
} }

View File

@ -0,0 +1,77 @@
using Adaptation.FileHandlers.TIBCO.Transport;
using System;
using System.Globalization;
using System.IO;
using System.Text.Json;
using System.Threading.Tasks;
namespace Adaptation.FileHandlers.MoveAllFiles.ApiController;
public class BarcodeHelper
{
#nullable enable
private static string? GetJson(System.Net.Http.HttpContent? httpContent)
{
string? result;
if (httpContent is null)
result = null;
else
{
Task<string> task = httpContent.ReadAsStringAsync();
task.Wait();
result = task.Result;
}
return result;
}
private static void Write(string barcodeHostFileShare, string cellInstanceConnectionName, Notification notification)
{
DateTime dateTime = DateTime.Now;
Calendar calendar = new CultureInfo("en-US").Calendar;
string weekOfYear = $"{dateTime:yyyy}_Week_{calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday):00}";
string directory = Path.Combine(barcodeHostFileShare, weekOfYear, dateTime.ToString("yyyy-MM-dd_HH"));
if (!Directory.Exists(directory))
_ = Directory.CreateDirectory(directory);
File.WriteAllText(Path.Combine(directory, $"{cellInstanceConnectionName}.csv"), notification.LastScanServiceResultValue);
}
private static Job GetJob(string lsl2SQLConnectionString, string metrologyFileShare, string barcodeHostFileShare, string id, Notification notification)
{
Job result;
string lastScan = notification.LastScanServiceResultValue.Length < 3 || notification.LastScanServiceResultValue[1] is not 't' and not 'T' || notification.LastScanServiceResultValue[0] != '1' ? notification.LastScanServiceResultValue : notification.LastScanServiceResultValue.Substring(2);
string json = string.Concat("{\"Area\": \"Si\", \"EquipmentType\": \"MET08THFTIRQS408M\", \"MesEntity\": \"", id, "\", \"Sequence\": \"", notification.KeyPressEvent.DateTime.Ticks, "\", \"MID\": \"-", lastScan, "-\", \"Recipe\": \"Recipe\"}");
result = new(lsl2SQLConnectionString, metrologyFileShare, barcodeHostFileShare, json);
return result;
}
internal static PostReplay? Post(string id, System.Net.Http.HttpContent? httpContent)
{
PostReplay? result;
string? json = GetJson(httpContent);
if (json is null)
result = null;
else
{
Notification? notification = JsonSerializer.Deserialize<Notification>(json);
if (notification is null)
result = null;
else
{
const string hyphen = "-";
Write(TIBCO.FileRead.BarcodeHostFileShare, id, notification.Value);
Job job = GetJob(TIBCO.FileRead.LSL2SQLConnectionString, TIBCO.FileRead.MetrologyFileShare, TIBCO.FileRead.BarcodeHostFileShare, id, notification.Value);
string mid = job.SpecName == hyphen || job.ProcessSpecName == hyphen ? $"{job.ProcessType}" : $"{job.ProcessType}.{job.SpecName}.{job.ProcessSpecName}";
try
{
// https://oi-prod-ec-api.mes.infineon.com/api/oiWizard/materials/rds/
}
catch (Exception) { }
result = new(job, mid, job.RecipeName);
}
}
return result;
}
}

View File

@ -2,6 +2,7 @@ namespace Adaptation.FileHandlers.MoveAllFiles.ApiController;
public readonly struct Notification public readonly struct Notification
{ {
public KeyPressEvent KeyPressEvent { get; } public KeyPressEvent KeyPressEvent { get; }
public string LastScanServiceResultValue { get; } public string LastScanServiceResultValue { get; }

View File

@ -0,0 +1,20 @@
using Adaptation.FileHandlers.TIBCO.Transport;
namespace Adaptation.FileHandlers.MoveAllFiles.ApiController;
public class PostReplay
{
public Job Job { get; }
public string MId { get; }
public string Recipe { get; }
[System.Text.Json.Serialization.JsonConstructor]
public PostReplay(Job job, string mid, string recipe)
{
Job = job;
MId = mid;
Recipe = recipe;
}
}

View File

@ -7,7 +7,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text.Json; using System.Text.Json;
#if SelfHost #if NETFRAMEWORK && NET48
using System.Web.Http; using System.Web.Http;
using System.Web.Http.SelfHost; using System.Web.Http.SelfHost;
#endif #endif
@ -20,12 +20,10 @@ public class FileRead : Shared.FileRead, IFileRead
#nullable enable #nullable enable
private long? _TickOffset; private long? _TickOffset;
#if SelfHost #if NETFRAMEWORK && NET48
private readonly HttpSelfHostServer? _HttpSelfHostServer; private readonly HttpSelfHostServer? _HttpSelfHostServer;
#endif #endif
public const string BarcodeHostFileShare = @"\\messv02ecc1.ec.local\EC_Metrology_Si\BarcodeHost\API"; // GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "BarcodeHost.FileShare");
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, Dictionary<long, List<string>> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, Dictionary<long, List<string>> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
{ {
@ -38,7 +36,7 @@ public class FileRead : Shared.FileRead, IFileRead
throw new Exception(cellInstanceConnectionName); throw new Exception(cellInstanceConnectionName);
if (_IsDuplicator) if (_IsDuplicator)
throw new Exception(cellInstanceConnectionName); throw new Exception(cellInstanceConnectionName);
#if SelfHost #if NETFRAMEWORK && NET48
if (!_IsEAFHosted) if (!_IsEAFHosted)
_HttpSelfHostServer = null; _HttpSelfHostServer = null;
else else
@ -127,7 +125,6 @@ public class FileRead : Shared.FileRead, IFileRead
_TickOffset ??= new FileInfo(reportFullPath).LastWriteTime.Ticks - dateTime.Ticks; _TickOffset ??= new FileInfo(reportFullPath).LastWriteTime.Ticks - dateTime.Ticks;
_Logistics = new Logistics(this, _TickOffset.Value, reportFullPath, useSplitForMID: true); _Logistics = new Logistics(this, _TickOffset.Value, reportFullPath, useSplitForMID: true);
SetFileParameterLotIDToLogisticsMID(); SetFileParameterLotIDToLogisticsMID();
return results; return results;
} }

View File

@ -15,8 +15,11 @@ public class FileRead : Shared.FileRead, IFileRead
#nullable enable #nullable enable
public const string BarcodeHostFileShare = @"\\messv02ecc1.ec.local\EC_Metrology_Si\BarcodeHost\API";
public const string MetrologyFileShare = @"\\messv02ecc1.ec.local\EC_Metrology_Si\WorkMaterialOut\API";
public const string LSL2SQLConnectionString = @"Data Source=10.95.128.28\\PROD1,53959;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;";
private long? _TickOffset; private long? _TickOffset;
private readonly string _BarcodeHostFileShare;
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, Dictionary<long, List<string>> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) : public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, int? connectionCount, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, Dictionary<long, List<string>> staticRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null) base(new Description(), false, smtp, fileParameter, cellInstanceName, connectionCount, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, staticRuns, useCyclicalForDescription, isEAFHosted: connectionCount is null)
@ -31,21 +34,27 @@ public class FileRead : Shared.FileRead, IFileRead
if (!_IsDuplicator) if (!_IsDuplicator)
throw new Exception(cellInstanceConnectionName); throw new Exception(cellInstanceConnectionName);
string metrologyFileShare = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "Metrology.FileShare"); string metrologyFileShare = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "Metrology.FileShare");
_BarcodeHostFileShare = @"\\messv02ecc1.ec.local\EC_Metrology_Si\BarcodeHost\API"; // GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "BarcodeHost.FileShare"); if (metrologyFileShare != MetrologyFileShare)
throw new NotSupportedException($"Update configuration for [{nameof(MetrologyFileShare)}]");
string barcodeHostFileShare = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "BarcodeHost.FileShare");
if (barcodeHostFileShare != BarcodeHostFileShare)
throw new NotSupportedException($"Update configuration for [{nameof(BarcodeHostFileShare)}]");
string lsl2SQLConnectionString = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "ConnectionString.LSL2SQL"); string lsl2SQLConnectionString = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "ConnectionString.LSL2SQL");
if (lsl2SQLConnectionString != LSL2SQLConnectionString)
throw new NotSupportedException($"Update configuration for [{nameof(LSL2SQLConnectionString)}]");
ModelObjectParameterDefinition[] tibcoParameters = GetProperties(cellInstanceConnectionName, modelObjectParameters, "TIBCO."); ModelObjectParameterDefinition[] tibcoParameters = GetProperties(cellInstanceConnectionName, modelObjectParameters, "TIBCO.");
string tibcoParameterChannel = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_CHANNEL"); string tibcoParameterChannel = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_CHANNEL");
string tibcoParameterSubject = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_SUBJECT"); string tibcoParameterSubject = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_SUBJECT");
string tibcoParameterSubjectPrefix = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_SUBJECT_PREFIX"); string tibcoParameterSubjectPrefix = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_SUBJECT_PREFIX");
string tibcoParameterConfigurationLocation = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_CONFIGURATION_LOCATION"); string tibcoParameterConfigurationLocation = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_CONFIGURATION_LOCATION");
string tibcoParameterConfigurationLocationCopy = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_CONFIGURATION_LOCATION_LOCAL_COPY"); string tibcoParameterConfigurationLocationCopy = GetPropertyValue(cellInstanceConnectionName, tibcoParameters, "TIBCO.IFX_CONFIGURATION_LOCATION_LOCAL_COPY");
if (!Directory.Exists(metrologyFileShare)) if (!Directory.Exists(MetrologyFileShare))
throw new Exception($"Unable to access file-share <{metrologyFileShare}>"); throw new Exception($"Unable to access file-share <{MetrologyFileShare}>");
if (!Directory.Exists(_BarcodeHostFileShare)) if (!Directory.Exists(BarcodeHostFileShare))
throw new Exception($"Unable to access file-share <{_BarcodeHostFileShare}>"); throw new Exception($"Unable to access file-share <{BarcodeHostFileShare}>");
if (_IsEAFHosted) if (_IsEAFHosted)
{ {
Transport.Main.Initialize(smtp, cellInstanceName, fileConnectorConfiguration, lsl2SQLConnectionString, metrologyFileShare, _BarcodeHostFileShare); Transport.Main.Initialize(smtp, cellInstanceName, fileConnectorConfiguration, LSL2SQLConnectionString, MetrologyFileShare, BarcodeHostFileShare);
if (!string.IsNullOrEmpty(fileConnectorConfiguration.SourceFileLocation)) if (!string.IsNullOrEmpty(fileConnectorConfiguration.SourceFileLocation))
_ = Transport.Main.Setup(useSleep: true, setIfxTransport: true, tibcoParameterChannel, tibcoParameterSubjectPrefix, tibcoParameterConfigurationLocation, tibcoParameterConfigurationLocationCopy, tibcoParameterSubject); _ = Transport.Main.Setup(useSleep: true, setIfxTransport: true, tibcoParameterChannel, tibcoParameterSubjectPrefix, tibcoParameterConfigurationLocation, tibcoParameterConfigurationLocationCopy, tibcoParameterSubject);
else else

View File

@ -43,7 +43,6 @@
<PackageReference Include="IKVM.OpenJDK.XML.API" Version="7.2.4630.5"><NoWarn>NU1701</NoWarn></PackageReference> <PackageReference Include="IKVM.OpenJDK.XML.API" Version="7.2.4630.5"><NoWarn>NU1701</NoWarn></PackageReference>
<PackageReference Include="IKVM.Runtime" Version="7.2.4630.5"><NoWarn>NU1701</NoWarn></PackageReference> <PackageReference Include="IKVM.Runtime" Version="7.2.4630.5"><NoWarn>NU1701</NoWarn></PackageReference>
<PackageReference Include="Instances" Version="3.0.0" /> <PackageReference Include="Instances" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.SelfHost" Version="5.2.9" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" /> <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />

View File

@ -48,6 +48,9 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(TargetFrameworkVersion)' == 'v4.8' ">
<DefineConstants>NETFRAMEWORK;NET20;NET35;NET40;NET45;NET451;NET452;NET46;NET461;NET462;NET47;NET471;NET472;NET48;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@ -103,10 +106,12 @@
<Compile Include="Adaptation\FileHandlers\Dummy\FileRead.cs" /> <Compile Include="Adaptation\FileHandlers\Dummy\FileRead.cs" />
<Compile Include="Adaptation\FileHandlers\IQSSi\FileRead.cs" /> <Compile Include="Adaptation\FileHandlers\IQSSi\FileRead.cs" />
<Compile Include="Adaptation\FileHandlers\MoveAllFiles\ApiController\BarcodeController.cs" /> <Compile Include="Adaptation\FileHandlers\MoveAllFiles\ApiController\BarcodeController.cs" />
<Compile Include="Adaptation\FileHandlers\MoveAllFiles\ApiController\BarcodeHelper.cs" />
<Compile Include="Adaptation\FileHandlers\MoveAllFiles\ApiController\EventCode.cs" /> <Compile Include="Adaptation\FileHandlers\MoveAllFiles\ApiController\EventCode.cs" />
<Compile Include="Adaptation\FileHandlers\MoveAllFiles\ApiController\KeyPressEvent.cs" /> <Compile Include="Adaptation\FileHandlers\MoveAllFiles\ApiController\KeyPressEvent.cs" />
<Compile Include="Adaptation\FileHandlers\MoveAllFiles\ApiController\KeyState.cs" /> <Compile Include="Adaptation\FileHandlers\MoveAllFiles\ApiController\KeyState.cs" />
<Compile Include="Adaptation\FileHandlers\MoveAllFiles\ApiController\Notification.cs" /> <Compile Include="Adaptation\FileHandlers\MoveAllFiles\ApiController\Notification.cs" />
<Compile Include="Adaptation\FileHandlers\MoveAllFiles\ApiController\PostReplay.cs" />
<Compile Include="Adaptation\FileHandlers\MoveAllFiles\FileRead.cs" /> <Compile Include="Adaptation\FileHandlers\MoveAllFiles\FileRead.cs" />
<Compile Include="Adaptation\FileHandlers\MoveMatchingFiles\FileRead.cs" /> <Compile Include="Adaptation\FileHandlers\MoveMatchingFiles\FileRead.cs" />
<Compile Include="Adaptation\FileHandlers\OpenInsightMetrologyViewerAttachments\FileRead.cs" /> <Compile Include="Adaptation\FileHandlers\OpenInsightMetrologyViewerAttachments\FileRead.cs" />
@ -179,6 +184,12 @@
<PackageReference Include="Infineon.EAF.Runtime"> <PackageReference Include="Infineon.EAF.Runtime">
<Version>2.49.2</Version> <Version>2.49.2</Version>
</PackageReference> </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"> <PackageReference Include="System.Text.Json">
<Version>6.0.3</Version> <Version>6.0.3</Version>
</PackageReference> </PackageReference>