Clean filename for temp files, centralize windream basepath

This commit is contained in:
Jonathan Jenne 2021-09-21 16:36:34 +02:00
parent ab2a0134f7
commit 9c0c31e141
11 changed files with 211 additions and 218 deletions

View File

@ -1,7 +1,7 @@
Imports System.Data.SqlClient Imports System.Data.SqlClient
Imports Oracle.ManagedDataAccess.Client Imports Oracle.ManagedDataAccess.Client
Imports DigitalData.Controls.LookupGrid Imports DigitalData.Controls.LookupGrid
Imports DigitalData.Modules.Language
Public Class ClassControls Public Class ClassControls
Private Property Form As frmIndex Private Property Form As frmIndex
@ -406,9 +406,9 @@ Public Class ClassControls
LOGGER.Debug("Found [{0}] depending controls for [{1}]", oDatatable.Rows.Count, Control.Name) LOGGER.Debug("Found [{0}] depending controls for [{1}]", oDatatable.Rows.Count, Control.Name)
For Each oRow As DataRow In oDatatable.Rows For Each oRow As DataRow In oDatatable.Rows
Dim oControlName As String = NotNull(oRow.Item("NAME"), "") Dim oControlName As String = Utils.NotNull(oRow.Item("NAME"), "")
Dim oConnectionId As Integer = NotNull(oRow.Item("CONNECTION_ID"), -1) Dim oConnectionId As Integer = Utils.NotNull(oRow.Item("CONNECTION_ID"), -1)
Dim oControlSql As String = NotNull(oRow.Item("SQL_RESULT"), "") Dim oControlSql As String = Utils.NotNull(oRow.Item("SQL_RESULT"), "")
If oConnectionId = -1 Or oControlSql = String.Empty Then If oConnectionId = -1 Or oControlSql = String.Empty Then
LOGGER.Warn("Missing SQL Query or ConnectionId for Control [{0}]! Continuing.", oControlName) LOGGER.Warn("Missing SQL Query or ConnectionId for Control [{0}]! Continuing.", oControlName)

View File

