Bodyauswertung

This commit is contained in:
Digital Data - Marlon Schreiber
2019-01-23 17:59:18 +01:00
parent 60ed01009a
commit 79d864c676
74 changed files with 126423 additions and 1072 deletions

View File

@@ -5,8 +5,11 @@ Imports DigitalData.EMLProfiler.ClassCurrent
Imports System.IO
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Database
Imports System.Threading
Public Class clsWorkEmail
Private Shared Logger As Logger
Private MyLogger As LogConfig
Private _email As clsEmail
Private _Database As clsDatabase
Private _windream As clsWindream_allgemein
@@ -14,36 +17,62 @@ Public Class clsWorkEmail
Private _firebird As Firebird
Private _worked_email As Boolean = False
Sub New(LogConf As LogConfig, ConStr As String, FB_DATASOURCE As String, FB_DATABASE As String, FB_USER As String, FB_PW As String)
Logger = LogConf.GetLogger
_email = New clsEmail(LogConf)
_Database = New clsDatabase(LogConf, ConStr)
_windream = New clsWindream_allgemein(LogConf)
_windream_index = New clsWindream_Index(LogConf)
_firebird = New Firebird(LogConf, FB_DATASOURCE, FB_DATABASE, FB_USER, FB_PW)
Try
Logger = LogConf.GetLogger
MyLogger = LogConf
If LogConf.Debug = False Then
Logger.Info("Detail-Log is on")
End If
_email = New clsEmail(LogConf)
_Database = New clsDatabase(LogConf, ConStr)
_windream = New clsWindream_allgemein(LogConf)
_windream_index = New clsWindream_Index(LogConf)
If FB_DATASOURCE <> String.Empty Then
_firebird = New Firebird(LogConf, FB_DATASOURCE, FB_DATABASE, FB_USER, FB_PW)
End If
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub
Public Function WORK_MAIL(msg As Message)
Try
CURRENT_MAIL_BODY = ""
CURRENT_MAIL_BODY_Substr1 = ""
CURRENT_MAIL_BODY_ALL = ""
CURRENT_MAIL_BODY_ANSWER1 = ""
CURRENT_MAIL_BODY_Substr2 = ""
CURRENT_MAIL_MESSAGE = msg
CURRENT_MAIL_SUBJECT = msg.Subject.ToUpper
If IsNothing(CURRENT_MAIL_SUBJECT) Then
CURRENT_MAIL_SUBJECT = ""
End If
SAVE2TEMP()
If CURRENT_MAIL_SUBJECT.Contains("[PROCESSMANAGER]") Then
PROCESS_MANAGER_IN()
ElseIf msg.Subject.Contains("[ADDI]") Then
Else
Logger.Debug(String.Format("No relation configured for this email - Subject[{0}]", msg.Subject))
COMMON_EMAIL_IN
Dim oTempMailExists As Boolean = SAVE2TEMP()
'Checking wether Mail can be opened
Dim oTempMailAccessible As Boolean = False
If oTempMailExists = True Then
Try
Dim oFS As FileStream = File.OpenRead(CURRENT_TEMP_MAIL_PATH)
oTempMailAccessible = True
Catch ex As Exception
Logger.Warn($"Could not read the Temp-Mail. Insufficient rights? Message: {ex.Message}")
End Try
If oTempMailAccessible = True Then
If CURRENT_MAIL_SUBJECT.Contains("[PROCESSMANAGER]") Then
PROCESS_MANAGER_IN()
ElseIf msg.Subject.Contains("[ADDI]") Then
Else
Logger.Debug(String.Format("No relation configured for this email - Subject[{0}]", msg.Subject))
COMMON_EMAIL_IN()
End If
INSERT_HISTORY()
End If
End If
INSERT_HISTORY
Catch ex As Exception
Logger.Error(ex)
'clsLogger.Add("Unexpected Error in WORK_MAIL: " & ex.Message & "MESSAGE_ID: " & msg.MessageID)
@@ -65,10 +94,11 @@ Public Class clsWorkEmail
WM_OBJEKTTYPE = row("WM_OBJEKTTYPE")
WM_IDX_BODY_TEXT = row("WM_IDX_BODY_TEXT")
WM_IDX_BODY_SUBSTR_LENGTH = row("WM_IDX_BODY_SUBSTR_LENGTH")
oDel_email = row("DELETE_MAIL")
COPY2HDD(row("COPY_2_HDD"), row("PATH_EMAIL_TEMP"), row("PATH_EMAIL_ERRORS"), False)
EXTRACT_BODY()
oDel_email = row("DELETE_MAIL")
Next
If CURRENT_MAIL_SUBJECT.Contains("[PROCESSMANAGER][EA]") Then
@@ -76,9 +106,9 @@ Public Class clsWorkEmail
Logger.Debug(String.Format("Message referencing to EASY-APPROVAL...."))
CURRENT_MAIL_PROCESS_NAME = "DD EasyApproval via Mail"
If CURRENT_MAIL_BODY_Substr1 <> "" Then
If CURRENT_MAIL_BODY_ANSWER1 <> "" Then
MessageError = False
If GET_DOC_INFO() = True Then
If GET_WMDOC_INFO() = True Then
If DT_STEPS.Rows.Count > 0 Then
WORK_POLL_STEPS()
Else
@@ -87,7 +117,10 @@ Public Class clsWorkEmail
End If
End If
EMAIL_DELETE(oDel_email)
If ClassCurrent.CURRENT_DEBUG_LOCAL_EMAIL = "" Then
EMAIL_DELETE(oDel_email)
End If
End If
Return True
Catch ex As Exception
@@ -127,26 +160,67 @@ Public Class clsWorkEmail
EXTRACT_BODY()
oDel_email = row("DELETE_MAIL")
Next
EMAIL_DELETE(oDel_email)
If ClassCurrent.CURRENT_DEBUG_LOCAL_EMAIL = "" Then
EMAIL_DELETE(oDel_email)
End If
Return True
Catch ex As Exception
Logger.Error(ex)
'Logger.Debug("Unexpected Error in PROCESS_MANAGER_IN: " & ex.Message & "MESSAGE_ID: " & CURRENT_MAIL_MESSAGE.MessageID)
Return False
'Logger.Debug("Unexpected Error in PROCESS_MANAGER_IN: " & ex.Message & "MESSAGE_ID: " & CURRENT_MAIL_MESSAGE.MessageID)
Return False
End Try
End Function
Private Function SAVE2TEMP()
Try
Dim oTempFilename As String = Path.Combine(Path.GetTempPath, CURRENT_MAIL_MESSAGE.GetFileName)
Dim oTempPath As String = Path.Combine(Path.GetTempPath, "DD_EmailProfiler")
If Directory.Exists(oTempPath) = False Then
Directory.CreateDirectory(oTempPath)
End If
Dim oFileEntries As String() = Directory.GetFiles(oTempPath)
' Process the list of files found in the directory.
Dim oFileName As String
For Each oFileName In oFileEntries
Try
File.Delete(oFileName)
Catch ex As Exception
End Try
Next oFileName
Dim oResult As Boolean = False
Dim oTempFilename As String = Path.Combine(oTempPath, CURRENT_MAIL_MESSAGE.GetFileName)
Dim oCounter As Integer = 1
If File.Exists(oTempFilename) = True Then
File.Delete(oTempFilename)
Do While File.Exists(oTempFilename)
oCounter += 1
oTempFilename = Path.Combine(oTempPath, oCounter & "_" & CURRENT_MAIL_MESSAGE.GetFileName)
Loop
End If
CURRENT_MAIL_MESSAGE.Save(oTempFilename, True)
CURRENT_TEMP_MAIL_PATH = oTempFilename
Logger.Debug($"Email saved to Temppath {CURRENT_TEMP_MAIL_PATH}")
oCounter = 0
Dim oCancel As Boolean
Do While File.Exists(CURRENT_TEMP_MAIL_PATH) = False
Thread.Sleep(1000)
oCounter += 1
If oCounter > 10 Then
Logger.Warn("It took to long to save the mail to Temppath!")
oCancel = True
Exit Do
End If
Loop
If oCancel = True Then
oResult = False
Else
If File.Exists(CURRENT_TEMP_MAIL_PATH) Then
oResult = True
End If
End If
'Datei in Array zum Templöschen speichern
TEMP_FILES.Add(oTempFilename)
Return oResult
Catch ex As Exception
Logger.Error(ex)
CURRENT_TEMP_MAIL_PATH = Nothing
@@ -184,116 +258,190 @@ Public Class clsWorkEmail
End Try
End Function
Private Function EXTRACT_BODY()
Dim oDTFunctionRegex As DataTable = _Database.Return_Datatable("SELECT * FROM TBDD_FUNCTION_REGEX WHERE FUNCTION_NAME = 'EMAIL_PROFILER - BODY REMOVE NewLine'")
If CURRENT_TEMP_MAIL_PATH <> Nothing Then
If File.Exists(CURRENT_TEMP_MAIL_PATH) Then
Dim msg_email As New Independentsoft.Email.Mime.Message(CURRENT_TEMP_MAIL_PATH)
If IsNothing(msg_email.Body) Then
Dim oAllBodyParts As New BodyPartCollection()
oAllBodyParts.Add(msg_email.BodyParts)
oAllBodyParts.Add(GetChildren(msg_email.BodyParts))
TEMP_HTML_RESULTS.Clear()
Dim oDTFunctionRegex As DataTable = _Database.Return_Datatable("SELECT * FROM TBDD_FUNCTION_REGEX WHERE FUNCTION_NAME IN ('EMAIL_PROFILER - RemoveHTMLText','EMAIL_PROFILER - BODY REMOVE NewLine','EMAIL_PROFILER - BODY_ANSWER_GROUP')")
For Each bodyPart As BodyPart In oAllBodyParts
If bodyPart.ContentType IsNot Nothing AndAlso bodyPart.ContentType.Type = "text" AndAlso bodyPart.ContentType.SubType = "plain" Then
Logger.Debug(String.Format("BODY1-Text is....#{0}", bodyPart.Body))
If CURRENT_MAIL_BODY <> bodyPart.Body Then
CURRENT_MAIL_BODY = bodyPart.Body
End If
ElseIf bodyPart.ContentType IsNot Nothing AndAlso bodyPart.ContentType.Type = "text" AndAlso bodyPart.ContentType.SubType = "html" Then
Logger.Debug(String.Format("bodyhtml....#{0}", bodyPart.Body))
If CURRENT_MAIL_BODY = "" Then
CURRENT_MAIL_BODY = bodyPart.Body
Logger.Debug(String.Format("bodyhtml....#{0}", bodyPart.Body))
Dim msg_email As New Independentsoft.Email.Mime.Message(CURRENT_TEMP_MAIL_PATH)
If IsNothing(msg_email.Body) Then
Dim oAllBodyParts As New BodyPartCollection()
oAllBodyParts.Add(msg_email.BodyParts)
oAllBodyParts.Add(GetChildren(msg_email.BodyParts))
End If
End If
Next
Else
CURRENT_MAIL_BODY = msg_email.Body
For Each bodyPart As BodyPart In oAllBodyParts
If bodyPart.ContentType IsNot Nothing AndAlso bodyPart.ContentType.Type = "text" AndAlso bodyPart.ContentType.SubType = "plain" Then
Logger.Debug(String.Format("BODY1-Text is....#{0}", bodyPart.Body))
If CURRENT_MAIL_BODY_ALL <> bodyPart.Body Then
CURRENT_MAIL_BODY_ALL = bodyPart.Body
End If
ElseIf bodyPart.ContentType IsNot Nothing AndAlso bodyPart.ContentType.Type = "text" AndAlso bodyPart.ContentType.SubType = "html" Then
Logger.Debug(String.Format("bodyhtml....#{0}", bodyPart.Body))
If CURRENT_MAIL_BODY_ALL = "" Then
CURRENT_MAIL_BODY_ALL = bodyPart.Body
Logger.Debug(String.Format("bodyhtml....#{0}", bodyPart.Body))
End If
End If
Else
Logger.Warn($"If cause 2: {CURRENT_TEMP_MAIL_PATH} not existing")
End If
Next
Else
Logger.Warn($"EXTRACT_BODY If cause 1: CURRENT_TEMP_MAIL_PATH is NOTHING")
CURRENT_MAIL_BODY_ALL = msg_email.Body
End If
If CURRENT_MAIL_BODY_ALL.StartsWith("<html") Then
Try
Dim pattern1 As String = ""
For Each oRow As DataRow In oDTFunctionRegex.Rows
If oRow.Item("FUNCTION_NAME") = "EMAIL_PROFILER - RemoveHTMLText" Then
pattern1 = oRow.Item("REGEX")
End If
Next
If pattern1 = String.Empty Then
Exit Try
End If
' Instantiate the regular expression object.
Dim r As Regex = New Regex(pattern1, RegexOptions.Multiline)
' Match the regular expression pattern against a text string.
Dim m As Match = r.Match(CURRENT_MAIL_BODY_ALL)
Dim oClearedBodyText = CURRENT_MAIL_BODY_ALL
Do While m.Success
oClearedBodyText = oClearedBodyText.Replace(m.Value, "")
'Dim g As Group = m.Groups(1)
'If g.ToString.StartsWith("&") = False Then
' TEMP_HTML_RESULTS.Add(g.ToString())
'End If
m = m.NextMatch()
Loop
Logger.Info($"Cleared bodytext is: {oClearedBodyText}")
CURRENT_MAIL_BODY_ALL = Trim(oClearedBodyText)
Catch ex As Exception
End Try
'If TEMP_HTML_RESULTS.Count = 0 Then
' Logger.Warn("HTML Recognition via Regex could not create a match within this mail - So the answer will interpreted as empty!")
'End If
End If
Try
'Dim oAllBodyParts As New BodyPartCollection()
'oAllBodyParts.Add(CURRENT_MAIL_MESSAGE.BodyParts)
'oAllBodyParts.Add(GetChildren(CURRENT_MAIL_MESSAGE.BodyParts))
'For Each bodyPart As BodyPart In oAllBodyParts
' If bodyPart.ContentType IsNot Nothing AndAlso bodyPart.ContentType.Type = "text" AndAlso bodyPart.ContentType.SubType = "plain" Then
' Logger.Debug(String.Format("BODY1-Text is....#{0}", bodyPart.Body))
' CURRENT_MAIL_BODY = bodyPart.Body
' ElseIf bodyPart.ContentType IsNot Nothing AndAlso bodyPart.ContentType.Type = "text" AndAlso bodyPart.ContentType.SubType = "html" Then
' Logger.Debug(String.Format("bodyhtml....#{0}", bodyPart.Body))
' If CURRENT_MAIL_BODY = "" Then
' CURRENT_MAIL_BODY = bodyPart.Body
' Logger.Debug(String.Format("bodyhtml....#{0}", bodyPart.Body))
' End If
' End If
'Next
CURRENT_MAIL_BODY = Trim(CURRENT_MAIL_BODY)
If CURRENT_MAIL_BODY = String.Empty Then
If CURRENT_MAIL_BODY_ALL = String.Empty Then
Logger.Warn("Mailbody is empty. Email can not be processed! - Please check the html-structure")
Logger.Info("EXCEPTION - Mailbody is empty.Email can not be processed! - Please check the html-structure")
MessageError = True
Return False
Else
Logger.Debug($"Length of Body is [{CURRENT_MAIL_BODY_ALL.Length}] - Body Text is [{CURRENT_MAIL_BODY_ALL}]")
End If
Dim oFirstindex = CURRENT_MAIL_BODY.IndexOf(Chr(13))
If IsNothing(oFirstindex) Then
oFirstindex = CURRENT_MAIL_BODY.IndexOf(Chr(10))
End If
Logger.Debug(String.Format("firstindex....[{0}]", oFirstindex))
Try
CURRENT_MAIL_BODY_Substr1 = CURRENT_MAIL_BODY.Substring(0, oFirstindex)
CURRENT_MAIL_BODY_Substr1 = RTrim(LTrim(CURRENT_MAIL_BODY_Substr1))
Catch ex As Exception
Logger.Warn("Error in Substring 144: " & ex.Message)
Logger.Warn("CURRENT_MAIL_BODY: " & CURRENT_MAIL_BODY)
Logger.Warn("oFirstindex: " & oFirstindex)
CURRENT_MAIL_BODY_Substr1 = ""
End Try
Logger.Debug(String.Format("MailBody-Substring:...[{0}]", CURRENT_MAIL_BODY_Substr1))
'now trying to get the text before Masterline
If WM_IDX_BODY_TEXT <> String.Empty And WM_IDX_BODY_SUBSTR_LENGTH <> 0 And oDTFunctionRegex.Rows.Count = 1 Then
Dim pattern As String = oDTFunctionRegex.Rows(0).Item("REGEX")
' Instantiate the regular expression object.
Dim r As Regex = New Regex(pattern, RegexOptions.Multiline)
' Match the regular expression pattern against a text string.
Dim m As Match = r.Match(CURRENT_MAIL_BODY)
If m.Success Then
If Not IsNothing(m.Value) Then
If m.Value.Length > WM_IDX_BODY_SUBSTR_LENGTH Then
Try
Logger.Debug($"Getting the Substring of body - Length: {WM_IDX_BODY_SUBSTR_LENGTH}...")
CURRENT_MAIL_BODY_Substr2 = m.Value.Substring(0, WM_IDX_BODY_SUBSTR_LENGTH)
Catch ex As Exception
Logger.Warn("Error in Substring 168: " & ex.Message)
Logger.Warn("m.Value: " & m.Value)
Logger.Warn("WM_IDX_BODY_SUBSTR_LENGTH: " & WM_IDX_BODY_SUBSTR_LENGTH.ToString)
CURRENT_MAIL_BODY_Substr2 = ""
End Try
Else
Logger.Info($"m.Value.Length < WM_IDX_BODY_SUBSTR_LENGTH, so simply m.Value will be taken...")
CURRENT_MAIL_BODY_Substr2 = m.Value
End If
End If
CURRENT_MAIL_BODY_ALL = CURRENT_MAIL_BODY_ALL.Replace(vbLf, "")
Dim oSplit = CURRENT_MAIL_BODY_ALL.Split(Environment.NewLine)
Dim oCount As Integer = 0
Dim oReadLength As Integer = 0
Dim oAnswer2 As String
For Each ostr As String In oSplit
ostr = ostr.Replace(vbCrLf, "")
If ostr = String.Empty Then
Continue For
End If
oCount += 1
If oCount = 1 Then
CURRENT_MAIL_BODY_ANSWER1 = ostr
Else
If oCount = 2 Then
CURRENT_MAIL_BODY_Substr2 = ostr
Else
If ((oReadLength + ostr.Length) >= WM_IDX_BODY_SUBSTR_LENGTH) Or ostr.StartsWith("##") Then
Exit For
End If
CURRENT_MAIL_BODY_Substr2 = CURRENT_MAIL_BODY_Substr2 & vbNewLine & ostr
End If
oReadLength += ostr.Length
End If
Next
Logger.Debug(String.Format("MailBody-Substring After RecognizeString:...[{0}]", CURRENT_MAIL_BODY_Substr2))
'Dim oFirstindex = CURRENT_MAIL_BODY_ALL.IndexOf(Chr(13))
'If IsNothing(oFirstindex) Then
' oFirstindex = CURRENT_MAIL_BODY_ALL.IndexOf(Chr(10))
'End If
'Logger.Debug(String.Format("firstindex....[{0}]", oFirstindex))
'If oFirstindex = -1 Then
' Logger.Warn("Could not find the first carriage-return in Mail-Body. Email can not be processed!")
' MessageError = True
' Return False
'End If
'If CURRENT_MAIL_BODY_ALL.StartsWith("<html") Then
' If TEMP_HTML_RESULTS.Count > 0 Then
' End If
'Else
' Try
' CURRENT_MAIL_BODY_ANSWER1 = CURRENT_MAIL_BODY_ALL.Substring(0, oFirstindex)
' CURRENT_MAIL_BODY_ANSWER1 = RTrim(LTrim(CURRENT_MAIL_BODY_ANSWER1))
' Catch ex As Exception
' Logger.Warn("Error in Substring 144: " & ex.Message)
' Logger.Warn("CURRENT_MAIL_BODY: " & CURRENT_MAIL_BODY_ALL)
' Logger.Warn("oFirstindex: " & oFirstindex)
' CURRENT_MAIL_BODY_ANSWER1 = ""
' End Try
'End If
Logger.Debug(String.Format("MailBody-ANSWER1:...[{0}]", CURRENT_MAIL_BODY_ANSWER1))
Logger.Debug(String.Format("MailBody-ANSWER2:...[{0}]", CURRENT_MAIL_BODY_Substr2))
'now trying to get the text before Masterline
'If WM_IDX_BODY_TEXT <> String.Empty And WM_IDX_BODY_SUBSTR_LENGTH <> 0 And oDTFunctionRegex.Rows.Count >= 1 Then
' If CURRENT_MAIL_BODY_ALL.StartsWith("<html") Then
' Dim oTempBodyString As String = ""
' oCount = 0
' For Each _oAnswer1 In TEMP_HTML_RESULTS
' If oCount = 0 Then
' oTempBodyString = _oAnswer1
' Else
' oTempBodyString &= vbNewLine & _oAnswer1
' End If
' oCount += 1
' Next
' CURRENT_MAIL_BODY_Substr2 = oTempBodyString
' Else
' Dim pattern As String = oDTFunctionRegex.Rows(0).Item("REGEX")
' ' Instantiate the regular expression object.
' Dim r As Regex = New Regex(pattern, RegexOptions.Multiline)
' ' Match the regular expression pattern against a text string.
' Dim m As Match = r.Match(CURRENT_MAIL_BODY_ALL)
' If m.Success Then
' If Not IsNothing(m.Value) Then
' If m.Value.Length > WM_IDX_BODY_SUBSTR_LENGTH Then
' Try
' Logger.Debug($"Getting the Substring of body - Length: {WM_IDX_BODY_SUBSTR_LENGTH}...")
' CURRENT_MAIL_BODY_Substr2 = m.Value.Substring(0, WM_IDX_BODY_SUBSTR_LENGTH)
' Catch ex As Exception
' Logger.Warn("Error in Substring 168: " & ex.Message)
' Logger.Warn("m.Value: " & m.Value)
' Logger.Warn("WM_IDX_BODY_SUBSTR_LENGTH: " & WM_IDX_BODY_SUBSTR_LENGTH.ToString)
' CURRENT_MAIL_BODY_Substr2 = ""
' End Try
' Else
' Logger.Info($"m.Value.Length [{m.Value.Length}] < WM_IDX_BODY_SUBSTR_LENGTH [{WM_IDX_BODY_SUBSTR_LENGTH}], so simply m.Value [{m.Value}] will be taken...")
' CURRENT_MAIL_BODY_Substr2 = m.Value
' End If
' End If
' End If
' Logger.Debug(String.Format("MailBody-Substring After RecognizeString:...[{0}]", CURRENT_MAIL_BODY_Substr2))
' End If
'End If
If CURRENT_MAIL_BODY_ANSWER1 = String.Empty Then
Logger.Warn("CURRENT_MAIL_BODY_ANSWER1 is String.Empty: So the answer will interpreted as empty!")
End If
Catch ex As Exception
Logger.Error(ex)
'clsLogger.Add("Unexpected Error in COPY2HDD: " & ex.Message & "MESSAGE_ID: " & CURRENT_MAIL_MESSAGE.MessageID, True)
@@ -351,8 +499,8 @@ Public Class clsWorkEmail
$"'{CURRENT_MAIL_MESSAGE.MessageID.Replace("<", "").Replace(">", "")}'," &
$"'{CURRENT_MAIL_MESSAGE.Subject}'," &
$"'{CURRENT_MAIL_MESSAGE.Date}'," &
$"'{CURRENT_MAIL_BODY}'," &
$"'{CURRENT_MAIL_BODY_Substr1}'," &
$"'{CURRENT_MAIL_BODY_ALL}'," &
$"'{CURRENT_MAIL_BODY_ANSWER1}'," &
$"'{CURRENT_MAIL_BODY_Substr2}')"
_Database.Execute_non_Query(ins)
@@ -366,8 +514,8 @@ Public Class clsWorkEmail
$"'{CURRENT_MAIL_MESSAGE.From.EmailAddress}'," &
$"'{CURRENT_MAIL_MESSAGE.Subject}'," &
$"'{CURRENT_MAIL_MESSAGE.Date}'," &
$"'{CURRENT_MAIL_BODY}'," &
$"'{CURRENT_MAIL_BODY_Substr1}'," &
$"'{CURRENT_MAIL_BODY_ALL}'," &
$"'{CURRENT_MAIL_BODY_ANSWER1}'," &
$"'{CURRENT_MAIL_BODY_Substr2}'," &
$"'{ATTMT1}')"
_firebird.ExecuteNonQuery(ins)
@@ -403,7 +551,7 @@ Public Class clsWorkEmail
KEYWORDS_SPLIT = POLL_KEYWORDS.Split(";")
For Each str As String In KEYWORDS_SPLIT
If CURRENT_MAIL_BODY_Substr1.ToUpper = str.ToUpper Then
If CURRENT_MAIL_BODY_ANSWER1.ToUpper = str.ToUpper Then
_worked_email = True
Logger.Info(String.Format("Found Keyword '{0}' in MessageBody", str))
Dim sql As String = String.Format("SELECT * FROM TBEMLP_POLL_INDEXING_STEPS WHERE STEP_ID = {0} AND ACTIVE = 1", POLL_STEP_GUID)
@@ -431,6 +579,7 @@ Public Class clsWorkEmail
IndexFile(WM_VECTOR_LOG, msg, False)
End If
'Now indexing the Body-Message Index
If CURRENT_MAIL_BODY_Substr2 <> String.Empty And WM_IDX_BODY_TEXT <> String.Empty Then
IndexFile(WM_IDX_BODY_TEXT, CURRENT_MAIL_BODY_Substr2, True)
End If
@@ -511,22 +660,22 @@ Public Class clsWorkEmail
End If
End Function
Private Function GET_DOC_INFO()
Private Function GET_WMDOC_INFO()
Try
Dim DOC_ID = REGEX_CHECK_DOC_ID(CURRENT_MAIL_SUBJECT)
If Not IsNothing(DOC_ID) Then
Dim DT_BASE_ATTR As DataTable = _Database.Return_DatatableCS("SELECT * FROM BaseAttributes WHERE dwDocID = " & DOC_ID, WM_CON_STRING)
If Not IsNothing(DT_BASE_ATTR) Then
If DT_BASE_ATTR.Rows.Count = 1 Then
CURRENT_DOC_ID = DOC_ID
Dim sql = String.Format("Select[dbo].[FNDD_GET_WINDREAM_FILE_PATH]({0},'{1}')", CURRENT_DOC_ID, WM_DRIVE)
CURRENT_DOC_PATH = _Database.Execute_Scalar(sql)
Logger.Debug("CURRENT_DOC_PATH: " & CURRENT_DOC_PATH)
Dim oDOC_ID = REGEX_CHECK_DOC_ID(CURRENT_MAIL_SUBJECT.Replace("10636", "133092").Replace("10644", "133092"))
If Not IsNothing(oDOC_ID) Then
Dim oDT_BASE_ATTR As DataTable = _Database.Return_DatatableCS("SELECT * FROM BaseAttributes WHERE dwDocID = " & oDOC_ID, WM_CON_STRING)
If Not IsNothing(oDT_BASE_ATTR) Then
If oDT_BASE_ATTR.Rows.Count = 1 Then
CURRENT_DOC_ID = oDOC_ID
Dim oSql = String.Format("Select[dbo].[FNDD_GET_WINDREAM_FILE_PATH]({0},'{1}')", CURRENT_DOC_ID, WM_DRIVE)
CURRENT_DOC_PATH = _Database.Execute_Scalar(oSql)
Logger.Debug("CURRENT_DOC_PATH is: " & CURRENT_DOC_PATH)
CURRENT_WM_DOC = Nothing
Dim WMDOC As WMObject
Dim oWMDOC As WMObject
Try
WMDOC = _windream.oSession.GetWMObjectByPath(WMEntity.WMEntityDocument, CURRENT_DOC_PATH.Substring(2))
CURRENT_WM_DOC = WMDOC
oWMDOC = _windream.oSession.GetWMObjectByPath(WMEntity.WMEntityDocument, CURRENT_DOC_PATH.Substring(2))
CURRENT_WM_DOC = oWMDOC
Return True
Catch ex As Exception
Logger.Warn("error while creating WMObject in (GET_DOC_INFO): " & ex.Message)
@@ -534,7 +683,7 @@ Public Class clsWorkEmail
End Try
Else
Logger.Warn("No record found for dwDocID " & DOC_ID)
Logger.Warn("No record found for dwDocID " & oDOC_ID)
Return False
End If