MS attachmentsHandling
This commit is contained in:
parent
e0bb1d84e2
commit
92b5a72537
@ -45,10 +45,11 @@ Public Class clsWorkEmail
|
|||||||
|
|
||||||
Private ReadOnly _EmailAccountID As Integer = 1
|
Private ReadOnly _EmailAccountID As Integer = 1
|
||||||
Private ReadOnly _RejectionTemplateId As Integer = 0
|
Private ReadOnly _RejectionTemplateId As Integer = 0
|
||||||
|
Private ReadOnly _InfoTemplateId As Integer = 0
|
||||||
|
|
||||||
Private _worked_email As Boolean = False
|
Private _worked_email As Boolean = False
|
||||||
|
|
||||||
Sub New(LogConf As LogConfig, ConStr As String, WmConStr As String, pUseWindream As Boolean, EmailAccountID As Integer, EmlProfPraefix As String, pRejectionTemplateId As Integer)
|
Sub New(LogConf As LogConfig, ConStr As String, WmConStr As String, pUseWindream As Boolean, EmailAccountID As Integer, EmlProfPraefix As String, pRejectionTemplateId As Integer, pInfoTemplateId As Integer)
|
||||||
Try
|
Try
|
||||||
_Logger = LogConf.GetLogger
|
_Logger = LogConf.GetLogger
|
||||||
_LogConfig = LogConf
|
_LogConfig = LogConf
|
||||||
@ -57,8 +58,10 @@ Public Class clsWorkEmail
|
|||||||
_UseWindream = pUseWindream
|
_UseWindream = pUseWindream
|
||||||
_Patterns = New Patterns2(LogConf)
|
_Patterns = New Patterns2(LogConf)
|
||||||
_RejectionTemplateId = pRejectionTemplateId
|
_RejectionTemplateId = pRejectionTemplateId
|
||||||
|
_InfoTemplateId = pInfoTemplateId
|
||||||
_Logger.Debug($"_RejectionTemplateId: {_RejectionTemplateId}")
|
_Logger.Debug($"_RejectionTemplateId: {_RejectionTemplateId}")
|
||||||
|
|
||||||
|
|
||||||
If pUseWindream Then
|
If pUseWindream Then
|
||||||
_windream = New clsWindream_allgemein(LogConf)
|
_windream = New clsWindream_allgemein(LogConf)
|
||||||
_windream_index = New clsWindream_Index(LogConf)
|
_windream_index = New clsWindream_Index(LogConf)
|
||||||
@ -217,7 +220,32 @@ Public Class clsWorkEmail
|
|||||||
Return False
|
Return False
|
||||||
End Try
|
End Try
|
||||||
End Function
|
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>
|
''' <summary>
|
||||||
''' Method to decide wether we use the old or the new
|
''' Method to decide wether we use the old or the new
|
||||||
''' Rejection E-mail method.
|
''' Rejection E-mail method.
|
||||||
@ -810,11 +838,21 @@ Public Class clsWorkEmail
|
|||||||
oATTFilename = oAttachment.SafeFileName.ToString.ToLower
|
oATTFilename = oAttachment.SafeFileName.ToString.ToLower
|
||||||
|
|
||||||
Dim oValidExtensions = New List(Of String) From {"pdf", "xls", "xlsx", "doc", "docx", "ppt", "pptx"}
|
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"}
|
||||||
Dim oValidExt = oValidExtensions.Any(Function(ext) oATTFilename.EndsWith(ext))
|
Dim oValidExt = oValidExtensions.Any(Function(ext) oATTFilename.EndsWith(ext))
|
||||||
|
|
||||||
If oValidExt = False Then
|
If oValidExt = False Then
|
||||||
_Logger.Info("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, "")
|
||||||
|
|
||||||
|
End If
|
||||||
Continue For
|
Continue For
|
||||||
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim oAttachmentFilePath = ""
|
Dim oAttachmentFilePath = ""
|
||||||
@ -850,16 +888,12 @@ Public Class clsWorkEmail
|
|||||||
Dim oStatus As GdPictureStatus = oGdPicturePDF.LoadFromFile(oAttachmentFilePath, True)
|
Dim oStatus As GdPictureStatus = oGdPicturePDF.LoadFromFile(oAttachmentFilePath, True)
|
||||||
If oStatus <> GdPictureStatus.OK Then
|
If oStatus <> GdPictureStatus.OK Then
|
||||||
oPDFConsistent = False
|
oPDFConsistent = False
|
||||||
'ABLEHNUNG da PDF ungültig
|
Dim oResult = $"PDF-Consistency of attached file {oATTFilename} is not ok. ({oStatus.ToString})"
|
||||||
MESSAGE_ERROR = True
|
AddTrackingStatusMSSQL(CurrentMail.MessageId, oResult, "PDF CONSISTENCY NOT OK", "Info GUI", "EML_PROF_EXTR_ATT2")
|
||||||
System.IO.File.Delete(oAttachmentFilePath)
|
|
||||||
Dim oResult = $"PDF CONSISTENCY of File {oATTFilename} IS NOT OK "
|
|
||||||
'insert history und exit
|
|
||||||
InsertHistoryEntryWithStatus(CurrentMail, "REJECTED", oResult)
|
|
||||||
AddToEmailQueueMSSQL(CurrentMail.MessageId, oResult, "PDF CONSISTENCY NOT OK", _EmailAccountID,
|
AddToEmailQueueMSSQL(CurrentMail.MessageId, oResult, "PDF CONSISTENCY NOT OK", _EmailAccountID,
|
||||||
_RejectionTemplateId, ErrorCode.PDFStructureCorrupt, oATTFilename, "")
|
_InfoTemplateId, ErrorCode.PDFStructureCorrupt, oATTFilename, "")
|
||||||
Exit For
|
System.IO.File.Delete(oAttachmentFilePath)
|
||||||
|
Continue For
|
||||||
Else
|
Else
|
||||||
Dim embeddedFileCount As Integer = oGdPicturePDF.GetEmbeddedFileCount()
|
Dim embeddedFileCount As Integer = oGdPicturePDF.GetEmbeddedFileCount()
|
||||||
If embeddedFileCount > 0 Then
|
If embeddedFileCount > 0 Then
|
||||||
@ -872,7 +906,14 @@ Public Class clsWorkEmail
|
|||||||
oValidExt = oValidExtensions.Any(Function(ext) oEmbAttName.EndsWith(ext))
|
oValidExt = oValidExtensions.Any(Function(ext) oEmbAttName.EndsWith(ext))
|
||||||
|
|
||||||
If oValidExt = False Then
|
If oValidExt = False Then
|
||||||
_Logger.Debug("Invalid FileExtension [{0}]", oEmbAttName)
|
_Logger.Info("Invalid FileExtension of embedded file [{0}]", oEmbAttName)
|
||||||
|
Dim GraphicExt = oGraphicExtensions.Any(Function(ext) oEmbAttName.EndsWith(ext))
|
||||||
|
If GraphicExt = False Then
|
||||||
|
Dim oInfo = $"Consistency or extension of attached file [{oEmbAttName}] is not ok."
|
||||||
|
AddTrackingStatusMSSQL(CurrentMail.MessageId, oInfo, "Extension invalid", "Info GUI", "EML_PROF_EXTR_ATT3")
|
||||||
|
AddToEmailQueueMSSQL(CurrentMail.MessageId, oInfo, "Extension invalid", _EmailAccountID,
|
||||||
|
_InfoTemplateId, ErrorCode.PDFStructureCorrupt, oEmbAttName, "")
|
||||||
|
End If
|
||||||
Continue For
|
Continue For
|
||||||
End If
|
End If
|
||||||
If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then
|
If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then
|
||||||
@ -880,15 +921,12 @@ Public Class clsWorkEmail
|
|||||||
Dim status As GdPictureStatus = oGdPicturePDF.ExtractEmbeddedFile(0, FileData)
|
Dim status As GdPictureStatus = oGdPicturePDF.ExtractEmbeddedFile(0, FileData)
|
||||||
If status <> GdPictureStatus.OK Or FileSize = 0 Then
|
If status <> GdPictureStatus.OK Or FileSize = 0 Then
|
||||||
oPDFConsistent = False
|
oPDFConsistent = False
|
||||||
'ABLEHNUNG da PDF ungültig
|
|
||||||
MESSAGE_ERROR = True
|
Dim oResult = $"Consistency or PDF-State of embedded file [{oEmbAttName}] is not ok."
|
||||||
System.IO.File.Delete(oAttachmentFilePath)
|
AddTrackingStatusMSSQL(CurrentMail.MessageId, oResult, "PDF CONSISTENCY EMBEDDED FILE NOT OK", "Info GUI", "EML_PROF_EXTR_ATT4")
|
||||||
Dim oResult = $"Consistency or PDF-State of embedded file [{oEmbAttName}] IS NOT OK "
|
AddToEmailQueueMSSQL(CurrentMail.MessageId, oResult, "PDF CONSISTENCY EMBEDDED FILE NOT OK", _EmailAccountID,
|
||||||
'insert history und exit
|
_InfoTemplateId, ErrorCode.PDFStructureCorrupt, oEmbAttName, "")
|
||||||
InsertHistoryEntryWithStatus(CurrentMail, "REJECTED", oResult)
|
Continue For
|
||||||
AddToEmailQueueMSSQL(CurrentMail.MessageId, oResult, "Consistency or PDF-State Embedded file NOT OK", _EmailAccountID,
|
|
||||||
_RejectionTemplateId, ErrorCode.PDFStructureCorrupt, oATTFilename, "")
|
|
||||||
Exit For
|
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
@ -900,19 +938,22 @@ Public Class clsWorkEmail
|
|||||||
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim oFileLenth As Long = oFileInfo1.Length
|
Dim oFileLength As Long = oFileInfo1.Length
|
||||||
If oFileLenth > 2 Then
|
If oFileLength > 2 Then
|
||||||
_Logger.Info(String.Format("Attachment saved to [{0}]", oAttachmentFilePath))
|
_Logger.Info(String.Format("Attachment saved to [{0}]", oAttachmentFilePath))
|
||||||
InsertAttachmentHistoryEntry(pCurrentMail, oAttachment.SafeFileName, oAttachmentFileName)
|
InsertAttachmentHistoryEntry(pCurrentMail, oAttachment.SafeFileName, oAttachmentFileName)
|
||||||
oAttachmentCount += 1
|
oAttachmentCount += 1
|
||||||
Else
|
Else
|
||||||
_Logger.Warn($"##!! oFileLenth for AttachmentObjects is <2 !!##")
|
_Logger.Warn($"##!! oFileLength for AttachmentObjects is <2 !!##")
|
||||||
|
Dim oResult = $"Consistency of attached file [{oAttachment.SafeFileName}] is not ok."
|
||||||
|
AddTrackingStatusMSSQL(CurrentMail.MessageId, oResult, "CONSISTENCY ATTACHED FILE NOT OK", "Info GUI", "EML_PROF_EXTR_ATT5")
|
||||||
|
AddToEmailQueueMSSQL(CurrentMail.MessageId, oResult, "CONSISTENCY ATTACHED FILE NOT OK", _EmailAccountID,
|
||||||
|
_InfoTemplateId, ErrorCode.PDFStructureCorrupt, oAttachment.SafeFileName, "")
|
||||||
Try
|
Try
|
||||||
System.IO.File.Delete(oAttachmentFilePath)
|
System.IO.File.Delete(oAttachmentFilePath)
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_Logger.Error(ex)
|
_Logger.Error(ex)
|
||||||
End Try
|
End Try
|
||||||
MESSAGE_ERROR = True
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
@ -963,7 +1004,7 @@ Public Class clsWorkEmail
|
|||||||
_Logger.Error(ex)
|
_Logger.Error(ex)
|
||||||
_Logger.Warn("Could not delete the tempworkfile : [{0}]", _file)
|
_Logger.Warn("Could not delete the tempworkfile : [{0}]", _file)
|
||||||
End Try
|
End Try
|
||||||
ElseIf pACT = "Move" Then
|
ElseIf pACT = "move" Then
|
||||||
IO.File.Move(_file, _file.Replace("\Temp", ""))
|
IO.File.Move(_file, _file.Replace("\Temp", ""))
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ Public Class clsWorker
|
|||||||
Private ReadOnly LocalEmlFile As String = ""
|
Private ReadOnly LocalEmlFile As String = ""
|
||||||
|
|
||||||
Sub New(pLogConfig As LogConfig, pConnectionString As String, pWindreamConnectionString As String, pPollProfileId As Integer, pUseWindream As Boolean,
|
Sub New(pLogConfig As LogConfig, pConnectionString As String, pWindreamConnectionString As String, pPollProfileId As Integer, pUseWindream As Boolean,
|
||||||
pEmailAccountID As Integer, pEmailPrefix As String, pEmailLimitationSender As String, pRejectionTemplateId As Integer, Optional pLocalEML As String = "")
|
pEmailAccountID As Integer, pEmailPrefix As String, pEmailLimitationSender As String, pRejectionTemplateId As Integer, pInfoTemplateId As Integer, Optional pLocalEML As String = "")
|
||||||
Logger = pLogConfig.GetLogger
|
Logger = pLogConfig.GetLogger
|
||||||
'ClassEmailImap = New clsEmailIMAP(pLogConfig)
|
'ClassEmailImap = New clsEmailIMAP(pLogConfig)
|
||||||
Fetcher = New MailFetcher(pLogConfig)
|
Fetcher = New MailFetcher(pLogConfig)
|
||||||
@ -43,7 +43,7 @@ Public Class clsWorker
|
|||||||
ClassWindreamIndex = New clsWindream_Index(pLogConfig)
|
ClassWindreamIndex = New clsWindream_Index(pLogConfig)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
ClassWorkMail = New clsWorkEmail(pLogConfig, pConnectionString, pWindreamConnectionString, pUseWindream, pEmailAccountID, pEmailPrefix, pRejectionTemplateId)
|
ClassWorkMail = New clsWorkEmail(pLogConfig, pConnectionString, pWindreamConnectionString, pUseWindream, pEmailAccountID, pEmailPrefix, pRejectionTemplateId, pInfoTemplateId)
|
||||||
|
|
||||||
|
|
||||||
Encryption = New clsEncryption("!35452didalog=", pLogConfig)
|
Encryption = New clsEncryption("!35452didalog=", pLogConfig)
|
||||||
|
|||||||
@ -15,6 +15,7 @@ Public Class Config
|
|||||||
''' Siehe Tabelle DD_ECM.dbo.TBDD_EMAIL_TEMPLATE
|
''' Siehe Tabelle DD_ECM.dbo.TBDD_EMAIL_TEMPLATE
|
||||||
''' </summary>
|
''' </summary>
|
||||||
Public Property RejectionTemplateId As Integer = 0
|
Public Property RejectionTemplateId As Integer = 0
|
||||||
|
Public Property InfoTemplateId As Integer = 0
|
||||||
|
|
||||||
Public Property EmailTestReceiver As String = ""
|
Public Property EmailTestReceiver As String = ""
|
||||||
Public Property EmailTestHTML As String = ""
|
Public Property EmailTestHTML As String = ""
|
||||||
|
|||||||
@ -341,7 +341,7 @@ Public Class frmMain
|
|||||||
LogConfig.Debug = True
|
LogConfig.Debug = True
|
||||||
Dim _work As New clsWorker(LogConfig, _SQLServerConString, _DBConfig.WindreamConnectionString, GUIDTextBox.Text,
|
Dim _work As New clsWorker(LogConfig, _SQLServerConString, _DBConfig.WindreamConnectionString, GUIDTextBox.Text,
|
||||||
ConfigManager.Config.UseWindream, ToolStripEmailAccountID2.Text, "EmailProfilerTestClient",
|
ConfigManager.Config.UseWindream, ToolStripEmailAccountID2.Text, "EmailProfilerTestClient",
|
||||||
ConfigManager.Config.EmailSenderLimitation, ConfigManager.Config.RejectionTemplateId)
|
ConfigManager.Config.EmailSenderLimitation, ConfigManager.Config.RejectionTemplateId, ConfigManager.Config.InfoTemplateId)
|
||||||
_work.Start_WorkingProfiles()
|
_work.Start_WorkingProfiles()
|
||||||
|
|
||||||
Else
|
Else
|
||||||
@ -349,7 +349,7 @@ Public Class frmMain
|
|||||||
Logger.Info($"## Manual working on file {ofile} ... ")
|
Logger.Info($"## Manual working on file {ofile} ... ")
|
||||||
Dim _work As New clsWorker(LogConfig, _SQLServerConString, _DBConfig.WindreamConnectionString, GUIDTextBox.Text,
|
Dim _work As New clsWorker(LogConfig, _SQLServerConString, _DBConfig.WindreamConnectionString, GUIDTextBox.Text,
|
||||||
ConfigManager.Config.UseWindream, ToolStripEmailAccountID2.Text, "EmailProfilerTestClient",
|
ConfigManager.Config.UseWindream, ToolStripEmailAccountID2.Text, "EmailProfilerTestClient",
|
||||||
ConfigManager.Config.EmailSenderLimitation, ConfigManager.Config.RejectionTemplateId, ofile)
|
ConfigManager.Config.EmailSenderLimitation, ConfigManager.Config.RejectionTemplateId, ConfigManager.Config.InfoTemplateId, ofile.ToString)
|
||||||
_work.Start_WorkingProfiles(True)
|
_work.Start_WorkingProfiles(True)
|
||||||
Next
|
Next
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user