From ed02436dd664ae2aab8082534dbaeebc6298464e Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Mon, 20 Apr 2020 10:58:13 +0200 Subject: [PATCH] Jobs.EDMI.ZUGFeRD: Use GDPicture for Validation, Fix Group counter being nothing, remove xml from allowed extensions --- .../EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb | 42 ++++++++----------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb b/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb index cb75847b..2bfb4757 100644 --- a/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb +++ b/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb @@ -27,7 +27,7 @@ Public Class ImportZUGFeRDFiles Public HISTORY_ID As Integer ' List of allowed extensions for PDF/A Attachments - Private ReadOnly AllowedExtensions As List(Of String) = New List(Of String) From {"xml", "docx", "doc", "pdf", "xls", "xlsx", "ppt", "pptx", "txt"} + Private ReadOnly AllowedExtensions As List(Of String) = New List(Of String) From {"docx", "doc", "pdf", "xls", "xlsx", "ppt", "pptx", "txt"} Private ReadOnly _logger As Logger Private ReadOnly _logConfig As LogConfig @@ -181,7 +181,7 @@ Public Class ImportZUGFeRDFiles _logger.Info("Start processing file {0}", oFile.Name) Try - oDocument = _zugferd.ExtractZUGFeRDFile(oFile.FullName) + oDocument = _zugferd.ExtractZUGFeRDFileWithGDPicture(oFile.FullName) Catch ex As ZUGFeRDExecption Select Case ex.ErrorType Case ZUGFeRDInterface.ErrorType.NoZugferd @@ -420,33 +420,25 @@ Public Class ImportZUGFeRDFiles End If For Each oProperty In oCheckResult.ValidProperties - Dim oGroupCounterValue = Nothing + Dim oGroupCounterValue = oProperty.GroupCounter - If oProperty.GroupCounter > -1 Then - oGroupCounterValue = oProperty.GroupCounter + ' If GroupCounter is -1, it means this is a default property that can only occur once. + ' Set the actual inserted value to 0 + If oGroupCounterValue = -1 Then + oGroupCounterValue = 0 End If - If (oGroupCounterValue > 0) = False Then - Dim oTerm As String - If IsNothing(oGroupCounterValue) Then - oTerm = "NOTHING" - Else - oTerm = oGroupCounterValue.ToString - End If - _logger.Warn($"[ImportZUGFeRDFiles] - oGroupCounterValue is not valid [{oTerm}]!!") - Else - Dim oCommand = $"INSERT INTO {oProperty.TableName} (REFERENCE_GUID, ITEM_DESCRIPTION, ITEM_VALUE, GROUP_COUNTER) VALUES ('{oMessageId}', '{oProperty.Description}', '{oProperty.Value}', {oGroupCounterValue})" - _logger.Debug("Mapping Property [{0}] to value [{1}] . Will be inserted into table {2}", oProperty.Description, oProperty.Value, oProperty.TableName) - ' Insert into SQL Server - If oArgs.InsertIntoSQLServer = True Then - Dim oResult = _mssql.NewExecutenonQuery(oCommand) - If oResult = False Then - _logger.Warn($"SQL Command [{oCommand}] was not successful. Check the log.") - End If + + Dim oCommand = $"INSERT INTO {oProperty.TableName} (REFERENCE_GUID, ITEM_DESCRIPTION, ITEM_VALUE, GROUP_COUNTER) VALUES ('{oMessageId}', '{oProperty.Description}', '{oProperty.Value}', {oGroupCounterValue})" + _logger.Debug("Mapping Property [{0}] to value [{1}] . Will be inserted into table {2}", oProperty.Description, oProperty.Value, oProperty.TableName) + ' Insert into SQL Server + If oArgs.InsertIntoSQLServer = True Then + Dim oResult = _mssql.NewExecutenonQuery(oCommand) + If oResult = False Then + _logger.Warn($"SQL Command [{oCommand}] was not successful. Check the log.") End If - ' Insert into Firebird - _firebird.ExecuteNonQueryWithConnection(oCommand, oConnection, Firebird.TransactionMode.ExternalTransaction, oTransaction) End If - + ' Insert into Firebird + _firebird.ExecuteNonQueryWithConnection(oCommand, oConnection, Firebird.TransactionMode.ExternalTransaction, oTransaction) Next Next