From 9ffff72f94a5e02213fd355dd41b9ca39fb97a1c Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 20 Feb 2023 11:21:27 +0100 Subject: [PATCH] Version 1.3.8451 Backend related changes - Feature: Added internal variables + %EXIT will immediatly exit rfidgear + adding a question-mark to the REPORTOUTPUTPATH variable will add a counter to the resulting filename i.e. REPORTOUTPUTPATH="C:\Path\where\Report\is\placed-??.pdf" would be replaced to REPORTOUTPUTPATH="C:\Path\where\Report\is\placed-01.pdf" where always +1 would be added to any existing filename matching. Notes: File must end with ".pdf"; The ?? must be the last character before the .pdf file extension. Available digits are: ?, ?? and ??? --- RFiDGear/Properties/AssemblyInfo.cs | 4 +- RFiDGear/RFiDGear.csproj.user | 2 +- RFiDGear/Resources/Manifest.de.resx | 2 +- RFiDGear/ViewModel/MainWindowViewModel.cs | 45 +++++++++++-- .../CommonTaskViewModel.cs | 22 ++++--- Setup/Product.wxs | 64 +++---------------- 6 files changed, 65 insertions(+), 74 deletions(-) diff --git a/RFiDGear/Properties/AssemblyInfo.cs b/RFiDGear/Properties/AssemblyInfo.cs index 812064e..9ba5fc4 100644 --- a/RFiDGear/Properties/AssemblyInfo.cs +++ b/RFiDGear/Properties/AssemblyInfo.cs @@ -13,7 +13,7 @@ [assembly: AssemblyConfiguration("x86")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("RFiDGear")] -[assembly: AssemblyCopyright("Copyright 2022")] +[assembly: AssemblyCopyright("Copyright 2023")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // This sets the default COM visibility of types in the assembly to invisible. @@ -25,6 +25,6 @@ // // You can specify all the values or you can use the default the Revision and // Build Numbers by using the '*' as shown below: -[assembly: AssemblyVersion("1.2.*")] +[assembly: AssemblyVersion("1.3.*")] [assembly: Guid("a34bc413-e349-4fd1-8b90-2eb95a333436")] [assembly: NeutralResourcesLanguage("")] diff --git a/RFiDGear/RFiDGear.csproj.user b/RFiDGear/RFiDGear.csproj.user index e3a899a..a1b1725 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-%3f%3f.pdf" AUTORUN=0 %24JobNumber=1234 %24CardType= 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 2bbf269..c308257 100644 --- a/RFiDGear/Resources/Manifest.de.resx +++ b/RFiDGear/Resources/Manifest.de.resx @@ -1464,7 +1464,7 @@ https://github.com/c3rebro/rfidgear NTAG - PDF Speichern unter... + PDF Bericht Speichern unter... PDF-Vorlage auswählen... diff --git a/RFiDGear/ViewModel/MainWindowViewModel.cs b/RFiDGear/ViewModel/MainWindowViewModel.cs index 63794e8..fd74aea 100644 --- a/RFiDGear/ViewModel/MainWindowViewModel.cs +++ b/RFiDGear/ViewModel/MainWindowViewModel.cs @@ -538,7 +538,7 @@ private void OnNewNewCreateReportTaskCommand() dialogs.Add(new CommonTaskViewModel(SelectedSetupViewModel, ChipTasks.TaskCollection, dialogs) { Caption = ResourceLoader.GetResource("windowCaptionAddEditGenericTask"), - + OnOk = (sender) => { @@ -1231,6 +1231,7 @@ private void OnNewWriteToChipOnceCommand() { Title = ResourceLoader.GetResource("windowCaptionSaveReport"), Filter = ResourceLoader.GetResource("filterStringSaveReport"), + ParentWindow = this.mw, InitialDirectory = reportTargetPathDirInfo != null ? (reportTargetPathDirInfo.Exists ? reportTargetPathDirInfo.FullName : null) : null }; @@ -1263,7 +1264,7 @@ private void OnNewWriteToChipOnceCommand() var dlg = new SaveFileDialogViewModel { - Title = ResourceLoader.GetResource("windowCaptionSaveTasks"), + Title = ResourceLoader.GetResource("windowCaptionSaveReport"), Filter = ResourceLoader.GetResource("filterStringSaveReport"), InitialDirectory = reportTargetPathDirInfo != null ? (reportTargetPathDirInfo.Exists ? reportTargetPathDirInfo.FullName : null) : null @@ -1752,6 +1753,7 @@ private void OnNewOpenFileDialog() { Title = ResourceLoader.GetResource("windowCaptionOpenProject"), Filter = ResourceLoader.GetResource("filterStringSaveTasks"), + ParentWindow = this.mw, Multiselect = false }; @@ -2284,13 +2286,44 @@ private void LoadCompleted(object sender, EventArgs e) { case "REPORTTARGETPATH": - variablesFromArgs.Add(arg.Split('=')[0], arg.Split('=')[1]); + variablesFromArgs.Add(arg.Split('=')[0], arg.Split('=')[1]); + + if (Directory.Exists(Path.GetDirectoryName(arg.Split('=')[1]))) + { + reportOutputPath = arg.Split('=')[1]; + var numbersInFileNames = new int[Directory.GetFiles(Path.GetDirectoryName(reportOutputPath)).Length]; - if (Directory.Exists(Path.GetDirectoryName(arg.Split('=')[1]))) + if (reportOutputPath.Contains("?")) { - reportOutputPath = arg.Split('=')[1]; + for (int i = 0; i < numbersInFileNames.Length; i++) + { + var fileName = Directory.GetFiles(Path.GetDirectoryName(reportOutputPath))[i]; + + if (fileName.Replace(".pdf",string.Empty).ToLower().Contains(reportOutputPath.ToLower().Replace("?",string.Empty).Replace(".pdf",string.Empty))) + { + _ = int.TryParse(fileName.ToLower().Replace( + reportOutputPath.ToLower().Replace("?", string.Empty).Replace(".pdf", string.Empty), string.Empty).Replace(".pdf", string.Empty), out int n); + numbersInFileNames[i] = n; + } + } } - break; + + if (reportOutputPath.Contains("???")) + { + reportOutputPath = reportOutputPath.Replace("???", string.Format("{0:D3}", numbersInFileNames.Max() + 1)); + } + + else if (reportOutputPath.Contains("??")) + { + reportOutputPath = reportOutputPath.Replace("??", string.Format("{0:D2}", numbersInFileNames.Max() + 1)); + } + + else if (reportOutputPath.Contains("?")) + { + reportOutputPath = reportOutputPath.Replace("?", string.Format("{0:D1}", numbersInFileNames.Max() + 1)); + } + } + break; case "AUTORUN": if (arg.Split('=')[1] == "1") diff --git a/RFiDGear/ViewModel/TaskSetupViewModels/CommonTaskViewModel.cs b/RFiDGear/ViewModel/TaskSetupViewModels/CommonTaskViewModel.cs index 4535ad3..616eb56 100644 --- a/RFiDGear/ViewModel/TaskSetupViewModels/CommonTaskViewModel.cs +++ b/RFiDGear/ViewModel/TaskSetupViewModels/CommonTaskViewModel.cs @@ -91,7 +91,7 @@ public CommonTaskViewModel(object _selectedSetupViewModel, ObservableCollection< try { CurrentTaskErrorLevel = ERROR.Empty; - + checkpoint = new Checkpoint(); Checkpoints = new ObservableCollection(); Args = new Dictionary(); @@ -911,15 +911,21 @@ private void OnNewWriteReportCommand(ReportReaderWriter _reportReaderWriter) if (temporaryContent.Contains("%SLAVECHIPTYPE")) { - temporaryContent = temporaryContent.Replace("%SLAVECHIPTYPE", ResourceLoader.GetResource( - string.Format("ENUM.CARD_TYPE.{0}", Enum.GetName(typeof(CARD_TYPE), GenericChip?.Slave?.CardType))) ?? ""); - hasVariable = true; + if (GenericChip?.Slave != null) + { + temporaryContent = temporaryContent.Replace("%SLAVECHIPTYPE", ResourceLoader.GetResource( + string.Format("ENUM.CARD_TYPE.{0}", Enum.GetName(typeof(CARD_TYPE), GenericChip?.Slave?.CardType))) ?? ""); + hasVariable = true; + } } if (temporaryContent.Contains("%SLAVEUID")) { - temporaryContent = temporaryContent.Replace("%SLAVEUID", GenericChip?.Slave?.UID ?? ""); - hasVariable = true; + if (GenericChip?.Slave != null) + { + temporaryContent = temporaryContent.Replace("%SLAVEUID", GenericChip?.Slave?.UID ?? ""); + hasVariable = true; + } } if (temporaryContent.Contains("%DATETIME")) @@ -1553,7 +1559,7 @@ private void OnNewExecuteProgramCommand() }; } - else if (ProgramToExecute.ToLower() == @"%exit%") + else if (ProgramToExecute.ToLower() == @"%exit") { info = null; @@ -1765,7 +1771,7 @@ public void Show(IList collection) { collection.Add(this); } - + #endregion IUserDialogViewModel Implementation #region Localization diff --git a/Setup/Product.wxs b/Setup/Product.wxs index 6d0535c..8110c18 100644 --- a/Setup/Product.wxs +++ b/Setup/Product.wxs @@ -97,7 +97,7 @@ --> = 601)]]> - +