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_EML = "ZUGFeRD Eml"
|
||||||
Public Const ZUGFERD_REJECTED_EML = "ZUGFeRD Eml Rejected"
|
Public Const ZUGFERD_REJECTED_EML = "ZUGFeRD Eml Rejected"
|
||||||
Public Const ZUGFERD_ATTACHMENTS = "ZUGFeRD Attachments"
|
Public Const ZUGFERD_ATTACHMENTS = "ZUGFeRD Attachments"
|
||||||
|
Public Const ZUGFERD_NO_ZUGFERD = "Non-ZUGFeRD Files"
|
||||||
|
|
||||||
Public HISTORY_ID As Integer
|
Public HISTORY_ID As Integer
|
||||||
|
|
||||||
Private Const DIRECTORY_DONT_MOVE = "DIRECTORY_DONT_MOVE"
|
Private Const DIRECTORY_DONT_MOVE = "DIRECTORY_DONT_MOVE"
|
||||||
@ -325,7 +327,21 @@ Public Class ImportZUGFeRDFiles
|
|||||||
|
|
||||||
'Check if there are no ZUGFeRD files
|
'Check if there are no ZUGFeRD files
|
||||||
If oZUGFeRDCount = 0 Then
|
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
|
End If
|
||||||
|
|
||||||
'If no errors occurred...
|
'If no errors occurred...
|
||||||
@ -393,6 +409,13 @@ Public Class ImportZUGFeRDFiles
|
|||||||
_email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "NoFerdsException", _EmailOutAccountId)
|
_email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "NoFerdsException", _EmailOutAccountId)
|
||||||
AddRejectedState(oMessageId, "NoFerdsException", " Email enthielt keine ZUGFeRD-Dokumente", "", oSQLTransaction)
|
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
|
Catch ex As MissingValueException
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|
||||||
|
|||||||
@ -2,31 +2,21 @@
|
|||||||
Imports DigitalData.Modules.Interfaces
|
Imports DigitalData.Modules.Interfaces
|
||||||
|
|
||||||
Public Class WorkerArgs
|
Public Class WorkerArgs
|
||||||
Public WatchDirectories As List(Of String)
|
' Directory Parameters
|
||||||
Public SuccessDirectory As String
|
Public WatchDirectories As New List(Of String)
|
||||||
Public ErrorDirectory As String
|
Public SuccessDirectory As String = Nothing
|
||||||
Public OriginalEmailDirectory As String
|
Public ErrorDirectory As String = Nothing
|
||||||
Public RejectedEmailDirectory As String
|
Public OriginalEmailDirectory As String = Nothing
|
||||||
Public AttachmentsSubDirectory As String
|
Public RejectedEmailDirectory As String = Nothing
|
||||||
Public PropertyMap As Dictionary(Of String, XmlItemProperty)
|
Public AttachmentsSubDirectory As String = Nothing
|
||||||
Public InsertIntoSQLServer As Boolean
|
Public NonZugferdDirectory As String = Nothing
|
||||||
|
|
||||||
Public ExceptionEmailAddress As String
|
' Property Parameter
|
||||||
Public IgnoreRejectionStatus As Boolean
|
Public PropertyMap As New Dictionary(Of String, XmlItemProperty)
|
||||||
Public MaxAttachmentSizeInMegaBytes As Integer
|
|
||||||
|
|
||||||
Public Sub New()
|
' Misc Flag Parameters
|
||||||
WatchDirectories = New List(Of String)
|
Public InsertIntoSQLServer As Boolean = False
|
||||||
SuccessDirectory = Nothing
|
Public ExceptionEmailAddress As String = Nothing
|
||||||
ErrorDirectory = Nothing
|
Public IgnoreRejectionStatus As Boolean = False
|
||||||
OriginalEmailDirectory = Nothing
|
Public MaxAttachmentSizeInMegaBytes As Integer = -1
|
||||||
RejectedEmailDirectory = Nothing
|
|
||||||
AttachmentsSubDirectory = Nothing
|
|
||||||
PropertyMap = New Dictionary(Of String, XmlItemProperty)
|
|
||||||
InsertIntoSQLServer = False
|
|
||||||
|
|
||||||
ExceptionEmailAddress = Nothing
|
|
||||||
IgnoreRejectionStatus = False
|
|
||||||
MaxAttachmentSizeInMegaBytes = -1
|
|
||||||
End Sub
|
|
||||||
End Class
|
End Class
|
||||||
@ -47,6 +47,16 @@ Public Class Exceptions
|
|||||||
MyBase.New("No ZUGFeRD documents found")
|
MyBase.New("No ZUGFeRD documents found")
|
||||||
End Sub
|
End Sub
|
||||||
End Class
|
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
|
Public Class MD5HashException
|
||||||
Inherits ApplicationException
|
Inherits ApplicationException
|
||||||
|
|
||||||
|
|||||||
@ -90,6 +90,11 @@ Public Class ThreadRunner
|
|||||||
_logger.Warn("RejectedEmailDirectory {0} does not exist!", oArgs.RejectedEmailDirectory)
|
_logger.Warn("RejectedEmailDirectory {0} does not exist!", oArgs.RejectedEmailDirectory)
|
||||||
End If
|
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)
|
_logger.Debug("Checking Exception Email Adress {0}", oArgs.ExceptionEmailAddress)
|
||||||
If oArgs.ExceptionEmailAddress = String.Empty Then
|
If oArgs.ExceptionEmailAddress = String.Empty Then
|
||||||
_logger.Warn("ExceptionEmailAddress {0} is not set!", oArgs.ExceptionEmailAddress)
|
_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 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)
|
Dim oResult As DataTable = _firebird.GetDatatable(oSQL)
|
||||||
|
|
||||||
For Each row As DataRow In oResult.Rows
|
For Each oRow As DataRow In oResult.Rows
|
||||||
Dim oFolderType = row.Item("FOLDER_TYPE")
|
Dim oFolderType = oRow.Item("FOLDER_TYPE")
|
||||||
|
|
||||||
Select Case oFolderType
|
Select Case oFolderType
|
||||||
Case ZUGFERD_IN
|
Case ZUGFERD_IN
|
||||||
pArgs.WatchDirectories.Add(row.Item("FOLDER_PATH"))
|
pArgs.WatchDirectories.Add(oRow.Item("FOLDER_PATH"))
|
||||||
|
|
||||||
Case ZUGFERD_SUCCESS
|
Case ZUGFERD_SUCCESS
|
||||||
pArgs.SuccessDirectory = row.Item("FOLDER_PATH")
|
pArgs.SuccessDirectory = oRow.Item("FOLDER_PATH")
|
||||||
|
|
||||||
Case ZUGFERD_ERROR
|
Case ZUGFERD_ERROR
|
||||||
pArgs.ErrorDirectory = row.Item("FOLDER_PATH")
|
pArgs.ErrorDirectory = oRow.Item("FOLDER_PATH")
|
||||||
|
|
||||||
Case ZUGFERD_EML
|
Case ZUGFERD_EML
|
||||||
pArgs.OriginalEmailDirectory = row.Item("FOLDER_PATH")
|
pArgs.OriginalEmailDirectory = oRow.Item("FOLDER_PATH")
|
||||||
|
|
||||||
Case ZUGFERD_REJECTED_EML
|
Case ZUGFERD_REJECTED_EML
|
||||||
pArgs.RejectedEmailDirectory = row.Item("FOLDER_PATH")
|
pArgs.RejectedEmailDirectory = oRow.Item("FOLDER_PATH")
|
||||||
|
|
||||||
Case ZUGFERD_ATTACHMENTS
|
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
|
End Select
|
||||||
Next
|
Next
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user