From f43c6608c0121a8f5ecc6927e9d9eff40d1a63e4 Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 27 May 2022 23:38:45 +0200 Subject: [PATCH] Added Feature Request: List Existing Apps as Variable + add Variable: %LISTAPPS = list all existing apps in desfire when accessible --- RFiDGear/ViewModel/MainWindowViewModel.cs | 16 +++++++++++++--- .../TaskSetupViewModels/CommonTaskViewModel.cs | 9 +++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/RFiDGear/ViewModel/MainWindowViewModel.cs b/RFiDGear/ViewModel/MainWindowViewModel.cs index 99fc3a8..a38e05d 100644 --- a/RFiDGear/ViewModel/MainWindowViewModel.cs +++ b/RFiDGear/ViewModel/MainWindowViewModel.cs @@ -1053,7 +1053,8 @@ private void OnNewWriteToChipOnceCommand(bool _runSelectedOnly = false) Task thread = new Task(() => { - GenericChipModel GenericChip; + GenericChipModel GenericChip = new GenericChipModel("", CARD_TYPE.Unspecified); + MifareDesfireChipModel DesfireChip = new MifareDesfireChipModel("", CARD_TYPE.Unspecified); ; try { @@ -1066,9 +1067,16 @@ private void OnNewWriteToChipOnceCommand(bool _runSelectedOnly = false) device.ReadChipPublic(); GenericChip = new GenericChipModel(device.GenericChip.UID, device.GenericChip.CardType); + + if(GenericChip != null) + { + if(GenericChip.CardType == CARD_TYPE.DESFireEV1 || GenericChip.CardType == CARD_TYPE.DESFireEV2) + { + DesfireChip = new MifareDesfireChipModel(GenericChip.UID, GenericChip.CardType); + device.GetMiFareDESFireChipAppIDs(); + } + } } - else - GenericChip = new GenericChipModel("", CARD_TYPE.Unspecified); } if (treeViewParentNodes.Any(x => x.IsSelected)) @@ -1202,6 +1210,7 @@ private void OnNewWriteToChipOnceCommand(bool _runSelectedOnly = false) reportReaderWriter.ReportOutputPath = reportOutputPath; (taskHandler.TaskCollection[taskIndex] as CommonTaskViewModel).GenericChip = GenericChip; + (taskHandler.TaskCollection[taskIndex] as CommonTaskViewModel).DesfireChip = DesfireChip; (taskHandler.TaskCollection[taskIndex] as CommonTaskViewModel).AvailableTasks = taskHandler.TaskCollection; (taskHandler.TaskCollection[taskIndex] as CommonTaskViewModel).WriteReportCommand.Execute(reportReaderWriter); } @@ -1239,6 +1248,7 @@ private void OnNewWriteToChipOnceCommand(bool _runSelectedOnly = false) reportReaderWriter.ReportOutputPath = reportOutputPath; (taskHandler.TaskCollection[taskIndex] as CommonTaskViewModel).GenericChip = GenericChip; + (taskHandler.TaskCollection[taskIndex] as CommonTaskViewModel).DesfireChip = DesfireChip; (taskHandler.TaskCollection[taskIndex] as CommonTaskViewModel).AvailableTasks = taskHandler.TaskCollection; (taskHandler.TaskCollection[taskIndex] as CommonTaskViewModel).WriteReportCommand.Execute(reportReaderWriter); } diff --git a/RFiDGear/ViewModel/TaskSetupViewModels/CommonTaskViewModel.cs b/RFiDGear/ViewModel/TaskSetupViewModels/CommonTaskViewModel.cs index 2af505e..03556d5 100644 --- a/RFiDGear/ViewModel/TaskSetupViewModels/CommonTaskViewModel.cs +++ b/RFiDGear/ViewModel/TaskSetupViewModels/CommonTaskViewModel.cs @@ -43,6 +43,9 @@ public class CommonTaskViewModel : ViewModelBase, IUserDialogViewModel [XmlIgnore] public GenericChipModel GenericChip { get; set; } + [XmlIgnore] + public MifareDesfireChipModel DesfireChip { get; set; } + #endregion #region Constructors @@ -888,6 +891,12 @@ private void OnNewWriteReportCommand(ReportReaderWriter _reportReaderWriter) hasVariable = true; } + if (temporaryContent.Contains("%LISTAPPS")) + { + temporaryContent = temporaryContent.Replace("%LISTAPPS", string.Join(", ", DesfireChip.AppList) ?? ""); + hasVariable = true; + } + if (temporaryContent.Contains("%CONCAT")) { temporaryContent = temporaryContent.Replace("%CONCAT ", string.Empty);