From a5226a8101225263f579d48261e8c8cd6acfd2bb Mon Sep 17 00:00:00 2001 From: pitzm Date: Fri, 25 Jul 2025 13:01:45 +0200 Subject: [PATCH] Modules.Interfaces: Try/Catch und logging --- Interfaces/ZUGFeRDInterface.vb | 39 ++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/Interfaces/ZUGFeRDInterface.vb b/Interfaces/ZUGFeRDInterface.vb index fdde7ca6..64f463c0 100644 --- a/Interfaces/ZUGFeRDInterface.vb +++ b/Interfaces/ZUGFeRDInterface.vb @@ -133,19 +133,40 @@ Public Class ZUGFeRDInterface End Sub Public Function FilterPropertyMap(pPropertyMapList As List(Of XmlItemProperty), pSpecification As String) As Dictionary(Of String, XmlItemProperty) - _logger.Debug("Filtering Property map for Specification [{0}]", pSpecification) + _logger.Debug("Filtering Property map list for Specification [{0}]", pSpecification) If pSpecification = ZUGFERD_SPEC_10 Then - _logger.Debug("Special Case [{0}], including [{1}]", ZUGFERD_SPEC_10, ZUGFERD_SPEC_DEFAULT) - Return pPropertyMapList. - Where(Function(kv) kv.Specification = pSpecification Or kv.Specification = ZUGFERD_SPEC_DEFAULT). - ToDictionary(Function(kv) kv.XMLPath, Function(kv) kv) + Try + + _logger.Debug("Special Case [{0}], including [{1}]", ZUGFERD_SPEC_10, ZUGFERD_SPEC_DEFAULT) + + Dim countElements As Integer = pPropertyMapList.Where(Function(x) x.Specification = pSpecification Or x.Specification = ZUGFERD_SPEC_DEFAULT).Count + _logger.Debug("Property map list contains [{0}] elements for specification [{1}]", countElements, pSpecification) + + Return pPropertyMapList. + Where(Function(kv) kv.Specification = pSpecification Or kv.Specification = ZUGFERD_SPEC_DEFAULT). + ToDictionary(Function(kv) kv.XMLPath, Function(kv) kv) + + Catch ex As Exception + _logger.Error(ex) + End Try Else - _logger.Debug("Using Specification [{0}]", pSpecification) - Return pPropertyMapList. - Where(Function(kv) kv.Specification = pSpecification). - ToDictionary(Function(kv) kv.XMLPath, Function(kv) kv) + + Try + + Dim countElements As Integer = pPropertyMapList.Where(Function(x) x.Specification = pSpecification).Count + _logger.Debug("Property map list contains [{0}] elements for specification [{1}]", countElements, pSpecification) + + Return pPropertyMapList. + Where(Function(kv) kv.Specification = pSpecification). + ToDictionary(Function(kv) kv.XMLPath, Function(kv) kv) + + Catch ex As Exception + _logger.Error(ex) + End Try End If + + Return Nothing End Function Public Function GetSerializedXMLContentFromFile(oFileInfo As FileInfo) As ZugferdResult