diff --git a/Global_Indexer/ClassDatabase.vb b/Global_Indexer/ClassDatabase.vb index 5b2418c..5e4a223 100644 --- a/Global_Indexer/ClassDatabase.vb +++ b/Global_Indexer/ClassDatabase.vb @@ -1,11 +1,17 @@ -Imports Oracle.ManagedDataAccess.Client +Imports System.Data.SqlClient +Imports Oracle.ManagedDataAccess.Client Public Class ClassDatabase + Private Const NETWORK_TIMEOUT As Integer = -1 + Private Shared SQLSERVERConnectionString As String Private Shared OracleConnectionString As String + + Public Shared DatabaseConnectionTimeout As Boolean = False + Public Shared Function Init() Try SQLSERVERConnectionString = MyConnectionString - Dim SQLconnect As New SqlClient.SqlConnection + Dim SQLconnect As New SqlConnection SQLconnect.ConnectionString = SQLSERVERConnectionString SQLconnect.Open() SQLconnect.Close() @@ -16,95 +22,158 @@ Public Class ClassDatabase End Try End Function - Public Shared Function Return_Datatable(Select_anweisung As String, Optional userInput As Boolean = False) + Public Shared Function Return_Datatable(sql_command As String, Optional userInput As Boolean = False) Try - Dim SQLconnect As New SqlClient.SqlConnection - Dim SQLcommand As SqlClient.SqlCommand + Dim SQLconnect As New SqlConnection + Dim SQLcommand As SqlCommand SQLconnect.ConnectionString = SQLSERVERConnectionString SQLconnect.Open() SQLcommand = SQLconnect.CreateCommand - SQLcommand.CommandText = Select_anweisung - Dim adapter1 As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(SQLcommand) + SQLcommand.CommandText = sql_command + Dim adapter1 As SqlDataAdapter = New SqlDataAdapter(SQLcommand) Dim dt As DataTable = New DataTable() adapter1.Fill(dt) SQLconnect.Close() - Return dt + ' Reset timeout counter when query was sucessful + DatabaseConnectionTimeout = False + + Return dt + Catch ex As SqlException + Dim handled = CatchDatabaseTimeout(ex, sql_command) + + If Not handled Then + If userInput = True Then + MsgBox("Error in Return_Datatable - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & sql_command, MsgBoxStyle.Critical) + End If + ClassLogger.Add("Unexpected error in Return_Datatable: " & ex.Message, True) + ClassLogger.Add("#SQL: " & sql_command, False) + End If + + Return False Catch ex As Exception If userInput = True Then - MsgBox("Error in Return Datatable - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & Select_anweisung, MsgBoxStyle.Critical) + MsgBox("Error in Return Datatable - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & sql_command, MsgBoxStyle.Critical) End If ClassLogger.Add("Unexpected error in Return_Datatable: " & ex.Message, True) - ClassLogger.Add("#SQL: " & Select_anweisung, False) + ClassLogger.Add("#SQL: " & sql_command, False) Return Nothing End Try End Function - Public Shared Function Return_Datatable_CS(Select_anweisung As String, ConString As String, Optional userInput As Boolean = False) + Public Shared Function Return_Datatable_CS(sql_command As String, ConString As String, Optional userInput As Boolean = False) Try - Dim SQLconnect As New SqlClient.SqlConnection - Dim SQLcommand As SqlClient.SqlCommand + Dim SQLconnect As New SqlConnection + Dim SQLcommand As SqlCommand SQLconnect.ConnectionString = ConString SQLconnect.Open() SQLcommand = SQLconnect.CreateCommand - SQLcommand.CommandText = Select_anweisung + SQLcommand.CommandText = sql_command - Dim adapter1 As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(SQLcommand) + Dim adapter1 As SqlDataAdapter = New SqlDataAdapter(SQLcommand) Dim dt As DataTable = New DataTable() adapter1.Fill(dt) SQLconnect.Close() + + ' Reset timeout counter when query was sucessful + DatabaseConnectionTimeout = False + Return dt + Catch ex As SqlException + Dim handled = CatchDatabaseTimeout(ex, sql_command) + + If Not handled Then + If userInput = True Then + MsgBox("Error in Return_Datatable_CS - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & sql_command, MsgBoxStyle.Critical) + End If + ClassLogger.Add("Unexpected error in Return_Datatable_CS: " & ex.Message, True) + ClassLogger.Add("#SQL: " & sql_command, False) + End If + + Return False Catch ex As Exception If userInput = True Then - MsgBox("Error in Return_Datatable_CS - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & Select_anweisung, MsgBoxStyle.Critical) + MsgBox("Error in Return_Datatable_CS - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & sql_command, MsgBoxStyle.Critical) End If ClassLogger.Add("Unexpected error in Return_Datatable_CS: " & ex.Message, True) - ClassLogger.Add("#SQL: " & Select_anweisung, False) + ClassLogger.Add("#SQL: " & sql_command, False) Return Nothing End Try End Function - Public Shared Function Execute_non_Query(ExecuteCMD As String, Optional userInput As Boolean = False) + Public Shared Function Execute_non_Query(sql_command As String, Optional userInput As Boolean = False) Try - Dim SQLconnect As New SqlClient.SqlConnection - Dim SQLcommand As SqlClient.SqlCommand + Dim SQLconnect As New SqlConnection + Dim SQLcommand As SqlCommand SQLconnect.ConnectionString = SQLSERVERConnectionString SQLconnect.Open() SQLcommand = SQLconnect.CreateCommand 'Update Last Created Record in Foo - SQLcommand.CommandText = ExecuteCMD + SQLcommand.CommandText = sql_command SQLcommand.ExecuteNonQuery() SQLcommand.Dispose() SQLconnect.Close() + + ' Reset timeout counter when query was sucessful + DatabaseConnectionTimeout = False + Return True + Catch ex As SqlException + Dim handled = CatchDatabaseTimeout(ex, sql_command) + + If Not handled Then + If userInput = True Then + MsgBox("Error in Execute non query - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & sql_command, MsgBoxStyle.Critical) + End If + ClassLogger.Add("Unexpected error in Execute_non_Query: " & ex.Message, True) + ClassLogger.Add("#SQL: " & sql_command, False) + End If + + Return False Catch ex As Exception If userInput = True Then - MsgBox("Error in Execute non query - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & ExecuteCMD, MsgBoxStyle.Critical) + MsgBox("Error in Execute non query - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & sql_command, MsgBoxStyle.Critical) End If ClassLogger.Add("Unexpected error in Execute_non_Query: " & ex.Message, True) - ClassLogger.Add("#SQL: " & ExecuteCMD, False) + ClassLogger.Add("#SQL: " & sql_command, False) Return False End Try End Function - Public Shared Function Execute_Scalar(cmdscalar As String, ConString As String, Optional userInput As Boolean = False) + Public Shared Function Execute_Scalar(sql_command As String, ConString As String, Optional userInput As Boolean = False) Dim result Try - Dim SQLconnect As New SqlClient.SqlConnection - Dim SQLcommand As SqlClient.SqlCommand + Dim SQLconnect As New SqlConnection + Dim SQLcommand As SqlCommand SQLconnect.ConnectionString = ConString SQLconnect.Open() SQLcommand = SQLconnect.CreateCommand 'Update Last Created Record in Foo - SQLcommand.CommandText = cmdscalar + SQLcommand.CommandText = sql_command result = SQLcommand.ExecuteScalar() SQLcommand.Dispose() SQLconnect.Close() + + ' Reset timeout counter when query was sucessful + DatabaseConnectionTimeout = False + Return result + Catch ex As SqlException + Dim handled = CatchDatabaseTimeout(ex, sql_command) + + If Not handled Then + If userInput = True Then + MsgBox("Error in Execute non query - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & sql_command, MsgBoxStyle.Critical) + End If + ClassLogger.Add("Unexpected error in Execute_non_Query: " & ex.Message, True) + ClassLogger.Add("#SQL: " & sql_command, False) + End If + + Return False Catch ex As Exception If userInput = True Then - MsgBox("Error in Execute Scalar - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & cmdscalar, MsgBoxStyle.Critical) + MsgBox("Error in Execute Scalar - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & sql_command, MsgBoxStyle.Critical) End If ClassLogger.Add("Unexpected error in Execute_Scalar: " & ex.Message, True) - ClassLogger.Add("#SQL: " & cmdscalar, False) + ClassLogger.Add("#SQL: " & sql_command, False) Return Nothing End Try End Function @@ -175,4 +244,19 @@ Public Class ClassDatabase Return Nothing End Try End Function + + Public Shared Function CatchDatabaseTimeout(ex As SqlException, sql_command As String) + Dim FatalErrors As New List(Of Integer) From {-1, -2, 121} + + If FatalErrors.Contains(ex.Number) Then + DatabaseConnectionTimeout = True + + ClassLogger.Add("Network timeout error in Return_Datatable: " & ex.Message, True) + ClassLogger.Add("#SQL: " & sql_command, False) + + Return True + Else + Return False + End If + End Function End Class diff --git a/Global_Indexer/ClassFolderWatcher.vb b/Global_Indexer/ClassFolderWatcher.vb index 2e864f6..150bc82 100644 --- a/Global_Indexer/ClassFolderWatcher.vb +++ b/Global_Indexer/ClassFolderWatcher.vb @@ -6,34 +6,42 @@ Public Class ClassFolderWatcher Public Shared FolderWatcher As FileSystemWatcher Public Shared FolderWatcher_SCAN As FileSystemWatcher Public Shared Function Restart_FolderWatch() - If FolderWatcher.EnableRaisingEvents = True Then - 'Gestartet also Stoppen - FolderWatcher.EnableRaisingEvents = False - FW_started = False - 'FolderWatch neu instanzieren - FolderWatcher = New System.IO.FileSystemWatcher(CURRENT_FOLDERWATCH, "*.*") - ClassLogger.Add(" >> FolderWatch neu instanziert", False) - FolderWatcher.IncludeSubdirectories = False - FolderWatcher.EnableRaisingEvents = True - AddHandler FolderWatcher.Created, AddressOf OnCreated - FW_started = True - SaveConfigValue("FW_started", "True") - End If + Try + If FolderWatcher.EnableRaisingEvents = True Then + 'Gestartet also Stoppen + FolderWatcher.EnableRaisingEvents = False + FW_started = False + 'FolderWatch neu instanzieren + FolderWatcher = New System.IO.FileSystemWatcher(CURRENT_FOLDERWATCH, "*.*") + ClassLogger.Add(" >> FolderWatch neu instanziert", False) + FolderWatcher.IncludeSubdirectories = False + FolderWatcher.EnableRaisingEvents = True + AddHandler FolderWatcher.Created, AddressOf OnCreated + FW_started = True + SaveConfigValue("FW_started", "True") + End If + Catch ex As Exception + ClassLogger.Add($"Error in Restart_FolderWatch: {ex.Message}", False) + End Try End Function Public Shared Function Restart_FolderWatchSCAN() - If FolderWatcher_SCAN.EnableRaisingEvents = True Then - 'Gestartet also Stoppen - FolderWatcher_SCAN.EnableRaisingEvents = False - FWSCAN_started = False - 'FolderWatch neu instanzieren - FolderWatcher_SCAN = New System.IO.FileSystemWatcher(CURRENT_SCAN_FOLDERWATCH, "*.*") - ClassLogger.Add(" >> FolderWatchScan neu instanziert", False) - FolderWatcher_SCAN.IncludeSubdirectories = False - FolderWatcher_SCAN.EnableRaisingEvents = True - AddHandler FolderWatcher_SCAN.Created, AddressOf OnCreated - FWSCAN_started = True - SaveConfigValue("FWSCAN_started", "True") - End If + Try + If FolderWatcher_SCAN.EnableRaisingEvents = True Then + 'Gestartet also Stoppen + FolderWatcher_SCAN.EnableRaisingEvents = False + FWSCAN_started = False + 'FolderWatch neu instanzieren + FolderWatcher_SCAN = New System.IO.FileSystemWatcher(CURRENT_SCAN_FOLDERWATCH, "*.*") + ClassLogger.Add(" >> FolderWatchScan neu instanziert", False) + FolderWatcher_SCAN.IncludeSubdirectories = False + FolderWatcher_SCAN.EnableRaisingEvents = True + AddHandler FolderWatcher_SCAN.Created, AddressOf OnCreated + FWSCAN_started = True + SaveConfigValue("FWSCAN_started", "True") + End If + Catch ex As Exception + ClassLogger.Add($"Error in Restart_FolderWatchSCAN: {ex.Message}", False) + End Try End Function Public Shared Function StartStop_FolderWatch() Try @@ -151,6 +159,11 @@ Public Class ClassFolderWatcher End If End Function Private Shared Sub OnCreated(source As Object, e As FileSystemEventArgs) + If ClassDatabase.DatabaseConnectionTimeout = True Then + ClassLogger.Add(">> File handling aborted because of database timeout error!", False) + Exit Sub + End If + Try For Each row As DataRow In DTEXCLUDE_FILES.Rows Dim content As String = row.Item(0).ToString.ToLower @@ -158,7 +171,7 @@ Public Class ClassFolderWatcher Exit Sub End If Next - + Dim handleType As String If e.FullPath.ToLower.EndsWith(".msg") Then handleType = "|FW_OUTLOOK_MESSAGE|" @@ -172,11 +185,11 @@ Public Class ClassFolderWatcher Else ClassLogger.Add(">> Folderwatcher: File already exists:" & e.FullPath, False) End If - + Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical, "Error in folder_watch_Created") End Try End Sub - + End Class diff --git a/Global_Indexer/ClassWindream.vb b/Global_Indexer/ClassWindream.vb index 0a031ed..1901cfd 100644 --- a/Global_Indexer/ClassWindream.vb +++ b/Global_Indexer/ClassWindream.vb @@ -851,19 +851,32 @@ Public Class ClassWindream ' ein windream-Objekt der Datei anlegen WMObject = aktWMObject 'oSession.GetWMObjectByPath(WINDREAMLib.WMEntity.WMEntityDocument, WD_File) Try + If LogErrorsOnly = False Then ClassLogger.Add(" ...Datei wird gesperrt", False) ' die Datei sperren WMObject.lock() Catch ex As Exception + If LogErrorsOnly = False Then ClassLogger.Add(" ...Datei ist bereits gesperrt", False) ' nichts tun (Datei ist bereits gesperrt) End Try + If IsNothing(WMObject) Then + If LogErrorsOnly = False Then ClassLogger.Add(" ...Windream Object ist nothing, Indexierung wird abgebrochen", False) + Return False + End If + + If IsNothing(WMObject.aObjectType) Then + If LogErrorsOnly = False Then ClassLogger.Add(" ...Kein Objekttyp gesetzt, Indexierung wird abgebrochen", False) + Return False + End If + + If LogErrorsOnly = False Then ClassLogger.Add($" ...Objekttyp wird gesetzt: " & _WDObjekttyp, False) ' wenn der Datei noch kein Dokumenttyp zugewiesen wurde If WMObject.aObjectType.aName = "Standard" Then ' ihr den entsprechenden Dokumenttyp zuweisen WMObject.aObjectType = oSession.GetWMObjectByName(WINDREAMLib.WMEntity.WMEntityObjectType, _WDObjekttyp) ' WMObject.aObjectType = Me.selectedProfile.Dokumenttyp - If LogErrorsOnly = False Then ClassLogger.Add(" ...Objekttyp wird gesetzt", False) + If LogErrorsOnly = False Then ClassLogger.Add(" ...Objekttyp wurde gesetzt", False) Else If LogErrorsOnly = False Then ClassLogger.Add(" ...Objekttyp war bereits gesetzt", False) End If diff --git a/Global_Indexer/My Project/AssemblyInfo.vb b/Global_Indexer/My Project/AssemblyInfo.vb index b1f2a3a..6970e8c 100644 --- a/Global_Indexer/My Project/AssemblyInfo.vb +++ b/Global_Indexer/My Project/AssemblyInfo.vb @@ -33,7 +33,7 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - + \ No newline at end of file diff --git a/Global_Indexer/frmIndex.vb b/Global_Indexer/frmIndex.vb index 21b21d0..4285185 100644 --- a/Global_Indexer/frmIndex.vb +++ b/Global_Indexer/frmIndex.vb @@ -520,26 +520,31 @@ Public Class frmIndex If NewDataset.Tables(0).Rows.Count > 0 Then 'Die Standardcombobox anlegen newCMB = addCombobox(indexname, y) - 'Die Standargrösse definieren - Dim newWidth As Integer = 300 - For i = 0 To NewDataset.Tables(0).Rows.Count - 1 - 'MsgBox(NewDataset.Tables(0).Rows(i).Item(0)) - AddComboBoxValue(newCMB, NewDataset.Tables(0).Rows(i).Item(0)) - Try - Dim text As String = NewDataset.Tables(0).Rows(i).Item(0) - If text.Length > 15 Then - Dim g As Graphics = newCMB.CreateGraphics - If g.MeasureString(text, newCMB.Font).Width + 30 > newWidth Then - newWidth = g.MeasureString(text, newCMB.Font).Width + 30 - End If - g.Dispose() - End If - Catch ex As Exception - MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error in Anpassung Breite ComboBox:") - End Try - Next - newCMB.Size = New Size(newWidth, 27) + + newCMB.DataSource = NewDataset.Tables(0) + newCMB.DisplayMember = NewDataset.Tables(0).Columns(0).ColumnName + + 'Die Standargrösse definieren + 'Dim newWidth As Integer = 300 + 'For i = 0 To NewDataset.Tables(0).Rows.Count - 1 + ' 'MsgBox(NewDataset.Tables(0).Rows(i).Item(0)) + ' AddComboBoxValue(newCMB, NewDataset.Tables(0).Rows(i).Item(0)) + ' Try + ' Dim text As String = NewDataset.Tables(0).Rows(i).Item(0) + ' If text.Length > 15 Then + ' Dim g As Graphics = newCMB.CreateGraphics + ' If g.MeasureString(text, newCMB.Font).Width + 30 > newWidth Then + ' newWidth = g.MeasureString(text, newCMB.Font).Width + 30 + ' End If + ' g.Dispose() + ' End If + ' Catch ex As Exception + ' MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error in Anpassung Breite ComboBox:") + ' End Try + + 'Next + 'newCMB.Size = New Size(newWidth, 27) newCMB.AutoCompleteSource = AutoCompleteSource.ListItems newCMB.AutoCompleteMode = AutoCompleteMode.Suggest newCMB.DropDownHeight = (newCMB.ItemHeight + 0.2) * 25 diff --git a/Global_Indexer/frmSQLSuggestion.Designer.vb b/Global_Indexer/frmSQLSuggestion.Designer.vb index cc277cb..0aacee1 100644 --- a/Global_Indexer/frmSQLSuggestion.Designer.vb +++ b/Global_Indexer/frmSQLSuggestion.Designer.vb @@ -181,7 +181,6 @@ Partial Class frmSQLSuggestion Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "frmSQLSuggestion" - Me.TopMost = True Me.GroupBox1.ResumeLayout(False) Me.GroupBox1.PerformLayout() CType(Me.TBDD_CONNECTIONBindingSource, System.ComponentModel.ISupportInitialize).EndInit() diff --git a/Global_Indexer/frmSQLSuggestion.resx b/Global_Indexer/frmSQLSuggestion.resx index 36a4807..ac27c4e 100644 --- a/Global_Indexer/frmSQLSuggestion.resx +++ b/Global_Indexer/frmSQLSuggestion.resx @@ -122,6 +122,12 @@ MiddleLeft + + 0 + + + 1172, 489 + True @@ -129,9 +135,6 @@ Top, Right - - Global_Indexer.MyDatasetTableAdapters.TableAdapterManager, MyDataset.Designer.vb.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - 227, 59 @@ -144,11 +147,11 @@ SQL_UEBERPRUEFUNGLabel - - 48 + + 610, 279 - - Label2 + + 51 195, 15 @@ -156,21 +159,27 @@ Button1 - - SQL_ERGEBNISTextBox - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 89, 25 - - 2 + + frmSQLSuggestion + + + True + + + GroupBox1 Bottom, Right + + $this + 289, 22 @@ -180,9 +189,6 @@ 212, 22 - - Top, Right - Speichern @@ -192,18 +198,21 @@ SQL_UEBERPRUEFUNGTextBox + + Segoe UI, 8.25pt + MiddleLeft + + 905, 441 + 6, 13 MiddleRight - - 103, 27 - 0 @@ -213,11 +222,8 @@ TBDD_CONNECTIONTableAdapter - - 2 - - - Segoe UI Semibold, 9pt, style=Bold, Italic + + SQL-Daten erfolgreich gespeichert! GroupBox1 @@ -228,8 +234,8 @@ System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + SQL für Vorschlagsliste: Geben Sie hier den Ausgangswert des manuellen Indexes ein. @@ -245,35 +251,23 @@ Ergebniswert angezeigt. TBDD_CONNECTIONBindingSource - - 52 - 7 + + $this + System.Windows.Forms.BindingSource, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 51 - - - 1 + + btnTestNachbearbeitung MyDataset - - Top, Right - - - 12, 66 - - - frmSQLSuggestion - - - 8 + + 1 433, 39 @@ -287,14 +281,14 @@ Ergebniswert angezeigt. True - - btnVorschlag - Top, Bottom, Left, Right - - $this + + Global_Indexer.MyDatasetTableAdapters.TBDD_CONNECTIONTableAdapter, MyDataset.Designer.vb.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + + + Label2 4 @@ -302,6 +296,9 @@ Ergebniswert angezeigt. TableAdapterManager + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + MiddleRight @@ -317,15 +314,12 @@ Ergebniswert angezeigt. 112, 23 - - Segoe UI, 8.25pt + + 2 lblSave - - 324, 39 - Test @@ -347,8 +341,8 @@ Ergebniswert angezeigt. 536, 54 - - 0 + + SQL_ERGEBNISTextBox 351, 93 @@ -362,8 +356,8 @@ Ergebniswert angezeigt. 15, 82 - - 90, 31 + + Global_Indexer.MyDatasetTableAdapters.TableAdapterManager, MyDataset.Designer.vb.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null 9, 63 @@ -371,20 +365,28 @@ Ergebniswert angezeigt. cmbConnection + + $this + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - $this + + 12, 66 + + + SQL-Überprüfung für manuellen Index: +Definieren Sie hier einen SQL-Befehl der die Auswahl auf VORHANDEN überprüft. +(SELECT COUNT(*) FROM IHRE_KEY_TABLE WHERE IHRE_WERT_SPALTE = INPUTVALUE) GroupBox1 - - 1 + + btnVorschlag - - Global_Indexer.MyDatasetTableAdapters.TBDD_CONNECTIONTableAdapter, MyDataset.Designer.vb.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + + Top, Right Bottom, Left @@ -392,9 +394,6 @@ Ergebniswert angezeigt. 3 - - 15, 367 - $this @@ -410,34 +409,38 @@ Ergebniswert angezeigt. 15, 24 - - SQL-Überprüfung für manuellen Index: -Definieren Sie hier einen SQL-Befehl der die Auswahl auf VORHANDEN überprüft. -(SELECT COUNT(*) FROM IHRE_KEY_TABLE WHERE IHRE_WERT_SPALTE = INPUTVALUE) + + $this + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 6 - - 905, 441 + + 2 686, 108 - - Teste SQL + + 1 683, 66 - - 610, 279 + + 90, 31 - - Konfiguration SQL + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - True + + 8 + + + 103, 27 True @@ -448,8 +451,8 @@ Definieren Sie hier einen SQL-Befehl der die Auswahl auf VORHANDEN überprüft. 483, 106 - - MiddleRight + + 15, 367 Both @@ -460,8 +463,11 @@ Definieren Sie hier einen SQL-Befehl der die Auswahl auf VORHANDEN überprüft. 1 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + MiddleRight + + + Consolas, 8.25pt GroupBox1 @@ -472,14 +478,8 @@ Definieren Sie hier einen SQL-Befehl der die Auswahl auf VORHANDEN überprüft. Nachbearbeitung testen: - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - SQL-Daten erfolgreich gespeichert! - - - False + + Segoe UI Semibold, 9pt, style=Bold, Italic Consolas, 8.25pt @@ -487,8 +487,8 @@ Definieren Sie hier einen SQL-Befehl der die Auswahl auf VORHANDEN überprüft. System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Consolas, 8.25pt + + Konfiguration SQL 54 @@ -496,23 +496,23 @@ Definieren Sie hier einen SQL-Befehl der die Auswahl auf VORHANDEN überprüft. MiddleLeft - - GroupBox1 + + Top, Right System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 0 + + 48 - - 1172, 489 + + 52 - - $this + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 324, 39 System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -523,17 +523,17 @@ Definieren Sie hier einen SQL-Befehl der die Auswahl auf VORHANDEN überprüft. $this - - SQL für Vorschlagsliste: + + False - - btnTestNachbearbeitung + + 0 Button2 - - $this + + Teste SQL 49 diff --git a/Global_Indexer/frmSplash.vb b/Global_Indexer/frmSplash.vb index d95c909..40816a1 100644 --- a/Global_Indexer/frmSplash.vb +++ b/Global_Indexer/frmSplash.vb @@ -83,7 +83,7 @@ Public NotInheritable Class frmSplash ' Bei Fehler MsgBox anzeigen und Programm beenden If e.Error IsNot Nothing Then MsgBox(e.Error.Message, MsgBoxStyle.Critical, "Error while Initializing application") - Application.Exit() + Application.ExitThread() End If ' Wenn kein Fehler, Splashscreen schließen diff --git a/Global_Indexer/frmStart.vb b/Global_Indexer/frmStart.vb index f2d6985..33b0cf2 100644 --- a/Global_Indexer/frmStart.vb +++ b/Global_Indexer/frmStart.vb @@ -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