diff --git a/Global_Indexer/ClassDatabase.vb b/Global_Indexer/ClassDatabase.vb index 937b41a..95669f9 100644 --- a/Global_Indexer/ClassDatabase.vb +++ b/Global_Indexer/ClassDatabase.vb @@ -216,9 +216,8 @@ Public Class ClassDatabase Public Shared Sub CatchDatabaseTimeout(ex As SqlException, sql_command As String) Dim FatalErrors As New List(Of Integer) From {-1, -2, 121} - If DatabaseConnectionTimeout = False And FatalErrors.Contains(ex.Number) Then + If FatalErrors.Contains(ex.Number) Then DatabaseConnectionTimeout = True - MsgBox($"Database could not be reached. Global Indexer will NOT work without a database!{vbCrLf}{vbCrLf}Please check your connection and restart.", MsgBoxStyle.Critical, "Critical Error") ClassLogger.Add("Network timeout error in Return_Datatable: " & ex.Message, True) ClassLogger.Add("#SQL: " & sql_command, False) diff --git a/Global_Indexer/frmStart.vb b/Global_Indexer/frmStart.vb index a8d5bd5..a16f846 100644 --- a/Global_Indexer/frmStart.vb +++ b/Global_Indexer/frmStart.vb @@ -671,54 +671,60 @@ Public Class frmStart Private Sub TimerFolderWatch_Tick(sender As Object, e As EventArgs) Handles TimerFolderWatch.Tick If ClassDatabase.DatabaseConnectionTimeout = True Then TimerFolderWatch.Enabled = False - ClassLogger.Add(">> Timer stopped because of database timeout error!", False) - Exit Sub + + Dim result = MsgBox($"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.", MsgBoxStyle.Critical, "Critical Error") + + 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 - 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 Sub Private Sub TimerClose3Minutes_Tick(sender As Object, e As EventArgs) Handles TimerClose3Minutes.Tick If LICENSE_EXPIRED = True Or LICENSE_COUNT < UserLoggedin Then