Rejection_Code nach TBEMLP_HISTORY und TBEMLP_HISTORY_STATE schreiben
This commit is contained in:
parent
948c499b9d
commit
d54001d73b
@ -1,8 +1,5 @@
|
|||||||
Imports System.Data.SqlClient
|
Imports DigitalData.Modules.Database
|
||||||
Imports System.ServiceModel.Channels
|
|
||||||
Imports DigitalData.Modules.Database
|
|
||||||
Imports DigitalData.Modules.Logging
|
Imports DigitalData.Modules.Logging
|
||||||
Imports Microsoft.VisualBasic.FileIO
|
|
||||||
|
|
||||||
Namespace ZUGFeRD
|
Namespace ZUGFeRD
|
||||||
Public Class HistoryFunctions
|
Public Class HistoryFunctions
|
||||||
@ -30,7 +27,8 @@ Namespace ZUGFeRD
|
|||||||
MD5HASH = '{pMD5Checksum}'
|
MD5HASH = '{pMD5Checksum}'
|
||||||
WHERE EMAIL_MSGID = '{pMessageId}'"
|
WHERE EMAIL_MSGID = '{pMessageId}'"
|
||||||
|
|
||||||
If pMessage.Contains("REJECTED") Then
|
'If pMessage.Contains("REJECTED") Then
|
||||||
|
If pMessage.Contains(EmailStrings.ErrorCodePraefix) Then
|
||||||
oSQL = $"UPDATE TBEMLP_HISTORY SET
|
oSQL = $"UPDATE TBEMLP_HISTORY SET
|
||||||
COMMENT = '{pMessage}',
|
COMMENT = '{pMessage}',
|
||||||
MD5HASH = '{pMD5Checksum}',
|
MD5HASH = '{pMD5Checksum}',
|
||||||
|
|||||||
@ -1,17 +1,14 @@
|
|||||||
Imports System.Collections.Generic
|
Imports System.Collections.Generic
|
||||||
Imports System.Data
|
Imports System.Data
|
||||||
|
Imports System.Data.SqlClient
|
||||||
Imports System.IO
|
Imports System.IO
|
||||||
Imports System.Linq
|
Imports System.Linq
|
||||||
Imports System.Security.Cryptography
|
|
||||||
Imports DigitalData.Modules.Base
|
Imports DigitalData.Modules.Base
|
||||||
Imports DigitalData.Modules.Database
|
Imports DigitalData.Modules.Database
|
||||||
Imports DigitalData.Modules.Interfaces
|
Imports DigitalData.Modules.Interfaces
|
||||||
Imports DigitalData.Modules.Interfaces.Exceptions
|
Imports DigitalData.Modules.Interfaces.Exceptions
|
||||||
Imports DigitalData.Modules.Jobs.Exceptions
|
Imports DigitalData.Modules.Jobs.Exceptions
|
||||||
Imports DigitalData.Modules.Logging
|
Imports DigitalData.Modules.Logging
|
||||||
Imports System.Data.SqlClient
|
|
||||||
Imports Newtonsoft.Json.Linq
|
|
||||||
Imports System.Xml.Linq
|
|
||||||
|
|
||||||
Public Class ImportZUGFeRDFiles
|
Public Class ImportZUGFeRDFiles
|
||||||
Implements IJob
|
Implements IJob
|
||||||
@ -220,7 +217,8 @@ Public Class ImportZUGFeRDFiles
|
|||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|
||||||
Dim oErrors = ex.ValidationErrors
|
Dim oErrors = ex.ValidationErrors
|
||||||
Dim oMessage = "REJECTED - ZUGFeRD yes but formal validation failed!"
|
'Dim oMessage = "REJECTED - ZUGFeRD yes but formal validation failed!"
|
||||||
|
Dim oMessage = $"{EmailStrings.ErrorCodePraefix}{ErrorCode.ValidationException}"
|
||||||
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oMessage)
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oMessage)
|
||||||
|
|
||||||
Dim oErrorList As String = ""
|
Dim oErrorList As String = ""
|
||||||
@ -233,78 +231,84 @@ Public Class ImportZUGFeRDFiles
|
|||||||
Dim oBody = String.Format(EmailStrings.EMAIL_VALIDATION_ERROR, oErrorList)
|
Dim oBody = String.Format(EmailStrings.EMAIL_VALIDATION_ERROR, oErrorList)
|
||||||
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
||||||
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "ValidationException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.ValidationException, oErrorListDE, oErrorList)
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "ValidationException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.ValidationException, oErrorListDE, oErrorList)
|
||||||
AddRejectedState(oMessageId, "ValidationException", "Die Rechnungsvalidierung ist fehlgeschlagen!", "", oSQLTransaction)
|
AddRejectedState(oMessageId, oMessage, "Die Rechnungsvalidierung ist fehlgeschlagen!", "", oSQLTransaction)
|
||||||
|
|
||||||
Catch ex As MD5HashException
|
Catch ex As MD5HashException
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|
||||||
' When MD5HashException is thrown, we don't have a MD5Hash yet.
|
' When MD5HashException is thrown, we don't have a MD5Hash yet.
|
||||||
' That 's why we set it to String.Empty here.
|
' That 's why we set it to String.Empty here.
|
||||||
Dim oMessage = "REJECTED - Already processed (MD5Hash)"
|
'Dim oMessage = "REJECTED - Already processed (MD5Hash)"
|
||||||
|
Dim oMessage = $"{EmailStrings.ErrorCodePraefix}{ErrorCode.MD5HashException}"
|
||||||
_history.Update_HistoryEntry(oMessageId, String.Empty, oMessage)
|
_history.Update_HistoryEntry(oMessageId, String.Empty, oMessage)
|
||||||
|
|
||||||
Dim oBody = String.Format(EmailStrings.EMAIL_MD5_ERROR, ex.FileName)
|
Dim oBody = String.Format(EmailStrings.EMAIL_MD5_ERROR, ex.FileName)
|
||||||
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
||||||
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "MD5HashException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.MD5HashException, ex.FileName, "")
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "MD5HashException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.MD5HashException, ex.FileName, "")
|
||||||
AddRejectedState(oMessageId, "MD5HashException", "Die gesendete Rechnung wurde bereits verarbeitet!", "", oSQLTransaction)
|
AddRejectedState(oMessageId, oMessage, "Die gesendete Rechnung wurde bereits verarbeitet!", "", oSQLTransaction)
|
||||||
|
|
||||||
Catch ex As UnsupportedFerdException
|
Catch ex As UnsupportedFerdException
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|
||||||
' When UnsupportedFerdException is thrown, we don't have a MD5Hash yet.
|
' When UnsupportedFerdException is thrown, we don't have a MD5Hash yet.
|
||||||
' That 's why we set it to String.Empty here.
|
' That 's why we set it to String.Empty here.
|
||||||
_history.Update_HistoryEntry(oMessageId, String.Empty, "REJECTED - ZUGFeRD yes but unsupported format")
|
Dim oMessage = $"{EmailStrings.ErrorCodePraefix}{ErrorCode.UnsupportedFerdException}"
|
||||||
|
_history.Update_HistoryEntry(oMessageId, String.Empty, oMessage)
|
||||||
|
|
||||||
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
||||||
Dim oBody As String = String.Format(EmailStrings.EMAIL_UNSUPPORTED_DOCUMENT, oEmailData.Subject, ex.XmlFile)
|
Dim oBody As String = String.Format(EmailStrings.EMAIL_UNSUPPORTED_DOCUMENT, oEmailData.Subject, ex.XmlFile)
|
||||||
|
|
||||||
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "UnsupportedFerdException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.UnsupportedFerdException, ex.XmlFile, "")
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "UnsupportedFerdException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.UnsupportedFerdException, ex.XmlFile, "")
|
||||||
AddRejectedState(oMessageId, "UnsupportedFerdException", "Nicht unterstütztes Datenformat", "", oSQLTransaction)
|
AddRejectedState(oMessageId, oMessage, "Nicht unterstütztes Datenformat", "", oSQLTransaction)
|
||||||
|
|
||||||
Catch ex As InvalidFerdException
|
Catch ex As InvalidFerdException
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|
||||||
' When InvalidFerdException is thrown, we don't have a MD5Hash yet.
|
' When InvalidFerdException is thrown, we don't have a MD5Hash yet.
|
||||||
' That 's why we set it to String.Empty here.
|
' That 's why we set it to String.Empty here.
|
||||||
_history.Update_HistoryEntry(oMessageId, String.Empty, "REJECTED - ZUGFeRD yes but incorrect format")
|
Dim oMessage = $"{EmailStrings.ErrorCodePraefix}{ErrorCode.InvalidFerdException}"
|
||||||
|
_history.Update_HistoryEntry(oMessageId, String.Empty, oMessage)
|
||||||
|
|
||||||
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
||||||
Dim oBody = String.Format(EmailStrings.EMAIL_INVALID_DOCUMENT, oEmailData.Subject)
|
Dim oBody = String.Format(EmailStrings.EMAIL_INVALID_DOCUMENT, oEmailData.Subject)
|
||||||
|
|
||||||
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "InvalidFerdException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.InvalidFerdException, "", "")
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "InvalidFerdException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.InvalidFerdException, "", "")
|
||||||
AddRejectedState(oMessageId, "InvalidFerdException", "Inkorrekte Formate", "", oSQLTransaction)
|
AddRejectedState(oMessageId, oMessage, "Inkorrektes Format", "", oSQLTransaction)
|
||||||
|
|
||||||
Catch ex As TooMuchFerdsException
|
Catch ex As TooMuchFerdsException
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|
||||||
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, "REJECTED - More than one ZUGFeRD-document in email")
|
Dim oMessage = $"{EmailStrings.ErrorCodePraefix}{ErrorCode.TooMuchFerdsException}"
|
||||||
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oMessage)
|
||||||
|
|
||||||
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
||||||
Dim oBody = String.Format(EmailStrings.EMAIL_TOO_MUCH_FERDS, oEmailData.Subject)
|
Dim oBody = String.Format(EmailStrings.EMAIL_TOO_MUCH_FERDS, oEmailData.Subject)
|
||||||
|
|
||||||
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "TooMuchFerdsException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.TooMuchFerdsException, "", "")
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "TooMuchFerdsException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.TooMuchFerdsException, "", "")
|
||||||
AddRejectedState(oMessageId, "TooMuchFerdsException", "Email enthielt mehr als ein ZUGFeRD-Dokument", "", oSQLTransaction)
|
AddRejectedState(oMessageId, oMessage, "Email enthielt mehr als ein ZUGFeRD-Dokument", "", oSQLTransaction)
|
||||||
|
|
||||||
Catch ex As NoFerdsException
|
Catch ex As NoFerdsException
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|
||||||
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, "REJECTED - no ZUGFeRD-Document in email")
|
Dim oMessage = $"{EmailStrings.ErrorCodePraefix}{ErrorCode.NoFerdsException}"
|
||||||
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oMessage)
|
||||||
|
|
||||||
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
||||||
Dim oBody = String.Format(EmailStrings.EMAIL_NO_FERDS, oEmailData.Subject)
|
Dim oBody = String.Format(EmailStrings.EMAIL_NO_FERDS, oEmailData.Subject)
|
||||||
|
|
||||||
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "NoFerdsException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.NoFerdsException, "", "")
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "NoFerdsException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.NoFerdsException, "", "")
|
||||||
AddRejectedState(oMessageId, "NoFerdsException", " Email enthielt keine ZUGFeRD-Dokumente", "", oSQLTransaction)
|
AddRejectedState(oMessageId, oMessage, "Email enthielt keine ZUGFeRD-Dokumente", "", oSQLTransaction)
|
||||||
|
|
||||||
Catch ex As MissingValueException
|
Catch ex As MissingValueException
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|
||||||
Dim oMessage As String = ""
|
'Dim oMessage As String = ""
|
||||||
For Each prop In ex.MissingProperties
|
'For Each prop In ex.MissingProperties
|
||||||
oMessage &= $"- {prop}"
|
' oMessage &= $"- {prop}"
|
||||||
Next
|
'Next
|
||||||
|
|
||||||
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, $"REJECTED - Missing Required Properties: [{oMessage}]")
|
Dim oMessage = $"{EmailStrings.ErrorCodePraefix}{ErrorCode.MissingValueException}"
|
||||||
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oMessage)
|
||||||
|
|
||||||
Dim oMissingFieldList As String = ""
|
Dim oMissingFieldList As String = ""
|
||||||
For Each oMissingFieldDescription In ex.MissingProperties
|
For Each oMissingFieldDescription In ex.MissingProperties
|
||||||
@ -314,12 +318,13 @@ Public Class ImportZUGFeRDFiles
|
|||||||
Dim oBody = _email.CreateBodyForMissingProperties(ex.File.Name, ex.MissingProperties)
|
Dim oBody = _email.CreateBodyForMissingProperties(ex.File.Name, ex.MissingProperties)
|
||||||
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
||||||
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "MissingValueException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.MissingValueException, ex.File.Name, oMissingFieldList)
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "MissingValueException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.MissingValueException, ex.File.Name, oMissingFieldList)
|
||||||
AddRejectedState(oMessageId, "MissingValueException", "Es fehlten ZugferdSpezifikationen", oMessage, oSQLTransaction)
|
AddRejectedState(oMessageId, oMessage, "Es fehlten ZugferdSpezifikationen", "", oSQLTransaction)
|
||||||
|
|
||||||
Catch ex As FileSizeLimitReachedException
|
Catch ex As FileSizeLimitReachedException
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|
||||||
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, "REJECTED - File size limit reached")
|
Dim oMessage = $"{EmailStrings.ErrorCodePraefix}{ErrorCode.FileSizeLimitReachedException}"
|
||||||
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oMessage)
|
||||||
|
|
||||||
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
||||||
|
|
||||||
@ -332,7 +337,7 @@ Public Class ImportZUGFeRDFiles
|
|||||||
Dim oBody = String.Format(EmailStrings.EMAIL_FILE_SIZE_REACHED, oArgs.MaxAttachmentSizeInMegaBytes, oFileWithoutMessageId)
|
Dim oBody = String.Format(EmailStrings.EMAIL_FILE_SIZE_REACHED, oArgs.MaxAttachmentSizeInMegaBytes, oFileWithoutMessageId)
|
||||||
|
|
||||||
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "FileSizeLimitReachedException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.FileSizeLimitReachedException, oArgs.MaxAttachmentSizeInMegaBytes, oFileWithoutMessageId)
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "FileSizeLimitReachedException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.FileSizeLimitReachedException, oArgs.MaxAttachmentSizeInMegaBytes, oFileWithoutMessageId)
|
||||||
AddRejectedState(oMessageId, "FileSizeLimitReachedException", "Erlaubte Dateigröße überschritten", "", oSQLTransaction)
|
AddRejectedState(oMessageId, oMessage, "Erlaubte Dateigröße überschritten", "", oSQLTransaction)
|
||||||
|
|
||||||
|
|
||||||
Catch ex As NoFerdsAlternateException
|
Catch ex As NoFerdsAlternateException
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user