diff --git a/Common/Common.sln b/Common/Common.sln index 894b3b22..8896c271 100644 --- a/Common/Common.sln +++ b/Common/Common.sln @@ -3863,8 +3863,8 @@ Global {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.COM|x64.Build.0 = Release|Any CPU {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.COM|x86.ActiveCfg = Release|Any CPU {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.COM|x86.Build.0 = Release|Any CPU - {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Debug|Any CPU.ActiveCfg = qweerqwer|Any CPU + {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Debug|Any CPU.Build.0 = qweerqwer|Any CPU {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {AFC428F5-0141-4A3F-BEF2-470A89D972F6}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -4567,8 +4567,8 @@ Global {8E1431E9-9B14-4BC2-8B65-47357C97B1FC}.COM|x64.Build.0 = Release|Any CPU {8E1431E9-9B14-4BC2-8B65-47357C97B1FC}.COM|x86.ActiveCfg = Release|Any CPU {8E1431E9-9B14-4BC2-8B65-47357C97B1FC}.COM|x86.Build.0 = Release|Any CPU - {8E1431E9-9B14-4BC2-8B65-47357C97B1FC}.Debug|Any CPU.ActiveCfg = Development|Any CPU - {8E1431E9-9B14-4BC2-8B65-47357C97B1FC}.Debug|Any CPU.Build.0 = Development|Any CPU + {8E1431E9-9B14-4BC2-8B65-47357C97B1FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E1431E9-9B14-4BC2-8B65-47357C97B1FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {8E1431E9-9B14-4BC2-8B65-47357C97B1FC}.Debug|Mixed Platforms.ActiveCfg = Development|Any CPU {8E1431E9-9B14-4BC2-8B65-47357C97B1FC}.Debug|Mixed Platforms.Build.0 = Development|Any CPU {8E1431E9-9B14-4BC2-8B65-47357C97B1FC}.Debug|x64.ActiveCfg = Debug|Any CPU diff --git a/Common/CommonConsole/CommonConsole.csproj b/Common/CommonConsole/CommonConsole.csproj index 535795a3..ef56b581 100644 --- a/Common/CommonConsole/CommonConsole.csproj +++ b/Common/CommonConsole/CommonConsole.csproj @@ -35,6 +35,15 @@ 4 false + + true + bin\qweerqwer\ + DEBUG;TRACE + full + AnyCPU + prompt + MinimumRecommendedRules.ruleset + ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll diff --git a/Common/CommonConsole/Program.cs b/Common/CommonConsole/Program.cs index fab693c4..ec6598d6 100644 --- a/Common/CommonConsole/Program.cs +++ b/Common/CommonConsole/Program.cs @@ -1,5 +1,6 @@ namespace CommonConsole { + using Common.Hardware.WaterMeter.OmniPlus; using Common.Utils.Extensions; using System; @@ -9,9 +10,20 @@ { public static void Main() { - var econnector = new EregisterConnector.EregisterConnector(); + var connection = new OmniConnection(); + connection.UseIrda("COM40"); - econnector.InitInspection(); + var _params = connection.ViewSystemParameters(); + + var x1 = connection.FactorySeal(false); + var x2 = connection.FactorySeal(true); + var x3 = connection.FactorySeal(false); + + connection.Disconnect(); + + //var econnector = new EregisterConnector.EregisterConnector(); + + //econnector.InitInspection(); } //var payloadLength = 32; diff --git a/Common/Logic/Common.Logic.Extensions.SQL/Interfaces/ISQLCommand.cs b/Common/Logic/Common.Logic.Extensions.SQL/Interfaces/ISQLCommand.cs index f37a1159..c1a7b708 100644 --- a/Common/Logic/Common.Logic.Extensions.SQL/Interfaces/ISQLCommand.cs +++ b/Common/Logic/Common.Logic.Extensions.SQL/Interfaces/ISQLCommand.cs @@ -16,5 +16,7 @@ T FirstOrDefault(Func expression); ISQLCommand SetParameter(String name, Object value); + + ISQLCommand SetParameter(String name, DateTime value); } } diff --git a/Common/Logic/Common.Logic.Extensions.SQL/SQLCommand.cs b/Common/Logic/Common.Logic.Extensions.SQL/SQLCommand.cs index c48de56a..ecb3061b 100644 --- a/Common/Logic/Common.Logic.Extensions.SQL/SQLCommand.cs +++ b/Common/Logic/Common.Logic.Extensions.SQL/SQLCommand.cs @@ -63,9 +63,23 @@ value = DBNull.Value; } - var parameter = new SqlParameter(name, value); + this.parameters[name] = new SqlParameter(name, value); - this.parameters[name] = parameter; + return this; + } + + public ISQLCommand SetParameter(String name, DateTime value) + { + name.ThrowIfNullOrWhiteSpace(nameof(name)); + + var sqlDate = new DateTime(1753, 1, 1, 12, 0, 0); + + if (value < sqlDate) + { + value = sqlDate; + } + + this.parameters[name] = new SqlParameter(name, value); return this; } diff --git a/Common/OmniPlus/InspectionUI.Plugins.Omni/InspectionUI.Plugins.Omni.csproj b/Common/OmniPlus/InspectionUI.Plugins.Omni/InspectionUI.Plugins.Omni.csproj index f2e2950d..f9a32580 100644 --- a/Common/OmniPlus/InspectionUI.Plugins.Omni/InspectionUI.Plugins.Omni.csproj +++ b/Common/OmniPlus/InspectionUI.Plugins.Omni/InspectionUI.Plugins.Omni.csproj @@ -26,6 +26,7 @@ 4 false InspectionUI.Plugins.Omni.ruleset + IDE0003;IDE0040;IDE0049; pdbonly @@ -44,9 +45,9 @@ false - bin\Development\ + bin\Debug\ DEBUG;TRACE - true + false none AnyCPU prompt diff --git a/Common/OmniPlus/InspectionUI/App.config b/Common/OmniPlus/InspectionUI/App.config index 0c6b9785..f2d22ac7 100644 --- a/Common/OmniPlus/InspectionUI/App.config +++ b/Common/OmniPlus/InspectionUI/App.config @@ -6,7 +6,7 @@ - + diff --git a/Common/OmniPlus/InspectionUI/Plugins/Appsettings.cs b/Common/OmniPlus/InspectionUI/Plugins/Appsettings.cs index 8f1ff4fa..9d502978 100644 --- a/Common/OmniPlus/InspectionUI/Plugins/Appsettings.cs +++ b/Common/OmniPlus/InspectionUI/Plugins/Appsettings.cs @@ -28,7 +28,7 @@ ConfigurationManager.RefreshSection(appsettingsSectionName); - return Settings[setting].Value ?? string.Empty; + return Settings[setting]?.Value ?? string.Empty; } } } diff --git a/Common/OmniPlus/OmniPlus/Inspection/OmniContext.cs b/Common/OmniPlus/OmniPlus/Inspection/OmniContext.cs index 9fce4601..c9fb1dbb 100644 --- a/Common/OmniPlus/OmniPlus/Inspection/OmniContext.cs +++ b/Common/OmniPlus/OmniPlus/Inspection/OmniContext.cs @@ -112,7 +112,7 @@ this.Pruefer = testerId; this.Pruefgang = this.http .GetRequest("/laaproductionweb/api/omni/inspection/testrun") - .AddQueryParameter("psno", psnr) + .AddQueryParameter("psno", psnr ?? "1000") .AddQueryParameter("tester", testerId) .AddQueryParameter("count", count) .AddQueryParameter("class", this.InspectionOrder.TestClass) diff --git a/Common/OmniPlus/OmniPlus/Inspection/OmniMeter.cs b/Common/OmniPlus/OmniPlus/Inspection/OmniMeter.cs index a3374600..21f46d5a 100644 --- a/Common/OmniPlus/OmniPlus/Inspection/OmniMeter.cs +++ b/Common/OmniPlus/OmniPlus/Inspection/OmniMeter.cs @@ -1,15 +1,16 @@ namespace OmniPlus.Inspection { + using Common.Hardware.WaterMeter.OmniPlus; + using Common.Hardware.WaterMeter.OmniPlus.Features; using NLog; - using OmniPlus.Features; + // using OmniPlus.Features; using System; - using System.Threading; public class OmniMeter { - const string NA = "n/a"; + private const string NA = "n/a"; private readonly ILogger logger; @@ -21,8 +22,10 @@ this.Slot = nr; this.PortName = portName; this.logger = logger; - this.connection = new OmniIrdaConnection(portName); - this.connection.StateChenged += this.NotifyStateChanged; + this.connection = new OmniConnection(); + this.connection.UseIrda(portName); + this.connection.StartRecording(); + // this.connection.StateChenged += this.NotifyStateChanged; } public int Slot { get; } @@ -73,9 +76,9 @@ { if (this.connection != null) { - this.connection.StateChenged -= this.NotifyStateChanged; - - this.connection.Close(); + // this.connection.StateChenged -= this.NotifyStateChanged; + this.logger.Trace(this.connection.GetRecords()); + this.connection.Disconnect(); } this.connection = null; diff --git a/Common/OmniPlus/OmniPlus/OmniConnection.cs b/Common/OmniPlus/OmniPlus/OmniConnection.cs index e17d9e67..7c867cd8 100644 --- a/Common/OmniPlus/OmniPlus/OmniConnection.cs +++ b/Common/OmniPlus/OmniPlus/OmniConnection.cs @@ -1,11 +1,13 @@ namespace OmniPlus { - using OmniPlus.Features; + using Common.Hardware.WaterMeter.OmniPlus.Features; + // using OmniPlus.Features; using System; using System.Linq; using System.Text; - using static OmniPlus.Features.Features; + + using static Common.Hardware.WaterMeter.OmniPlus.Features.Commands; public delegate byte[] MessageHandler(params byte[] bytes); public delegate void StateChanged(object state); diff --git a/Common/OmniPlus/OmniPlus/OmniIrdaConnection.cs b/Common/OmniPlus/OmniPlus/OmniIrdaConnection.cs index 62d5faa2..93be10d4 100644 --- a/Common/OmniPlus/OmniPlus/OmniIrdaConnection.cs +++ b/Common/OmniPlus/OmniPlus/OmniIrdaConnection.cs @@ -1,33 +1,33 @@ namespace OmniPlus { - using OmniPlus.Connections; + // using OmniPlus.Connections; using System.IO.Ports; - public sealed class OmniIrdaConnection : OmniConnection + public sealed class _OmniIrdaConnection // : OmniConnection { - private readonly IRDAStream stream; + private readonly object stream; - public OmniIrdaConnection(string portName) + public _OmniIrdaConnection(string portName) { - this.stream = new IRDAStream( - encoder: new IRDAEncoder(new UI1236Encoder()), - settings: new SerialPortSettings - { - BaudRate = 115200, - DataBits = 8, - Parity = Parity.None, - PortName = portName, - StopBits = StopBits.One - }); - this.stream.StateChanged += this.OnStateChanged; - this.MessageHandler = this.stream.Send; + //this.stream = new IRDAStream( + // encoder: new IRDAEncoder(new UI1236Encoder()), + // settings: new SerialPortSettings + // { + // BaudRate = 115200, + // DataBits = 8, + // Parity = Parity.None, + // PortName = portName, + // StopBits = StopBits.One + // }); + //this.stream.StateChanged += this.OnStateChanged; + //this.MessageHandler = this.stream.Send; } - public override bool IsOpen => this.stream.IsOpen; + //public override bool IsOpen => this.stream.IsOpen; - public override void Close() => this.stream.Close(); + //public override void Close() => this.stream.Close(); - public override void Open() => this.stream.Open(); + //public override void Open() => this.stream.Open(); } } diff --git a/Common/OmniPlus/OmniPlus/OmniPlus.csproj b/Common/OmniPlus/OmniPlus/OmniPlus.csproj index bfc055c7..a4502576 100644 --- a/Common/OmniPlus/OmniPlus/OmniPlus.csproj +++ b/Common/OmniPlus/OmniPlus/OmniPlus.csproj @@ -63,58 +63,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -123,11 +71,8 @@ - - - @@ -135,6 +80,14 @@ + + {9D89FA2A-1217-4CE9-B217-E7602B974EA9} + Common.Hardware.WaterMeter.OmniPlus.Features + + + {6480CC2A-AB54-4A26-8413-D5141431C080} + Common.Hardware.WaterMeter.OmniPlus + {57DDAE1E-FD6B-47E0-AD5E-8CCFAD07F1D7} Common.Logic.Extensions.Http diff --git a/Common/OmniPlus/OmniPlus/OmniUniProConnection.cs b/Common/OmniPlus/OmniPlus/OmniUniProConnection.cs index f21b02cd..8ef5cac2 100644 --- a/Common/OmniPlus/OmniPlus/OmniUniProConnection.cs +++ b/Common/OmniPlus/OmniPlus/OmniUniProConnection.cs @@ -1,42 +1,42 @@ namespace OmniPlus { - using OmniPlus.Connections; + // using OmniPlus.Connections; using System.IO.Ports; - public class OmniUniProConnection : OmniConnection + public class _OmniUniProConnection // : OmniConnection { - private readonly UniProStream stream; + private readonly object stream; - public OmniUniProConnection(string portName) + public _OmniUniProConnection(string portName) { - this.stream = new UniProStream( - encoder: new UniProEncoder(), - settings: new SerialPortSettings - { - BaudRate = 2400, - DataBits = 8, - Parity = Parity.None, - PortName = portName, - StopBits = StopBits.One - }); - this.stream.StateChanged += this.OnStateChanged; - this.MessageHandler = this.stream.Send; + //this.stream = new UniProStream( + // encoder: new UniProEncoder(), + // settings: new SerialPortSettings + // { + // BaudRate = 2400, + // DataBits = 8, + // Parity = Parity.None, + // PortName = portName, + // StopBits = StopBits.One + // }); + //this.stream.StateChanged += this.OnStateChanged; + //this.MessageHandler = this.stream.Send; } - public override bool IsOpen - { - get => this.stream.IsOpen; - } + //public override bool IsOpen + //{ + // get => this.stream.IsOpen; + //} - public override void Close() - { - this.stream.Close(); - } + //public override void Close() + //{ + // this.stream.Close(); + //} - public override void Open() - { - this.stream.Open(); - } + //public override void Open() + //{ + // this.stream.Open(); + //} } } diff --git a/Common/PendingEmails/Program.cs b/Common/PendingEmails/Program.cs index ab194ed1..6d6febc5 100644 --- a/Common/PendingEmails/Program.cs +++ b/Common/PendingEmails/Program.cs @@ -10,6 +10,7 @@ using System.Net.Mail; using System.Threading; using System.Timers; + using SystemTimersTimer = System.Timers.Timer; public static class Program diff --git a/LaaProductionWeb/Data/LaaProduction.Data.Omni/OmniDbContext.cs b/LaaProductionWeb/Data/LaaProduction.Data.Omni/OmniDbContext.cs index 702286ff..4293b816 100644 --- a/LaaProductionWeb/Data/LaaProduction.Data.Omni/OmniDbContext.cs +++ b/LaaProductionWeb/Data/LaaProduction.Data.Omni/OmniDbContext.cs @@ -32,6 +32,7 @@ , [ManifacturingTime]) OUTPUT [inserted].[Id] , [inserted].[AddDate] + , [inserted].[ManifacturingTime] VALUES ((SELECT MAX([Id]) + 1 FROM [OmniTestRuns]) , @{nameof(testRun.PSNO)} , @{nameof(testRun.Slot)} @@ -54,6 +55,7 @@ { testRun.Id = x.GetValue(0); testRun.AddDate = x.GetValue(1); + testRun.ManifacturingDate = x.GetValue(2); return true; }); diff --git a/LaaProductionWeb/LaaProduction.Data.SQL/Interfaces/ISQLCommand.cs b/LaaProductionWeb/LaaProduction.Data.SQL/Interfaces/ISQLCommand.cs index 7a7b35e0..11fc7854 100644 --- a/LaaProductionWeb/LaaProduction.Data.SQL/Interfaces/ISQLCommand.cs +++ b/LaaProductionWeb/LaaProduction.Data.SQL/Interfaces/ISQLCommand.cs @@ -14,5 +14,7 @@ T FirstOrDefault(Func expression); ISQLCommand SetParameter(String name, Object value); + + ISQLCommand SetParameter(String name, DateTime value); } } diff --git a/LaaProductionWeb/LaaProduction.Data.SQL/SQLCommand.cs b/LaaProductionWeb/LaaProduction.Data.SQL/SQLCommand.cs index d318db46..c5cf2790 100644 --- a/LaaProductionWeb/LaaProduction.Data.SQL/SQLCommand.cs +++ b/LaaProductionWeb/LaaProduction.Data.SQL/SQLCommand.cs @@ -47,10 +47,22 @@ { value = DBNull.Value; } - //else if (value is DateTime dt && (DateTime.MinValue >= dt || dt >= DateTime.MaxValue)) - //{ - // value = DateTime.Now; - //} + + var parameter = new SqlParameter(name, value); + + this.parameters[name] = parameter; + + return this; + } + + public ISQLCommand SetParameter(String name, DateTime value) + { + var _default = new DateTime(1753, 1, 1, 12, 0, 0); + + if (value < _default) + { + value = _default; + } var parameter = new SqlParameter(name, value);