Wir wollen die Nummer, nicht den Text.
This commit is contained in:
parent
5fb0b2b817
commit
09b52f441b
@ -216,12 +216,10 @@ Public Class ImportZUGFeRDFiles
|
|||||||
Catch ex As ValidationException
|
Catch ex As ValidationException
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|
||||||
Dim oErrorCodeString = $"{EmailStrings.ErrorCodePraefix}{ErrorCode.ValidationException}"
|
Dim oRejectionCodeString = GetRejectionCodeString(oMessageId, ErrorCode.ValidationException)
|
||||||
Dim oErrorMessage = $"Error {oErrorCodeString} occured for '{oMessageId}'"
|
|
||||||
_logger.Error(oErrorMessage)
|
|
||||||
|
|
||||||
'Dim oMessage = "REJECTED - ZUGFeRD yes but formal validation failed!"
|
'Dim oMessage = "REJECTED - ZUGFeRD yes but formal validation failed!"
|
||||||
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oErrorCodeString)
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oRejectionCodeString)
|
||||||
|
|
||||||
Dim oErrors = ex.ValidationErrors
|
Dim oErrors = ex.ValidationErrors
|
||||||
Dim oErrorList As String = ""
|
Dim oErrorList As String = ""
|
||||||
@ -234,97 +232,85 @@ 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, oErrorCodeString, "Die Rechnungsvalidierung ist fehlgeschlagen!", "", oSQLTransaction)
|
AddRejectedState(oMessageId, oRejectionCodeString, "Die Rechnungsvalidierung ist fehlgeschlagen!", "", oSQLTransaction)
|
||||||
|
|
||||||
Catch ex As MD5HashException
|
Catch ex As MD5HashException
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|
||||||
Dim oErrorCodeString = $"{EmailStrings.ErrorCodePraefix}{ErrorCode.MD5HashException}"
|
Dim oRejectionCodeString = GetRejectionCodeString(oMessageId, ErrorCode.MD5HashException)
|
||||||
Dim oErrorMessage = $"Error {oErrorCodeString} occured for '{oMessageId}'"
|
|
||||||
_logger.Error(oErrorMessage)
|
|
||||||
|
|
||||||
' 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.
|
' Thats why we set it to String.Empty here.
|
||||||
'Dim oMessage = "REJECTED - Already processed (MD5Hash)"
|
'Dim oMessage = "REJECTED - Already processed (MD5Hash)"
|
||||||
_history.Update_HistoryEntry(oMessageId, String.Empty, oErrorCodeString)
|
_history.Update_HistoryEntry(oMessageId, String.Empty, oRejectionCodeString)
|
||||||
|
|
||||||
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, oErrorCodeString, "Die gesendete Rechnung wurde bereits verarbeitet!", "", oSQLTransaction)
|
AddRejectedState(oMessageId, oRejectionCodeString, "Die gesendete Rechnung wurde bereits verarbeitet!", "", oSQLTransaction)
|
||||||
|
|
||||||
Catch ex As UnsupportedFerdException
|
Catch ex As UnsupportedFerdException
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|
||||||
Dim oErrorCodeString = $"{EmailStrings.ErrorCodePraefix}{ErrorCode.UnsupportedFerdException}"
|
Dim oRejectionCodeString = GetRejectionCodeString(oMessageId, ErrorCode.UnsupportedFerdException)
|
||||||
Dim oErrorMessage = $"Error {oErrorCodeString} occured for '{oMessageId}'"
|
|
||||||
_logger.Error(oErrorMessage)
|
|
||||||
|
|
||||||
' 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.
|
' Thats why we set it to String.Empty here.
|
||||||
_history.Update_HistoryEntry(oMessageId, String.Empty, oErrorCodeString)
|
_history.Update_HistoryEntry(oMessageId, String.Empty, oRejectionCodeString)
|
||||||
|
|
||||||
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, oErrorCodeString, "Nicht unterstütztes Datenformat", "", oSQLTransaction)
|
AddRejectedState(oMessageId, oRejectionCodeString, "Nicht unterstütztes Datenformat", "", oSQLTransaction)
|
||||||
|
|
||||||
Catch ex As InvalidFerdException
|
Catch ex As InvalidFerdException
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|
||||||
Dim oErrorCodeString = $"{EmailStrings.ErrorCodePraefix}{ErrorCode.InvalidFerdException}"
|
Dim oRejectionCodeString = GetRejectionCodeString(oMessageId, ErrorCode.InvalidFerdException)
|
||||||
Dim oErrorMessage = $"Error {oErrorCodeString} occured for '{oMessageId}'"
|
|
||||||
_logger.Error(oErrorMessage)
|
|
||||||
|
|
||||||
' 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.
|
' Thats why we set it to String.Empty here.
|
||||||
_history.Update_HistoryEntry(oMessageId, String.Empty, oErrorCodeString)
|
_history.Update_HistoryEntry(oMessageId, String.Empty, oRejectionCodeString)
|
||||||
|
|
||||||
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, oErrorCodeString, "Inkorrektes Format", "", oSQLTransaction)
|
AddRejectedState(oMessageId, oRejectionCodeString, "Inkorrektes Format", "", oSQLTransaction)
|
||||||
|
|
||||||
Catch ex As TooMuchFerdsException
|
Catch ex As TooMuchFerdsException
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|
||||||
Dim oErrorCodeString = $"{EmailStrings.ErrorCodePraefix}{ErrorCode.TooMuchFerdsException}"
|
Dim oRejectionCodeString = GetRejectionCodeString(oMessageId, ErrorCode.TooMuchFerdsException)
|
||||||
Dim oErrorMessage = $"Error {oErrorCodeString} occured for '{oMessageId}'"
|
|
||||||
_logger.Error(oErrorMessage)
|
|
||||||
|
|
||||||
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oErrorCodeString)
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oRejectionCodeString)
|
||||||
|
|
||||||
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, oErrorCodeString, "Email enthielt mehr als ein ZUGFeRD-Dokument", "", oSQLTransaction)
|
AddRejectedState(oMessageId, oRejectionCodeString, "Email enthielt mehr als ein ZUGFeRD-Dokument", "", oSQLTransaction)
|
||||||
|
|
||||||
Catch ex As NoFerdsException
|
Catch ex As NoFerdsException
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|
||||||
Dim oErrorCodeString = $"{EmailStrings.ErrorCodePraefix}{ErrorCode.NoFerdsException}"
|
Dim oRejectionCodeString = GetRejectionCodeString(oMessageId, ErrorCode.NoFerdsException)
|
||||||
Dim oErrorMessage = $"Error {oErrorCodeString} occured for '{oMessageId}'"
|
|
||||||
_logger.Error(oErrorMessage)
|
|
||||||
|
|
||||||
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oErrorCodeString)
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oRejectionCodeString)
|
||||||
|
|
||||||
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, oErrorCodeString, "Email enthielt keine ZUGFeRD-Dokumente", "", oSQLTransaction)
|
AddRejectedState(oMessageId, oRejectionCodeString, "Email enthielt keine ZUGFeRD-Dokumente", "", oSQLTransaction)
|
||||||
|
|
||||||
Catch ex As MissingValueException
|
Catch ex As MissingValueException
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|
||||||
Dim oErrorCodeString = $"{EmailStrings.ErrorCodePraefix}{ErrorCode.MissingValueException}"
|
Dim oRejectionCodeString = GetRejectionCodeString(oMessageId, ErrorCode.MissingValueException)
|
||||||
Dim oErrorMessage = $"Error {oErrorCodeString} occured for '{oMessageId}'"
|
|
||||||
_logger.Error(oErrorMessage)
|
|
||||||
|
|
||||||
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oErrorCodeString)
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oRejectionCodeString)
|
||||||
|
|
||||||
Dim oMissingFieldList As String = ""
|
Dim oMissingFieldList As String = ""
|
||||||
For Each oMissingFieldDescription In ex.MissingProperties
|
For Each oMissingFieldDescription In ex.MissingProperties
|
||||||
@ -336,16 +322,14 @@ Public Class ImportZUGFeRDFiles
|
|||||||
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, oOrgFilename, oMissingFieldList)
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "MissingValueException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.MissingValueException, oOrgFilename, oMissingFieldList)
|
||||||
AddRejectedState(oMessageId, oErrorCodeString, "Es fehlten ZugferdSpezifikationen", "", oSQLTransaction)
|
AddRejectedState(oMessageId, oRejectionCodeString, "Es fehlten ZugferdSpezifikationen", "", oSQLTransaction)
|
||||||
|
|
||||||
Catch ex As FileSizeLimitReachedException
|
Catch ex As FileSizeLimitReachedException
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|
||||||
Dim oErrorCodeString = $"{EmailStrings.ErrorCodePraefix}{ErrorCode.FileSizeLimitReachedException}"
|
Dim oRejectionCodeString = GetRejectionCodeString(oMessageId, ErrorCode.FileSizeLimitReachedException)
|
||||||
Dim oErrorMessage = $"Error {oErrorCodeString} occured for '{oMessageId}'"
|
|
||||||
_logger.Error(oErrorMessage)
|
|
||||||
|
|
||||||
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oErrorCodeString)
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oRejectionCodeString)
|
||||||
|
|
||||||
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
||||||
|
|
||||||
@ -356,8 +340,7 @@ Public Class ImportZUGFeRDFiles
|
|||||||
Dim oBody = String.Format(EmailStrings.EMAIL_FILE_SIZE_REACHED, oArgs.MaxAttachmentSizeInMegaBytes, oOrgFilename)
|
Dim oBody = String.Format(EmailStrings.EMAIL_FILE_SIZE_REACHED, oArgs.MaxAttachmentSizeInMegaBytes, oOrgFilename)
|
||||||
|
|
||||||
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "FileSizeLimitReachedException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.FileSizeLimitReachedException, oArgs.MaxAttachmentSizeInMegaBytes, oOrgFilename)
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "FileSizeLimitReachedException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.FileSizeLimitReachedException, oArgs.MaxAttachmentSizeInMegaBytes, oOrgFilename)
|
||||||
AddRejectedState(oMessageId, oErrorCodeString, "Erlaubte Dateigröße überschritten", "", oSQLTransaction)
|
AddRejectedState(oMessageId, oRejectionCodeString, "Erlaubte Dateigröße überschritten", "", oSQLTransaction)
|
||||||
|
|
||||||
|
|
||||||
Catch ex As NoFerdsAlternateException
|
Catch ex As NoFerdsAlternateException
|
||||||
' TODO: Maybe dont even log this 'error', since it's not really an error and it might happen *A LOT*
|
' TODO: Maybe dont even log this 'error', since it's not really an error and it might happen *A LOT*
|
||||||
@ -456,6 +439,18 @@ Public Class ImportZUGFeRDFiles
|
|||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Function GetRejectionCodeString(pMessageId As String, pRejectionCode As ErrorCode) As String
|
||||||
|
|
||||||
|
Dim intCode As Integer = DirectCast(pRejectionCode, Integer)
|
||||||
|
Dim oRejectionCodeString = $"{EmailStrings.ErrorCodePraefix}{intCode}"
|
||||||
|
|
||||||
|
' Wir wollen im error-Log den Code und die MessageID haben, um die es geht
|
||||||
|
Dim oInfoMessage = $"Rejection {oRejectionCodeString} triggered for '{pMessageId}'"
|
||||||
|
_logger.Error(oInfoMessage)
|
||||||
|
|
||||||
|
Return oRejectionCodeString
|
||||||
|
End Function
|
||||||
|
|
||||||
Private Function ProcessFile(pMessageId As String, pEmailData As EmailData, pZugferdFiles As Integer, oFile As FileInfo, oConnections As DatabaseConnections, pArgs As WorkerArgs) As ProcessFileResult
|
Private Function ProcessFile(pMessageId As String, pEmailData As EmailData, pZugferdFiles As Integer, oFile As FileInfo, oConnections As DatabaseConnections, pArgs As WorkerArgs) As ProcessFileResult
|
||||||
Dim oDocument As ZUGFeRDInterface.ZugferdResult
|
Dim oDocument As ZUGFeRDInterface.ZugferdResult
|
||||||
Dim oResult As New ProcessFileResult()
|
Dim oResult As New ProcessFileResult()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user