Jobs/ZUGFeRD: Fix transactions not committed when expected errors happen (md5, etc.)

This commit is contained in:
Jonathan Jenne 2021-05-10 16:11:38 +02:00
parent bac5a3bcd4
commit 23a65cdeef

View File

@ -177,6 +177,10 @@ Public Class ImportZUGFeRDFiles
' Will be set only at the end of the function if no error occurred. ' Will be set only at the end of the function if no error occurred.
Dim oIsSuccess As Boolean = False Dim oIsSuccess As Boolean = False
' Flag to save if the occurred error (if any) was expected
' Used to determine if transactions should be committed or not
Dim oExpectedError As Boolean = True
' Create file lists ' Create file lists
Dim oFileGroupFiles As List(Of FileInfo) = oFileGroup.Value Dim oFileGroupFiles As List(Of FileInfo) = oFileGroup.Value
Dim oEmailAttachmentFiles As New List(Of FileInfo) Dim oEmailAttachmentFiles As New List(Of FileInfo)
@ -433,6 +437,8 @@ Public Class ImportZUGFeRDFiles
oMoveDirectory = DIRECTORY_DONT_MOVE oMoveDirectory = DIRECTORY_DONT_MOVE
oExpectedError = False
Catch ex As Exception Catch ex As Exception
_logger.Warn("Unknown Error occurred: {0}", ex.Message) _logger.Warn("Unknown Error occurred: {0}", ex.Message)
_logger.Error(ex) _logger.Error(ex)
@ -453,6 +459,8 @@ Public Class ImportZUGFeRDFiles
oMoveDirectory = DIRECTORY_DONT_MOVE oMoveDirectory = DIRECTORY_DONT_MOVE
oExpectedError = False
Finally Finally
Try Try
' If an application error occurred, dont move files so they will be processed again later ' If an application error occurred, dont move files so they will be processed again later
@ -480,9 +488,10 @@ Public Class ImportZUGFeRDFiles
End Try End Try
Try Try
' If everything went OK, finally commit all changes to the Database ' If everything went OK or an expected error occurred,
' finally commit all changes To the Database
' ================================================================== ' ==================================================================
If oIsSuccess Then If oIsSuccess Or oExpectedError Then
' Commit SQL Transaction ' Commit SQL Transaction
oSQLTransaction.Commit() oSQLTransaction.Commit()