Modules.Interfaces & Modules.Jobs: Weitergabe der ErrorCodes in den Exceptions, um sie im WebService auswerten zu können.

This commit is contained in:
2025-08-08 11:46:21 +02:00
parent d7d2ecf8a0
commit 2007bb91f3
7 changed files with 119 additions and 58 deletions

View File

@@ -559,36 +559,46 @@ Public Class ImportZUGFeRDFiles
Try
oDocument = _zugferd.GetSerializedXMLContentFromFile(pFile)
oDocument.ReceiptFileType = ZUGFeRDInterface.RECEIPT_TYPE_XML
Catch ex As ValidationException
Throw ex
Catch ex As ZUGFeRDExecption
Select Case ex.ErrorType
Case ZUGFeRDInterface.ErrorType.NoZugferd
_logger.Info("File [{0}] is not a valid eInvoice document. Skipping.", pFile.Name)
oResult.EmailAttachmentFiles.Add(pFile)
Return oResult
If ex.ErrorCode > 0 Then
_logger.Info("New Rejection Logik")
Case ZUGFeRDInterface.ErrorType.UnsupportedFormat
_logger.Info("File [{0}/{1}] is an unsupported eInvoice document format!", pFile.Name, ex.XmlFile)
Throw New UnsupportedFerdException(ex.XmlFile)
Select Case ex.ErrorCode
Case ErrorCode.NoFerdsException
_logger.Info("File [{0}] is not a valid eInvoice document. Skipping.", pFile.Name)
Case ZUGFeRDInterface.ErrorType.NoValidZugferd
_logger.Info("File [{0}] is an Incorrectly formatted eInvoice document!", pFile.Name)
Throw New InvalidFerdException()
oResult.EmailAttachmentFiles.Add(pFile)
Return oResult
Case Else
_logger.Warn("Unexpected Error occurred while extracting eInvoice Information from file {0}", pFile.Name)
Throw ex
End Select
Case ErrorCode.UnsupportedFerdException
_logger.Info("File [{0}/{1}] is an unsupported eInvoice document format!", pFile.Name, ex.XmlFile)
Throw New UnsupportedFerdException(ex.XmlFile)
Case ErrorCode.InvalidFerdException
_logger.Info("File [{0}] is an incorrectly formatted eInvoice document!", pFile.Name)
Throw New InvalidFerdException()
Case Else
_logger.Warn("Unexpected Error occurred while extracting eInvoice Information from file {0}", pFile.Name)
Throw ex
End Select
End If
End Try
Try
oDocument.ReceiptFileType = ZUGFeRDInterface.RECEIPT_TYPE_XML
Dim sqlResult As Boolean = StoreXMLItemsInDatabase(pMessageId, oDocument, pFile, pConnections, pArgs, oResult)
Dim sqlResult As Boolean = False
If oDocument IsNot Nothing Then
sqlResult = StoreXMLItemsInDatabase(pMessageId, oDocument, pFile, pConnections, pArgs, oResult)
End If
Catch ex As Exception
Throw ex
End Try
@@ -631,30 +641,37 @@ Public Class ImportZUGFeRDFiles
Try
oDocument = _zugferd.ExtractZUGFeRDFileWithGDPicture(pFile.FullName)
oDocument.ReceiptFileType = ZUGFeRDInterface.RECEIPT_TYPE_PDF
Catch ex As ValidationException
Throw ex
Catch ex As ZUGFeRDExecption
Select Case ex.ErrorType
Case ZUGFeRDInterface.ErrorType.NoZugferd
_logger.Info("File [{0}] is not a valid eInvoice document. Skipping.", pFile.Name)
If ex.ErrorCode > 0 Then
_logger.Info("New Rejection Logik")
oResult.EmailAttachmentFiles.Add(pFile)
Return oResult
Select Case ex.ErrorCode
Case ErrorCode.NoFerdsException
_logger.Info("File [{0}] is not a valid eInvoice document. Skipping.", pFile.Name)
Case ZUGFeRDInterface.ErrorType.UnsupportedFormat
_logger.Info("File [{0}/{1}] is an unsupported eInvoice document format!", pFile.Name, ex.XmlFile)
Throw New UnsupportedFerdException(ex.XmlFile)
oResult.EmailAttachmentFiles.Add(pFile)
Return oResult
Case ZUGFeRDInterface.ErrorType.NoValidZugferd
_logger.Info("File [{0}] is an incorrectly formatted eInvoice document!", pFile.Name)
Throw New InvalidFerdException()
Case ErrorCode.UnsupportedFerdException
_logger.Info("File [{0}/{1}] is an unsupported eInvoice document format!", pFile.Name, ex.XmlFile)
Throw New UnsupportedFerdException(ex.XmlFile)
Case ErrorCode.InvalidFerdException
_logger.Info("File [{0}] is an incorrectly formatted eInvoice document!", pFile.Name)
Throw New InvalidFerdException()
Case Else
_logger.Warn("Unexpected Error occurred while extracting eInvoice Information from file {0}", pFile.Name)
Throw ex
End Select
End If
Case Else
_logger.Warn("Unexpected Error occurred while extracting eInvoice Information from file {0}", pFile.Name)
Throw ex
End Select
End Try
' Check if there are more than one ZUGFeRD files
@@ -677,7 +694,6 @@ Public Class ImportZUGFeRDFiles
End If
Try
oDocument.ReceiptFileType = ZUGFeRDInterface.RECEIPT_TYPE_PDF
Dim sqlResult As Boolean = StoreXMLItemsInDatabase(pMessageId, oDocument, pFile, pConnections, pArgs, oResult)
Catch ex As Exception
Throw ex