Add Setting for Non-ZUGFeRD Files which are not rejected and instead moved to a special folder

This commit is contained in:
Jonathan Jenne
2021-08-26 15:54:07 +02:00
parent d887fe107c
commit 4db589ecdd
4 changed files with 65 additions and 34 deletions

View File

@@ -20,6 +20,8 @@ Public Class ImportZUGFeRDFiles
Public Const ZUGFERD_EML = "ZUGFeRD Eml"
Public Const ZUGFERD_REJECTED_EML = "ZUGFeRD Eml Rejected"
Public Const ZUGFERD_ATTACHMENTS = "ZUGFeRD Attachments"
Public Const ZUGFERD_NO_ZUGFERD = "Non-ZUGFeRD Files"
Public HISTORY_ID As Integer
Private Const DIRECTORY_DONT_MOVE = "DIRECTORY_DONT_MOVE"
@@ -325,7 +327,21 @@ Public Class ImportZUGFeRDFiles
'Check if there are no ZUGFeRD files
If oZUGFeRDCount = 0 Then
Throw New NoFerdsException()
' If NonZugferdDirectory is not set, a NoFerdsException will be thrown and a rejection will be generated
' This is the default/initial behaviour.
If oArgs.NonZugferdDirectory Is Nothing OrElse oArgs.NonZugferdDirectory = String.Empty Then
Throw New NoFerdsException()
End If
' Also, if the directory is set but does not exist, still a rejection will be generated.
If Not IO.Directory.Exists(oArgs.NonZugferdDirectory) Then
Throw New NoFerdsException()
End If
' Only if the directory is set and does exist, it will be used and any file groups which
' do NOT CONTAIN ANY ZUGFERD DOCUMENTS, are moved to that directory.
Throw New NoFerdsAlternateException()
End If
'If no errors occurred...
@@ -393,6 +409,13 @@ Public Class ImportZUGFeRDFiles
_email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "NoFerdsException", _EmailOutAccountId)
AddRejectedState(oMessageId, "NoFerdsException", " Email enthielt keine ZUGFeRD-Dokumente", "", oSQLTransaction)
Catch ex As NoFerdsAlternateException
' TODO
' Maybe dont even log this 'error', since it's not really an error
' and it might happen *A LOT*
_logger.Error(ex)
oMoveDirectory = oArgs.NonZugferdDirectory
Catch ex As MissingValueException
_logger.Error(ex)

View File

@@ -2,31 +2,21 @@
Imports DigitalData.Modules.Interfaces
Public Class WorkerArgs
Public WatchDirectories As List(Of String)
Public SuccessDirectory As String
Public ErrorDirectory As String
Public OriginalEmailDirectory As String
Public RejectedEmailDirectory As String
Public AttachmentsSubDirectory As String
Public PropertyMap As Dictionary(Of String, XmlItemProperty)
Public InsertIntoSQLServer As Boolean
' Directory Parameters
Public WatchDirectories As New List(Of String)
Public SuccessDirectory As String = Nothing
Public ErrorDirectory As String = Nothing
Public OriginalEmailDirectory As String = Nothing
Public RejectedEmailDirectory As String = Nothing
Public AttachmentsSubDirectory As String = Nothing
Public NonZugferdDirectory As String = Nothing
Public ExceptionEmailAddress As String
Public IgnoreRejectionStatus As Boolean
Public MaxAttachmentSizeInMegaBytes As Integer
' Property Parameter
Public PropertyMap As New Dictionary(Of String, XmlItemProperty)
Public Sub New()
WatchDirectories = New List(Of String)
SuccessDirectory = Nothing
ErrorDirectory = Nothing
OriginalEmailDirectory = Nothing
RejectedEmailDirectory = Nothing
AttachmentsSubDirectory = Nothing
PropertyMap = New Dictionary(Of String, XmlItemProperty)
InsertIntoSQLServer = False
ExceptionEmailAddress = Nothing
IgnoreRejectionStatus = False
MaxAttachmentSizeInMegaBytes = -1
End Sub
' Misc Flag Parameters
Public InsertIntoSQLServer As Boolean = False
Public ExceptionEmailAddress As String = Nothing
Public IgnoreRejectionStatus As Boolean = False
Public MaxAttachmentSizeInMegaBytes As Integer = -1
End Class

View File

@@ -47,6 +47,16 @@ Public Class Exceptions
MyBase.New("No ZUGFeRD documents found")
End Sub
End Class
Public Class NoFerdsAlternateException
Inherits ApplicationException
Public Sub New()
MyBase.New("No ZUGFeRD documents found, no rejection will be generated")
End Sub
End Class
Public Class MD5HashException
Inherits ApplicationException