diff --git a/RFiDGear/DataAccessLayer/Remote/FromFile/ReportReaderWriter.cs b/RFiDGear/DataAccessLayer/Remote/FromFile/ReportReaderWriter.cs index 3c8f5c9..4d235a5 100644 --- a/RFiDGear/DataAccessLayer/Remote/FromFile/ReportReaderWriter.cs +++ b/RFiDGear/DataAccessLayer/Remote/FromFile/ReportReaderWriter.cs @@ -24,7 +24,7 @@ public class ReportReaderWriter : IDisposable private const string reportTemplateTempFileName = "temptemplate.pdf"; private readonly string appDataPath; public string ReportOutputPath { get; set; } - public string ReportTemplatePath { get; set; } + public string ReportTemplateFile { get; set; } #endregion fields @@ -62,7 +62,7 @@ public ObservableCollection GetReportFields() { var temp = new ObservableCollection(); - using (var pdfDoc = PdfDocument.Load(ReportTemplatePath)) + using (var pdfDoc = PdfDocument.Load(ReportTemplateFile)) { var form = pdfDoc.Form; @@ -98,11 +98,11 @@ public void SetReportField(string _field, string _value) { try { - using (var pdfDoc = PdfDocument.Load(ReportTemplatePath)) // (new PdfReader(ReportTemplatePath), new PdfWriter(ReportOutputPath))) + using (var pdfDoc = PdfDocument.Load(ReportTemplateFile)) // (new PdfReader(ReportTemplateFile), new PdfWriter(ReportOutputPath))) { try { - ReportTemplatePath = System.IO.Path.Combine(appDataPath, reportTemplateTempFileName); + ReportTemplateFile = System.IO.Path.Combine(appDataPath, reportTemplateTempFileName); var form = pdfDoc.Form; pdfDoc.Info.Title = "RFiDGear Report"; @@ -137,9 +137,9 @@ public void ConcatReportField(string _field, string _value) { try { - ReportTemplatePath = System.IO.Path.Combine(appDataPath, reportTemplateTempFileName); + ReportTemplateFile = System.IO.Path.Combine(appDataPath, reportTemplateTempFileName); - using (var pdfDoc = PdfDocument.Load(ReportTemplatePath)) + using (var pdfDoc = PdfDocument.Load(ReportTemplateFile)) { try { diff --git a/RFiDGear/DataAccessLayer/Remote/FromIO/ElatecNetProvider.cs b/RFiDGear/DataAccessLayer/Remote/FromIO/ElatecNetProvider.cs index eb4172d..287c630 100644 --- a/RFiDGear/DataAccessLayer/Remote/FromIO/ElatecNetProvider.cs +++ b/RFiDGear/DataAccessLayer/Remote/FromIO/ElatecNetProvider.cs @@ -104,14 +104,28 @@ public override ERROR ReadChipPublic() hfTag.VersionL4 ); - if (lfTag != null && lfTag?.CardType != CARD_TYPE.NOTAG) - { - GenericChip.Child = new GenericChipModel(lfTag.UID, (RFiDGear.DataAccessLayer.CARD_TYPE)lfTag.CardType); - } - else if(legicTag != null && legicTag?.CardType != CARD_TYPE.NOTAG) - { - GenericChip.Child = new GenericChipModel(legicTag.UID, (RFiDGear.DataAccessLayer.CARD_TYPE)legicTag.CardType); - } + if (lfTag != null && lfTag?.CardType != CARD_TYPE.NOTAG) + { + if(GenericChip != null && GenericChip.CardType != CARD_TYPE.NOTAG) + { + GenericChip.Child = new GenericChipModel(lfTag.UID, lfTag.CardType); + } + else + { + GenericChip = new GenericChipModel(lfTag.UID, lfTag.CardType); + } + } + else if (legicTag != null && legicTag?.CardType != CARD_TYPE.NOTAG) + { + if (GenericChip != null && GenericChip.CardType != CARD_TYPE.NOTAG) + { + GenericChip.Child = new GenericChipModel(legicTag.UID, legicTag.CardType); + } + else + { + GenericChip = new GenericChipModel(legicTag.UID, legicTag.CardType); + } + } //readerDevice.GetSingleChip(true); return ERROR.NoError; diff --git a/RFiDGear/Properties/AssemblyInfo.cs b/RFiDGear/Properties/AssemblyInfo.cs index 8662ea3..d66fd6c 100644 --- a/RFiDGear/Properties/AssemblyInfo.cs +++ b/RFiDGear/Properties/AssemblyInfo.cs @@ -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.5.*")] +[assembly: AssemblyVersion("1.6.*")] [assembly: Guid("a34bc413-e349-4fd1-8b90-2eb95a333436")] [assembly: NeutralResourcesLanguage("")] diff --git a/RFiDGear/RFiDGear.csproj.user b/RFiDGear/RFiDGear.csproj.user index 7177512..f90e435 100644 --- a/RFiDGear/RFiDGear.csproj.user +++ b/RFiDGear/RFiDGear.csproj.user @@ -1,7 +1,7 @@  - REPORTTARGETPATH="C:\temp\test file-%3f%3f.pdf" AUTORUN=0 %24JobNumber=1234 CUSTOMPROJECTFILE="D:\CardCheck_Data\KPruefung_Vorlagen\00_RFID_Gear_Vorlage\CardCheckAssistant.rfPrj" + REPORTTARGETPATH="C:\temp\test file_final.pdf" REPORTTEMPLATEFILE="C:\temp\test file.pdf" CUSTOMPROJECTFILE="D:\CardCheck_Data\KPruefung_Vorlagen\00_RFID_Gear_Vorlage\CardCheckAssistant.rfPrj" AUTORUN=0 %24JobNumber=1234 D:\Seafile\Dokumente Privat\Steven\Projekte\Software\Windows\RFIDGear\RFiDGear\bin\Debug\ diff --git a/RFiDGear/ViewModel/MainWindowViewModel.cs b/RFiDGear/ViewModel/MainWindowViewModel.cs index 666bf85..8850ba3 100644 --- a/RFiDGear/ViewModel/MainWindowViewModel.cs +++ b/RFiDGear/ViewModel/MainWindowViewModel.cs @@ -65,6 +65,7 @@ public class MainWindowViewModel : ObservableObject private protected DispatcherTimer triggerReadChip; private protected DispatcherTimer taskTimeout; private protected string reportOutputPath; + private protected string reportTemplateFile; private protected ChipTaskHandlerModel taskHandler; private protected List mifareClassicUidModels = new List(); private protected List mifareDesfireViewModels = new List(); @@ -1030,7 +1031,7 @@ private void OnNewResetReportTaskDirectoryCommand() ssVM.IsTaskCompletedSuccessfully = null; reportOutputPath = null; reportReaderWriter.ReportOutputPath = null; - reportReaderWriter.ReportTemplatePath = null; + reportReaderWriter.ReportTemplateFile = null; ssVM.CurrentTaskErrorLevel = ERROR.Empty; break; } @@ -1224,8 +1225,9 @@ private void OnNewWriteToChipOnceCommand() try { - var initDir = variablesFromArgs["REPORTTARGETPATH"]; - reportTargetPathDirInfo = new DirectoryInfo(Path.GetDirectoryName(initDir)); + var targetReportDir = variablesFromArgs["REPORTTARGETPATH"]; + var sourceTemplateFile = variablesFromArgs["REPORTTEMPLATEFILE"]; + reportTargetPathDirInfo = new DirectoryInfo(Path.GetDirectoryName(targetReportDir)); } catch @@ -1258,6 +1260,10 @@ private void OnNewWriteToChipOnceCommand() } reportReaderWriter.ReportOutputPath = reportOutputPath; + if (!string.IsNullOrEmpty(reportTemplateFile)) + { + reportReaderWriter.ReportTemplateFile = reportTemplateFile; + } (taskHandler.TaskCollection[currentTaskIndex] as CommonTaskViewModel).WriteReportCommand.Execute(reportReaderWriter); } @@ -1292,6 +1298,10 @@ private void OnNewWriteToChipOnceCommand() } reportReaderWriter.ReportOutputPath = reportOutputPath; + if (!string.IsNullOrEmpty(reportTemplateFile)) + { + reportReaderWriter.ReportTemplateFile = reportTemplateFile; + } (taskHandler.TaskCollection[currentTaskIndex] as CommonTaskViewModel).WriteReportCommand.Execute(reportReaderWriter); } @@ -2320,44 +2330,54 @@ 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 (reportOutputPath.Contains("?")) + if (Directory.Exists(Path.GetDirectoryName(arg.Split('=')[1]))) { - for (int i = 0; i < numbersInFileNames.Length; i++) - { - var fileName = Directory.GetFiles(Path.GetDirectoryName(reportOutputPath))[i]; + reportOutputPath = arg.Split('=')[1]; + var numbersInFileNames = new int[Directory.GetFiles(Path.GetDirectoryName(reportOutputPath)).Length]; - if (fileName.Replace(".pdf",string.Empty).ToLower().Contains(reportOutputPath.ToLower().Replace("?",string.Empty).Replace(".pdf",string.Empty))) + if (reportOutputPath.Contains("?")) + { + for (int i = 0; i < numbersInFileNames.Length; i++) { - _ = 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; + 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; + } } } - } - if (reportOutputPath.Contains("???")) - { - reportOutputPath = reportOutputPath.Replace("???", string.Format("{0:D3}", numbersInFileNames.Max() + 1)); - } + 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:D2}", numbersInFileNames.Max() + 1)); + } + + else if (reportOutputPath.Contains("?")) + { + reportOutputPath = reportOutputPath.Replace("?", string.Format("{0:D1}", numbersInFileNames.Max() + 1)); + } } + break; + + case "REPORTTEMPLATEFILE": - else if (reportOutputPath.Contains("?")) + variablesFromArgs.Add(arg.Split('=')[0], arg.Split('=')[1]); + + if (File.Exists(arg.Split('=')[1])) { - reportOutputPath = reportOutputPath.Replace("?", string.Format("{0:D1}", numbersInFileNames.Max() + 1)); + reportTemplateFile = arg.Split('=')[1]; } - } - break; + break; case "AUTORUN": if (arg.Split('=')[1] == "1") diff --git a/RFiDGear/ViewModel/TaskSetupViewModels/CommonTaskViewModel.cs b/RFiDGear/ViewModel/TaskSetupViewModels/CommonTaskViewModel.cs index 4f52194..2f2a936 100644 --- a/RFiDGear/ViewModel/TaskSetupViewModels/CommonTaskViewModel.cs +++ b/RFiDGear/ViewModel/TaskSetupViewModels/CommonTaskViewModel.cs @@ -126,7 +126,7 @@ public CommonTaskViewModel(object _selectedSetupViewModel, ObservableCollection< { if (!string.IsNullOrEmpty(reportTemplatePath)) { - reader.ReportTemplatePath = reportTemplatePath; + reader.ReportTemplateFile = reportTemplatePath; TemplateFields = new ObservableCollection(reader.GetReportFields().OrderBy(x => x)); } @@ -835,7 +835,7 @@ private void OnNewOpenReportTemplateCommand() ReportTemplatePath = path; reportReaderWriter = new ReportReaderWriter { - ReportTemplatePath = ReportTemplatePath + ReportTemplateFile = ReportTemplatePath }; TemplateFields = new ObservableCollection(reportReaderWriter.GetReportFields().OrderBy(x => x)); @@ -848,7 +848,7 @@ private void OnNewOpenReportTemplateCommand() else { - //ReportTemplatePath = string.Empty; + //ReportTemplateFile = string.Empty; } } @@ -880,12 +880,12 @@ private void OnNewWriteReportCommand(ReportReaderWriter _reportReaderWriter) try { reportReaderWriter = _reportReaderWriter; - if (string.IsNullOrEmpty(reportReaderWriter.ReportTemplatePath)) + if (string.IsNullOrEmpty(reportReaderWriter.ReportTemplateFile)) { - reportReaderWriter.ReportTemplatePath = ReportTemplatePath; + reportReaderWriter.ReportTemplateFile = ReportTemplatePath; } - if (!String.IsNullOrWhiteSpace(reportReaderWriter.ReportTemplatePath)) + if (!String.IsNullOrWhiteSpace(reportReaderWriter.ReportTemplateFile)) { foreach (var checkpoint in Checkpoints)