This commit is contained in:
Developer01 2024-10-24 15:09:44 +02:00
commit c6776b408b
2 changed files with 51 additions and 34 deletions

View File

@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("DigitalData.EMLProfiler")>
<Assembly: AssemblyCopyright("Copyright © 2024")>
<Assembly: AssemblyTrademark("3.0.2.0")>
<Assembly: AssemblyTrademark("3.0.4.0")>
<Assembly: ComVisible(False)>
@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("3.1.0.0")>
<Assembly: AssemblyFileVersion("3.1.0.0")>
<Assembly: AssemblyVersion("3.0.4.0")>
<Assembly: AssemblyFileVersion("3.0.4.0")>

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.
@ -837,19 +818,18 @@ Public Class clsWorkEmail
oATTFilename = oAttachment.SafeFileName.ToString.ToLower
Dim oValidExtensions = New List(Of String) From {"pdf", "xls", "xlsx", "doc", "docx", "ppt", "pptx"}
Dim oGraphicExtensions = New List(Of String) From {"jpg", "bmp", "jpg", "gif", "xml", "png", "jpeg"}
Dim oGraphicExtensions = New List(Of String) From {"jpg", "bmp", "jpeg", "gif", "png", "xml"}
Dim oValidExt = oValidExtensions.Any(Function(ext) oATTFilename.EndsWith(ext))
If oValidExt = False Then
_Logger.Info("Potentially invalid fileExtension [{0}] ...", oATTFilename)
_Logger.Info("Invalid FileExtension [{0}]", oATTFilename)
Dim GraphicExt = oGraphicExtensions.Any(Function(ext) oATTFilename.EndsWith(ext))
If GraphicExt = False Then
Dim oInfo = $"Consistency or extension of attached file {oATTFilename} is not ok."
AddTrackingStatusMSSQL(CurrentMail.MessageId, oInfo, "PDF CONSISTENCY NOT OK", "Info GUI", "EML_PROF_EXTR_ATT1")
AddToEmailQueueMSSQL(CurrentMail.MessageId, oInfo, "PDF CONSISTENCY NOT OK", _EmailAccountID,
_InfoTemplateId, ErrorCode.PDFStructureCorrupt, oATTFilename, "")
Else
_Logger.Info("..but graphic extension!")
End If
Continue For
@ -1124,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
@ -1321,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