From b1b0835a20637b640741693849060f78055a581b Mon Sep 17 00:00:00 2001 From: Stoyan Zlatev Date: Wed, 9 Apr 2025 15:19:25 +0200 Subject: [PATCH] csd preparations and calculations in the common console --- Common/.vs/config/applicationhost.config | 2 +- Common/CommonConsole/CommonConsole.csproj | 9 - Common/CommonConsole/Program.cs | 193 +++++++++--------- ...erRegisters.csproj.CoreCompileInputs.cache | 2 +- .../Eregister.cs | 34 +-- .../EregisterBatch.cs | 5 +- .../EregisterCheckInitializationTask.cs | 2 - .../EregisterTask.cs | 33 +-- .../Models/EregisterProgrammingParameters.cs | 9 +- Common/LaaPackages | 2 +- Common/Ui/Common.UI/App.config | 5 +- Common/Ui/Common.UI/Common.UI.csproj | 11 +- Common/Ui/Common.UI/Controls/MainMenu.xaml | 17 +- Common/Ui/Common.UI/Controls/MainMenu.xaml.cs | 14 ++ .../Common.UI/Controls/SIRTBroadcasters.xaml | 6 +- Common/Ui/Common.UI/Infrastructure/AppHost.cs | 5 +- .../Ui/Common.UI/Infrastructure/VMLocator.cs | 12 +- Common/Ui/Common.UI/Infrastructure/VM[T].cs | 2 +- Common/Ui/Common.UI/MainWindow.xaml | 1 - Common/Ui/Common.UI/MainWindow.xaml.cs | 9 +- .../Ui/Common.UI/Models/AuftragDbContext.cs | 20 +- Common/Ui/Common.UI/Models/P2000_Shared.cs | 14 +- .../Common.UI/Pages/Eregister/VM/HistoryVM.cs | 2 +- .../Ui/Common.UI/Pages/EregisterFinalize.xaml | 13 +- .../Ui/Common.UI/Pages/EregisterHistory.xaml | 42 ++++ .../Common.UI/Pages/EregisterHistory.xaml.cs | 19 ++ .../Common.UI/Pages/EregisterInitialize.xaml | 7 +- .../ViewModels/EregisterFinalizeVM.cs | 24 ++- .../ViewModels/EregisterHistoryVM.cs | 100 +++++++++ .../ViewModels/EregisterInitializeVM.cs | 186 ++++++++--------- Common/Ui/Common.UI/ViewModels/MainMenuVM.cs | 25 --- ...BroadcasterVM.cs => SIRTBroadcastersVM.cs} | 4 +- .../Common.UI/ViewModels/SIRTConnectionVM.cs | 8 +- 33 files changed, 480 insertions(+), 357 deletions(-) create mode 100644 Common/Ui/Common.UI/Pages/EregisterHistory.xaml create mode 100644 Common/Ui/Common.UI/Pages/EregisterHistory.xaml.cs create mode 100644 Common/Ui/Common.UI/ViewModels/EregisterHistoryVM.cs delete mode 100644 Common/Ui/Common.UI/ViewModels/MainMenuVM.cs rename Common/Ui/Common.UI/ViewModels/{SIRTBroadcasterVM.cs => SIRTBroadcastersVM.cs} (95%) diff --git a/Common/.vs/config/applicationhost.config b/Common/.vs/config/applicationhost.config index 883679a3..a894c3cf 100644 --- a/Common/.vs/config/applicationhost.config +++ b/Common/.vs/config/applicationhost.config @@ -155,7 +155,7 @@ - + diff --git a/Common/CommonConsole/CommonConsole.csproj b/Common/CommonConsole/CommonConsole.csproj index 2113067b..329466b8 100644 --- a/Common/CommonConsole/CommonConsole.csproj +++ b/Common/CommonConsole/CommonConsole.csproj @@ -51,7 +51,6 @@ - @@ -69,14 +68,6 @@ {4e8bb839-d40a-488c-88ce-f21811f1f476} Common.Hardware.WaterMeter.eRegister - - {f013a56b-7be6-4852-9cd8-b971cd1add0c} - GenesisConfig - - - {04201e95-90a0-4b73-a72f-379739b2a3ae} - GenesisCore - {f4aaf7e6-7333-4284-b735-e32deb076c64} Registers diff --git a/Common/CommonConsole/Program.cs b/Common/CommonConsole/Program.cs index 12742a90..8fbc8322 100644 --- a/Common/CommonConsole/Program.cs +++ b/Common/CommonConsole/Program.cs @@ -1,99 +1,60 @@ namespace CommonConsole { - using Common.Hardware.SIRT; - using Common.Hardware.SIRT.Parameters; - using Common.Hardware.SIRT.Tasks; - using Common.Hardware.WaterMeter.eRegister.Features; - using Common.Hardware.WaterMeter.eRegister.Telegrams; - using System; - using System.Collections.Concurrent; - using System.Linq; - using System.Threading.Tasks; - public static class Program { - private static uint[] addresses433 = new uint[] + public static void Main() { - 4291024821, - 4291175952, - 4291318920, - 4291369854, - 4291577251, - 4291721523, - 4291796136, - 4291922942, - 4291922963, - 4291011837, - }; - private static uint[] addresses868 = new uint[] - { - 0309018341, - 0309023213, - 0309023279, - 4291094212, - 4291134308, - 4291657730, - 4291759578, - 4291808024, - 4291868627, - 4291922821, - 4291923131, - }; + } - private static readonly ConcurrentDictionary addressesWithFrequencies - = new ConcurrentDictionary(); - - - internal enum AlarmMask - { - ALARM_REBOOT = 1 << 0, - ALARM_LOW_BATTERY = 1 << 1, - ALARM_VERY_LOW_BATTERY = 1 << 2, /* For consistency with st_alarm_bit_t only */ - ALARM_CONFIG_ERROR = 1 << 3, - ALARM_EMPTY_PIPE = 1 << 4, - ALARM_MAGNETIC_TAMPER = 1 << 5, /* For consistency with st_alarm_bit_t only */ - ALARM_REVERSE_FLOW = 1 << 6, - ALARM_SUSPECT_LEAK = 1 << 7, - ALARM_BROKEN_PIPE = 1 << 8, - ALARM_LOW_PRESSURE = 1 << 9, - ALARM_HIGH_PRESSURE = 1 << 10, - ALARM_LOW_TEMPERATURE = 1 << 11, - ALARM_HIGH_TEMPERATURE = 1 << 12, - ALARM_RADIO_ERROR = 1 << 13, - ALARM_METROLOGY_PARAMS = 1 << 14, - ALARM_METROLOGY_MEASURE = 1 << 15, - ALARM_MAX = 1 << 16 - }; - - internal enum FDRMask - { - LOG_BILLING_COUNTER = 0x00000002, //!< BillingCounter - LOG_FORWARD_COUNTER = 0x00001000, //!< ForwardCounter - LOG_REVERSE_COUNTER = 0x00000004, //!< Backward or ReverseCounter - LOG_MIN_FLOW_TIME = 0x00000800, //!< Date/Time of FlowMin - LOG_MIN_FLOW_VAL = 0x00000400, //!< Value of FlowMin - LOG_BROKEN_PIPE_FLOW_TIME = 0x00000200, //!< Date/Time of BrokenPipe - LOG_BROKEN_PIPE_FLOW_VAL = 0x00000100, //!< Value of BrokenPipe - LOG_CUR_FLOW_VAL = 0x00000080, //!< Current Flow Value (Average of Period) - LOG_PEAK_FLOW_TIME = 0x00000040, //!< Date/Time of PeakFlow - LOG_PEAK_FLOW_VAL = 0x00000020, //!< Value of PeakFlow - LOG_MAX_FLOW_TIME = 0x00000010, //!< Date/Time of MaxFlow - LOG_MAX_FLOW_VAL = 0x00000008, //!< Value of MaxFlow - LOG_CUR_TEMP_VAL = 0x02000000, //!< Temperature Current Value - LOG_MAX_TEMP_TIME = 0x00800000, //!< Temperature Maximum - LOG_MAX_TEMP_VAL = 0x00400000, //!< Temperature Maximum - LOG_MIN_TEMP_TIME = 0x00200000, //!< Temperature Minimum - LOG_MIN_TEMP_VAL = 0x00100000, //!< Temperature Minimum - LOG_CUR_PRESS_VAL = 0x01000000, //!< Pressure Current Value - LOG_MAX_PRESS_TIME = 0x00080000, //!< Pressure Maximum Time - LOG_MAX_PRESS_VAL = 0x00040000, //!< Pressure Maximum - LOG_MIN_PRESS_TIME = 0x00020000, //!< Pressure Minimum Time - LOG_MIN_PRESS_VAL = 0x00010000, //!< Pressure Minimum - LOG_ALARM_STATE = 0x00000001, //!< AlarmState (16 bits) - LOG_EXT_ALARM_STATE = 0x04000000,    // this.state; - internal void StartProgrammingAsync() + internal void StartProgrammingAsync(CancellationToken cancellationToken) { this.history.SerienNr = this.parameters.SerienNr; this.history.Adresse = this.parameters.Adresse; @@ -120,19 +123,20 @@ this.sirtChannel.MessageReceived += messageReceived; var lastTask = default(EregisterTask); + var firstTask = true; - while (this.runningTasks.TryPeek(out var task) && task.State != SIRTTaskState.Cancelled) + while (this.runningTasks.TryPeek(out var task) && task.State != SIRTTaskState.Cancelled && !cancellationToken.IsCancellationRequested) { lastTask = task; - while (task.State != SIRTTaskState.Completed) + while (task.State != SIRTTaskState.Completed && !cancellationToken.IsCancellationRequested) { this.sirtChannel.WriteHandler(task); this.history.Push(task); - readEvent.Wait(4000); + readEvent.Wait(5000); readEvent.Reset(); - if (!task.AnyTelegramReceived) + if (firstTask && !task.AnyTelegramReceived) { var result = MessageBox.Show($"Das Rechenwerk an Ep: {task.SlotNr} mit Funkadresse: {task.RequestAddress}|{task.ResponseAddress} sendet nicht. " + $"Überprüfen Sie, ob alle SIRT's sind und oder die Funkfrequenz von dem Rechenwerk ist nicht verwechselt." @@ -175,6 +179,8 @@ } } + firstTask = false; + if (task.State == SIRTTaskState.Completed) { var cultureInfo = CultureInfo.InvariantCulture; diff --git a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterBatch.cs b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterBatch.cs index 2d8087bf..064fd291 100644 --- a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterBatch.cs +++ b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterBatch.cs @@ -2,8 +2,7 @@ { using Common.Hardware.SIRT; using Common.Hardware.WaterMeter.eRegister.Models; - - using System; + using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -55,7 +54,7 @@ foreach (var eregister in this.eregisters) { - tasks.Add(Task.Run((Action)eregister.StartProgrammingAsync, cancellationToken)); + tasks.Add(Task.Run(() => eregister.StartProgrammingAsync(cancellationToken), cancellationToken)); } return Task.WhenAll(tasks); diff --git a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterCheckInitializationTask.cs b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterCheckInitializationTask.cs index c0cf3106..b2997736 100644 --- a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterCheckInitializationTask.cs +++ b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterCheckInitializationTask.cs @@ -32,7 +32,6 @@ if (this.State == SIRTTaskState.Completed) { - this.Name = "Initial Check - ✓"; this.ErrorMessage = default(ErrorMessage); var message = new StringBuilder(); message.AppendLine(); @@ -102,7 +101,6 @@ message.AppendLine(); message.AppendLine("Linienleitung informieren!"); - this.Name = "Initial Check ✘"; this.ErrorMessage = new ErrorMessage { Title = "Fehler bei der Prüfungsinitialisierung", diff --git a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterTask.cs b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterTask.cs index bc711df9..4947f8a1 100644 --- a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterTask.cs +++ b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/EregisterTask.cs @@ -96,11 +96,13 @@ public override void Push(SIRTMessage response) { + this.AnyTelegramReceived = true; + if (this.State == SIRTTaskState.Cancelled) { this.Label = nameof(SIRTTaskState.Cancelled); } - else + else if (this.State != SIRTTaskState.Pending) { if (response.Address != this.RequestAddress) { @@ -113,33 +115,32 @@ if (response.Command == SIRTConstants.FROM_AIR) { - this.AnyTelegramReceived = true; this.P11 = new P11(response.P1); this.RSSI = new RSSI(response.P2, (ushort)this.Frequency); var data = response.Payload; var length = data.Length; - if (this.IsEncrypted) - { - data = data.DecryptResponse(this.EncryptionKey); - } - if (length > 0) { var type = data[0]; + + if (this.IsEncrypted) + { + data = data.DecryptResponse(this.EncryptionKey); + } if (type == SIRTConstants.BUP) { this.Label = nameof(SIRTConstants.BUP); + this.IsEncrypted = this.DEBUG.Crc != 0; this.BUP = new BUP(data, this.P11); - this.IsEncrypted = this.BUP.Crc != 0; } else if (type == SIRTConstants.LAT) { this.Label = nameof(SIRTConstants.LAT); + this.IsEncrypted = this.DEBUG.Crc != 0; this.LAT = new LAT(data, this.P11); - this.IsEncrypted = this.LAT.Crc != 0; } else if (type == SIRTConstants.DEBUG) { @@ -151,15 +152,19 @@ else if (type == SIRTConstants.SEMI) { this.SEMI = new SEMI(data, this.Frequency, this.P11); - this.IsEncrypted = this.SEMI.Crc != 0; + this.IsEncrypted = this.DEBUG.Crc != 0; this.Label = default(string); - if (this.SEMI.PAMStatus == PAMStatus.OK || this.RadioFWVersion < 4352) + if (this.SEMI.PAMStatus == PAMStatus.OK) { if (this.request.Length > 0 && this.request.Payload[0] == Pam.GetDebug && this.DEBUG == null) { this.Label = "!DEBUG"; } + else if (this.LAT is null) + { + this.Label = "!LAT"; + } else { this.State = SIRTTaskState.Completed; @@ -170,11 +175,7 @@ { this.Label = this.SEMI.PAMStatus.ToString(); - if (this.SEMI.PAMStatus == PAMStatus.EXPIREDAUTH) - { - this.State = SIRTTaskState.Cancelled; - } - else if (++this.countFailures > 3) + if (++this.countFailures > 3 && this.SEMI.PAMStatus == PAMStatus.EXPIREDAUTH) { this.State = SIRTTaskState.Cancelled; } diff --git a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Models/EregisterProgrammingParameters.cs b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Models/EregisterProgrammingParameters.cs index d99b602f..3c7cf8d1 100644 --- a/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Models/EregisterProgrammingParameters.cs +++ b/Common/Hardware/WaterMeter/eRegister/Common.Hardware.WaterMeter.eRegister/Models/EregisterProgrammingParameters.cs @@ -11,7 +11,6 @@ [XmlRoot(nameof(EregisterProgrammingParameters))] public class EregisterProgrammingParameters { - [XmlAttribute("P2000_Shared_Id")] public int SharedId { get; set; } public int SlotNr { get; set; } @@ -258,13 +257,6 @@ EncryptionKey = this.EncryptionKey.GetEncryptionKey(), }; - if (!this.IsValid) - { - features.ChangeMeterReading = new ChangeMeterReading(222_222_222); - - return features; - } - if (this.StatusFertigung != 30) { features.ChangeMeterReading = new ChangeMeterReading(333_333_333); @@ -428,6 +420,7 @@ features.ChangeNumberOfLatWindows = new ChangeNumberOfLatWindows(this.LatWindowsInitialization); features.ChangeMeterReading = new ChangeMeterReading(111_111_111); features.WirelessMBusMode = new WirelessMBusMode(this.MBusStatus); + // features.ChangeRadioId = new ChangeRadioId(this.ResponseAddress); features.SetMetrologyParameters = new SetMetrologyParameters { UseCandIRules = this.DisallowReverseVolume, diff --git a/Common/LaaPackages b/Common/LaaPackages index e7aa3e27..ce1dc260 160000 --- a/Common/LaaPackages +++ b/Common/LaaPackages @@ -1 +1 @@ -Subproject commit e7aa3e2723a435f0a714df661dc5d86dfd45a71c +Subproject commit ce1dc26047374fd7a9328914a6c2bd7eb591f012 diff --git a/Common/Ui/Common.UI/App.config b/Common/Ui/Common.UI/App.config index 80dee492..c879d111 100644 --- a/Common/Ui/Common.UI/App.config +++ b/Common/Ui/Common.UI/App.config @@ -4,10 +4,11 @@ - + + - + diff --git a/Common/Ui/Common.UI/Common.UI.csproj b/Common/Ui/Common.UI/Common.UI.csproj index 6f680526..fcd9d1d9 100644 --- a/Common/Ui/Common.UI/Common.UI.csproj +++ b/Common/Ui/Common.UI/Common.UI.csproj @@ -157,6 +157,9 @@ + + EregisterHistory.xaml + EregisterInitialize.xaml @@ -181,13 +184,13 @@ + - - + SIRTBroadcasters.xaml @@ -237,6 +240,10 @@ MainWindow.xaml Code + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/Common/Ui/Common.UI/Controls/MainMenu.xaml b/Common/Ui/Common.UI/Controls/MainMenu.xaml index 198d305f..5eec1455 100644 --- a/Common/Ui/Common.UI/Controls/MainMenu.xaml +++ b/Common/Ui/Common.UI/Controls/MainMenu.xaml @@ -1,10 +1,13 @@  - - - - - + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> + + + diff --git a/Common/Ui/Common.UI/Controls/MainMenu.xaml.cs b/Common/Ui/Common.UI/Controls/MainMenu.xaml.cs index 28fb2d13..2ecf85d2 100644 --- a/Common/Ui/Common.UI/Controls/MainMenu.xaml.cs +++ b/Common/Ui/Common.UI/Controls/MainMenu.xaml.cs @@ -1,9 +1,23 @@ namespace Common.UI.Controls { + using System; + using System.Windows; using System.Windows.Controls; + using System.Windows.Navigation; public partial class MainMenu : Menu { public MainMenu() => this.InitializeComponent(); + + private void MenuItem_Click(object sender, RoutedEventArgs args) + { + if (sender is MenuItem menuItem && menuItem.CommandParameter is string page) + { + if (App.Current.MainWindow is NavigationWindow navigationWindow) + { + navigationWindow.Navigate(new Uri(page, UriKind.RelativeOrAbsolute)); + } + } + } } } diff --git a/Common/Ui/Common.UI/Controls/SIRTBroadcasters.xaml b/Common/Ui/Common.UI/Controls/SIRTBroadcasters.xaml index d747a27e..c3b43136 100644 --- a/Common/Ui/Common.UI/Controls/SIRTBroadcasters.xaml +++ b/Common/Ui/Common.UI/Controls/SIRTBroadcasters.xaml @@ -1,10 +1,8 @@  - - - + xmlns:vm="clr-namespace:Common.UI.ViewModels" + DataContext="{Binding SIRTBroadcasterVM, Source={StaticResource VMLocator}}"> diff --git a/Common/Ui/Common.UI/Infrastructure/AppHost.cs b/Common/Ui/Common.UI/Infrastructure/AppHost.cs index c6e319f7..6a357437 100644 --- a/Common/Ui/Common.UI/Infrastructure/AppHost.cs +++ b/Common/Ui/Common.UI/Infrastructure/AppHost.cs @@ -19,9 +19,10 @@ private static ILogger CreateNLogger() { + var dll = new FileInfo(typeof(AppHost).Assembly.Location); var name = "NLogs"; - var dir = Directory.CreateDirectory("NLogs"); - var file = Path.Combine(dir.FullName, $"{DateTime.Now:yyyy-MM-dd}.txt"); + var nlogs = dll.Directory.CreateSubdirectory(name); + var file = Path.Combine(nlogs.FullName, $"{DateTime.Now:yyyy-MM-dd}.txt"); LogManager.Configuration = new LoggingConfiguration(); LogManager.ThrowConfigExceptions = true; diff --git a/Common/Ui/Common.UI/Infrastructure/VMLocator.cs b/Common/Ui/Common.UI/Infrastructure/VMLocator.cs index d9ab4425..3e367e4d 100644 --- a/Common/Ui/Common.UI/Infrastructure/VMLocator.cs +++ b/Common/Ui/Common.UI/Infrastructure/VMLocator.cs @@ -1,9 +1,15 @@ namespace Common.UI.Infrastructure { - using Common.UI.Pages.Eregister.VM; + using Common.UI.ViewModels; - internal class VMLocator + public class VMLocator { - public EregisterLocator Eregister { get; } = new EregisterLocator(); + public SIRTBroadcastersVM SIRTBroadcasterVM { get; } = new SIRTBroadcastersVM(); + + public EregisterHistoryVM EregisterHistoryVM { get; } = new EregisterHistoryVM(); + + public EregisterInitializeVM EregisterInitializeVM { get; } = new EregisterInitializeVM(); + + public EregisterFinalizeVM EregisterFinalizeVM { get; } = new EregisterFinalizeVM(); } } diff --git a/Common/Ui/Common.UI/Infrastructure/VM[T].cs b/Common/Ui/Common.UI/Infrastructure/VM[T].cs index b436cc77..a23524e1 100644 --- a/Common/Ui/Common.UI/Infrastructure/VM[T].cs +++ b/Common/Ui/Common.UI/Infrastructure/VM[T].cs @@ -14,7 +14,7 @@ { } - protected void Set(Action propertySetterCallback, [CallerMemberName] string property = null) + protected void SetValue(Action propertySetterCallback, [CallerMemberName] string property = null) { propertySetterCallback?.Invoke(this as T); this.NotifyPropertyChanged(property); diff --git a/Common/Ui/Common.UI/MainWindow.xaml b/Common/Ui/Common.UI/MainWindow.xaml index d1fb7bca..11db098a 100644 --- a/Common/Ui/Common.UI/MainWindow.xaml +++ b/Common/Ui/Common.UI/MainWindow.xaml @@ -4,5 +4,4 @@ ShowsNavigationUI="False" Source="Pages/EregisterInitialize.xaml" Title="TestBench UI"> - diff --git a/Common/Ui/Common.UI/MainWindow.xaml.cs b/Common/Ui/Common.UI/MainWindow.xaml.cs index 9ac3dc31..c11c8de5 100644 --- a/Common/Ui/Common.UI/MainWindow.xaml.cs +++ b/Common/Ui/Common.UI/MainWindow.xaml.cs @@ -11,17 +11,14 @@ { this.InitializeComponent(); - this.NavigationService.LoadCompleted += this.NavigationService_LoadCompleted; + this.NavigationService.Navigated += this.NavigationService_LoadCompleted; } private void NavigationService_LoadCompleted(object sender, NavigationEventArgs args) { - if (args.Content is Page page) + if (args.Content is Page page && page.DataContext is VM vm) { - if (page.DataContext is VM vm) - { - App.InvokeAsync(() => vm.ViewModel_Loaded(args.ExtraData)); - } + App.InvokeAsync(() => vm.ViewModel_Loaded(args.ExtraData)); } } } diff --git a/Common/Ui/Common.UI/Models/AuftragDbContext.cs b/Common/Ui/Common.UI/Models/AuftragDbContext.cs index 33befca9..0e204f76 100644 --- a/Common/Ui/Common.UI/Models/AuftragDbContext.cs +++ b/Common/Ui/Common.UI/Models/AuftragDbContext.cs @@ -82,8 +82,8 @@ internal class P2000Shared { - internal static P2000_Shared LoadPendingAction(int psno) - => sqlConnection.LoadPendingActions(psno); + internal static int FindSharedId(int psno, string action) + => sqlConnection.FindSharedId(psno, action); } internal static EregisterProgrammingParametersList LoadEregisterProgrammingParametersListForSharedId(int sharedId) @@ -156,21 +156,5 @@ return xmlDeserialized as EregisterProgrammingParametersList ?? new EregisterProgrammingParametersList(); } - - internal static EregisterProgrammingParametersList LoadEregisterProgrammingParametersList(int sharedId, string psno) - { - if (sharedId <= 0 && int.TryParse($"{Appsettings.GetSetting("PSNR")}", out var psnr)) - { - var pendingAction = P2000Shared.LoadPendingAction(psnr); - sharedId = pendingAction?.Id ?? 0; - } - - if (sharedId <= 0) - { - return new EregisterProgrammingParametersList(); - } - - return LoadEregisterProgrammingParametersListForSharedId(sharedId); - } } } diff --git a/Common/Ui/Common.UI/Models/P2000_Shared.cs b/Common/Ui/Common.UI/Models/P2000_Shared.cs index b96e183f..4969d074 100644 --- a/Common/Ui/Common.UI/Models/P2000_Shared.cs +++ b/Common/Ui/Common.UI/Models/P2000_Shared.cs @@ -17,21 +17,17 @@ internal static class P2000_Shared_Extensions { - public static P2000_Shared LoadPendingActions(this SqlConnection connection, int psno) + public static int FindSharedId(this SqlConnection connection, int psno, string action) => connection .CreateCommand($@" - SELECT TOP 1 - Id - , Action + SELECT TOP 1 Id FROM P2000_Shared WHERE Psno = @{nameof(psno)} + AND Action = @{nameof(action)} AND Completed = 0 ORDER BY Id DESC") .SetParameter(nameof(psno), psno) - .FirstOrDefault(x => new P2000_Shared - { - Id = x.GetValue(0), - Action = x.GetValue(1) - }); + .SetParameter(nameof(action), action) + .FirstOrDefault(x => x.GetValue(0)); } } diff --git a/Common/Ui/Common.UI/Pages/Eregister/VM/HistoryVM.cs b/Common/Ui/Common.UI/Pages/Eregister/VM/HistoryVM.cs index 8a5cad52..ca728083 100644 --- a/Common/Ui/Common.UI/Pages/Eregister/VM/HistoryVM.cs +++ b/Common/Ui/Common.UI/Pages/Eregister/VM/HistoryVM.cs @@ -24,7 +24,7 @@ public AddressVM Address { get => this.address; - set => this.Set(x => x.address = value); + set => this.SetValue(x => x.address = value); } public ICommand RefreshAddresses { get; } diff --git a/Common/Ui/Common.UI/Pages/EregisterFinalize.xaml b/Common/Ui/Common.UI/Pages/EregisterFinalize.xaml index 977d2c8f..45dd1b46 100644 --- a/Common/Ui/Common.UI/Pages/EregisterFinalize.xaml +++ b/Common/Ui/Common.UI/Pages/EregisterFinalize.xaml @@ -2,12 +2,9 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:Common.UI.Controls" - xmlns:VM="clr-namespace:Common.UI.ViewModels" WindowTitle="Prüfungsabschluss" - FontFamily="Consolas"> - - - + FontFamily="Consolas" + DataContext="{Binding EregisterFinalizeVM, Source={StaticResource VMLocator}}"> @@ -24,7 +21,7 @@ VerticalScrollBarVisibility="Auto"> - @@ -34,14 +31,14 @@ HorizontalAlignment="Left" IsEnabled="{Binding StartEnabled}" Margin="0, 0, 5, 0" - Padding="20, 3"/> + Padding="20, 5"/>