Big update: MessageID replaced with Hash of MessageID

This commit is contained in:
Jonathan Jenne
2023-07-03 16:35:24 +02:00
parent 2b21650c53
commit aa5a268e14
14 changed files with 523 additions and 538 deletions

View File

@@ -0,0 +1,72 @@
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Base
Public Class ClassConfig
Public Class Config
Public Property PathError As String
Public Property PathAttachments As String
Public Property BodyFont As String
Public Property WindreamConnectionString As String
Public Property TimerInterval As Integer
Public Property WindreamDrive As String = "W"
End Class
Private ReadOnly Logger As Logger
Private ReadOnly Database As MSSQLServer
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer)
Logger = pLogConfig.GetLogger()
Database = pDatabase
End Sub
Private Function GetConfigTable() As DataTable
Dim oSQL As String = "SELECT * FROM TBEMLP_CONFIG"
Dim oTable As DataTable = Database.GetDatatable(oSQL)
Return oTable
End Function
Private Function GetBaseConfigTable() As DataTable
Dim oSQL As String = "SELECT * FROM TBDD_BASECONFIG"
Dim oTable As DataTable = Database.GetDatatable(oSQL)
Return oTable
End Function
Public Function GetConfig() As Config
Dim oConfigTable = GetConfigTable()
Dim oBaseTable = GetBaseConfigTable()
If oBaseTable Is Nothing Then
Logger.Warn("Config from TBDD_BASECONFIG could not be loaded!")
Return Nothing
End If
If oBaseTable.Rows.Count = 0 Then
Logger.Warn("Config from TBDD_BASECONFIG could not be loaded!")
Return Nothing
End If
If oConfigTable Is Nothing Then
Logger.Warn("Config from TBEMLP_CONFIG could not be loaded!")
Return Nothing
End If
If oConfigTable.Rows.Count = 0 Then
Logger.Warn("Config from TBEMLP_CONFIG is empty!")
Return Nothing
End If
Dim oRow As DataRow = oConfigTable.Rows.Item(0)
Dim oConfig As New Config With {
.PathAttachments = oRow.ItemEx("PATH_EMAIL_TEMP", ""),
.PathError = oRow.ItemEx("PATH_EMAIL_ERRORS", ""),
.BodyFont = oRow.ItemEx("FONT_BODY", "Arial"),
.TimerInterval = oRow.ItemEx("CHECK_INTERVALL_MINUTES", 5),
.WindreamConnectionString = oRow.ItemEx("WM_CON_STRING", ""),
.WindreamDrive = oRow.ItemEx("WM_DRIVE", "W")
}
Return oConfig
End Function
End Class

View File

@@ -6,18 +6,13 @@ Imports MailBox = Limilabs.Mail.Headers.MailBox
Imports Limilabs.Client.IMAP
Public Class ClassCurrent
Public Shared Property WM_CON_STRING As String
Public Shared Property WM_DRIVE As String
Public Shared Property TIMER_INTERVALL As Integer = 5
Public Shared Property CURRENT_EMAIL_GUID As Integer
Public Shared Property CURRENT_PROFILE_GUID As Integer
Public Shared Property DTCONFIG As DataTable
Public Shared Property DT_ECM_BASE_CONFIG As DataTable
Public Shared Property PATH_TEMP As String
Public Shared Property PATH_ERROR As String
Public Shared Property MAIL_BODY_FONT As String = ""
Public Shared Property MAIL_FROM As String = ""
Public Shared Property MAIL_SERVER As String = ""
Public Shared Property MAIL_USER As String = ""
@@ -30,20 +25,21 @@ Public Class ClassCurrent
Public Shared Property DT_STEPS As DataTable
Public Shared Property DT_INDEXING_STEPS As DataTable
Public Shared Property CURRENToWMSession As Object
Public Shared Property CURRENToWMSession_Created As Date = Now
Public Shared Property CURRENToWMConnect As Object
Public Shared Property CURRENT_ATTMT_COUNT As Integer
Public Shared Property SUBJECT_PRAFIX As String = "EmailProfiler"
Public Shared Property CURRENT_DRIVE_CHECK As String = ""
Public Shared Property CURRENT_DRIVE_ISFULL As Boolean = False
' Public Shared Property oCURRENT_WORKMAIL_LIST As New ArrayList()
Public Shared Property CURRENT_WORKMAIL_UID_LIST As New List(Of Long)
Public Shared Property CURRENT_MAIL_MESSAGE As IMail
Public Shared Property CURRENT_TEMP_MAIL_PATH As String
Public Shared Property CURRENT_MAIL_BODY_ALL As String
Public Shared Property CURRENT_MAIL_BODY_ANSWER1 As String = ""
Public Shared Property CURRENT_MAIL_BODY_Substr2 As String = ""
Public Shared Property CURRENT_MAIL_SUBJECT As String = ""
Public Shared Property CURRENT_MAIL_FROM As String = ""
Public Shared Property CURRENT_MAIL_MESSAGE_ID As String = ""
Public Shared Property CURRENT_MAIL_UID As Long
Public Shared Property CURRENT_MAIL_PROCESS_NAME As String
Public Shared Property CURRENT_ImapObject As Imap
Public Shared Property CURRENT_MAIL_UID As Long
Public Shared Property DeleteMail As Boolean = False
Public Shared Property CURRENT_POLL_TYPE As String