@ -4,34 +4,35 @@ Imports Microsoft.Office.Interop
Public Class ClassFileDrop Public Class ClassFileDrop
Public Shared files_dropped As String() 'Public Shared Property FilesDropped As String()
Public Shared Property FilesDropped As New List(Of String)
' Tobit David Drag Drop: https://www.david-forum.de/thread/12671-drag-and-drop-von-faxen-und-mails-in-net-anwendung/ ' Tobit David Drag Drop: https://www.david-forum.de/thread/12671-drag-and-drop-von-faxen-und-mails-in-net-anwendung/
'Private Declare Function DVEmlFromMailItem Lib "DvApi32" (ByVal oMailItem As MailItem, ByVal strFileName As String) As Long 'Private Declare Function DVEmlFromMailItem Lib "DvApi32" (ByVal oMailItem As MailItem, ByVal strFileName As String) As Long
Public Shared Function Drop_File(e As DragEventArgs) Public Shared Function Drop_File(e As DragEventArgs)
Try Try
LOGGER.Debug("Available Drop Formats:")
For Each oFormat As String In e.Data.GetFormats()
LOGGER.Debug(oFormat)
Next
LOGGER.Info("Drop_File") LOGGER.Info("Drop_File")
files_dropped = Nothing
FilesDropped.Clear()
If e.Data.GetDataPresent(DataFormats.FileDrop) Then If e.Data.GetDataPresent(DataFormats.FileDrop) Then
Dim MyFiles() As String Dim oFilesFromEvent() As String
Dim i As Integer Dim oIndex As Integer
' Assign the files to an array. ' Assign the files to an array.
MyFiles = e.Data.GetData(DataFormats.FileDrop) oFilesFromEvent = e.Data.GetData(DataFormats.FileDrop)
' Loop through the array and add the files to the list. ' Loop through the array and add the files to the list.
For i = 0 To MyFiles.Length - 1 For oIndex = 0 To oFilesFromEvent.Length - 1
LOGGER.Info("Simple FileDrop - File: " & MyFiles(i)) LOGGER.Info("Simple FileDrop - File: " & oFilesFromEvent(oIndex))
ReDim Preserve files_dropped(i) FilesDropped.Add("|DROPFROMFSYSTEM|" & oFilesFromEvent(oIndex))
files_dropped(i) = "|DROPFROMFSYSTEM|" & MyFiles(i)
'ReDim Preserve FilesDropped(oIndex)
'FilesDropped(oIndex) = "|DROPFROMFSYSTEM|" & oFilesFromEvent(oIndex)
' ListBox1.Items.Add(MyFiles(i)) ' ListBox1.Items.Add(MyFiles(i))
Next Next
Return True Return True
ElseIf (e.Data.GetDataPresent("FileGroupDescriptor")) AndAlso (e.Data.GetDataPresent("FileContents")) Then ElseIf (e.Data.GetDataPresent("FileGroupDescriptor")) AndAlso (e.Data.GetDataPresent("FileContents")) Then
'// the first step here is to get the stbFileName '// the first step here is to get the stbFileName
'// of the attachment and '// of the attachment and
@ -40,9 +41,9 @@ Public Class ClassFileDrop
'// '//
'// set up to obtain the aryFileGroupDescriptor '// set up to obtain the aryFileGroupDescriptor
'// and extract the file name '// and extract the file name
Dim stmInput As IO.Stream = CType(e.Data.GetData("FileGroupDescriptor"), IO.Stream) Dim oStream As IO.Stream = CType(e.Data.GetData("FileGroupDescriptor"), IO.Stream)
Dim aryFileGroupDescriptor(512) As Byte ' = new byte[512] Dim aryFileGroupDescriptor(512) As Byte ' = new byte[512]
stmInput.Read(aryFileGroupDescriptor, 0, 512) oStream.Read(aryFileGroupDescriptor, 0, 512)
'// used to build the stbFileName from the aryFileGroupDescriptor block '// used to build the stbFileName from the aryFileGroupDescriptor block
Dim stbFileName As System.Text.StringBuilder = New System.Text.StringBuilder("") Dim stbFileName As System.Text.StringBuilder = New System.Text.StringBuilder("")
'// this trick gets the stbFileName of the passed attached file '// this trick gets the stbFileName of the passed attached file
@ -51,13 +52,11 @@ Public Class ClassFileDrop
stbFileName.Append(Convert.ToChar(aryFileGroupDescriptor(intCnt), System.Globalization.CultureInfo.CreateSpecificCulture("de-DE"))) stbFileName.Append(Convert.ToChar(aryFileGroupDescriptor(intCnt), System.Globalization.CultureInfo.CreateSpecificCulture("de-DE")))
intCnt += 1 intCnt += 1
Loop Loop
stmInput.Close() oStream.Close()
'Sonderzeichen entfernen 'Sonderzeichen entfernen
Dim Tempfilename = DigitalData.Modules.Language.Utils.RemoveInvalidCharacters(stbFileName.ToString) Dim oTempFileName = DigitalData.Modules.Language.Utils.RemoveInvalidCharacters(stbFileName.ToString)
Dim anhaenge = e.Data.GetDataPresent("FileContents") Dim oAttachments = e.Data.GetDataPresent("FileContents")
'Dim path As String = "C:\VBProjekte\Dateien" Dim strOutFile As String = Path.Combine(Path.GetTempPath(), oTempFileName)
'// put the zip file into the temp directory
Dim strOutFile As String = Path.GetTempPath() & Tempfilename
'// create the full-path name '// create the full-path name
'// '//
'// Second step: we have the file name. '// Second step: we have the file name.
@ -65,13 +64,13 @@ Public Class ClassFileDrop
'// data for the attached file and copy it to disk so we work on it. '// data for the attached file and copy it to disk so we work on it.
'// '//
'// get the actual raw file into memory '// get the actual raw file into memory
Dim msInput As IO.MemoryStream = CType(e.Data.GetData("FileContents", True), IO.MemoryStream) 'This returns nothing for an Email Dim oMemoryStreamInput As IO.MemoryStream = CType(e.Data.GetData("FileContents", True), IO.MemoryStream) 'This returns nothing for an Email
If msInput Is Nothing = False Then If oMemoryStreamInput Is Nothing = False Then
'// allocate enough bytes to hold the raw date '// allocate enough bytes to hold the raw date
Dim aryFileBytes(CType(msInput.Length, Int32)) As Byte Dim aryFileBytes(CType(oMemoryStreamInput.Length, Int32)) As Byte
'// set starting position at first byte and read in the raw data '// set starting position at first byte and read in the raw data
msInput.Position = 0 oMemoryStreamInput.Position = 0
msInput.Read(aryFileBytes, 0, CType(msInput.Length, Int32)) oMemoryStreamInput.Read(aryFileBytes, 0, CType(oMemoryStreamInput.Length, Int32))
'// create a file and save the raw zip file to it '// create a file and save the raw zip file to it
Dim fsOutput As IO.FileStream = New IO.FileStream(strOutFile, IO.FileMode.Create) '; Dim fsOutput As IO.FileStream = New IO.FileStream(strOutFile, IO.FileMode.Create) ';
fsOutput.Write(aryFileBytes, 0, aryFileBytes.Length) fsOutput.Write(aryFileBytes, 0, aryFileBytes.Length)
@ -83,9 +82,12 @@ Public Class ClassFileDrop
Dim finTemp As IO.FileInfo = New IO.FileInfo(strOutFile) Dim finTemp As IO.FileInfo = New IO.FileInfo(strOutFile)
'// always good to make sure we actually created the file '// always good to make sure we actually created the file
If (finTemp.Exists = True) Then If (finTemp.Exists = True) Then
ReDim Preserve files_dropped(0)
files_dropped(0) = "|OUTLOOK_ATTACHMENT|" & strOutFile
LOGGER.Info("Drop an Attachment - File: " & strOutFile) LOGGER.Info("Drop an Attachment - File: " & strOutFile)
FilesDropped.Add("|OUTLOOK_ATTACHMENT|" & strOutFile)
'ReDim Preserve FilesDropped(0)
'FilesDropped(0) = "|OUTLOOK_ATTACHMENT|" & strOutFile
Return True Return True
Else Else
LOGGER.Info("Attachment File from Outlook could not be created") LOGGER.Info("Attachment File from Outlook could not be created")
@ -111,12 +113,6 @@ Public Class ClassFileDrop
If subj = "" Then If subj = "" Then
subj = "NO_SUBJECT" subj = "NO_SUBJECT"
End If End If
If subj.Contains("\") Then
subj = subj.Replace("\", "-")
End If
If subj.Contains("/") Then
subj = subj.Replace("/", "-")
End If
'Sonderzeichen entfernen 'Sonderzeichen entfernen
subj = DigitalData.Modules.Language.Utils.RemoveInvalidCharacters(subj) subj = DigitalData.Modules.Language.Utils.RemoveInvalidCharacters(subj)
@ -138,8 +134,10 @@ Public Class ClassFileDrop
"Weitere Informationen finden Sie im Log.", MsgBoxStyle.Critical, "Global Indexer") "Weitere Informationen finden Sie im Log.", MsgBoxStyle.Critical, "Global Indexer")
End Try End Try
ReDim Preserve files_dropped(i) FilesDropped.Add("|OUTLOOK_MESSAGE|" & oFilename)
files_dropped(i) = "|OUTLOOK_MESSAGE|" & oFilename
'ReDim Preserve FilesDropped(i)
'FilesDropped(i) = "|OUTLOOK_MESSAGE|" & oFilename
Next Next

