Compare commits

..

4 Commits

Author SHA1 Message Date
Jonathan Jenne
47a66e1220 Version 2.4.0.7 2021-07-06 16:46:39 +02:00
Jonathan Jenne
5c44668002 FileExists in DropTable: generate hash from filename for msg files 2021-07-06 16:45:32 +02:00
Jonathan Jenne
a0c725163a Decide_Filehandle: topmost MessageBox Fix 2021-07-06 16:41:10 +02:00
Jonathan Jenne
2ca5bd4c37 extractFromHeader: Make regex matching case insensitive 2021-07-06 16:40:17 +02:00
4 changed files with 38 additions and 23 deletions

View File

@@ -63,7 +63,7 @@ Public Class ClassEmailHeaderExtractor
End If End If
' einen Regulären Ausdruck laden ' einen Regulären Ausdruck laden
Dim strRegex As String = Regex Dim strRegex As String = Regex
Dim myRegex As New Regex(strRegex, RegexOptions.IgnorePatternWhitespace) Dim myRegex As New Regex(strRegex, RegexOptions.IgnorePatternWhitespace Or RegexOptions.IgnoreCase)
Dim strTargetString As String = messageHeaders.Trim Dim strTargetString As String = messageHeaders.Trim
' die Vorkommen im String auslesen ' die Vorkommen im String auslesen
For Each myMatch As Match In myRegex.Matches(strTargetString) For Each myMatch As Match In myRegex.Matches(strTargetString)

View File

@@ -1,5 +1,6 @@
Imports System.IO Imports System.IO
Imports System.Text.RegularExpressions Imports System.Text.RegularExpressions
Imports DevExpress.XtraEditors
Imports Independentsoft Imports Independentsoft
Public Class ClassFilehandle Public Class ClassFilehandle
@@ -16,31 +17,40 @@ Public Class ClassFilehandle
Dim r = New Regex(String.Format("[{0}]", Regex.Escape(regexSearch))) Dim r = New Regex(String.Format("[{0}]", Regex.Escape(regexSearch)))
Return r.Replace(Input, replacement) Return r.Replace(Input, replacement)
End Function End Function
Public Shared Function Decide_FileHandle(filename As String, handletype As String) Public Shared Function Decide_FileHandle(pFilename As String, pHandletype As String)
Try Try
If filename.EndsWith(".msg") Then If pFilename.EndsWith(".msg") Then
CURRENT_MESSAGEID = "" CURRENT_MESSAGEID = ""
Dim _msg As New Msg.Message(filename) Dim oMsg As New Msg.Message(pFilename)
If _msg.Attachments.Count > 0 Then If oMsg.Attachments.Count > 0 Then
Dim result As MsgBoxResult
Dim oTitle As String
Dim oMessage As String
If USER_LANGUAGE = "de-DE" Then If USER_LANGUAGE = "de-DE" Then
result = MessageBox.Show(New Form With {.TopMost = True}, "Achtung: Die Email enthält Anhänge!" & vbNewLine & "Wollen Sie die Anhänge separat indexieren und herauslösen?", "Nachfrage zur Indexierung:", MessageBoxButtons.YesNo, MessageBoxIcon.Question) oTitle = "Nachfrage zur Indexierung:"
oMessage = "Achtung: Die Email enthält Anhänge!" & vbNewLine & "Wollen Sie die Anhänge separat indexieren und herauslösen?"
Else Else
result = MessageBox.Show(New Form With {.TopMost = True}, "Attention: This Email contains Attachments!" & vbNewLine & "Do you want to extract the attachments and index them seperately?", "Question about Indexing:", MessageBoxButtons.YesNo, MessageBoxIcon.Question) oTitle = "Question about Indexing:"
oMessage = "Attention: This Email contains Attachments!" & vbNewLine & "Do you want to extract the attachments and index them seperately?"
End If End If
Dim oResult As DialogResult
If result = MsgBoxResult.Yes Then ' Weird hack to force messagebox to be topmost
If handletype.StartsWith("|FW") Then ' https://stackoverflow.com/questions/1220882/keep-messagebox-show-on-top-of-other-application-using-c-sharp
Return Email_Decay(filename, True) oResult = MessageBox.Show(oMessage, oTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
If oResult = MsgBoxResult.Yes Then
If pHandletype.StartsWith("|FW") Then
Return Email_Decay(pFilename, True)
Else Else
Return Email_Decay(filename) Return Email_Decay(pFilename)
End If End If
End If End If
End If End If
End If End If
If filename.ToUpper.EndsWith(".LNK") Then If pFilename.ToUpper.EndsWith(".LNK") Then
If USER_LANGUAGE = "de-DE" Then If USER_LANGUAGE = "de-DE" Then
MsgBox("Verknüpfungen können nicht abgelegt werden!", MsgBoxStyle.Critical, "Global Indexer") MsgBox("Verknüpfungen können nicht abgelegt werden!", MsgBoxStyle.Critical, "Global Indexer")
Else Else
@@ -49,7 +59,7 @@ Public Class ClassFilehandle
Return False Return False
End If End If
Return Insert_GI_File(filename, handletype) Return Insert_GI_File(pFilename, pHandletype)
Catch ex As Exception Catch ex As Exception
MsgBox("Unexpected Error in Decide_FileHandle: " & ex.Message, MsgBoxStyle.Critical) MsgBox("Unexpected Error in Decide_FileHandle: " & ex.Message, MsgBoxStyle.Critical)
Return False Return False

View File

@@ -1,21 +1,26 @@
Imports System.IO Imports System.IO
Public Class ClassIndexFunctions Public Class ClassIndexFunctions
Public Shared Function FileExistsinDropTable(Filename As String) As Date Public Shared Function FileExistsinDropTable(pFilename As String) As Date
Dim oSQL As String Dim oSQL As String
Dim oHash As String Dim oHash As String
Try Try
If Filename.Contains("'") Then If pFilename.Contains("'") Then
Filename = Filename.Replace("'", "''") pFilename = pFilename.Replace("'", "''")
End If End If
' If file cannot be accessed, checksum cannot be generated If pFilename.ToUpper.EndsWith(".MSG") Then
' In this case, the file should be treated as not yet existing ' MSG Files cannot be hashed based on filecontents, so we use the filename instead
oHash = FILESYSTEM.GetChecksum(Filename) oHash = FILESYSTEM.GetChecksumFromString(pFilename)
Else
' If file cannot be accessed, checksum cannot be generated
' In this case, the file should be treated as not yet existing
oHash = FILESYSTEM.GetChecksum(pFilename)
End If
If oHash Is Nothing Then If oHash Is Nothing Then
LOGGER.Warn("Checksum for file {0} could not be generated. Treating as new file.", Filename) LOGGER.Warn("Checksum for file {0} could not be generated. Treating as new file.", pFilename)
Return Nothing Return Nothing
End If End If

View File

@@ -15,7 +15,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("Digital Data")> <Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("Global Indexer")> <Assembly: AssemblyProduct("Global Indexer")>
<Assembly: AssemblyCopyright("Copyright © 2021")> <Assembly: AssemblyCopyright("Copyright © 2021")>
<Assembly: AssemblyTrademark("2406")> <Assembly: AssemblyTrademark("2407")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>
@@ -33,7 +33,7 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("2.4.0.6")> <Assembly: AssemblyVersion("2.4.0.7")>
<Assembly: AssemblyFileVersion("1.0.0.0")> <Assembly: AssemblyFileVersion("1.0.0.0")>
<Assembly: NeutralResourcesLanguageAttribute("")> <Assembly: NeutralResourcesLanguageAttribute("")>