From 3433c90d426d9ef020603b964226fe4f6af86fde Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 24 Jan 2023 13:24:56 +0100 Subject: [PATCH] fix: Deserializer must be sync --- RFiDGear/App.xaml | 1 - .../Remote/FromFile/DatabaseReaderWriter.cs | 17 ++--- RFiDGear/RFiDGear.csproj | 3 + RFiDGear/RFiDGear.csproj.user | 2 +- RFiDGear/View/MainWindow.xaml | 11 ++- RFiDGear/View/SettingsView/SetupView.xaml | 5 +- RFiDGear/View/Splash.xaml | 8 +- RFiDGear/View/UpdateNotifierView.xaml | 2 +- RFiDGear/ViewModel/MainWindowViewModel.cs | 74 ++++++++++--------- .../CommonTaskViewModel.cs | 19 +++-- 10 files changed, 78 insertions(+), 64 deletions(-) diff --git a/RFiDGear/App.xaml b/RFiDGear/App.xaml index 5d388a0..e83caf7 100644 --- a/RFiDGear/App.xaml +++ b/RFiDGear/App.xaml @@ -11,7 +11,6 @@ xmlns:mainvm="clr-namespace:MefMvvm.SharedContracts.ViewModel;assembly=PluginSystem" xmlns:pre="clr-namespace:MvvmDialogs.Presenters;assembly=MVVMDialogs" xmlns:vm="clr-namespace:RFiDGear.ViewModel" - d1p1:Ignorable="d" StartupUri="View/MainWindow.xaml"> diff --git a/RFiDGear/DataAccessLayer/Remote/FromFile/DatabaseReaderWriter.cs b/RFiDGear/DataAccessLayer/Remote/FromFile/DatabaseReaderWriter.cs index ca6d21b..a310229 100644 --- a/RFiDGear/DataAccessLayer/Remote/FromFile/DatabaseReaderWriter.cs +++ b/RFiDGear/DataAccessLayer/Remote/FromFile/DatabaseReaderWriter.cs @@ -42,7 +42,7 @@ public DatabaseReaderWriter() { try { - AsyncRelayCommandLoadDB = new AsyncRelayCommand(LoadXMLAsync,AsyncRelayCommandOptions.AllowConcurrentExecutions); + //AsyncRelayCommandLoadDB = new AsyncRelayCommand(LoadXML,AsyncRelayCommandOptions.AllowConcurrentExecutions); // Combine the base folder with the specific folder.... appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "RFiDGear"); @@ -165,9 +165,8 @@ public bool ReadDatabase(string _fileName = "") try { - var serializer = new XmlSerializer(typeof(ChipTaskHandlerModel)); - AsyncRelayCommandLoadDB.ExecuteAsync(reader); - SetupModel = (SetupModel as ChipTaskHandlerModel); + XmlSerializer serializer = new XmlSerializer(typeof(ChipTaskHandlerModel)); + SetupModel = (serializer.Deserialize(reader) as ChipTaskHandlerModel); } catch (Exception e) { @@ -261,14 +260,12 @@ public void DeleteDatabase() File.Delete(Path.Combine(appDataPath, chipDatabaseFileName)); } - private Task LoadXMLAsync(TextReader reader) + private object LoadXML(TextReader reader) { try { var serializer = new XmlSerializer(typeof(ChipTaskHandlerModel)); - SetupModel = (serializer.Deserialize(reader) as ChipTaskHandlerModel); - - return Task.FromResult(SetupModel as object); + return (serializer.Deserialize(reader) as ChipTaskHandlerModel); } catch (Exception e) { @@ -277,9 +274,7 @@ private Task LoadXMLAsync(TextReader reader) try { var serializer = new XmlSerializer(typeof(ObservableCollection)); - TreeViewModel = serializer.Deserialize(reader) as ObservableCollection; - - return Task.FromResult(TreeViewModel as object); + return serializer.Deserialize(reader) as ObservableCollection; } catch (Exception innerE) diff --git a/RFiDGear/RFiDGear.csproj b/RFiDGear/RFiDGear.csproj index ea0a5a0..7c4dfbe 100644 --- a/RFiDGear/RFiDGear.csproj +++ b/RFiDGear/RFiDGear.csproj @@ -436,6 +436,9 @@ 1.9.0 + + 2022.12.1 + 4.5.1 diff --git a/RFiDGear/RFiDGear.csproj.user b/RFiDGear/RFiDGear.csproj.user index e3a899a..b634f8f 100644 --- a/RFiDGear/RFiDGear.csproj.user +++ b/RFiDGear/RFiDGear.csproj.user @@ -1,7 +1,7 @@  - REPORTTARGETPATH="C:\temp\test file.pdf" AUTORUN=0 %24JobNumber=1234 %24CardType= + REPORTTARGETPATH="C:\temp\test file.pdf" AUTORUN=1 %24JobNumber=1234 %24CardType= D:\Seafile\Dokumente Privat\Steven\Projekte\Software\Windows\RFIDGear\RFiDGear\bin\Debug\ diff --git a/RFiDGear/View/MainWindow.xaml b/RFiDGear/View/MainWindow.xaml index 574fee1..73707ca 100644 --- a/RFiDGear/View/MainWindow.xaml +++ b/RFiDGear/View/MainWindow.xaml @@ -459,7 +459,7 @@ - - + + @@ -587,7 +587,10 @@ Height="auto"/> - + + + +