View File

@ -6,11 +6,25 @@ Imports DigitalData.Modules.Language
Imports Limilabs.Mail Imports Limilabs.Mail
Public Class ClassFilehandle Public Class ClassFilehandle
Public Shared Function Decide_FileHandle(pFilename As String, pHandletype As String) Public Shared Function Decide_FileHandle(pFilepath As String, pHandletype As String)
Try Try
If pFilename.ToUpper.EndsWith(".MSG") Or pFilename.ToUpper.EndsWith(".EML") Then 'TODO: Before doing anything, clean the filename
Dim oFilename = IO.Path.GetFileName(pFilepath)
Dim oCleanFileName = Utils.RemoveInvalidCharacters(oFilename)
Dim oTempDirectory = IO.Path.GetTempPath()
Dim oTempFilePath = IO.Path.Combine(oTempDirectory, oCleanFileName)
Try
TEMP_FILES.Add(oTempFilePath)
IO.File.Copy(pFilepath, oTempFilePath, True)
Catch ex As Exception
LOGGER.Error(ex)
Throw ex
End Try
If oTempFilePath.ToUpper.EndsWith(".MSG") Or oTempFilePath.ToUpper.EndsWith(".EML") Then
CURRENT_MESSAGEID = "" CURRENT_MESSAGEID = ""
Dim oMail As IMail = EMAIL.Load_Email(pFilename) Dim oMail As IMail = EMAIL.Load_Email(oTempFilePath)
If oMail.Attachments.Count > 0 Then If oMail.Attachments.Count > 0 Then
Dim oTitle As String Dim oTitle As String
Dim oMessage As String Dim oMessage As String
@ -28,14 +42,15 @@ Public Class ClassFilehandle
' https://stackoverflow.com/questions/1220882/keep-messagebox-show-on-top-of-other-application-using-c-sharp ' https://stackoverflow.com/questions/1220882/keep-messagebox-show-on-top-of-other-application-using-c-sharp
oResult = MessageBox.Show(oMessage, oTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly) oResult = MessageBox.Show(oMessage, oTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
If oResult = MsgBoxResult.Yes Then If oResult = MsgBoxResult.Yes Then
Dim oIsFolderWatch = pHandletype.StartsWith("|FW") Dim oIsFolderWatch = pHandletype.StartsWith("|FW")
Return Save_EmailAndAttachmentsToDisk(pFilename, oIsFolderWatch) Return Save_EmailAndAttachmentsToDisk(oTempFilePath, oIsFolderWatch)
End If End If
End If End If
End If End If
If pFilename.ToUpper.EndsWith(".LNK") Then If oTempFilePath.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
@ -44,7 +59,7 @@ Public Class ClassFilehandle
Return False Return False
End If End If
Return Insert_GI_File(pFilename, pHandletype) Return Insert_GI_File(oTempFilePath, 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

@ -79,7 +79,7 @@ Public Class ClassInit
Else Else
If IDB_ACTIVE = False Then If IDB_ACTIVE = False Then
Try Try
WINDREAM = New Windream(LOGCONFIG, False, WMDrive, "\\windream\objects", True, "", "", "", "") WINDREAM = New Windream(LOGCONFIG, False, WMDrive, WINDREAM_BASEPATH, True, "", "", "", "")
If Not IsNothing(WINDREAM) Then If Not IsNothing(WINDREAM) Then
If WINDREAM.SessionLoggedin = True Then If WINDREAM.SessionLoggedin = True Then
LOGGER.Debug("windream initialisiert") LOGGER.Debug("windream initialisiert")

View File

@ -1,6 +1,7 @@
Imports System.Text.RegularExpressions Imports System.Text.RegularExpressions
Imports DevExpress.XtraEditors Imports DevExpress.XtraEditors
Imports DigitalData.Controls.LookupGrid Imports DigitalData.Controls.LookupGrid
Imports DigitalData.Modules.Language
Imports DigitalData.GUIs.GlobalIndexer Imports DigitalData.GUIs.GlobalIndexer
Imports WINDREAMLib Imports WINDREAMLib
@ -239,7 +240,7 @@ Public Class ClassPatterns
LOGGER.Warn("Lookup Control with [{0}] is not supported!", oFoundType) LOGGER.Warn("Lookup Control with [{0}] is not supported!", oFoundType)
End Select End Select
Else Else
oValue = NotNull(oLookupControl.Properties.SelectedValues.Item(0), "") oValue = Utils.NotNull(oLookupControl.Properties.SelectedValues.Item(0), "")
End If End If
Catch ex As Exception Catch ex As Exception
LOGGER.Error(ex) LOGGER.Error(ex)

View File

@ -385,7 +385,6 @@
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="ModuleCURRENT.vb" /> <Compile Include="ModuleCURRENT.vb" />
<Compile Include="ModuleHelpers.vb" />
<Compile Include="ModuleRuntime.vb" /> <Compile Include="ModuleRuntime.vb" />
<Compile Include="ModuleUserSavings.vb" /> <Compile Include="ModuleUserSavings.vb" />
<Compile Include="ModuleWindowHandles.vb" /> <Compile Include="ModuleWindowHandles.vb" />

View File

@ -4,90 +4,83 @@ Imports DigitalData.Modules.Filesystem
Imports DigitalData.Modules.Messaging Imports DigitalData.Modules.Messaging
Module ModuleCURRENT Module ModuleCURRENT
Public ERROR_STATE As String Public Property TEMP_FILES As List(Of String) = New List(Of String)
Public START_INCOMPLETE As Boolean = False
Public CURRENT_FILENAME As String
Public CURRENT_NEWFILENAME As String
Public CURRENT_WORKFILE_GUID As Integer
Public CURRENT_WORKFILE_HASH As String
Public CURRENT_WORKFILE As String
Public CURR_WORKFILE_EXTENSION As String
Public CONFIG As ConfigManager(Of ClassConfig) Public Property ERROR_STATE As String
Public LOGCONFIG As LogConfig Public Property START_INCOMPLETE As Boolean = False
Public LOGGER As Logger Public Property CURRENT_FILENAME As String
Public FILESYSTEM As File Public Property CURRENT_NEWFILENAME As String
Public EMAIL As Email2 Public Property CURRENT_WORKFILE_GUID As Integer
Public Property CURRENT_WORKFILE_HASH As String
Public Property CURRENT_WORKFILE As String
Public Property CURR_WORKFILE_EXTENSION As String
Public CURRENT_DOKART_ID As Integer Public Property CONFIG As ConfigManager(Of ClassConfig)
Public CURRENT_DOKART_DUPLICATE_HANDLING As String = "Default" Public Property LOGCONFIG As LogConfig
Public CURRENT_LASTDOKART As String = "" Public Property LOGGER As Logger
Public CURRENT_INDEXMAN As Integer Public Property FILESYSTEM As File
Public CURRENT_INDEXAUTO As Integer Public Property EMAIL As Email2
Public CURRENT_SQL_CONFIG As String
Public VERSION_DELIMITER As String Public Property CURRENT_DOKART_ID As Integer
Public FILE_DELIMITER As String Public Property CURRENT_DOKART_DUPLICATE_HANDLING As String = "Default"
Public CURRENT_MESSAGEID As String Public Property CURRENT_LASTDOKART As String = ""
Public CURRENT_MESSAGEDATE As String Public Property CURRENT_INDEXMAN As Integer
Public CURRENT_MESSAGESUBJECT As String Public Property CURRENT_INDEXAUTO As Integer
Public CURRENT_ISATTACHMENT As Boolean = False
Public USER_ID Public Property VERSION_DELIMITER As String
Public USER_IN_MODULE As Boolean = False Public Property FILE_DELIMITER As String
Public USER_IS_ADMIN As Boolean = False Public Property CURRENT_MESSAGEID As String
Public Property CURRENT_MESSAGEDATE As String
Public Property CURRENT_MESSAGESUBJECT As String
Public Property CURRENT_ISATTACHMENT As Boolean = False
Public USER_SHORTNAME As String = "" Public Property USER_ID
Public USER_PRENAME As String = "" Public Property USER_IN_MODULE As Boolean = False
Public USER_SURNAME As String = "" Public Property USER_IS_ADMIN As Boolean = False
Public USER_EMAIL As String = ""
Public USER_LANGUAGE As String = "DE"
Public USER_USERNAME As String = ""
Public USERCOUNT_LOGGED_IN As Integer = 0
Public CURRENT_FOLDERWATCH As String = "" Public Property USER_SHORTNAME As String = ""
Public CURRENT_SCAN_FOLDERWATCH As String = "" Public Property USER_PRENAME As String = ""
Public Property USER_SURNAME As String = ""
Public Property USER_EMAIL As String = ""
Public Property USER_LANGUAGE As String = "DE"
Public Property USER_USERNAME As String = ""
Public Property USERCOUNT_LOGGED_IN As Integer = 0
Public FWFunction_STARTED As Boolean = False Public Property CURRENT_FOLDERWATCH As String = ""
Public Property CURRENT_SCAN_FOLDERWATCH As String = ""
Public CURR_DOKART_WD_DIRECT As Boolean = False Public Property FWFunction_STARTED As Boolean = False
Public CURR_DOKART_OBJECTTYPE As String
Public CURRENT_WD_TEMPSEARCH As String = ""
Public LICENSE_EXPIRED As Boolean = False Public Property CURR_DOKART_WD_DIRECT As Boolean = False
Public LICENSE_COUNT As Integer = 0 Public Property CURR_DOKART_OBJECTTYPE As String
Public LICENSE_DOCTYPE_COUNT As Integer = 0
Public DOCTYPE_COUNT_ACTUAL As Integer = 0
Public LicenseHotKey As Integer = 0
Public CURRENT_HTML_DOC As String Public Property LICENSE_EXPIRED As Boolean = False
Public Property LICENSE_COUNT As Integer = 0
Public Property LICENSE_DOCTYPE_COUNT As Integer = 0
Public Property DOCTYPE_COUNT_ACTUAL As Integer = 0
Public Property LicenseHotKey As Integer = 0
Public INDEXING_ACTIVE As Boolean = False Public Property INDEXING_ACTIVE As Boolean = False
Public MULTIINDEXING_ACTIVE As Boolean = False Public Property MULTIINDEXING_ACTIVE As Boolean = False
Public ABORT_INDEXING As Boolean = False Public Property ABORT_INDEXING As Boolean = False
Public DTACTUAL_FILES As DataTable Public Property DTACTUAL_FILES As DataTable
Public DTEXCLUDE_FILES As DataTable Public Property DTEXCLUDE_FILES As DataTable
Public DTTBGI_REGEX_DOCTYPE As DataTable Public Property DTTBGI_REGEX_DOCTYPE As DataTable
Public CURRENT_SQLRESULT As String Public Property CURRENT_SQLRESULT As String
Public DTSQL_RESULT As DataTable Public Property DTSQL_RESULT As DataTable
Public TEMP_FILES As List(Of String) = New List(Of String)
Public CURRENT_FOCUSES_WINDOWNAME As String Public Property LANGUAGE_CHANGED As Boolean = False
Public Property CURR_MISSING_PATTERN_NAME As String
Public Property CURR_MISSING_SEARCH_STRING As String
Public Property CURR_MISSING_MANUAL_VALUE As String
Public Property CURR_DELETE_ORIGIN As Boolean = False
Public Property CURRENT_DT_REGEX As DataTable
Public Property REGEX_CLEAN_FILENAME As String = "[?*^""<>|]"
Public Property CURRENT_DROPTYPE
Public LANGUAGE_CHANGED As Boolean = False Public Property VIEWER_LICENSE As String = ""
Public CURR_MISSING_PATTERN_NAME As String
Public CURR_MISSING_SEARCH_STRING As String
Public CURR_MISSING_MANUAL_VALUE As String
Public CURR_DELETE_ORIGIN As Boolean = False
Public CURRENT_DT_REGEX As DataTable
Public REGEX_CLEAN_FILENAME As String = "[?*^""<>|]"
Public CURRENT_DROPTYPE
Public VIEWER_LICENSE As String = ""
Public INDEX_FORM_LOADED As Boolean
End Module End Module

View File

@ -1,15 +0,0 @@
Module ModuleHelpers
''' <summary>
''' Überprüft einen Wert auf verschiedene Arten von "Null" und gibt einen Standard-Wert zurück, wenn der Wert "Null" ist.
''' </summary>
''' <param name="value">Der zu überprüfende Wert</param>
''' <param name="defaultValue">Der Standard Wert</param>
''' <returns>value oder wenn dieser "Null" ist, defaultValue</returns>
Public Function NotNull(Of T)(ByVal value As T, ByVal defaultValue As T) As T
If IsNothing(value) OrElse String.IsNullOrEmpty(value.ToString) OrElse IsDBNull(value) Then
Return defaultValue
Else
Return value
End If
End Function
End Module

View File

@ -5,6 +5,7 @@ Module ModuleRuntime
'Dim ConfigPath As String = Path.Combine(Application.UserAppDataPath(), "UserConfig.xml") 'Dim ConfigPath As String = Path.Combine(Application.UserAppDataPath(), "UserConfig.xml")
Public Const USER_CONFIG_FILE = "UserConfig.xml" Public Const USER_CONFIG_FILE = "UserConfig.xml"
Public Const COMPUTER_CONFIG_FILE = "ComputerConfig.xml" Public Const COMPUTER_CONFIG_FILE = "ComputerConfig.xml"
Public Const WINDREAM_BASEPATH = "\\windream\objects"
Public MyConnectionString As String = "" Public MyConnectionString As String = ""
Public LogErrorsOnly As Boolean = True Public LogErrorsOnly As Boolean = True
@ -23,5 +24,5 @@ Module ModuleRuntime
Public IDB_DOC_ID As Int64 Public IDB_DOC_ID As Int64
Public IDB_LOG_INDEX As String Public IDB_LOG_INDEX As String
Public WINDREAM As Windream Public Property WINDREAM As Windream
End Module End Module

View File

@ -5,6 +5,7 @@ Imports System.Security.AccessControl
Imports System.Security.Principal Imports System.Security.Principal
Imports System.DirectoryServices Imports System.DirectoryServices
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Language
Imports DigitalData.Controls.LookupGrid Imports DigitalData.Controls.LookupGrid
Imports DigitalData.GUIs.GlobalIndexer Imports DigitalData.GUIs.GlobalIndexer
Imports DevExpress.XtraEditors.Controls Imports DevExpress.XtraEditors.Controls
@ -538,7 +539,7 @@ Public Class frmIndex
CURR_WORKFILE_EXTENSION = extension CURR_WORKFILE_EXTENSION = extension
oRAWZielordner = WINDREAM.GetNormalizedPath(DT.Rows(0).Item("ZIEL_PFAD")) oRAWZielordner = WINDREAM.GetNormalizedPath(DT.Rows(0).Item("ZIEL_PFAD"))
oRAWZielordner = Path.Combine("\\windream\objects", oRAWZielordner) oRAWZielordner = Path.Combine(WINDREAM_BASEPATH, oRAWZielordner)
'#### '####
' Regulären Ausdruck zum Auslesen der Indexe definieren ' Regulären Ausdruck zum Auslesen der Indexe definieren
@ -835,7 +836,7 @@ Public Class frmIndex
End If End If
Next Next
End If End If
If DropType = "|OUTLOOK_MESSAGE|" Or DropType = "|FW_MSGONLY|" Or DropType = "|MSGONLY|" Or CURRENT_NEWFILENAME.ToUpper.EndsWith(".msg") Or CURRENT_NEWFILENAME.ToUpper.EndsWith(".eml") Then If DropType = "|OUTLOOK_MESSAGE|" Or DropType = "|FW_MSGONLY|" Or DropType = "|MSGONLY|" Or CURRENT_NEWFILENAME.ToUpper.EndsWith(".MSG") Or CURRENT_NEWFILENAME.ToUpper.EndsWith(".EML") Then
indexierung_erfolgreich = SetEmailIndicies(pIndexAttachment:=False) indexierung_erfolgreich = SetEmailIndicies(pIndexAttachment:=False)
If indexierung_erfolgreich = False Then If indexierung_erfolgreich = False Then
MsgBox("Error in SetEmailIndices - See log", MsgBoxStyle.Critical) MsgBox("Error in SetEmailIndices - See log", MsgBoxStyle.Critical)
@ -894,7 +895,7 @@ Public Class frmIndex
' If file is an attachment, rely on the previously extracted value ' If file is an attachment, rely on the previously extracted value
If pIndexAttachment = False Then If pIndexAttachment = False Then
Dim oMsgFilePath As String = Path.Combine("\\windream\objects", CURRENT_NEWFILENAME) Dim oMsgFilePath As String = Path.Combine(WINDREAM_BASEPATH, CURRENT_NEWFILENAME)
Dim oMail As IMail = EMAIL.Load_Email(oMsgFilePath) Dim oMail As IMail = EMAIL.Load_Email(oMsgFilePath)
Dim oMessageId As String = oMail.MessageID Dim oMessageId As String = oMail.MessageID
@ -965,7 +966,7 @@ Public Class frmIndex
' Dim _step As String = "1" ' Dim _step As String = "1"
' Try ' Try
' Dim oTempPath As String = Path.Combine("\\windream\objects", CURRENT_NEWFILENAME) ' Dim oTempPath As String = Path.Combine(WINDREAM_BASEPATH, CURRENT_NEWFILENAME)
' Dim msg As Msg.Message = New Msg.Message(oTempPath) ' Dim msg As Msg.Message = New Msg.Message(oTempPath)
' Dim msgDisplayTo = msg.DisplayTo ' Dim msgDisplayTo = msg.DisplayTo
' Dim msgInternetAccountName = msg.InternetAccountName ' Dim msgInternetAccountName = msg.InternetAccountName
@ -1349,7 +1350,7 @@ Public Class frmIndex
End If End If
Dim oStreamSuccessful = WINDREAM.NewFileStream(CURRENT_WORKFILE, CURRENT_NEWFILENAME) Dim oStreamSuccessful = WINDREAM.NewFileStream(CURRENT_WORKFILE, CURRENT_NEWFILENAME)
Dim oTempPath As String = Path.Combine("\\windream\objects", CURRENT_NEWFILENAME) Dim oTempPath As String = Path.Combine(WINDREAM_BASEPATH, CURRENT_NEWFILENAME)
_Logger.Debug("Checks for file [{0}]", oTempPath) _Logger.Debug("Checks for file [{0}]", oTempPath)
_Logger.Debug("File streamed to Windream: {0}", oStreamSuccessful) _Logger.Debug("File streamed to Windream: {0}", oStreamSuccessful)
@ -1835,7 +1836,7 @@ Public Class frmIndex
Dim AddNewItems As Boolean = oRow.Item("VKT_ADD_ITEM") Dim AddNewItems As Boolean = oRow.Item("VKT_ADD_ITEM")
Dim PreventDuplicates As Boolean = oRow.Item("VKT_PREVENT_MULTIPLE_VALUES") Dim PreventDuplicates As Boolean = oRow.Item("VKT_PREVENT_MULTIPLE_VALUES")
Dim oControlName As String = oRow.Item("NAME") Dim oControlName As String = oRow.Item("NAME")
Dim oConnectionId = NotNull(oRow.Item("CONNECTION_ID"), 0) Dim oConnectionId = Utils.NotNull(oRow.Item("CONNECTION_ID"), 0)
Dim oSQLSuggestion = oRow.Item("SUGGESTION") Dim oSQLSuggestion = oRow.Item("SUGGESTION")
Dim oSQLResult = oRow.Item("SQL_RESULT") Dim oSQLResult = oRow.Item("SQL_RESULT")
@ -1961,9 +1962,9 @@ Public Class frmIndex
LOGGER.Debug("Found [{0}] depending controls for [{1}]", oDatatable.Rows.Count, Control.Name) LOGGER.Debug("Found [{0}] depending controls for [{1}]", oDatatable.Rows.Count, Control.Name)
For Each oRow As DataRow In oDatatable.Rows For Each oRow As DataRow In oDatatable.Rows
Dim oControlName As String = NotNull(oRow.Item("NAME"), "") Dim oControlName As String = Utils.NotNull(oRow.Item("NAME"), "")
Dim oConnectionId As Integer = NotNull(oRow.Item("CONNECTION_ID"), -1) Dim oConnectionId As Integer = Utils.NotNull(oRow.Item("CONNECTION_ID"), -1)
Dim oControlSql As String = NotNull(oRow.Item("SQL_RESULT"), "") Dim oControlSql As String = Utils.NotNull(oRow.Item("SQL_RESULT"), "")
If oConnectionId = -1 Or oControlSql = String.Empty Then If oConnectionId = -1 Or oControlSql = String.Empty Then
LOGGER.Warn("Missing SQL Query or ConnectionId for Control [{0}]! Continuing.", oControlName) LOGGER.Warn("Missing SQL Query or ConnectionId for Control [{0}]! Continuing.", oControlName)
@ -2716,6 +2717,7 @@ Public Class frmIndex
End Sub End Sub
Private Sub SimpleButton1_Click(sender As Object, e As EventArgs) Handles btnOK.Click Private Sub SimpleButton1_Click(sender As Object, e As EventArgs) Handles btnOK.Click
Try
ClearError() ClearError()
ClearNotice() ClearNotice()
@ -2736,7 +2738,7 @@ Public Class frmIndex
For Each filerow As DataRow In DTFiles2Work.Rows For Each filerow As DataRow In DTFiles2Work.Rows
CURRENT_WORKFILE_GUID = filerow.Item("GUID") CURRENT_WORKFILE_GUID = filerow.Item("GUID")
CURRENT_WORKFILE = filerow.Item("FILENAME2WORK") CURRENT_WORKFILE = filerow.Item("FILENAME2WORK")
CURRENT_WORKFILE_HASH = NotNull(filerow.Item("FILE_HASH"), "") CURRENT_WORKFILE_HASH = Utils.NotNull(filerow.Item("FILE_HASH"), "")
DropType = filerow.Item("HANDLE_TYPE") DropType = filerow.Item("HANDLE_TYPE")
If WORK_FILE() = False Then If WORK_FILE() = False Then
@ -2783,7 +2785,15 @@ Public Class frmIndex
Clear_Tempfiles() Clear_Tempfiles()
EMAIL.Clear_TempFiles() EMAIL.Clear_TempFiles()
Catch ex As Exception
MsgBox("Uncaught error while indexing: " & vbNewLine & ex.Message, MsgBoxStyle.Critical, Text)
' Clear all temp files after indexing
Clear_Tempfiles()
EMAIL.Clear_TempFiles()
Finally
Me.Cursor = Cursors.Default Me.Cursor = Cursors.Default
End Try
End Sub End Sub
Private Sub Clear_Tempfiles() Private Sub Clear_Tempfiles()

View File

@ -5,6 +5,7 @@ Imports System.Text
Imports System.Globalization Imports System.Globalization
Imports System.Threading Imports System.Threading
Imports System.Runtime.InteropServices Imports System.Runtime.InteropServices
Imports DigitalData.Modules.Language
Public Class frmStart Public Class frmStart
Public _lizenzManager As ClassLicenseManager Public _lizenzManager As ClassLicenseManager
@ -160,7 +161,7 @@ Public Class frmStart
Try Try
ClassDatabase.Execute_non_Query($"DELETE FROM TBGI_FILES_USER WHERE WORKED = 1 AND UPPER(USER@WORK) = UPPER('{Environment.UserName}')") ClassDatabase.Execute_non_Query($"DELETE FROM TBGI_FILES_USER WHERE WORKED = 1 AND UPPER(USER@WORK) = UPPER('{Environment.UserName}')")
For Each oFiledropString As String In ClassFileDrop.files_dropped For Each oFiledropString As String In ClassFileDrop.FilesDropped
If oFiledropString IsNot Nothing Then If oFiledropString IsNot Nothing Then
LOGGER.Info(">> Check Drop-File: " & oFiledropString.ToString) LOGGER.Info(">> Check Drop-File: " & oFiledropString.ToString)
Dim oLastPipe = oFiledropString.LastIndexOf("|") Dim oLastPipe = oFiledropString.LastIndexOf("|")
@ -211,11 +212,13 @@ Public Class frmStart
CURRENT_FILENAME = Filerow.Item("FILENAME2WORK") CURRENT_FILENAME = Filerow.Item("FILENAME2WORK")
CURRENT_WORKFILE_GUID = Filerow.Item(0) CURRENT_WORKFILE_GUID = Filerow.Item(0)
CURRENT_WORKFILE = Filerow.Item("FILENAME2WORK") CURRENT_WORKFILE = Filerow.Item("FILENAME2WORK")
CURRENT_WORKFILE_HASH = NotNull(Filerow.Item("FILE_HASH"), "") CURRENT_WORKFILE_HASH = Utils.NotNull(Filerow.Item("FILE_HASH"), "")
LOGGER.Info(">> CURRENT_WORKFILE: " & CURRENT_WORKFILE) LOGGER.Info(">> CURRENT_WORKFILE: " & CURRENT_WORKFILE)
If File.Exists(CURRENT_WORKFILE) = True And DTACTUAL_FILES.Rows.Count > 0 Then If File.Exists(CURRENT_WORKFILE) = True And DTACTUAL_FILES.Rows.Count > 0 Then
Open_IndexDialog() Open_IndexDialog()
Else
Throw New FileNotFoundException("Dropped file does not exist anymore!")
End If End If
' If multi-indexing is active, all files have been indexed by now, so we can leave the loop ' If multi-indexing is active, all files have been indexed by now, so we can leave the loop
@ -254,17 +257,6 @@ Public Class frmStart
MsgBox("Unexpected Error in Closing Application: " & vbNewLine & ex.Message, MsgBoxStyle.Critical) MsgBox("Unexpected Error in Closing Application: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try End Try
EMAIL.Clear_TempFiles()
'TempDateien löschen
For Each oFile In TEMP_FILES
Try
System.IO.File.Delete(oFile)
Catch ex As Exception
LOGGER.Error(ex)
End Try
Next
Try Try
IndexForm.DisposeViewer() IndexForm.DisposeViewer()
IndexForm.Dispose() IndexForm.Dispose()
@ -613,14 +605,13 @@ Public Class frmStart
} }
If oOpenFileDialog.ShowDialog() = DialogResult.OK Then If oOpenFileDialog.ShowDialog() = DialogResult.OK Then
Dim i As Integer = 0 ClassFileDrop.FilesDropped.Clear()
ClassFileDrop.files_dropped = Nothing
For Each oFileName In oOpenFileDialog.FileNames For Each oFileName In oOpenFileDialog.FileNames
ReDim Preserve ClassFileDrop.files_dropped(i)
LOGGER.Info(">> Chosen File: " & oFileName) LOGGER.Info(">> Chosen File: " & oFileName)
ClassFileDrop.files_dropped(i) = "|DROPFROMFSYSTEM|" & oFileName ClassFileDrop.FilesDropped.Add("|DROPFROMFSYSTEM|" & oFileName)
i += 1
Next Next
TimerCheckDroppedFiles.Start() TimerCheckDroppedFiles.Start()
End If End If
Catch ex As Exception Catch ex As Exception