Compare commits

...

3 Commits

Author SHA1 Message Date
3be1605d93 Email profiler Service: Version 3.0.3.0 2024-11-13 13:25:34 +01:00
1cb9a7ac95 EmailProfiler.Common: Version 3.0.6.0 2024-11-13 13:25:01 +01:00
167b7e1210 temp. GDPicture Lizenz-Abfrage
ExtractAttachment-Logik
2024-11-13 10:58:48 +01:00
5 changed files with 80 additions and 31 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.5.0")>
<Assembly: AssemblyTrademark("3.0.6.0")>
<Assembly: ComVisible(False)>
@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("3.0.5.0")>
<Assembly: AssemblyFileVersion("3.0.5.0")>
<Assembly: AssemblyVersion("3.0.6.0")>
<Assembly: AssemblyFileVersion("3.0.6.0")>

View File

@ -15,6 +15,7 @@ Imports System.Data.SqlClient
Imports GdPicture14
Imports Limilabs.Client.IMAP
Imports System.Net.NetworkInformation
Imports System.Collections.Specialized.BitVector32
Public Class clsWorkEmail
Private Const SUBJECT_MAX_LENGTH = 25
@ -222,9 +223,7 @@ Public Class clsWorkEmail
End If
Else
If IS_LOCAL_TEST = False Then
InsertHistoryEntry(CurrentMail)
End If
' Jetzt werden die ggf gefundenen Attachment-Fehler überprüft und verarbeitet
Dim oNormalAttachmentsNotValid As Boolean = False
@ -234,13 +233,26 @@ Public Class clsWorkEmail
Where(Function(att) att.EmbeddedFiles.Count > 0).
Any(Function(emb) emb.EmbeddedFiles.Any(Function(ext) ext.IsAttachmentValid = False))
oNormalAttachmentsNotValid = EmailAttachments.Any(Function(ext) ext.IsAttachmentValid = False)
If oEmbeddedAttachmentsNotValid = True Then
Dim oRejectionCodeString = GetRejectionCodeString(CurrentMail.MessageId, ErrorCode.EmbeddedFileAttachmentCorrupt)
InsertHistoryEntryWithStatus(CurrentMail, "REJECTED", oRejectionCodeString)
AddTrackingStatusMSSQL(CurrentMail.MessageId, oRejectionCodeString, "Embedded File corrupt", "", "EMailProfiler")
SendRejectionMailToSenderIfEmbeddedAttachmentsAreNotValid()
ElseIf oNormalAttachmentsNotValid = True Then
DeleteAllCollectedAttachments()
CURRENT_ImapObject.DeleteMessageByUID(poUID)
Else
If IS_LOCAL_TEST = False Then
InsertHistoryEntry(CurrentMail)
End If
oNormalAttachmentsNotValid = EmailAttachments.Any(Function(ext) ext.IsAttachmentValid = False)
If oNormalAttachmentsNotValid = True Then
SendInfoMailToSenderIfNormalAttachmentsAreNotValid()
End If
End If
Return True
End If
@ -274,17 +286,14 @@ Public Class clsWorkEmail
''' <summary>
''' Wenn beim Herauslösen der Attachments festgestellt wurde,
''' das ein Teil der _normalen_ Attachments fehlerhaft war, wird der Absender hier
''' darüber informiert.
''' das ein PDF-Attachments korrupte Anhänge enthält war, bekommt der Absender hier
''' die Ablehnung.
''' </summary>
Private Sub SendRejectionMailToSenderIfEmbeddedAttachmentsAreNotValid()
Dim oHtmlFilenameList As String = GetHtmlFilenameList()
If oHtmlFilenameList.IsNotNullOrEmpty() Then
AddToEmailQueueMSSQL(CurrentMail.MessageId, "", "Attachment invalid", _EmailAccountID, _RejectionTemplateId, ErrorCode.EmbeddedFileAttachmentCorrupt, oHtmlFilenameList, "")
End If
End Sub
@ -964,7 +973,7 @@ Public Class clsWorkEmail
End If
' Sichere Datei auf Platte
If SaveFileToDisk(oAttachment, oEmailAttachment.DestFilePath) = True Then
If SaveFileToDisk(oAttachment, oEmailAttachment) = True Then
_Logger.Info(String.Format("Attachment saved to [{0}]", oEmailAttachment.DestFilePath))
' Schreibe Satz nach EMLP_HISTORY
@ -973,7 +982,6 @@ Public Class clsWorkEmail
End If
Else
_Logger.Warn($"Error while saving AttachmentName: {oEmailAttachment.DestFilePath}")
MESSAGE_ERROR = True
Continue For
End If
@ -1000,15 +1008,17 @@ Public Class clsWorkEmail
End If
If (oEmailAttachment.ErrorCodeValue = ErrorCode.Unknown) Then
' Wenn der Status ok ist, wird das Attachment eingetragen, sonst nicht
TEMP_WORK_FILES.Add(oEmailAttachment.DestFilePath)
End If
Next
CURRENT_ATTMT_COUNT = oAttachmentCount
If MESSAGE_ERROR = True Then
WorkTempFiles("delete")
Return False
Return True
End If
WorkTempFiles("move")
@ -1050,6 +1060,11 @@ Public Class clsWorkEmail
oEmbeddedFile.ErrorCodeValue = ErrorCode.EmbeddedFileAttachmentCorrupt
oEmbeddedFile.ErrorCodeComment = "PDF Structure corrupt"
oEmbeddedFile.IsAttachmentValid = False
' wenn ein eingebettetes attachment defekt ist, ist das Hauptattachment auch defekt
pEmailAttachment.ErrorCodeValue = ErrorCode.NormalFileAttachmentCorrupt
pEmailAttachment.ErrorCodeComment = "PDF Structure corrupt"
pEmailAttachment.IsAttachmentValid = False
Continue For
End If
End If
@ -1058,17 +1073,20 @@ Public Class clsWorkEmail
End Sub
Private Function SaveFileToDisk(pAttachment As MimeData, pAttachmentFilePath As String) As Boolean
Private Function SaveFileToDisk(pAttachment As MimeData, pAttachmentData As EmailAttachment) As Boolean
Try
_Logger.Debug(String.Format("Trying to save attachment [{0}]", pAttachmentFilePath))
pAttachment.Save(pAttachmentFilePath)
Dim oFilePath = pAttachmentData.DestFilePath
_Logger.Debug(String.Format("Trying to save attachment [{0}]", oFilePath))
pAttachment.Save(oFilePath)
Dim oFileInfo As New FileInfo(pAttachmentFilePath)
Dim oFileInfo As New FileInfo(oFilePath)
Dim oFileLength As Long = oFileInfo.Length
If oFileLength <= 2 Then
_Logger.Warn($"##!! oFileLength for AttachmentObjects is <= 2 !!##")
CleanUpFilePath(pAttachmentFilePath)
CleanUpFilePath(oFilePath)
pAttachmentData.ErrorCodeValue = ErrorCode.NormalFileAttachmentCorrupt
pAttachmentData.ErrorCodeComment = "Filesize is zero"
Return False
End If
@ -1076,10 +1094,14 @@ Public Class clsWorkEmail
Catch ex As Exception
_Logger.Error(ex)
MESSAGE_ERROR = True
Return False
End Try
End Function
''' <summary>
''' Falls Datei bereits existiert, lösche sie jetzt
''' </summary>
Private Function CleanUpFilePath(pFilePath As String) As Boolean
Try
If File.Exists(pFilePath) Then
@ -1335,6 +1357,28 @@ Public Class clsWorkEmail
TEMP_WORK_FILES.Clear()
End Sub
''' <summary>
''' Wenn eingebettete Attachments defekt sind,
''' gilt die ganze E-Mail als defekt und wird abgelehnt.
''' Hier wird noch aufgeräumt.
''' </summary>
Private Sub DeleteAllCollectedAttachments()
For Each attachment In EmailAttachments
_Logger.Debug("Delete from temp work file: [{0}]", attachment.DestFilePath)
Try
If File.Exists(attachment.DestFilePath) Then
File.Delete(attachment.DestFilePath)
End If
Catch ex As Exception
_Logger.Error(ex)
_Logger.Warn("Could not delete the tempworkfile : [{0}]", attachment.DestFilePath)
End Try
Next
EmailAttachments.Clear()
End Sub
Private Function InsertHistoryEntry(pCurrentMail As MailContainer) As Boolean
If MESSAGE_ERROR = False Then
Return InsertHistoryEntryWithStatus(pCurrentMail, String.Empty, String.Empty)

View File

@ -6,6 +6,7 @@ Imports DigitalData.Modules.Messaging.Mail
Imports Limilabs.Mail
Imports Limilabs.Mail.Headers
Imports System.Reflection.Emit
Imports GdPicture14
Public Class clsWorker
Private ReadOnly Logger As Logger
@ -84,7 +85,7 @@ Public Class clsWorker
Return Database.GetDatatable(oSQL)
End Function
Public Sub Start_WorkingProfiles(Optional LocalEmail As Boolean = False)
Public Sub Start_WorkingProfiles(Optional LocalEmail As Boolean = False, Optional CallFromService As Boolean = False)
Try
DeleteTempFiles()
IS_LOCAL_TEST = LocalEmail
@ -107,6 +108,10 @@ Public Class clsWorker
Dim PollingProfileTable = LoadPollingProfiles(ProfileId)
Dim oSQLGDPicture = "SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE ACTIVE = 1"
If CallFromService = True Then
oSQLGDPicture = "SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE EMAIL_PROFILER'"
End If
GDPictureLicense = Database.GetScalarValue(oSQLGDPicture)
If IsNothing(PollingProfileTable) Then

View File

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

View File

@ -106,7 +106,7 @@ Public Class MyService
Config.EmailTitlePrefix,
Config.RejectionTemplateId,
Config.InfoTemplateId)
oWorker.Start_WorkingProfiles()
oWorker.Start_WorkingProfiles(False, True)
Catch ex As Exception
Logger.Error(ex)
End Try