From a517211195ce129b1afcee2f1c6b5e4c4ab59ffb Mon Sep 17 00:00:00 2001 From: C3rebro Date: Tue, 21 Nov 2023 14:35:38 +0100 Subject: [PATCH] v1.0.33 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hintergrundfunktionen: + Änderung: Text "Sprachauswahl" ist keine Frage mehr. Anpassung der Funktion erfolgt später: Die Sprache soll zwar änderbar sein, jedoch erfolgt die Einstellung aus Omni heraus. + Änderung: Es werden Standardmäßig nur Aufträge mit dem Status "In Bearbeitung" angezeigt und nicht mehr alle. Dies kann über die Filterfunktion geändert werden. + Neue Funktion: Neue Einstellung: "Temporäre Berichtdateien löschen". Löscht alle editierbaren *_.pdf und *.pdf Dateien aus den Berichtverzeichnissen und behält nur die *_final.pdf* Dateien nach Fertigstellung. Ein Abschalten belässt diese Berichtdateien im Pfad. + Fehlerbehebung: InfoBar: "geöffneten Bericht wieder schließen" und Fortschrittverhinderung wenn dieser noch geöffnet ist. Dies verhindert ein "Steckenbleiben" wegen einer Zugriffsverweigerung auf die geöffnete PDF Datei. + Fehlerbehebung: "Schritt-Icon's" im linken Menüband (Häuschen-Icon und 1,2,3 - Icons) sind nicht mehr zur Navigation vorgesehen. Dies verhindert ein Springen zwischen Schritten wenn der Kartenleser noch beschäftigt ist. + Fehlerbehebung: Solange ein Bericht geöffnet ist, kann nicht von Schritt 2 auf Schritt 3 gewechselt werden. + Fehlerbehebung: Ein Prüfvorgang kann nicht gestartet werden, wenn der Bericht bereits exitiert und nicht überschrieben werden kann oder werden soll. --- CardCheckAssistant/CardCheckAssistant.csproj | 2 +- .../DataAccessLayer/DefaultSettings.cs | 10 + CardCheckAssistant/MainWindow.xaml | 4 +- CardCheckAssistant/Models/LSMCardTemplate.cs | 31 ++ CardCheckAssistant/Package.appxmanifest | 2 +- CardCheckAssistant/Shell.xaml | 11 +- CardCheckAssistant/Shell.xaml.Navigation.cs | 4 +- .../ViewModels/AboutPageViewModel.cs | 122 +++++++ .../ViewModels/HomePageViewModel.cs | 10 +- .../ViewModels/SettingsPageViewModel.cs | 23 +- .../ViewModels/Step1PageViewModel.cs | 51 ++- .../ViewModels/Step2PageViewModel.cs | 337 +++++++++++++----- .../ViewModels/Step3PageViewModel.cs | 62 +++- CardCheckAssistant/Views/AboutPage.xaml | 63 +++- CardCheckAssistant/Views/AboutPage.xaml.cs | 9 +- CardCheckAssistant/Views/HomePage.xaml | 8 +- CardCheckAssistant/Views/SettingsPage.xaml | 172 ++++++--- CardCheckAssistant/Views/SettingsPage.xaml.cs | 15 +- CardCheckAssistant/Views/Step1Page.xaml | 6 +- CardCheckAssistant/Views/Step2Page.xaml | 53 ++- CardCheckAssistant/Views/Step3Page.xaml | 2 +- README.md | 49 +++ 22 files changed, 819 insertions(+), 227 deletions(-) create mode 100644 CardCheckAssistant/ViewModels/AboutPageViewModel.cs diff --git a/CardCheckAssistant/CardCheckAssistant.csproj b/CardCheckAssistant/CardCheckAssistant.csproj index 3c4c41c..770dc43 100644 --- a/CardCheckAssistant/CardCheckAssistant.csproj +++ b/CardCheckAssistant/CardCheckAssistant.csproj @@ -68,7 +68,7 @@ v1.0.20 CardCheckAssistant Messgeraetetechnik Hansen Steven Hansen - 1.0.32 + 1.0.33 $(AssemblyVersion) https://github.com/c3rebro/CardCheckAssistant/releases/latest/download AnyCPU diff --git a/CardCheckAssistant/DataAccessLayer/DefaultSettings.cs b/CardCheckAssistant/DataAccessLayer/DefaultSettings.cs index 60fa259..1be5ec8 100644 --- a/CardCheckAssistant/DataAccessLayer/DefaultSettings.cs +++ b/CardCheckAssistant/DataAccessLayer/DefaultSettings.cs @@ -171,6 +171,16 @@ public string? LastUsedProjectPath } private string? _lastUsedProjectPath; + /// + /// + /// + public bool? RemoveTemporaryReportsIsEnabled + { + get => _removeTemporaryReportsIsEnabled; + set => _removeTemporaryReportsIsEnabled = value; + } + private bool? _removeTemporaryReportsIsEnabled; + /// /// /// diff --git a/CardCheckAssistant/MainWindow.xaml b/CardCheckAssistant/MainWindow.xaml index 9c97d29..53c69de 100644 --- a/CardCheckAssistant/MainWindow.xaml +++ b/CardCheckAssistant/MainWindow.xaml @@ -6,7 +6,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> - + @@ -89,7 +89,7 @@ --> - + diff --git a/CardCheckAssistant/Models/LSMCardTemplate.cs b/CardCheckAssistant/Models/LSMCardTemplate.cs index 66904a2..31b1061 100644 --- a/CardCheckAssistant/Models/LSMCardTemplate.cs +++ b/CardCheckAssistant/Models/LSMCardTemplate.cs @@ -33,6 +33,37 @@ public LSMCardTemplate(string templateText, string templateToolTip) TemplateToolTip = templateToolTip; } + /// + /// + /// + /// + /// + /// + /// + public LSMCardTemplate(string templateText, string templateToolTip, int freeBytes, int freeSectors) + { + TemplateText = templateText; + TemplateToolTip = templateToolTip; + SizeInBytes = freeBytes; + SizeInFreeSectorsCount = freeSectors; + } + + /// + /// + /// + public int SizeInBytes + { + get; set; + } + + /// + /// + /// + public int SizeInFreeSectorsCount + { + get; set; + } + /// /// /// diff --git a/CardCheckAssistant/Package.appxmanifest b/CardCheckAssistant/Package.appxmanifest index 1aff8e5..882c3cb 100644 --- a/CardCheckAssistant/Package.appxmanifest +++ b/CardCheckAssistant/Package.appxmanifest @@ -10,7 +10,7 @@ + Version="1.0.33.0" /> CardCheckAssistant diff --git a/CardCheckAssistant/Shell.xaml b/CardCheckAssistant/Shell.xaml index f4c22a4..21589ac 100644 --- a/CardCheckAssistant/Shell.xaml +++ b/CardCheckAssistant/Shell.xaml @@ -23,12 +23,16 @@ SelectedItem="{x:Bind ViewModel.Selected, Mode=OneWay}"> - + @@ -40,6 +44,7 @@ @@ -49,6 +54,7 @@ @@ -58,6 +64,7 @@ @@ -79,7 +86,7 @@ + Margin="0 0 0 0" > diff --git a/CardCheckAssistant/Shell.xaml.Navigation.cs b/CardCheckAssistant/Shell.xaml.Navigation.cs index bff8c06..a7faf1d 100644 --- a/CardCheckAssistant/Shell.xaml.Navigation.cs +++ b/CardCheckAssistant/Shell.xaml.Navigation.cs @@ -61,9 +61,9 @@ public void SetCurrentNavigationViewItem(NavigationViewItem item) if (Type.GetType(item.Tag.ToString()) != null) { ContentFrame.Navigate(Type.GetType(item.Tag.ToString()), item.Content); + NavigationView.Header = item.Content; + NavigationView.SelectedItem = item; } - - NavigationView.Header = item.Content; } public NavigationViewItem GetCurrentNavigationViewItem() diff --git a/CardCheckAssistant/ViewModels/AboutPageViewModel.cs b/CardCheckAssistant/ViewModels/AboutPageViewModel.cs new file mode 100644 index 0000000..aca1521 --- /dev/null +++ b/CardCheckAssistant/ViewModels/AboutPageViewModel.cs @@ -0,0 +1,122 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; + +using Microsoft.UI.Xaml; + +using CardCheckAssistant.Views; + +using Log4CSharp; + +using System.Windows.Input; + +namespace CardCheckAssistant.ViewModels; + +/// +/// +/// +public class AboutPageViewModel : ObservableObject +{ + /// + /// + /// + public AboutPageViewModel() + { + NextStepCanExecute = false; + GoBackCanExecute = true; + } + + #region ObservableObjects + + /// + /// + /// + public bool NextStepCanExecute + { + get => _nextStepCanExecute; + set => SetProperty(ref _nextStepCanExecute, value); + } + private bool _nextStepCanExecute; + + /// + /// + /// + public bool GoBackCanExecute + { + get => _goBackCanExecute; + set => SetProperty(ref _goBackCanExecute, value); + } + private bool _goBackCanExecute; + + #endregion + + #region Commands + + /// + /// + /// + public ICommand PostPageLoadedCommand => new AsyncRelayCommand(PostPageLoadedCommand_Executed); + + /// + /// + /// + public ICommand NavigateNextStepCommand => new RelayCommand(NavigateNextStepCommand_Executed); + + /// + /// + /// + public ICommand NavigateBackCommand => new RelayCommand(NavigateBackCommand_Executed); + + #endregion + + #region Extension Methods + + /// + /// + /// + /// + private async Task PostPageLoadedCommand_Executed() + { + try + { + + } + catch (Exception e) + { + LogWriter.CreateLogEntry(e); + } + } + + #endregion + + /// + /// + /// + /// + private async void NavigateNextStepCommand_Executed() + { + try + { + var window = (Application.Current as App)?.Window as MainWindow ?? new MainWindow(); + var navigation = window.Navigation; + var step2Page = navigation.GetNavigationViewItems(typeof(Step2Page)).First(); + navigation.SetCurrentNavigationViewItem(step2Page); + step2Page.IsEnabled = true; + } + + catch (Exception e) + { + LogWriter.CreateLogEntry(e); + } + } + + /// + /// + /// + private void NavigateBackCommand_Executed() + { + var window = (Application.Current as App)?.Window as MainWindow ?? new MainWindow(); + var navigation = window.Navigation; + var homePage = navigation.GetNavigationViewItems(typeof(HomePage)).First(); + navigation.SetCurrentNavigationViewItem(homePage); + } +} diff --git a/CardCheckAssistant/ViewModels/HomePageViewModel.cs b/CardCheckAssistant/ViewModels/HomePageViewModel.cs index 47e6e2c..6c47191 100644 --- a/CardCheckAssistant/ViewModels/HomePageViewModel.cs +++ b/CardCheckAssistant/ViewModels/HomePageViewModel.cs @@ -47,7 +47,7 @@ public HomePageViewModel() scanDBTimer.Interval = new TimeSpan(0,0,10); scanDBTimer.Stop(); - SelectedFilter = "All"; + SelectedFilter = "InProgress"; SelectedSort = "JobNumber"; ButtonStartCheckContent = ResourceLoaderService.GetResource("buttonContentStartCheck"); @@ -59,7 +59,7 @@ public HomePageViewModel() #endif - // Select First "InProgress" Job if any + // Select First "InProgress" Job... if any if (DataGridItemCollection != null && _dataGridItemCollection.Any()) { if (DataGridItemCollection.Any(x => x.Status == "InProgress")) @@ -502,7 +502,11 @@ private async Task PostPageLoadedCommand_Executed() if (cardCheckProcessesFromCache != null) { - DataGridItemCollection = cardCheckProcessesFromCache; + DataGridItemCollection = FilterData(cardCheckProcessesFromCache, SelectedFilter); + } + else + { + return; } ModalView.Dialogs.Where(x => x.Name == "connectWaitMsgDlg").Single().Hide(); diff --git a/CardCheckAssistant/ViewModels/SettingsPageViewModel.cs b/CardCheckAssistant/ViewModels/SettingsPageViewModel.cs index d82f4f0..aa22dd0 100644 --- a/CardCheckAssistant/ViewModels/SettingsPageViewModel.cs +++ b/CardCheckAssistant/ViewModels/SettingsPageViewModel.cs @@ -38,8 +38,9 @@ public SettingsPageViewModel() SelectedDBUsername = settings.DefaultSettings.SelectedDBUsername; CardCheckUseSQLLite = settings.DefaultSettings.CardCheckUseMSSQL; CreateSubdirectoryIsEnabled = settings.DefaultSettings.CreateSubdirectoryIsEnabled; + RemoveTemporaryReportsIsEnabled = settings.DefaultSettings.RemoveTemporaryReportsIsEnabled; - SelectedDBUserPwd = enc.Decrypt(settings.DefaultSettings.SelectedDBUserPwd); + SelectedDBUserPwd = enc.Decrypt(settings?.DefaultSettings?.SelectedDBUserPwd ?? "NoPWD"); } catch (Exception ex) { @@ -167,6 +168,20 @@ public string? SelectedRFIDGearPath } private string? _selectedRFIDGearPath; + public bool? RemoveTemporaryReportsIsEnabled + { + get => _removeTemporaryReportsIsEnabled; + set + { + SetProperty(ref _removeTemporaryReportsIsEnabled, value); + using SettingsReaderWriter settings = new SettingsReaderWriter(); + + settings.DefaultSettings.RemoveTemporaryReportsIsEnabled = value; + settings.SaveSettings(); + } + } + private bool? _removeTemporaryReportsIsEnabled; + public bool? CreateSubdirectoryIsEnabled { get => _createSubdirectoryIsEnabled; @@ -337,9 +352,9 @@ private void NavigateBackCommand_Executed() { var window = (Application.Current as App)?.Window as MainWindow ?? new MainWindow(); var navigation = window.Navigation; - var step1Page = navigation.GetNavigationViewItems(typeof(Step1Page)).First(); - navigation.SetCurrentNavigationViewItem(step1Page); - step1Page.IsEnabled = true; + var homePage = navigation.GetNavigationViewItems(typeof(HomePage)).First(); + navigation.SetCurrentNavigationViewItem(homePage); + homePage.IsEnabled = true; } private class RijndaelEnc : IDisposable diff --git a/CardCheckAssistant/ViewModels/Step1PageViewModel.cs b/CardCheckAssistant/ViewModels/Step1PageViewModel.cs index 6d06a53..30663d0 100644 --- a/CardCheckAssistant/ViewModels/Step1PageViewModel.cs +++ b/CardCheckAssistant/ViewModels/Step1PageViewModel.cs @@ -11,8 +11,7 @@ using System.Diagnostics; using System.Windows.Input; using System.Collections.ObjectModel; - - +using Microsoft.UI.Xaml.Documents; namespace CardCheckAssistant.ViewModels; @@ -291,7 +290,50 @@ private async void NavigateNextStepCommand_Executed() { try { - using ReaderService readerService = new ReaderService(); + using SettingsReaderWriter settings = new SettingsReaderWriter(); + + settings.ReadSettings(); + + FileInfo fi = new FileInfo(settings.DefaultSettings.DefaultProjectOutputPath + "\\" + + (settings.DefaultSettings.CreateSubdirectoryIsEnabled == true ? CheckProcessService.CurrentCardCheckProcess.JobNr + "\\" : string.Empty) + + CheckProcessService.CurrentCardCheckProcess.JobNr + "-" + + CheckProcessService.CurrentCardCheckProcess.ChipNumber + + ".pdf"); + + if (fi.Exists) + { + if (await App.MainRoot.ConfirmationDialogAsync( + "Warnung", + string.Format("Die Datei die erstellt werden soll existiert bereits.\n" + + "Soll sie überschrieben werden?"), + "Ja", "Nein") == true) + { + try + { + // try to overwrite the file + FileStream fs = fi.Open(FileMode.Create); + fs.Close(); + fi.Delete(); + } + catch (IOException ioex) + { + await App.MainRoot.MessageDialogAsync( + "Fehler", + string.Format("Windows Fehlertext: {0}\n\n" + + "Bitte beende die Anwendung die auf diese Datei zugreift und versuche es im Anschluss erneut.",ioex.Message), + "OK"); + + return; + } + finally { + LogWriter.CreateLogEntry("ioex"); + } + } + else + { + return; + } + } NextStepCanExecute = false; WaitForNextStep = true; @@ -307,7 +349,8 @@ private async void NavigateNextStepCommand_Executed() navigation.SetCurrentNavigationViewItem(step2Page); step2Page.IsEnabled = true; } - catch(Exception e) + + catch (Exception e) { LogWriter.CreateLogEntry(e); } diff --git a/CardCheckAssistant/ViewModels/Step2PageViewModel.cs b/CardCheckAssistant/ViewModels/Step2PageViewModel.cs index 60e4002..5d13090 100644 --- a/CardCheckAssistant/ViewModels/Step2PageViewModel.cs +++ b/CardCheckAssistant/ViewModels/Step2PageViewModel.cs @@ -1,5 +1,7 @@ using System.Collections.ObjectModel; +using System.Data.Entity.Core.Metadata.Edm; using System.Diagnostics; +using System.Linq; using System.Windows.Input; using CardCheckAssistant.Models; using CardCheckAssistant.Services; @@ -14,7 +16,12 @@ namespace CardCheckAssistant.ViewModels; public class Step2PageViewModel : ObservableObject { + // Define the cancellation token. + CancellationTokenSource source = new CancellationTokenSource(); + CancellationToken token; + private readonly DispatcherTimer scanChipTimer; + private bool isCancelled; #if DEBUG private const string DBNAME = "OT_CardCheck_Test"; @@ -27,6 +34,9 @@ public class Step2PageViewModel : ObservableObject /// public Step2PageViewModel() { + token = source.Token; + isCancelled = false; + NavigateNextStepCommand = new AsyncRelayCommand(NavigateNextStepCommand_Executed); PostPageLoadedCommand = new AsyncRelayCommand(PostPageLoadedCommand_Executed); @@ -35,6 +45,7 @@ public Step2PageViewModel() scanChipTimer.Stop(); NextStepCanExecute = false; + IsReportOpen = false; GoBackCanExecute = true; TextBlockCheckFinishedAndResultIsSuppOnlyIsVisible = false; @@ -52,20 +63,20 @@ public Step2PageViewModel() CardTemplates = new List() { - new ("N/A", "Keine Auswahl"), - new ("MCBasic (Speicherbedarf: 1 Sektor)", string.Empty), - new ("MC1200L (Speicherbedarf: 4 Sektoren)", string.Empty), - new ("MC3800L (Speicherbedarf: 11 Sektoren)", string.Empty), - new ("MC1000L_AV (Speicherbedarf: 11 Sektoren)", string.Empty), - new ("MC2400L_AV (Speicherbedarf: 19 Sektoren)", string.Empty), - new ("MC8000L_AV (Speicherbedarf: 43 Sektoren / 32 + 3)", string.Empty), - new ("MDBasic (Speicherbedarf: 48 + 176 = 224 Bytes)", string.Empty), - new ("MD1200L (Speicherbedarf: 192 + 160 = 352 Bytes)", string.Empty), - new ("MD3800L (Speicherbedarf: 528 + 176 = 704 Bytes)", string.Empty), - new ("MD2500L_AV (Speicherbedarf: 1024 + 160 = 1184 Bytes)", string.Empty), - new ("MD4000L_AV (Speicherbedarf: 1600 + 160 = 1760 Bytes)", string.Empty), - new ("MD10000L_AV (Speicherbedarf: 3048 + 184 = 3232 Bytes)", string.Empty), - new ("MD32000L_AV (Speicherbedarf: 7000 + 168 = 7168 Bytes)", string.Empty) + new ("N/A", "Keine Auswahl", 0, 0), + new ("MCBasic (Speicherbedarf: 1 Sektor)", string.Empty, 0, 1), + new ("MC1200L (Speicherbedarf: 4 Sektoren)", string.Empty, 0, 4), + new ("MC3800L (Speicherbedarf: 11 Sektoren)", string.Empty, 0 , 11), + new ("MC1000L_AV (Speicherbedarf: 11 Sektoren)", string.Empty, 0 , 11), + new ("MC2400L_AV (Speicherbedarf: 19 Sektoren)", string.Empty, 0, 19), + new ("MC8000L_AV (Speicherbedarf: 43 Sektoren / 32 + 3)", string.Empty, 0, 43), + new ("MDBasic (Speicherbedarf: 48 + 176 = 224 Bytes)", string.Empty, 224, 0), + new ("MD1200L (Speicherbedarf: 192 + 160 = 352 Bytes)", string.Empty, 352, 0), + new ("MD3800L (Speicherbedarf: 528 + 176 = 704 Bytes)", string.Empty, 704, 0), + new ("MD2500L_AV (Speicherbedarf: 1024 + 160 = 1184 Bytes)", string.Empty, 1184, 0), + new ("MD4000L_AV (Speicherbedarf: 1600 + 160 = 1760 Bytes)", string.Empty, 1760, 0), + new ("MD10000L_AV (Speicherbedarf: 3048 + 184 = 3232 Bytes)", string.Empty, 1760, 0), + new ("MD32000L_AV (Speicherbedarf: 7000 + 168 = 7168 Bytes)", string.Empty, 7168, 0) }; SelectedCustomerRequestTemplate = CustomerRequestTemplate.NA; @@ -106,6 +117,43 @@ public string InfoBarSupportedChipType set => SetProperty(ref _infoBarSupportedChipType, value); } private string _infoBarSupportedChipType; + + /// + /// + /// + public string InfoBarReportOpen + { + get => _infoBarReportOpen; + set => SetProperty(ref _infoBarReportOpen, value); + } + private string _infoBarReportOpen; + + /// + /// + /// + public string TextBoxAdditionalHints + { + get => _textBoxAdditionalHints; + set + { + SetProperty(ref _textBoxAdditionalHints, value); + } + } + private string _textBoxAdditionalHints; + + /// + /// + /// + public bool IsReportOpen + { + get => _isReportOpen; + set + { + SetProperty(ref _isReportOpen, value); + NextStepCanExecute = !value; + } + } + private bool _isReportOpen; /// /// @@ -116,7 +164,10 @@ public bool CheckBoxChipProgrammableYes set { SetProperty(ref _checkBoxChipProgrammableYes, value); - CheckBoxChipProgrammableNo = !value; + if(_checkBoxChipProgrammableNo) + { + CheckBoxChipProgrammableNo = !value; + } } } private bool _checkBoxChipProgrammableYes; @@ -127,7 +178,14 @@ public bool CheckBoxChipProgrammableYes public bool CheckBoxChipProgrammableNo { get => _checkBoxChipProgrammableNo; - set => SetProperty(ref _checkBoxChipProgrammableNo, value); + set + { + SetProperty(ref _checkBoxChipProgrammableNo, value); + if (_checkBoxChipProgrammableYes) + { + CheckBoxChipProgrammableYes = !value; + } + } } private bool _checkBoxChipProgrammableNo; @@ -137,7 +195,14 @@ public bool CheckBoxChipProgrammableNo public bool CheckBoxTestOnLockSuccess { get => _checkBoxTestOnLockSuccess; - set => SetProperty(ref _checkBoxTestOnLockSuccess, value); + set + { + SetProperty(ref _checkBoxTestOnLockSuccess, value); + if (_checkBoxTestOnLockFailed) + { + CheckBoxTestOnLockFailed = !value; + } + } } private bool _checkBoxTestOnLockSuccess; @@ -147,7 +212,14 @@ public bool CheckBoxTestOnLockSuccess public bool CheckBoxTestOnLockFailed { get => _checkBoxTestOnLockFailed; - set => SetProperty(ref _checkBoxTestOnLockFailed, value); + set + { + SetProperty(ref _checkBoxTestOnLockFailed, value); + if (_checkBoxTestOnLockSuccess) + { + CheckBoxTestOnLockSuccess = !value; + } + } } private bool _checkBoxTestOnLockFailed; @@ -157,7 +229,14 @@ public bool CheckBoxTestOnLockFailed public bool CheckBoxTestOnLockLimitedYes { get => _checkBoxTestOnLockLimitedYes; - set => SetProperty(ref _checkBoxTestOnLockLimitedYes, value); + set + { + SetProperty(ref _checkBoxTestOnLockLimitedYes, value); + if (_checkBoxTestOnLockLimitedNo) + { + CheckBoxTestOnLockLimitedNo = !value; + } + } } private bool _checkBoxTestOnLockLimitedYes; @@ -170,7 +249,10 @@ public bool CheckBoxTestOnLockLimitedNo set { SetProperty(ref _checkBoxTestOnLockLimitedNo, value); - SetProperty(ref _checkBoxTestOnLockLimitedYes, !value); + if(_checkBoxTestOnLockLimitedYes) + { + CheckBoxTestOnLockLimitedYes = !value; + } } } private bool _checkBoxTestOnLockLimitedNo; @@ -375,7 +457,7 @@ public bool GoBackCanExecute /// /// /// - public ICommand NavigateBackCommand => new RelayCommand(NavigateBackCommand_Executed); + public ICommand NavigateBackCommand => new AsyncRelayCommand(NavigateBackCommand_Executed); /// /// @@ -385,12 +467,12 @@ public bool GoBackCanExecute /// /// /// - public ICommand OpenReportCommand => new RelayCommand(OpenReportCommand_Executed); + public ICommand OpenReportCommand => new AsyncRelayCommand(OpenReportCommand_Executed); /// /// /// - public ICommand OpenReportPathCommand => new RelayCommand(OpenReportPathCommand_Executed); + public ICommand OpenReportPathCommand => new AsyncRelayCommand(OpenReportPathCommand_Executed); /// /// @@ -414,6 +496,7 @@ private async Task ExecuteRFIDGearCommand() bool notEnoughFreeMemory = true; bool supported = false; bool programmable = false; + string addHintsText = ""; using ReportReaderWriterService reportReader = new ReportReaderWriterService(); using SettingsReaderWriter settings = new SettingsReaderWriter(); @@ -471,21 +554,31 @@ private async Task ExecuteRFIDGearCommand() programmable = reportReader.GetReportField("CheckBox_ChipCanUseYes") != null && reportReader.GetReportField("CheckBox_ChipCanUseYes") == "Yes"; freeMemField = reportReader.GetReportField("TextBox_Detail_FreeMem_1") ?? "NA"; chipType = reportReader.GetReportField("TextBox_ChipType") ?? "NA"; + addHintsText = reportReader.GetReportField("TextBox_Hints") ?? "NA"; + }; p.Start(); await p.WaitForExitAsync(); + TextBoxAdditionalHints = addHintsText; + if (freeMemField != null) { if (int.TryParse(freeMemField.Split(' ')[0], out amountOfFreeMemory)) { + //seem's to be a desfire TextBlockFreeMem = freeMemField; if (amountOfFreeMemory >= 225) { notEnoughFreeMemory = false; + + //show only usable templates on desfire + CardTemplates = new List( + CardTemplates.Where(x => x.TemplateText.Contains("MD")) + .Where(x => x.SizeInBytes <= amountOfFreeMemory)); } else { @@ -502,6 +595,10 @@ private async Task ExecuteRFIDGearCommand() if (sectors.Length >= 1) { notEnoughFreeMemory = false; + + CardTemplates = new List( + CardTemplates.Where(x => x.TemplateText.Contains("MC")) + .Where(x => x.SizeInFreeSectorsCount <= sectors.Length)); } else { @@ -515,6 +612,15 @@ private async Task ExecuteRFIDGearCommand() } TextBlockCheckNotYetFinishedIsVisible = false; + // Select "MD4000L_AV" Template... if any. OR Select "MC1000L_AV" if any. + // Select first item if no MD4000L_AV nor MC1000L_AV is available + SelectedLSMCardTemplate = CardTemplates.Any( + x => x.TemplateText.Contains("MD4000L_AV")) + ? CardTemplates.FirstOrDefault(y => y.TemplateText.Contains("MD4000L_AV")) ?? new LSMCardTemplate() + : CardTemplates.Any(x => x.TemplateText.Contains("MC1000L_AV")) + ? CardTemplates.FirstOrDefault(y => y.TemplateText.Contains("MC1000L_AV")) ?? new LSMCardTemplate() + : CardTemplates.FirstOrDefault() ?? new LSMCardTemplate(); + if (!supported) { @@ -599,20 +705,20 @@ private async Task ChipIsRemoved(ReaderService readerService) { scanChipTimer.Stop(); - await Task.Delay(1000); + await Task.Delay(1000).WaitAsync(token); - if (await readerService.ReadChipPublic() >= 0) + if (await readerService.ReadChipPublic().WaitAsync(token) >= 0) { - while (readerService.GenericChip != null) + while (readerService.GenericChip != null && !isCancelled) { - await readerService.ReadChipPublic(); + await readerService.ReadChipPublic().WaitAsync(token); if (readerService.GenericChip == null) { continue; } else { - await Task.Delay(1500); + await Task.Delay(1500).WaitAsync(token); } } } @@ -638,12 +744,17 @@ private async Task ChipIsPlacedAgain(ReaderService readerService) { scanChipTimer.Stop(); - await Task.Delay(100); - await readerService.ReadChipPublic(); + await Task.Delay(100).WaitAsync(token); + await readerService.ReadChipPublic().WaitAsync(token); while (readerService.GenericChip == null && !NextStepCanExecute) { - await readerService.ReadChipPublic(); + if(isCancelled) + { + return; + } + + await readerService.ReadChipPublic().WaitAsync(token); if (readerService.GenericChip != null) { @@ -651,7 +762,7 @@ private async Task ChipIsPlacedAgain(ReaderService readerService) } else { - await Task.Delay(1500); + await Task.Delay(1500).WaitAsync(token); } } @@ -674,71 +785,87 @@ private async Task ChipIsPlacedAgain(ReaderService readerService) /// private async void ScanChipEvent(object? sender, object e) { - try + if(!isCancelled) { - scanChipTimer.Stop(); - - using (ReaderService readerService = new ReaderService()) + try { - if(!NavigateNextStepCommand.IsRunning) - { - await readerService.ReadChipPublic(); - } + scanChipTimer.Stop(); - if (readerService.MoreThanOneReaderFound) + using (ReaderService readerService = new ReaderService()) { - NextStepCanExecute = false; - } + if(!NavigateNextStepCommand.IsRunning) + { + await readerService.ReadChipPublic(); + } - else - { - if (readerService.GenericChip != null && !NextStepCanExecute && !NavigateNextStepCommand.IsRunning) + if (readerService.MoreThanOneReaderFound) + { + NextStepCanExecute = false; + } + + else { - await ChipIsRemoved(readerService); + if (readerService.GenericChip != null && !NextStepCanExecute && !NavigateNextStepCommand.IsRunning) + { + try + { + await ChipIsRemoved(readerService).WaitAsync(token); - ReaderHasNoChipInfoBarIsVisible = true; + ReaderHasNoChipInfoBarIsVisible = true; - await ChipIsPlacedAgain(readerService); + await ChipIsPlacedAgain(readerService).WaitAsync(token); - var ChipInfoMessage = string.Format("Es wurde ein Chip erkannt:\nErkannt 1: {0}", readerService.GenericChip.CardType.ToString()); + var ChipInfoMessage = string.Format("Es wurde ein Chip erkannt:\nErkannt 1: {0}", readerService.GenericChip?.CardType.ToString() ?? ""); - if (readerService.GenericChip.Child != null) - { - ChipInfoMessage = ChipInfoMessage + string.Format("\nErkannt 2: {0}", readerService.GenericChip.Child.CardType); + if (!isCancelled && readerService.GenericChip?.Child != null) + { + ChipInfoMessage = ChipInfoMessage + string.Format("\nErkannt 2: {0}", readerService.GenericChip.Child.CardType); + } + + NextStepCanExecute = true; + } + catch (Exception ae) + { + //readerService.Close(); + } } - NextStepCanExecute = true; - } + if (!isCancelled && readerService.GenericChip != null && NextStepCanExecute && !NavigateNextStepCommand.IsRunning) + { - if (readerService.GenericChip != null && NextStepCanExecute && !NavigateNextStepCommand.IsRunning) - { + ReaderHasNoChipInfoBarIsVisible = false; - ReaderHasNoChipInfoBarIsVisible = false; + var ChipInfoMessage = string.Format("Es wurde ein Chip erkannt:\nErkannt 1: {0}", readerService.GenericChip.CardType.ToString()); - var ChipInfoMessage = string.Format("Es wurde ein Chip erkannt:\nErkannt 1: {0}", readerService.GenericChip.CardType.ToString()); + if (readerService.GenericChip?.Child != null) + { + ChipInfoMessage = ChipInfoMessage + string.Format("\nErkannt 2: {0}", readerService.GenericChip.Child.CardType); + } - if (readerService.GenericChip.Child != null) - { - ChipInfoMessage = ChipInfoMessage + string.Format("\nErkannt 2: {0}", readerService.GenericChip.Child.CardType); + NextStepCanExecute = true; } - NextStepCanExecute = true; - } - - else if (readerService.GenericChip == null && !NavigateNextStepCommand.IsRunning) - { - NextStepCanExecute = true; - ReaderHasNoChipInfoBarIsVisible = true; + else if (!isCancelled && readerService.GenericChip == null && !NavigateNextStepCommand.IsRunning) + { + NextStepCanExecute = true; + ReaderHasNoChipInfoBarIsVisible = true; + } } } + + scanChipTimer.Start(); } - scanChipTimer.Start(); - } - catch(Exception ex) - { - LogWriter.CreateLogEntry(ex); + catch (Exception ex) + { + await App.MainRoot.MessageDialogAsync( + "Fehler", + string.Format("Bitte melde den folgenden Fehler an mich:\n{0}", ex.Message)); + + LogWriter.CreateLogEntry(ex); + } } + } /// @@ -749,8 +876,6 @@ public async Task PostPageLoadedCommand_Executed() { try { - using ReaderService readerService = new ReaderService(); - scanChipTimer.Stop(); scanChipTimer.Tick -= ScanChipEvent; @@ -759,20 +884,24 @@ public async Task PostPageLoadedCommand_Executed() scanChipTimer.Tick += ScanChipEvent; scanChipTimer.Start(); } - catch(Exception e) + catch(Exception ex) { - LogWriter.CreateLogEntry(e); + await App.MainRoot.MessageDialogAsync( + "Fehler", + string.Format("Bitte melde den folgenden Fehler an mich:\n{0}", ex.Message)); + LogWriter.CreateLogEntry(ex); } } /// /// /// - private void OpenReportCommand_Executed() + private async Task OpenReportCommand_Executed() { try { using SettingsReaderWriter settings = new SettingsReaderWriter(); + IsReportOpen = true; settings.ReadSettings(); var p = new Process(); @@ -789,19 +918,27 @@ private void OpenReportCommand_Executed() }; p.StartInfo = info; - p.Start(); + + await p.WaitForExitAsync(); + + IsReportOpen = false; } catch (Exception ex) { + await App.MainRoot.MessageDialogAsync( + "Fehler", + string.Format("Bitte melde den folgenden Fehler an mich:\n{0}", ex.Message)); + LogWriter.CreateLogEntry(ex); + IsReportOpen = false; } } /// /// /// - private void OpenReportPathCommand_Executed() + private async Task OpenReportPathCommand_Executed() { try { @@ -819,11 +956,13 @@ private void OpenReportPathCommand_Executed() }; p.StartInfo = info; - p.Start(); } catch (Exception ex) { + await App.MainRoot.MessageDialogAsync( + "Fehler", + string.Format("Bitte melde den folgenden Fehler an mich:\n{0}", ex.Message)); LogWriter.CreateLogEntry(ex); } } @@ -909,6 +1048,22 @@ private async Task NavigateNextStepCommand_Executed() await SQLDBService.Instance.InsertData(CheckProcessService.CurrentCardCheckProcess.ID, OrderStatus.CheckFinished.ToString()); fileStream.Close(); + + if (settings.DefaultSettings.RemoveTemporaryReportsIsEnabled == true) + { + try + { + File.Delete(preFinalPath); + File.Delete(semiFinalPath); + } + catch (Exception ex) + { + await App.MainRoot.MessageDialogAsync( + "Fehler", + string.Format("Bitte melde den folgenden Fehler an mich:\n{0}", ex.Message)); + } //The Files may be opened + + } } else if (TextBlockCheckFinishedAndResultIsSuppAndProgIsVisible) @@ -950,6 +1105,8 @@ private async Task NavigateNextStepCommand_Executed() { reportReader.SetReportField("CheckBox_Detail_Reserved_4_2", "Off"); reportReader.SetReportField("CheckBox_Detail_Reserved_4_1", "Yes"); + + reportReader.SetReportField("TextBox_Hints", TextBoxAdditionalHints); } reportReader.SetReportField("ComboBox_UsedTemplate",SelectedLSMCardTemplate.TemplateText); @@ -965,6 +1122,10 @@ private async Task NavigateNextStepCommand_Executed() } catch (Exception ex) { + await App.MainRoot.MessageDialogAsync( + "Fehler", + string.Format("Bitte melde den folgenden Fehler an mich:\n{0}", ex.Message)); + LogWriter.CreateLogEntry(ex); } } @@ -972,15 +1133,17 @@ private async Task NavigateNextStepCommand_Executed() /// /// /// - private async void NavigateBackCommand_Executed() + private async Task NavigateBackCommand_Executed() { try { - using ReaderService readerService = new ReaderService(); - scanChipTimer.Stop(); scanChipTimer.Tick -= ScanChipEvent; + source.Cancel(); + + await Task.Delay(1000); + var window = (Application.Current as App)?.Window as MainWindow ?? new MainWindow(); var navigation = window.Navigation; var step1Page = navigation.GetNavigationViewItems(typeof(Step1Page)).First(); @@ -988,6 +1151,10 @@ private async void NavigateBackCommand_Executed() } catch (Exception ex) { + await App.MainRoot.MessageDialogAsync( + "Fehler", + string.Format("Bitte melde den folgenden Fehler an mich:\n{0}", ex.Message)); + LogWriter.CreateLogEntry(ex); } } diff --git a/CardCheckAssistant/ViewModels/Step3PageViewModel.cs b/CardCheckAssistant/ViewModels/Step3PageViewModel.cs index 298f34d..5c43e3b 100644 --- a/CardCheckAssistant/ViewModels/Step3PageViewModel.cs +++ b/CardCheckAssistant/ViewModels/Step3PageViewModel.cs @@ -281,9 +281,13 @@ await App.MainRoot.MessageDialogAsync( } } - catch (Exception e) + catch (Exception ex) { - LogWriter.CreateLogEntry(e); + await App.MainRoot.MessageDialogAsync( + "Fehler", + string.Format("Bitte melde den folgenden Fehler an mich:\n{0}", ex.Message)); + + LogWriter.CreateLogEntry(ex); } } @@ -300,16 +304,20 @@ public async Task PostPageLoadedCommand_Executed() await ExecuteRFIDGearCommand(); NextStepCanExecute = true; } - catch (Exception e) + catch (Exception ex) { - LogWriter.CreateLogEntry(e); + await App.MainRoot.MessageDialogAsync( + "Fehler", + string.Format("Bitte melde den folgenden Fehler an mich:\n{0}", ex.Message)); + + LogWriter.CreateLogEntry(ex); } } /// /// /// - private void OpenReportCommand_Executed() + private async void OpenReportCommand_Executed() { try { @@ -333,16 +341,20 @@ private void OpenReportCommand_Executed() p.Start(); } - catch (Exception e) + catch (Exception ex) { - LogWriter.CreateLogEntry(e); + await App.MainRoot.MessageDialogAsync( + "Fehler", + string.Format("Bitte melde den folgenden Fehler an mich:\n{0}", ex.Message)); + + LogWriter.CreateLogEntry(ex); } } /// /// /// - private void OpenReportPathCommand_Executed() + private async void OpenReportPathCommand_Executed() { try { @@ -363,9 +375,13 @@ private void OpenReportPathCommand_Executed() p.Start(); } - catch (Exception e) + catch (Exception ex) { - LogWriter.CreateLogEntry(e); + await App.MainRoot.MessageDialogAsync( + "Fehler", + string.Format("Bitte melde den folgenden Fehler an mich:\n{0}", ex.Message)); + + LogWriter.CreateLogEntry(ex); } } @@ -425,16 +441,34 @@ private async Task NavigateNextStepCommand_Executed() fileStream.Close(); - File.Delete(preFinalPath); - File.Delete(semiFinalPath); + try + { + if(settings.DefaultSettings.RemoveTemporaryReportsIsEnabled == true) + { + File.Delete(preFinalPath); + File.Delete(semiFinalPath); + } + } + catch (Exception ex) + { + await App.MainRoot.MessageDialogAsync( + "Fehler", + string.Format("Bitte melde den folgenden Fehler an mich:\n{0}", ex.Message)); + + return; + } navigation.SetCurrentNavigationViewItem(nextpage); nextpage.IsEnabled = true; } - catch (Exception e) + catch (Exception ex) { - LogWriter.CreateLogEntry(e); + await App.MainRoot.MessageDialogAsync( + "Fehler", + string.Format("Bitte melde den folgenden Fehler an mich:\n{0}", ex.Message)); + + LogWriter.CreateLogEntry(ex); } } diff --git a/CardCheckAssistant/Views/AboutPage.xaml b/CardCheckAssistant/Views/AboutPage.xaml index e8e9f83..03f097e 100644 --- a/CardCheckAssistant/Views/AboutPage.xaml +++ b/CardCheckAssistant/Views/AboutPage.xaml @@ -4,16 +4,57 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" + xmlns:viewmodels="using:CardCheckAssistant.ViewModels" Background="Transparent"> - + + + + - + + + - + @@ -81,19 +122,19 @@ Grid.Column="0"> - - + + - - - + + + @@ -111,7 +152,7 @@ @@ -145,7 +186,7 @@ diff --git a/CardCheckAssistant/Views/AboutPage.xaml.cs b/CardCheckAssistant/Views/AboutPage.xaml.cs index 5f60061..b5c8455 100644 --- a/CardCheckAssistant/Views/AboutPage.xaml.cs +++ b/CardCheckAssistant/Views/AboutPage.xaml.cs @@ -1,6 +1,4 @@ -using CommunityToolkit.Mvvm.Input; -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls; namespace CardCheckAssistant.Views { @@ -10,10 +8,5 @@ public AboutPage() { InitializeComponent(); } - - private void OpenOmniCommand (object sender, RoutedEventArgs args) - { - - } } } diff --git a/CardCheckAssistant/Views/HomePage.xaml b/CardCheckAssistant/Views/HomePage.xaml index fb765a6..8c625c6 100644 --- a/CardCheckAssistant/Views/HomePage.xaml +++ b/CardCheckAssistant/Views/HomePage.xaml @@ -23,7 +23,7 @@ + Margin="10 0 10 10"> - - @@ -277,7 +277,7 @@ + + + + + + + - - - + + + + + Header="RFiDGear Pfad" + Icon="" + Style="{StaticResource ExpanderHeaderSettingStyle}">