This commit is contained in:
Digital Data - Marlon Schreiber
2018-07-12 16:07:47 +02:00
9 changed files with 438 additions and 292 deletions

View File

@@ -486,68 +486,79 @@ Public Class frmStart
Else
tslblFW.Visible = False
End If
If FWSCAN_started = True Then
If LogErrorsOnly = False Then ClassLogger.Add(">> FWSCAN started - Checking file:" & CURRENT_SCAN_FOLDERWATCH, False)
Dim fileEntries As String() = Directory.GetFiles(CURRENT_SCAN_FOLDERWATCH)
' Process the list of files found in the directory.
Dim fileName As String
For Each fileName In fileEntries
If LogErrorsOnly = False Then ClassLogger.Add(">> Scanfolder after startup: Checking file:" & fileName, False)
For Each row As DataRow In DTEXCLUDE_FILES.Rows
Dim content As String = row.Item(0).ToString.ToLower
If fileName.ToLower.Contains(content) Then
Exit Sub
End If
Next
Dim handleType As String
If fileName.ToLower.EndsWith(".msg") Then
handleType = "|FW_OUTLOOK_MESSAGE|"
Else
handleType = "|FW_SIMPLEINDEXER|"
End If
'Die Datei übergeben
If LogErrorsOnly = False Then ClassLogger.Add(">> Adding file from Scanfolder after startup:" & fileName, False)
If ClassIndexFunctions.FileExistsinDropTable(fileName) = False Then
ClassFilehandle.Decide_FileHandle(fileName, handleType)
Else
ClassLogger.Add(">> Scanfolder Startup: File already exists:" & fileName, False)
End If
Next fileName
Else
If LogErrorsOnly = False Then ClassLogger.Add(">> FWSCAN not started", False)
End If
If FW_started = True Then
If LogErrorsOnly = False Then ClassLogger.Add(">> FW_started started - Checking file:" & CURRENT_FOLDERWATCH, False)
Dim fileEntries As String() = Directory.GetFiles(CURRENT_FOLDERWATCH)
' Process the list of files found in the directory.
Dim fileName As String
For Each fileName In fileEntries
If LogErrorsOnly = False Then ClassLogger.Add(">> Folderwach after startup: Checking file:" & fileName, False)
For Each row As DataRow In DTEXCLUDE_FILES.Rows
Dim content As String = row.Item(0).ToString.ToLower
If fileName.ToLower.Contains(content) Then
Exit Sub
Try
If FWSCAN_started = True Then
If LogErrorsOnly = False Then ClassLogger.Add(">> FWSCAN started - Checking file:" & CURRENT_SCAN_FOLDERWATCH, False)
Dim fileEntries As String() = Directory.GetFiles(CURRENT_SCAN_FOLDERWATCH)
' Process the list of files found in the directory.
Dim fileName As String
For Each fileName In fileEntries
If LogErrorsOnly = False Then ClassLogger.Add(">> Scanfolder after startup: Checking file:" & fileName, False)
For Each row As DataRow In DTEXCLUDE_FILES.Rows
Dim content As String = row.Item(0).ToString.ToLower
If fileName.ToLower.Contains(content) Then
Exit Sub
End If
Next
Dim handleType As String
If fileName.ToLower.EndsWith(".msg") Then
handleType = "|FW_OUTLOOK_MESSAGE|"
Else
handleType = "|FW_SIMPLEINDEXER|"
End If
Next
Dim handleType As String
If fileName.ToLower.EndsWith(".msg") Then
handleType = "|FW_OUTLOOK_MESSAGE|"
Else
handleType = "|FW_SIMPLEINDEXER|"
End If
'Die Datei übergeben
If LogErrorsOnly = False Then ClassLogger.Add(">> Adding file from Folderwatch after startup:" & fileName, False)
If ClassIndexFunctions.FileExistsinDropTable(fileName) = False Then
ClassFilehandle.Decide_FileHandle(fileName, handleType)
Else
ClassLogger.Add(">> Folderwatch Startup: File already exists:" & fileName, False)
End If
Next fileName
'Die Datei übergeben
If LogErrorsOnly = False Then ClassLogger.Add(">> Adding file from Scanfolder after startup:" & fileName, False)
If ClassIndexFunctions.FileExistsinDropTable(fileName) = False Then
ClassFilehandle.Decide_FileHandle(fileName, handleType)
Else
ClassLogger.Add(">> Scanfolder Startup: File already exists:" & fileName, False)
End If
Next fileName
Else
If LogErrorsOnly = False Then ClassLogger.Add(">> FWSCAN not started", False)
End If
Catch ex As Exception
ClassLogger.Add(">> Error while starting folderwatch scan: " & ex.Message, False)
End Try
Try
If FW_started = True Then
If LogErrorsOnly = False Then ClassLogger.Add(">> FW_started started - Checking file:" & CURRENT_FOLDERWATCH, False)
Dim fileEntries As String() = Directory.GetFiles(CURRENT_FOLDERWATCH)
' Process the list of files found in the directory.
Dim fileName As String
For Each fileName In fileEntries
If LogErrorsOnly = False Then ClassLogger.Add(">> Folderwach after startup: Checking file:" & fileName, False)
For Each row As DataRow In DTEXCLUDE_FILES.Rows
Dim content As String = row.Item(0).ToString.ToLower
If fileName.ToLower.Contains(content) Then
Exit Sub
End If
Next
Dim handleType As String
If fileName.ToLower.EndsWith(".msg") Then
handleType = "|FW_OUTLOOK_MESSAGE|"
Else
handleType = "|FW_SIMPLEINDEXER|"
End If
'Die Datei übergeben
If LogErrorsOnly = False Then ClassLogger.Add(">> Adding file from Folderwatch after startup:" & fileName, False)
If ClassIndexFunctions.FileExistsinDropTable(fileName) = False Then
ClassFilehandle.Decide_FileHandle(fileName, handleType)
Else
ClassLogger.Add(">> Folderwatch Startup: File already exists:" & fileName, False)
End If
Next fileName
Else
If LogErrorsOnly = False Then ClassLogger.Add(">> FW_started not started", False)
End If
Catch ex As Exception
ClassLogger.Add(">> Error while starting folderwatch: " & ex.Message, False)
End Try
Else
If LogErrorsOnly = False Then ClassLogger.Add(">> FW_started not started", False)
End If
If TimerFolderWatch.Enabled = False Then
TimerFolderWatch.Start()
End If
@@ -669,49 +680,70 @@ Public Class frmStart
End Sub
Private Sub TimerFolderWatch_Tick(sender As Object, e As EventArgs) Handles TimerFolderWatch.Tick
Try
If FW_started = True Or FWSCAN_started = True Then
'Prüfen ob alle Files abgearbeitet wurden
Dim sql = "SELECT * FROM TBGI_FILES_USER WHERE WORKED = 0 AND HANDLE_TYPE like '%|FW%' AND UPPER(USER@WORK) = UPPER('" & Environment.UserName & "')"
DTACTUAL_FILES = ClassDatabase.Return_Datatable(sql, True)
If DTACTUAL_FILES.Rows.Count > 0 Then
ABORT_INDEXING = False
' Dim fil As String
Me.TimerFolderWatch.Stop()
For Each row As DataRow In DTACTUAL_FILES.Rows
Dim FILEGUID = row.Item("GUID")
If ABORT_INDEXING = True Then
Exit For
End If
Dim FileForWork As String = row.Item(1)
If LogErrorsOnly = False Then ClassLogger.Add(">> In Timer Folderwatch - File: " & FileForWork, False)
Dim fileInUse As Boolean = ClassFilehandle.IsFileInUse(FileForWork)
Dim fileexists As Boolean = System.IO.File.Exists(FileForWork)
If fileInUse = False Then
If fileexists = True Then
CURRENT_WORKFILE = FileForWork
CURRENT_FILENAME = FileForWork
CURRENT_WORKFILE_GUID = row.Item("GUID")
Open_IndexDialog()
Else
ClassLogger.Add(">> File not existing - Row will be deleted!", False)
Dim del = String.Format("DELETE FROM TBGI_FILES_USER WHERE GUID = {0}", FILEGUID)
ClassDatabase.Execute_non_Query(del)
End If
Else
ClassLogger.Add(">> file '" & row.Item(1) & "' could not be opened exclusively - fileInUse!", False)
End If
If ClassDatabase.DatabaseConnectionTimeout = True Then
TimerFolderWatch.Enabled = False
Next
Me.TimerFolderWatch.Start()
End If
tslblFW.Visible = True
Else
tslblFW.Visible = False
Dim title = "Critical Error"
Dim message = $"Database could not be reached. Global Indexer will NOT work without a database!{vbCrLf}{vbCrLf}Please check your connection.{vbCrLf}The Application will exit now."
If USER_LANGUAGE = "de-DE" Then
title = "Kritischer Fehler"
message = $"Die Datenbank konnte nicht erreicht werden. Global Indexer funktioniert NICHT ohne Datenbankverbindung{vbCrLf}{vbCrLf}Bitte überprüfen Sie Ihre Netzwerkverbindung oder benachrichtigen Sie Ihren Administrator.{vbCrLf}Die Anwendung wird nun geschlossen."
End If
Catch ex As Exception
MsgBox("Error in Work FolderWatch-File:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
Dim result = MsgBox(message, MsgBoxStyle.Critical, title)
If result = MsgBoxResult.Ok Then
Application.ExitThread()
End If
Else
Try
If FW_started = True Or FWSCAN_started = True Then
'Prüfen ob alle Files abgearbeitet wurden
Dim sql = "SELECT * FROM TBGI_FILES_USER WHERE WORKED = 0 AND HANDLE_TYPE like '%|FW%' AND UPPER(USER@WORK) = UPPER('" & Environment.UserName & "')"
DTACTUAL_FILES = ClassDatabase.Return_Datatable(sql, True)
If DTACTUAL_FILES.Rows.Count > 0 Then
ABORT_INDEXING = False
' Dim fil As String
Me.TimerFolderWatch.Stop()
For Each row As DataRow In DTACTUAL_FILES.Rows
Dim FILEGUID = row.Item("GUID")
If ABORT_INDEXING = True Then
Exit For
End If
Dim FileForWork As String = row.Item(1)
If LogErrorsOnly = False Then ClassLogger.Add(">> In Timer Folderwatch - File: " & FileForWork, False)
Dim fileInUse As Boolean = ClassFilehandle.IsFileInUse(FileForWork)
Dim fileexists As Boolean = System.IO.File.Exists(FileForWork)
If fileInUse = False Then
If fileexists = True Then
CURRENT_WORKFILE = FileForWork
CURRENT_FILENAME = FileForWork
CURRENT_WORKFILE_GUID = row.Item("GUID")
Open_IndexDialog()
Else
ClassLogger.Add(">> File not existing - Row will be deleted!", False)
Dim del = String.Format("DELETE FROM TBGI_FILES_USER WHERE GUID = {0}", FILEGUID)
ClassDatabase.Execute_non_Query(del)
End If
Else
ClassLogger.Add(">> file '" & row.Item(1) & "' could not be opened exclusively - fileInUse!", False)
End If
Next
Me.TimerFolderWatch.Start()
End If
tslblFW.Visible = True
Else
tslblFW.Visible = False
End If
Catch ex As Exception
MsgBox("Error in Work FolderWatch-File:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End If
End Sub
Private Sub TimerClose3Minutes_Tick(sender As Object, e As EventArgs) Handles TimerClose3Minutes.Tick
If LICENSE_EXPIRED = True Or LICENSE_COUNT < UserLoggedin Then