Add Setting for Non-ZUGFeRD Files which are not rejected and instead moved to a special folder
This commit is contained in:
parent
d887fe107c
commit
4db589ecdd
@ -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)
|
||||
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
|
||||
|
||||
@ -90,6 +90,11 @@ Public Class ThreadRunner
|
||||
_logger.Warn("RejectedEmailDirectory {0} does not exist!", oArgs.RejectedEmailDirectory)
|
||||
End If
|
||||
|
||||
_logger.Debug("Checking Non ZUGFeRD Directory {0}", oArgs.NonZugferdDirectory)
|
||||
If Not Directory.Exists(oArgs.NonZugferdDirectory) Then
|
||||
_logger.Warn("RejectedEmailDirectory {0} does not exist!", oArgs.RejectedEmailDirectory)
|
||||
End If
|
||||
|
||||
_logger.Debug("Checking Exception Email Adress {0}", oArgs.ExceptionEmailAddress)
|
||||
If oArgs.ExceptionEmailAddress = String.Empty Then
|
||||
_logger.Warn("ExceptionEmailAddress {0} is not set!", oArgs.ExceptionEmailAddress)
|
||||
@ -171,27 +176,30 @@ Public Class ThreadRunner
|
||||
Dim oSQL As String = "SELECT T1.FOLDER_TYPE, T.FOLDER_PATH FROM TBEDM_FOLDER T, TBEDM_FOLDER_TYPE T1 WHERE T.FOLDER_TYPE_ID = T1.GUID AND T1.""ACTIVE"" = True AND T.""ACTIVE"" = True"
|
||||
Dim oResult As DataTable = _firebird.GetDatatable(oSQL)
|
||||
|
||||
For Each row As DataRow In oResult.Rows
|
||||
Dim oFolderType = row.Item("FOLDER_TYPE")
|
||||
For Each oRow As DataRow In oResult.Rows
|
||||
Dim oFolderType = oRow.Item("FOLDER_TYPE")
|
||||
|
||||
Select Case oFolderType
|
||||
Case ZUGFERD_IN
|
||||
pArgs.WatchDirectories.Add(row.Item("FOLDER_PATH"))
|
||||
pArgs.WatchDirectories.Add(oRow.Item("FOLDER_PATH"))
|
||||
|
||||
Case ZUGFERD_SUCCESS
|
||||
pArgs.SuccessDirectory = row.Item("FOLDER_PATH")
|
||||
pArgs.SuccessDirectory = oRow.Item("FOLDER_PATH")
|
||||
|
||||
Case ZUGFERD_ERROR
|
||||
pArgs.ErrorDirectory = row.Item("FOLDER_PATH")
|
||||
pArgs.ErrorDirectory = oRow.Item("FOLDER_PATH")
|
||||
|
||||
Case ZUGFERD_EML
|
||||
pArgs.OriginalEmailDirectory = row.Item("FOLDER_PATH")
|
||||
pArgs.OriginalEmailDirectory = oRow.Item("FOLDER_PATH")
|
||||
|
||||
Case ZUGFERD_REJECTED_EML
|
||||
pArgs.RejectedEmailDirectory = row.Item("FOLDER_PATH")
|
||||
pArgs.RejectedEmailDirectory = oRow.Item("FOLDER_PATH")
|
||||
|
||||
Case ZUGFERD_ATTACHMENTS
|
||||
pArgs.AttachmentsSubDirectory = row.Item("FOLDER_PATH")
|
||||
pArgs.AttachmentsSubDirectory = oRow.Item("FOLDER_PATH")
|
||||
|
||||
Case ZUGFERD_NO_ZUGFERD
|
||||
pArgs.NonZugferdDirectory = oRow.Item("FOLDER_PATH")
|
||||
|
||||
End Select
|
||||
Next
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user