jconfig - by default loaded from the databse as fallback from current directory,
calibration results class added
This commit is contained in:
parent
ebae1847a4
commit
f47c57cbde
@ -38,91 +38,91 @@ namespace Xylem.Common.Logic.ProductionOrderCore.TestResults
|
||||
/// <summary>
|
||||
/// Unique identifier for PCB
|
||||
/// </summary>
|
||||
public String PcbId { get; set;}
|
||||
public String PcbId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Calibration value channel 1
|
||||
/// </summary>
|
||||
public Int32 CalFactor1 { get; set;}
|
||||
public Int32 CalFactor1 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Calibration value channel 2
|
||||
/// </summary>
|
||||
public Int32 CalFactor2 { get; set;}
|
||||
public Int32 CalFactor2 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Calibration value channel 3
|
||||
/// </summary>
|
||||
public Int32 CalFactor3 { get; set;}
|
||||
public Int32 CalFactor3 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Zero offset channel 1
|
||||
/// </summary>
|
||||
public Int32 ZeroOffset1{ get; set;}
|
||||
public Int32 ZeroOffset1 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Zero offset channel 2
|
||||
/// </summary>
|
||||
public Int32 ZeroOffset2{ get; set;}
|
||||
public Int32 ZeroOffset2 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Zero offset channel 3
|
||||
/// </summary>
|
||||
public Int32 ZeroOffset3{ get; set;}
|
||||
public Int32 ZeroOffset3 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// First hit update period
|
||||
/// </summary>
|
||||
public Int32 FirstHitUpdatePer{ get; set;}
|
||||
public Int32 FirstHitUpdatePer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// First hit shift
|
||||
/// </summary>
|
||||
public Int32 FirstHitShift { get; set;}
|
||||
public Int32 FirstHitShift { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// First hit percent channel 1
|
||||
/// </summary>
|
||||
public Int32 FirstHitPercent1 { get; set;}
|
||||
public Int32 FirstHitPercent1 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// First hit percent channel 2
|
||||
/// </summary>
|
||||
public Int32 FirstHitPercent2 { get; set;}
|
||||
public Int32 FirstHitPercent2 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// First hit percent channel 3
|
||||
/// </summary>
|
||||
public Int32 FirstHitPercent3 { get; set;}
|
||||
public Int32 FirstHitPercent3 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Time of flight temperature offset channel 1
|
||||
/// </summary>
|
||||
public Int32 ToFTempOffset1 { get; set;}
|
||||
public Int32 ToFTempOffset1 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Time of flight temperature offset channel 2
|
||||
/// </summary>
|
||||
public Int32 ToFTempOffset2 { get; set;}
|
||||
|
||||
public Int32 ToFTempOffset2 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Time of flight temperature offset channel 3
|
||||
/// </summary>
|
||||
public Int32 ToFTempOffset3 { get; set;}
|
||||
public Int32 ToFTempOffset3 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Meter size
|
||||
/// </summary>
|
||||
public Int32 MeterSize { get; set;}
|
||||
public Int32 MeterSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Test date time
|
||||
/// </summary>
|
||||
public DateTime Date { get; set;}
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Test labeled as succeeded
|
||||
/// </summary>
|
||||
public Boolean Succeeded { get; set;}
|
||||
public Boolean Succeeded { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,33 +1,67 @@
|
||||
namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
{
|
||||
using global::Common.Logic.Extensions.SQL;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
|
||||
[RoutePrefix("api/configurationjson")]
|
||||
[RoutePrefix("configurationjson")]
|
||||
public class ConfigurationJsonController : ApiController
|
||||
{
|
||||
[HttpGet]
|
||||
[Route]
|
||||
public IHttpActionResult Get()
|
||||
{
|
||||
var message = String.Empty;
|
||||
var configurationText = String.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
var currentDirectory = HttpContext.Current.Request.MapPath("..");
|
||||
var files = Directory.GetFiles(currentDirectory);
|
||||
var configurationJsonFilePath = Path.Combine(currentDirectory, "configuration.json");
|
||||
var configurationJsonContent = File.ReadAllText(configurationJsonFilePath);
|
||||
var configurationJson = JsonConvert.DeserializeObject(configurationJsonContent);
|
||||
var serializerSettings = new JsonSerializerSettings();
|
||||
|
||||
return this.Json(configurationJson, serializerSettings, Encoding.UTF8);
|
||||
var connectionString = ConfigurationManager.ConnectionStrings["Default"].ConnectionString;
|
||||
var configurationBytes = SQLConnection
|
||||
.CreateSQLConnection(connectionString)
|
||||
.CreateCommand(@"
|
||||
SELECT TOP 1 f.FileContent
|
||||
FROM FileClusterStore AS fcs
|
||||
JOIN FileMapToCluster AS fmc
|
||||
ON fcs.FileId = fmc.FileMapToCluster_FileClusterId
|
||||
JOIN [File] AS f
|
||||
ON fmc.FileMapToCluster_FileId = f.FileId
|
||||
WHERE FileCategoryID = 2
|
||||
ORDER BY f.FileId DESC")
|
||||
.FirstOrDefault(x => x.GetValue<Byte[]>(0));
|
||||
configurationText = Encoding.ASCII.GetString(configurationBytes);
|
||||
}
|
||||
catch
|
||||
catch (Exception dbe)
|
||||
{
|
||||
return this.BadRequest("Unable to find or load ...\\configuration.json");
|
||||
message = dbe.Message;
|
||||
|
||||
try
|
||||
{
|
||||
var configurationPath = HttpContext.Current.Request.MapPath("configuration.json");
|
||||
configurationText = File.ReadAllText(configurationPath);
|
||||
}
|
||||
catch (Exception fe)
|
||||
{
|
||||
message = fe.Message;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var configurationJson = JsonConvert.DeserializeObject(configurationText);
|
||||
|
||||
return this.Json(configurationJson, new JsonSerializerSettings(), Encoding.UTF8);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return this.BadRequest($"{e.Message}{Environment.NewLine}{message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ using System.Web.Http;
|
||||
using Xylem.Common.Logic.ProductionOrderCore;
|
||||
using Xylem.Common.Logic.ProductionOrderCore.KitronTestResults;
|
||||
using Xylem.Common.Logic.ProductionOrderCore.OrderData;
|
||||
using Xylem.Common.Logic.ProductionOrderCore.TestResults;
|
||||
using Xylem.Common.Logic.ProductionOrderCore.Vako;
|
||||
using Xylem.Common.Logic.ServiceCore;
|
||||
|
||||
@ -1306,7 +1307,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
AND PcbId = @{nameof(pcbId)}
|
||||
ORDER BY date DESC")
|
||||
.SetParameter(nameof(pcbId), pcbId)
|
||||
.FirstOrDefault(x => new
|
||||
.FirstOrDefault(x => new CalibrationResults
|
||||
{
|
||||
Id = x.GetValue<Int32>(0),
|
||||
PcbId = x.GetValue<String>(1),
|
||||
@ -1316,7 +1317,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
ZeroOffset1 = x.GetValue<Int32>(5),
|
||||
ZeroOffset2 = x.GetValue<Int32>(6),
|
||||
ZeroOffset3 = x.GetValue<Int32>(7),
|
||||
FirstHitUpdatePeriod = x.GetValue<Int32>(8),
|
||||
FirstHitUpdatePer = x.GetValue<Int32>(8),
|
||||
FirstHitShift = x.GetValue<Int32>(9),
|
||||
FirstHitPercent1 = x.GetValue<Int32>(10),
|
||||
FirstHitPercent2 = x.GetValue<Int32>(11),
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<LangVersion>7</LangVersion>
|
||||
<DocumentationFile>bin\Xylem.Common.Service.MeterProcessState.xml</DocumentationFile>
|
||||
<NoWarn>0049;1591</NoWarn>
|
||||
<NoWarn>IDE0003;IDE0049;CS1591;</NoWarn>
|
||||
<FilesToIncludeForPublish>OnlyFilesToRunTheApp</FilesToIncludeForPublish>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1 +1 @@
|
||||
Subproject commit 0508fcf3df61d529f18cd3991ee255b9ee62ae96
|
||||
Subproject commit 99c93561572034cdd1124b0b7e90ed8153261469
|
||||
@ -8,7 +8,7 @@
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>LaaProduction.Console</RootNamespace>
|
||||
<AssemblyName>LaaProduction.Console</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
@ -42,8 +42,15 @@
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.Primitives, Version=4.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.WebRequest" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
@ -64,10 +71,29 @@
|
||||
<Project>{03784923-1FD3-4535-80F5-286728DF62AB}</Project>
|
||||
<Name>LaaProduction.Data.Cordonel</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\LaaPackages\LaaPackages.Features.Cordonel\LaaPackages.Features.Cordonel.csproj">
|
||||
<Project>{8BEFD3AC-BB21-4B62-8D9A-CF8CBFD439EB}</Project>
|
||||
<Name>LaaPackages.Features.Cordonel</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\LaaPackages\LaaPackages.HttpClient\LaaPackages.HttpClient.csproj">
|
||||
<Project>{C9816412-7752-4F7A-8BD2-765DB6D58B3C}</Project>
|
||||
<Name>LaaPackages.HttpClient</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\LaaPackages\LaaPackages.SqlClient\LaaPackages.SqlClient.csproj">
|
||||
<Project>{F90B940C-9A83-496D-AAE0-11CD02CE0A22}</Project>
|
||||
<Name>LaaPackages.SqlClient</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>del "$(TargetDir)*.pdb"
|
||||
del "$(TargetDir)*.xml"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
@ -1,12 +1,56 @@
|
||||
namespace LaaProduction.Console
|
||||
{
|
||||
using LaaPackages.Features.Cordonel;
|
||||
using LaaPackages.HttpClient;
|
||||
using LaaPackages.SqlClient;
|
||||
|
||||
using System;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static void Main(String[] args)
|
||||
{
|
||||
var pcbidString = "192000024";
|
||||
var cordonelApps = HttpConnection
|
||||
.CreateHttpConnection<MPSConnection>("http://10.49.40.25/")
|
||||
.Get<CordonelAppsDictionary>(x => x.SetPath("/MeterProcessState/api/ConfigurationJson"))
|
||||
?.Value ?? new CordonelAppsDictionary();
|
||||
SqlConnection
|
||||
.CreateSqlConnection("Server=SLASQL01;Database=Auftrag;User Id=sa;Password=sqlserver")
|
||||
.CreateCommand($@"
|
||||
SELECT x.Id
|
||||
, x.Address
|
||||
, x.Value
|
||||
FROM (SELECT gmh.ID AS Id
|
||||
, CONVERT(VARBINARY(MAX), REPLACE(ISNULL(gmh.Address, '00'), '-', ''), 2) AS Address
|
||||
, CONVERT(VARBINARY(MAX), REPLACE(REPLACE(ISNULL(gmh.Value, '00'), 'NULL', '00'), '-', ''), 2) AS Value
|
||||
, ROW_NUMBER() OVER (PARTITION BY gmh.Address ORDER BY gmh.date DESC) AS Row
|
||||
FROM GenesisMeterRegisterHistory AS gmh
|
||||
WHERE gmh.PcbId = @{nameof(pcbidString)}) AS x
|
||||
WHERE x.Row = 1
|
||||
ORDER BY x.Address")
|
||||
.SetParameter(nameof(pcbidString), pcbidString)
|
||||
.ExecuteReader(reader =>
|
||||
{
|
||||
var addressBytes = reader.GetValue<Byte[]>(1);
|
||||
|
||||
if (addressBytes?.Length == 2)
|
||||
{
|
||||
var appId = addressBytes[0];
|
||||
var registerId = addressBytes[1];
|
||||
var register = cordonelApps[appId][registerId];
|
||||
|
||||
register.HistoryId = reader.GetValue<Int32>(0);
|
||||
register.Value = reader.GetValue<Byte[]>(2);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class MPSConnection : HttpConnection
|
||||
{
|
||||
public MPSConnection(string baseURL) : base(baseURL)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,19 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1" /></startup>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.29.0" newVersion="2.2.29.0" />
|
||||
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.29.0" newVersion="2.2.29.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.1" newVersion="8.0.0.1" />
|
||||
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.1" newVersion="8.0.0.1"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net481" />
|
||||
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net45" />
|
||||
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net481" />
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net481" />
|
||||
</packages>
|
||||
Loading…
Reference in New Issue
Block a user