View File

@@ -106,6 +106,7 @@
<Import Include="System.Threading.Tasks" />
</ItemGroup>
<ItemGroup>
<Compile Include="ClassConfig.vb" />
<Compile Include="ClassCurrent.vb" />
<Compile Include="clsDatabase.vb" />
<Compile Include="clsEmail.IMAP.vb" />
@@ -116,7 +117,6 @@
<Compile Include="clsWorkEmail.vb" />
<Compile Include="clsWorker.vb" />
<Compile Include="MailContainer.vb" />
<Compile Include="ModuleCurrent.vb" />
<Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen>

View File

@@ -1,52 +1,64 @@
Imports Limilabs.Mail
Imports DigitalData.Modules.Language
Imports DigitalData.Modules.Base
Public Class MailContainer
Private ReadOnly Uid As String
Private ReadOnly FilteredMessageId
Private Const SUBJECT_MAX_LENGTH = 25
''' <summary>
''' The Mail object created by Limilabs
''' </summary>
Public ReadOnly Property Mail As IMail
Public ReadOnly Property Subject As String
Get
Return Mail.Subject
End Get
End Property
''' <summary>
''' The IMAP Id coming from the IMAP folder. Used to reference the mail.
''' </summary>
Public ReadOnly Property ImapId As Integer
''' <summary>
''' The original MessageID from the eml file
''' </summary>
Public ReadOnly Property MessageIdOriginal As String
''' <summary>
''' The new MessageID, which is generated by hashing the original MessageID
''' </summary>
Public ReadOnly Property MessageId As String
Get
Return Mail.MessageID
End Get
End Property
''' <summary>
''' The subject, truncated to SUBJECT_MAX_LENGTH characters
''' </summary>
Public ReadOnly Property Subject As String
Public ReadOnly Property MessageIdPathSafe As String
Get
Return FilteredMessageId
End Get
End Property
Public Property BodyComplete As String
Public Property BodySubstring1 As String
Public Property BodySubstring2 As String
Public ReadOnly Property SenderDomain As String
Public ReadOnly Property SenderAddress As String
Public Sub New(pMail As IMail, pUid As String)
Public Sub New(pMail As IMail, pImapId As Integer)
Mail = pMail
Uid = pUid
FilteredMessageId = ProcessMessageId(pMail.MessageID)
ImapId = pImapId
MessageIdOriginal = pMail.MessageID
MessageId = StringEx.GetHash(pMail.MessageID)
Subject = ObjectEx.NotNull(pMail.Subject.Truncate(SUBJECT_MAX_LENGTH), String.Empty)
SenderAddress = GetSenderAddress(pMail)
SenderDomain = GetSenderDomain(pMail)
End Sub
Private Function ProcessMessageId(pOriginalMessageId As String) As String
If pOriginalMessageId Is Nothing Then
Return Guid.NewGuid.ToString
End If
If TypeOf pOriginalMessageId Is String AndAlso pOriginalMessageId.Length = 0 Then
Return Guid.NewGuid.ToString
Private Function GetSenderAddress(pMail As IMail)
Dim oMailBox = pMail.From.FirstOrDefault()
If oMailBox Is Nothing Then
Return "InvalidSenderAddress"
Else
Return oMailBox.Address
End If
End Function
Return Utils.RemoveInvalidCharacters(pOriginalMessageId)
Private Function GetSenderDomain(pMail As IMail)
Dim oMailBox = pMail.From.FirstOrDefault()
If oMailBox Is Nothing Then
Return "InvalidSenderAddress"
Else
Return oMailBox.DomainPart
End If
End Function
End Class

View File

@@ -1,9 +0,0 @@
Module ModuleCurrent
Public CURRENToWMSession As Object
Public CURRENToWMSession_Created As Date = Now
Public CURRENToWMConnect As Object
Public CURRENT_ATTMT_COUNT As Integer
Public SUBJECT_PRAFIX As String = "EmailProfiler"
Public CURRENT_DRIVE_CHECK As String = ""
Public CURRENT_DRIVE_ISFULL As Boolean = False
End Module

View File

@@ -10,7 +10,7 @@ Public Class clsDatabase
MyLogger = LogConf
Init(ConStr)
End Sub
Public Function Init(ConString As String)
Public Function Init(ConString As String) As Boolean
Try
Dim SQLconnect As New SqlClient.SqlConnection
@@ -21,11 +21,11 @@ Public Class clsDatabase
DTCONFIG = Return_Datatable("select * from TBEMLP_CONFIG")
If Not IsNothing(DTCONFIG) Then
If DTCONFIG.Rows.Count = 1 Then
PATH_TEMP = DTCONFIG.Rows(0).Item("PATH_EMAIL_TEMP")
PATH_ERROR = DTCONFIG.Rows(0).Item("PATH_EMAIL_ERRORS")
MAIL_BODY_FONT = DTCONFIG.Rows(0).Item("FONT_BODY")
WM_CON_STRING = DTCONFIG.Rows(0).Item("WM_CON_STRING")
TIMER_INTERVALL = DTCONFIG.Rows(0).Item("CHECK_INTERVALL_MINUTES")
'PATH_EXTRACT_ATTACHMENTS = DTCONFIG.Rows(0).Item("PATH_EMAIL_TEMP")
'PATH_ERROR = DTCONFIG.Rows(0).Item("PATH_EMAIL_ERRORS")
'MAIL_BODY_FONT = DTCONFIG.Rows(0).Item("FONT_BODY")
'WM_CON_STRING = DTCONFIG.Rows(0).Item("WM_CON_STRING")
'TIMER_INTERVALL = DTCONFIG.Rows(0).Item("CHECK_INTERVALL_MINUTES")
End If
End If
DT_ECM_BASE_CONFIG = Return_Datatable("select * from TBDD_BASECONFIG")
@@ -132,25 +132,4 @@ Public Class clsDatabase
Return Nothing
End Try
End Function
Public Function Execute_Scalar_CS(cmdscalar As String, constring As String)
Dim result
Try
Dim SQLconnect As New SqlClient.SqlConnection
Dim SQLcommand As SqlClient.SqlCommand
SQLconnect.ConnectionString = constring
SQLconnect.Open()
SQLcommand = SQLconnect.CreateCommand
'Update Last Created Record in Foo
SQLcommand.CommandText = cmdscalar
result = SQLcommand.ExecuteScalar()
SQLcommand.Dispose()
SQLconnect.Close()
Return result
Catch ex As Exception
Logger.Error(ex)
Logger.Warn("Unexpected Error in Execute_Scalar_CS: " & ex.Message)
Logger.Warn("SQL: " & cmdscalar)
Return Nothing
End Try
End Function
End Class

View File

@@ -10,12 +10,10 @@ Imports DigitalData.Modules.Messaging
Public Class clsEmailIMAP
Private Shared Logger As Logger
Private Shared LogConfig As LogConfig
Private _DB_MSSQL As clsDatabase
Private _limilab As Limilab
Sub New(LogConf As LogConfig, ECMConnectionString As String)
Sub New(LogConf As LogConfig)
LogConfig = LogConf
Logger = LogConf.GetLogger
_DB_MSSQL = New clsDatabase(LogConf, ECMConnectionString)
_limilab = New Limilab(LogConf)
End Sub
Public Function FetchIMAPMessagesLimilab(Server As String, Port As Integer, Username As String, Password As String, AuthType As String) As Boolean

View File

@@ -9,6 +9,7 @@ Imports WMOBRWSLib
Imports WMOSRCHLib
Imports System.IO
Imports DigitalData.Modules.Logging
Imports DigitalData.EMLProfiler.ClassCurrent
Public Class clsWindream_allgemein

File diff suppressed because it is too large Load Diff

View File

@@ -4,37 +4,37 @@ Imports DigitalData.Modules.Messaging
Imports Limilabs.Mail
Imports Limilabs.Mail.MIME
Imports Limilabs.Mail.Headers
Imports DigitalData.Modules.Database
Public Class clsWorker
Private Shared Logger As Logger
Private MyLogConfig As LogConfig
'Private _email As clsEmail
Private _emailIMAP As clsEmailIMAP
Private _Database As clsDatabase
Private _USE_WM As Boolean = False
Private _windream As clsWindream_allgemein
Private _windream_index As clsWindream_Index
Private _workmail As clsWorkEmail
Private _wrapper As clsEncryption
Private _POLL_PROFILEID As Integer = 0
Private Eml_Limitation_Sender As String = ""
Dim cs As String
Sub New(EML_LIMITATION As String, LogConf As LogConfig, ConStr As String, POLL_PROFILEID As Integer, FB_DATASOURCE As String, FB_DATABASE As String, FB_USER As String, FB_PW As String, USE_WM As Boolean, EmailAccountID As Integer, EmlProfPraefix As String, Optional plocaleml As String = "")
MyLogConfig = LogConf
Logger = LogConf.GetLogger
_emailIMAP = New clsEmailIMAP(LogConf, ConStr)
_Database = New clsDatabase(LogConf, ConStr)
cs = ConStr
Private ReadOnly _emailIMAP As clsEmailIMAP
'Private _Database As clsDatabase
Private ReadOnly _Database As MSSQLServer
Private ReadOnly _USE_WM As Boolean = False
Private ReadOnly _windream As clsWindream_allgemein
Private ReadOnly _windream_index As clsWindream_Index
Private ReadOnly _workmail As clsWorkEmail
Private ReadOnly _wrapper As clsEncryption
Private ReadOnly _POLL_PROFILEID As Integer = 0
Private ReadOnly Eml_Limitation_Sender As String = ""
Sub New(EML_LIMITATION As String, pLogConfig As LogConfig, ConStr As String, WMConStr As String, POLL_PROFILEID As Integer, FB_DATASOURCE As String, FB_DATABASE As String, FB_USER As String, FB_PW As String, USE_WM As Boolean, EmailAccountID As Integer, EmlProfPraefix As String, Optional plocaleml As String = "")
Logger = pLogConfig.GetLogger
_emailIMAP = New clsEmailIMAP(pLogConfig)
_Database = New MSSQLServer(pLogConfig, ConStr)
_USE_WM = USE_WM
Eml_Limitation_Sender = EML_LIMITATION
If _USE_WM Then
_windream = New clsWindream_allgemein(LogConf)
_windream_index = New clsWindream_Index(LogConf)
_windream = New clsWindream_allgemein(pLogConfig)
_windream_index = New clsWindream_Index(pLogConfig)
End If
_workmail = New clsWorkEmail(LogConf, ConStr, FB_DATASOURCE, FB_DATABASE, FB_USER, FB_PW, USE_WM, EmailAccountID, EmlProfPraefix)
_wrapper = New clsEncryption("!35452didalog=", LogConf)
_workmail = New clsWorkEmail(pLogConfig, ConStr, WMConStr, FB_DATASOURCE, FB_DATABASE, FB_USER, FB_PW, USE_WM, EmailAccountID, EmlProfPraefix)
_wrapper = New clsEncryption("!35452didalog=", pLogConfig)
_POLL_PROFILEID = POLL_PROFILEID
ClassCurrent.CURRENT_DEBUG_LOCAL_EMAIL = plocaleml
CURRENT_DEBUG_LOCAL_EMAIL = plocaleml
End Sub
Public Sub Start_WorkingProfiles(Optional LocalEmail As Boolean = False)
@@ -53,7 +53,7 @@ Public Class clsWorker
Next
TEMP_FILES.Clear()
If _Database.Init(cs) = True Then
If _Database.DBInitialized = True Then
Logger.Debug("now windream_init... ")
If _USE_WM Then
If _windream.Init = False Then
@@ -69,8 +69,8 @@ Public Class clsWorker
Else
osql &= " WHERE GUID = " & _POLL_PROFILEID
End If
Dim DT_TBDD_EMAIL As DataTable = _Database.Return_Datatable("SELECT * FROM TBDD_EMAIL_ACCOUNT WHERE ACTIVE = 1")
Dim DT_PROFILES = _Database.Return_Datatable(osql)
Dim DT_TBDD_EMAIL As DataTable = _Database.GetDatatable("SELECT * FROM TBDD_EMAIL_ACCOUNT WHERE ACTIVE = 1")
Dim DT_PROFILES = _Database.GetDatatable(osql)
If Not IsNothing(DT_PROFILES) Then
If DT_PROFILES.Rows.Count > 0 Then
Logger.Debug("count of active profiles: " & DT_PROFILES.Rows.Count.ToString)
@@ -78,14 +78,14 @@ Public Class clsWorker
CURRENT_PROFILE_GUID = oDR_Profile.Item("GUID")
DT_POLL_PROCESS = Nothing
Dim sql = String.Format("SELECT * FROM TBEMLP_POLL_PROCESS WHERE PROFILE_ID = {0} AND ACTIVE = 1", CURRENT_PROFILE_GUID)
DT_POLL_PROCESS = _Database.Return_Datatable(sql)
DT_POLL_PROCESS = _Database.GetDatatable(sql)
If Not IsNothing(DT_POLL_PROCESS) Then
If DT_POLL_PROCESS.Rows.Count = 0 Then
Logger.Info("No processes configured for this Email-Profile - " & sql)
Continue For
Else
DT_STEPS = Nothing
DT_STEPS = _Database.Return_Datatable(String.Format("SELECT T.* FROM TBEMLP_POLL_STEPS T,TBEMLP_POLL_PROCESS T1 WHERE T.PROCESS_ID = T1.GUID AND T1.PROFILE_ID = {0} AND T1.ACTIVE = 1", CURRENT_PROFILE_GUID))
DT_STEPS = _Database.GetDatatable(String.Format("SELECT T.* FROM TBEMLP_POLL_STEPS T,TBEMLP_POLL_PROCESS T1 WHERE T.PROCESS_ID = T1.GUID AND T1.PROFILE_ID = {0} AND T1.ACTIVE = 1", CURRENT_PROFILE_GUID))
End If
Else
@@ -175,7 +175,7 @@ Public Class clsWorker
If Not IsNothing(oEmail) Then
If LIMIT_EMAIL_FROM Then
Dim oEmailFrom As String
Dim oEmailFrom As String = ""
For Each m As MailBox In oEmail.From
oEmailFrom = m.Address
Next
@@ -185,7 +185,7 @@ Public Class clsWorker
End If
End If
If _workmail.WorkEmailMessage(oEmail, oUID) = True Then
If ClassCurrent.CURRENT_DEBUG_LOCAL_EMAIL = "" Then
If CURRENT_DEBUG_LOCAL_EMAIL = "" Then
EMAIL_DELETE()
End If
End If
@@ -216,7 +216,7 @@ Public Class clsWorker
Logger.Warn("For the Email-Profile ID " & CURRENT_EMAIL_GUID & " no record could be found!")
End If
_Database.Execute_non_Query("UPDATE TBEMLP_POLL_PROFILES SET LAST_TICK = GETDATE() WHERE GUID = " & oDR_Profile.Item("GUID").ToString)
_Database.ExecuteNonQuery("UPDATE TBEMLP_POLL_PROFILES SET LAST_TICK = GETDATE() WHERE GUID = " & oDR_Profile.Item("GUID").ToString)
Else
Logger.Warn("For the Email-Profile ID " & CURRENT_EMAIL_GUID & " no record could be found! Check wether Email-Profile is active!")
End If
@@ -245,7 +245,7 @@ Public Class clsWorker
End If
End If
_Database.Execute_non_Query("UPDATE TBEMLP_CONFIG SET LAST_TICK = GETDATE() WHERE GUID = 1")
_Database.ExecuteNonQuery("UPDATE TBEMLP_CONFIG SET LAST_TICK = GETDATE() WHERE GUID = 1")
End If
Catch ex As Exception
Logger.Error(ex)