Ablehnungscode nach EMLP_HISTORY usw. schreiben

This commit is contained in:
PitzM 2024-06-21 13:10:08 +02:00
parent be743445e5
commit 72e66df02b

View File

@ -167,8 +167,11 @@ Public Class clsWorkEmail
Dim oResult As String = ObjectEx.NotNull(_DB_MSSQL.GetScalarValue(pValidationSQLWithPlaceholders), "")
If oResult <> "" Then
Dim oRejectionCodeString = GetRejectionCodeString(CurrentMail.MessageId, ErrorCode.SenderValidationFailed)
'insert history und exit
InsertHistoryEntryWithStatus(CurrentMail, "REJECTED", oResult)
InsertHistoryEntryWithStatus(CurrentMail, "REJECTED", oRejectionCodeString)
AddTrackingStatusMSSQL(CurrentMail.MessageId, oRejectionCodeString, "Email-Adress validation failed", "", "EMailProfiler")
'AddEmailToQueueMSSQL(CurrentMail.MessageId, oResult, "Email validation failed", _EmailAccountID)
AddToEmailQueueMSSQL(CurrentMail.MessageId, oResult, "Email validation failed", _EmailAccountID,
@ -195,7 +198,10 @@ Public Class clsWorkEmail
If CURRENT_ATTMT_COUNT = 0 Then
_Logger.Info("### Mail contained no Attachments!! ###")
InsertHistoryEntryWithStatus(CurrentMail, "REJECTED", "No Attachments")
Dim oRejectionCodeString = GetRejectionCodeString(CurrentMail.MessageId, ErrorCode.NoAttachments)
InsertHistoryEntryWithStatus(CurrentMail, "REJECTED", oRejectionCodeString)
AddTrackingStatusMSSQL(CurrentMail.MessageId, oRejectionCodeString, "No Attachments", "", "EMailProfiler")
Dim oBody = EmailStrings.EMAIL_NO_FERDS
'If AddEmailToQueueMSSQL(CurrentMail.MessageId, oBody, "No Attachments", _EmailAccountID) = True Then
@ -219,32 +225,7 @@ Public Class clsWorkEmail
Return False
End Try
End Function
''' <summary>
''' Method to decide wether we use the old or the new
''' Rejection E-mail method.
'''
''' TODO we have no information about the language of the receiver at the moment
''' </summary>
''' <param name="pMessageId">E-Mail Message ID</param>
''' <param name="pSTATE_TITLE">Comment</param>
''' <param name="pSTATE_TITLE1">Name oder Reason</param>
Public Function AddTrackingStatusMSSQL(pMessageId As String, pSTATE_TITLE As String, pSTATE_TITLE1 As String, pCOMMENT As String, pADDEDWHO As String) As Boolean
Dim oInsert = $"INSERT INTO [dbo].[TBEMLP_HISTORY_STATE]
([MESSAGE_ID]
,[STATE_TITLE]
,[STATE_TITLE1]
,[COMMENT]
,ADDED_WHO)
VALUES
('{pMessageId}'
,'{pSTATE_TITLE}'
,'{pSTATE_TITLE1}'
,'{pCOMMENT}'
,'{pADDEDWHO}')"
Return _DB_MSSQL.ExecuteNonQuery(oInsert)
End Function
''' <summary>
''' Method to decide wether we use the old or the new
''' Rejection E-mail method.
@ -1123,6 +1104,31 @@ Public Class clsWorkEmail
End Try
End Function
Public Function AddTrackingStatusMSSQL(pMessageId As String, pSTATE_TITLE As String, pSTATE_TITLE1 As String, pCOMMENT As String, pADDEDWHO As String) As Boolean
Try
Dim oInsert =
$"INSERT INTO [dbo].[TBEMLP_HISTORY_STATE]
([MESSAGE_ID]
,[STATE_TITLE]
,[STATE_TITLE1]
,[COMMENT]
,ADDED_WHO)
VALUES
('{pMessageId}'
,'{pSTATE_TITLE}'
,'{pSTATE_TITLE1}'
,'{pCOMMENT}'
,'{pADDEDWHO}')"
Return _DB_MSSQL.ExecuteNonQuery(oInsert)
Catch ex As Exception
_Logger.Error(ex)
Return False
End Try
End Function
Private Function WORK_POLL_STEPS() As Boolean
Try
Dim oFoundSomething As Boolean = False
@ -1320,4 +1326,16 @@ Public Class clsWorkEmail
Return Nothing
End Try
End Function
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
End Class