From 92e63c2b9e8612f80ef6661e7fc2108ab23670ca Mon Sep 17 00:00:00 2001 From: Steven Date: Wed, 28 Sep 2022 00:49:41 +0200 Subject: [PATCH] Fix: Update log error --- .../RedCell.Diagnostics.Update/Updater.cs | 3 +- .../Remote/FromIO/LibLogicalAccessProvider.cs | 1 - .../MifareClassic/MifareClassicChipModel.cs | 2 + RFiDGear/Properties/AssemblyInfo.cs | 2 +- RFiDGear/RFiDGear.csproj.user | 2 +- RFiDGear/Resources/Manifest.de.resx | 28 ++- RFiDGear/Resources/Manifest.en.resx | 16 +- RFiDGear/View/MainWindow.xaml | 30 +-- RFiDGear/ViewModel/MainWindowViewModel.cs | 171 +++++++++--------- .../CommonTaskViewModel.cs | 14 +- 10 files changed, 159 insertions(+), 110 deletions(-) diff --git a/RFiDGear/3rdParty/RedCell/RedCell.Diagnostics.Update/Updater.cs b/RFiDGear/3rdParty/RedCell/RedCell.Diagnostics.Update/Updater.cs index 91001d6..bdc4426 100644 --- a/RFiDGear/3rdParty/RedCell/RedCell.Diagnostics.Update/Updater.cs +++ b/RFiDGear/3rdParty/RedCell/RedCell.Diagnostics.Update/Updater.cs @@ -327,7 +327,8 @@ public void Update() ProcessStartInfo info = new ProcessStartInfo() { FileName = "msiexec.exe", - Arguments = string.Format("/i \"{0}\" /lv \"c:\\temp\\rfidgeardeploy.log\"", Path.Combine(appDataPath, WorkPath, "Setup.msi")), + Verb="runas", + Arguments = string.Format("/i \"{0}\" ", Path.Combine(appDataPath, WorkPath, "Setup.msi")), UseShellExecute = false }; diff --git a/RFiDGear/DataAccessLayer/Remote/FromIO/LibLogicalAccessProvider.cs b/RFiDGear/DataAccessLayer/Remote/FromIO/LibLogicalAccessProvider.cs index 4a2bd7c..ff77d9d 100644 --- a/RFiDGear/DataAccessLayer/Remote/FromIO/LibLogicalAccessProvider.cs +++ b/RFiDGear/DataAccessLayer/Remote/FromIO/LibLogicalAccessProvider.cs @@ -221,7 +221,6 @@ public override ERROR ReadChipPublic() #endregion common #region mifare classic - public override ERROR ReadMifareClassicSingleSector(int sectorNumber, string aKey, string bKey) { Sector = new MifareClassicSectorModel(); diff --git a/RFiDGear/Model/MifareClassic/MifareClassicChipModel.cs b/RFiDGear/Model/MifareClassic/MifareClassicChipModel.cs index 76cd10e..dd6139b 100644 --- a/RFiDGear/Model/MifareClassic/MifareClassicChipModel.cs +++ b/RFiDGear/Model/MifareClassic/MifareClassicChipModel.cs @@ -23,5 +23,7 @@ public MifareClassicChipModel(string uid, CARD_TYPE cardType) CardType = cardType; UID = uid; } + + public uint FreeMemory { get; set; } } } \ No newline at end of file diff --git a/RFiDGear/Properties/AssemblyInfo.cs b/RFiDGear/Properties/AssemblyInfo.cs index 8e228ec..f65875d 100644 --- a/RFiDGear/Properties/AssemblyInfo.cs +++ b/RFiDGear/Properties/AssemblyInfo.cs @@ -27,4 +27,4 @@ // Build Numbers by using the '*' as shown below: [assembly: AssemblyVersion("1.1.*")] [assembly: Guid("a34bc413-e349-4fd1-8b90-2eb95a333436")] -[assembly: NeutralResourcesLanguage("en")] +[assembly: NeutralResourcesLanguage("")] diff --git a/RFiDGear/RFiDGear.csproj.user b/RFiDGear/RFiDGear.csproj.user index 9480e51..5dc4cda 100644 --- a/RFiDGear/RFiDGear.csproj.user +++ b/RFiDGear/RFiDGear.csproj.user @@ -1,7 +1,7 @@  - REPORTTARGETPATH="C:\temp\test file.pdf" AUTORUN=1 %24JobNumber=1234 + REPORTTARGETPATH="C:\temp\test file.pdf" AUTORUN=1 %24JobNumber=1234 %24CardType=MifareDesfire D:\Seafile\Dokumente Privat\Steven\Projekte\Software\Windows\RFIDGear\RFiDGear\bin\Debug\ diff --git a/RFiDGear/Resources/Manifest.de.resx b/RFiDGear/Resources/Manifest.de.resx index 1a654dd..05277ac 100644 --- a/RFiDGear/Resources/Manifest.de.resx +++ b/RFiDGear/Resources/Manifest.de.resx @@ -437,13 +437,13 @@ ein Kartenlesegerät auswählen _Aufgabenstatus zurücksetzen - _Alle Aufgaben automatisch ausführen + _Alle Aufgaben automatisch wiederholen - _Markierte Aufgabe automatisch ausführen + _Markierte Aufgabe automatisch wiederholen - Markierte Aufgaben _einmalig ausführen + Markierte Aufgabe(n) _einmalig ausführen Alle A_ufgaben einmalig ausführen @@ -451,11 +451,11 @@ ein Kartenlesegerät auswählen Projektdatei _öffnen... - - _Projektdatei Speichern unter... + + _Projekt Speichern unter... - _RFiD Chipliste Speichern unter... + _Chipliste Speichern unter... _RFiD Chip einlesen @@ -555,7 +555,7 @@ Soll die Aktualisierung jetzt herunter geladen und installiert werden? Strg + O - + Strg + S @@ -1334,7 +1334,7 @@ Needed by: Aufgabe zurücksetzen - Alle Aufgaben ausführen + Alle Aufgaben zurücksetzen und ausführen Neue Aufgabe anlegen @@ -1472,4 +1472,16 @@ https://github.com/c3rebro/rfidgear Verbunden: + + _Berichtausgabepfade zurücksetzen + + + Projekt _Speichern + + + Soll dieses Projekt als Voreinstellung gesetzt und beim Start automatisch geladen werden? (Einstellung "Projekt automatisch laden muss gesetzt sein") + + + Als Voreinstellung speichern? + \ No newline at end of file diff --git a/RFiDGear/Resources/Manifest.en.resx b/RFiDGear/Resources/Manifest.en.resx index a18d66f..89976d8 100644 --- a/RFiDGear/Resources/Manifest.en.resx +++ b/RFiDGear/Resources/Manifest.en.resx @@ -439,7 +439,7 @@ slot of an available reader _Open Project... - + _Save Tasks... @@ -540,7 +540,7 @@ Use a csv file to acuire default keys for authentication Ctrl + O - + Ctrl + S @@ -1450,4 +1450,16 @@ https://github.com/c3rebro/rfidgear Connected: + + Rese_t Report Target Paths + + + Save Tasks + + + Do you want to set this Project as default when "Load last used Project on Start" is set? + + + Set as Default? + \ No newline at end of file diff --git a/RFiDGear/View/MainWindow.xaml b/RFiDGear/View/MainWindow.xaml index 5970dad..b936c89 100644 --- a/RFiDGear/View/MainWindow.xaml +++ b/RFiDGear/View/MainWindow.xaml @@ -37,7 +37,7 @@ Modifiers="Control" /> + Header="{Binding LocalizationResourceSet, Converter={StaticResource Localization}, ConverterParameter='menuItemSaveTask'}"/> + @@ -458,6 +461,11 @@ + + + + + - - - - - + + + new RelayCommand(OnNewResetTaskStatusCommand); private void OnNewResetTaskStatusCommand() { - foreach (object chipTask in taskHandler.TaskCollection) + foreach (IGenericTaskModel chipTask in taskHandler.TaskCollection) { - switch (chipTask) - { - case CommonTaskViewModel ssVM: - ssVM.IsTaskCompletedSuccessfully = null; - ssVM.CurrentTaskErrorLevel = ERROR.Empty; - break; - case GenericChipTaskViewModel ssVM: - ssVM.IsTaskCompletedSuccessfully = null; - ssVM.CurrentTaskErrorLevel = ERROR.Empty; - break; - case MifareClassicSetupViewModel ssVM: - ssVM.IsTaskCompletedSuccessfully = null; - ssVM.CurrentTaskErrorLevel = ERROR.Empty; - break; - case MifareDesfireSetupViewModel ssVM: - ssVM.IsTaskCompletedSuccessfully = null; - ssVM.CurrentTaskErrorLevel = ERROR.Empty; - break; - case MifareUltralightSetupViewModel ssVM: - ssVM.IsTaskCompletedSuccessfully = null; - ssVM.CurrentTaskErrorLevel = ERROR.Empty; - break; - } + chipTask.IsTaskCompletedSuccessfully = null; + chipTask.CurrentTaskErrorLevel = ERROR.Empty; } } @@ -1037,19 +998,26 @@ private void OnNewResetTaskStatusCommand() public ICommand ResetReportTaskDirectoryCommand => new RelayCommand(OnNewResetReportTaskDirectoryCommand); private void OnNewResetReportTaskDirectoryCommand() { - foreach (object chipTask in taskHandler.TaskCollection) + try { - switch (chipTask) + foreach (object chipTask in taskHandler.TaskCollection) { - case CommonTaskViewModel ssVM: - ssVM.IsTaskCompletedSuccessfully = null; - reportOutputPath = null; - reportReaderWriter.ReportOutputPath = null; - reportReaderWriter.ReportTemplatePath = null; - ssVM.CurrentTaskErrorLevel = ERROR.Empty; - break; + switch (chipTask) + { + case CommonTaskViewModel ssVM: + ssVM.IsTaskCompletedSuccessfully = null; + reportOutputPath = null; + reportReaderWriter.ReportOutputPath = null; + reportReaderWriter.ReportTemplatePath = null; + ssVM.CurrentTaskErrorLevel = ERROR.Empty; + break; + } } } + catch (Exception e) + { + LogWriter.CreateLogEntry(e, FacilityName); + } } /// @@ -1058,31 +1026,8 @@ private void OnNewResetReportTaskDirectoryCommand() public ICommand ResetSelectedTaskStatusCommand => new RelayCommand(OnNewResetSelectedTaskStatusCommand); private void OnNewResetSelectedTaskStatusCommand() { - switch (SelectedSetupViewModel) - { - case CommonTaskViewModel ssVM: - ssVM.IsTaskCompletedSuccessfully = null; - reportOutputPath = null; - reportReaderWriter = null; - ssVM.CurrentTaskErrorLevel = ERROR.Empty; - break; - case GenericChipTaskViewModel ssVM: - ssVM.IsTaskCompletedSuccessfully = null; - ssVM.CurrentTaskErrorLevel = ERROR.Empty; - break; - case MifareClassicSetupViewModel ssVM: - ssVM.IsTaskCompletedSuccessfully = null; - ssVM.CurrentTaskErrorLevel = ERROR.Empty; - break; - case MifareDesfireSetupViewModel ssVM: - ssVM.IsTaskCompletedSuccessfully = null; - ssVM.CurrentTaskErrorLevel = ERROR.Empty; - break; - case MifareUltralightSetupViewModel ssVM: - ssVM.IsTaskCompletedSuccessfully = null; - ssVM.CurrentTaskErrorLevel = ERROR.Empty; - break; - } + (SelectedSetupViewModel as IGenericTaskModel).IsTaskCompletedSuccessfully = null; + (SelectedSetupViewModel as IGenericTaskModel).CurrentTaskErrorLevel = ERROR.Empty; } /// @@ -1251,6 +1196,19 @@ private void OnNewWriteToChipOnceCommand() taskTimeout.Start(); taskTimeout.Stop(); + DirectoryInfo reportTargetPathDirInfo; + + try + { + string initDir = variablesFromArgs["REPORTTARGETPATH"]; + reportTargetPathDirInfo = new DirectoryInfo(Path.GetDirectoryName(initDir)); + + } + catch + { + reportTargetPathDirInfo = null; + } + if ((taskHandler.TaskCollection[currentTaskIndex] as IGenericTaskModel).SelectedExecuteConditionErrorLevel == ERROR.Empty) { if (string.IsNullOrEmpty(reportOutputPath)) @@ -1258,7 +1216,9 @@ private void OnNewWriteToChipOnceCommand() var dlg = new SaveFileDialogViewModel { Title = ResourceLoader.GetResource("windowCaptionSaveReport"), - Filter = ResourceLoader.GetResource("filterStringSaveReport") + Filter = ResourceLoader.GetResource("filterStringSaveReport"), + InitialDirectory = reportTargetPathDirInfo != null ? + (reportTargetPathDirInfo.Exists ? reportTargetPathDirInfo.FullName : null) : null }; if (dlg.Show(Dialogs) && dlg.FileName != null) @@ -1286,10 +1246,13 @@ private void OnNewWriteToChipOnceCommand() { if (string.IsNullOrEmpty(reportOutputPath)) { + var dlg = new SaveFileDialogViewModel { Title = ResourceLoader.GetResource("windowCaptionSaveTasks"), - Filter = ResourceLoader.GetResource("filterStringSaveReport") + Filter = ResourceLoader.GetResource("filterStringSaveReport"), + InitialDirectory = reportTargetPathDirInfo != null ? + (reportTargetPathDirInfo.Exists ? reportTargetPathDirInfo.FullName : null) : null }; if (dlg.Show(Dialogs) && dlg.FileName != null) @@ -1769,20 +1732,59 @@ private void OnNewOpenFileDialog() } /// - /// Expose Command to Save As Menu Item + /// Expose Command to Save ProjectFile Menu Item /// public ICommand SaveTaskDialogCommand => new RelayCommand(OnNewSaveTaskDialogCommand); private void OnNewSaveTaskDialogCommand() { + using (SettingsReaderWriter settings = new SettingsReaderWriter()) + { + databaseReaderWriter.WriteDatabase(ChipTasks, settings.DefaultSpecification.LastUsedProjectPath); + } + } + + /// + /// Expose Command to Save As Menu Item + /// + public ICommand SaveTaskAsDialogCommand => new RelayCommand(OnNewSaveTaskAsDialogCommand); + private void OnNewSaveTaskAsDialogCommand() + { + string fileName = ""; + var dlg = new SaveFileDialogViewModel { Title = ResourceLoader.GetResource("windowCaptionSaveTasks"), - Filter = ResourceLoader.GetResource("filterStringSaveTasks") + Filter = ResourceLoader.GetResource("filterStringSaveTasks"), }; if (dlg.Show(Dialogs) && dlg.FileName != null) { - databaseReaderWriter.WriteDatabase(ChipTasks, dlg.FileName); + fileName = dlg.FileName; + } + else + { + return; + } + + var mbox = new MessageBoxViewModel + { + Caption = ResourceLoader.GetResource("windowCaptionAskTaskDefault"), + Message = ResourceLoader.GetResource("messageBoxMessageSetProjectAsDefault"), + Buttons = MessageBoxButton.YesNo + }; + + if (mbox.Show(Dialogs) == MessageBoxResult.Yes) + { + using (SettingsReaderWriter settings = new SettingsReaderWriter()) + { + settings.DefaultSpecification.LastUsedProjectPath = fileName; + settings.SaveSettings(); + } + } + + if (!string.IsNullOrEmpty(fileName)) + { + databaseReaderWriter.WriteDatabase(ChipTasks, fileName); } } @@ -2207,6 +2209,9 @@ private void LoadCompleted(object sender, EventArgs e) switch (arg.Split('=')[0]) { case "REPORTTARGETPATH": + + variablesFromArgs.Add(arg.Split('=')[0], arg.Split('=')[1]); + if (Directory.Exists(Path.GetDirectoryName(arg.Split('=')[1]))) { reportOutputPath = arg.Split('=')[1]; diff --git a/RFiDGear/ViewModel/TaskSetupViewModels/CommonTaskViewModel.cs b/RFiDGear/ViewModel/TaskSetupViewModels/CommonTaskViewModel.cs index 20bdc8c..80c8167 100644 --- a/RFiDGear/ViewModel/TaskSetupViewModels/CommonTaskViewModel.cs +++ b/RFiDGear/ViewModel/TaskSetupViewModels/CommonTaskViewModel.cs @@ -40,6 +40,7 @@ public class CommonTaskViewModel : ObservableObject, IUserDialogViewModel, IGene private protected ReportReaderWriter reportReaderWriter; private protected Checkpoint checkpoint; + private protected string lastUsedReportPath; [XmlIgnore] public ReportReaderWriter ReportReaderWriterToUse { get; set; } @@ -858,7 +859,7 @@ private void OnNewCommandDelegatorCall(TaskType_CommonTask classicTaskType) public ICommand OpenReportTemplateCommand => new RelayCommand(OnNewOpenReportTemplateCommand); private void OnNewOpenReportTemplateCommand() { - + CurrentTaskErrorLevel = ERROR.Empty; try @@ -876,7 +877,7 @@ private void OnNewOpenReportTemplateCommand() Mouse.OverrideCursor = Cursors.AppStarting; string path = dlg.FileName; - + if (!String.IsNullOrWhiteSpace(path)) { ReportTemplatePath = path; @@ -974,6 +975,12 @@ private void OnNewWriteReportCommand(ReportReaderWriter _reportReaderWriter) hasVariable = true; } + if (temporaryContent.Contains("%FREECLASSICMEM")) + { + temporaryContent = temporaryContent.Replace("%FREECLASSICMEM", ClassicChip?.FreeMemory.ToString(CultureInfo.CurrentCulture) ?? ""); + hasVariable = true; + } + if (temporaryContent.Contains("%LISTAPPS")) { temporaryContent = temporaryContent.Replace("%LISTAPPS", string.Join(", ", DesfireChip?.AppList.Select(x => x.appID)) ?? ""); @@ -1003,18 +1010,21 @@ private void OnNewWriteReportCommand(ReportReaderWriter _reportReaderWriter) if (temporaryContent.Contains("%nnn")) { temporaryContent = temporaryContent.Replace("%nnn", IterCounter.ToString("D3")); + hasVariable = true; IterCounter++; } if (temporaryContent.Contains("%nn")) { temporaryContent = temporaryContent.Replace("%nn", IterCounter.ToString("D2")); + hasVariable = true; IterCounter++; } if (temporaryContent.Contains("%n")) { temporaryContent = temporaryContent.Replace("%n", IterCounter.ToString("D1")); + hasVariable = true; IterCounter++; }