From e3dd905c6953563782624da133818d2b2fd50677 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Fri, 4 May 2018 14:04:34 +0200 Subject: [PATCH] jj: Fix a million Error messages on failed db connection --- Global_Indexer/ClassInit.vb | 6 ++--- Global_Indexer/frmSplash.vb | 50 +++++++++---------------------------- 2 files changed, 14 insertions(+), 42 deletions(-) diff --git a/Global_Indexer/ClassInit.vb b/Global_Indexer/ClassInit.vb index 976200d..a5ad341 100644 --- a/Global_Indexer/ClassInit.vb +++ b/Global_Indexer/ClassInit.vb @@ -36,7 +36,8 @@ Public Class ClassInit If dbResult = False Then ERROR_STATE = "FAILED DBCONNECTION" - MsgBox("Error in init database. (Connection failed) More information in the logfile.", MsgBoxStyle.Critical) + ' Fehler wird in frmSplash abgehandelt + 'MsgBox("Error in init database. (Connection failed) More information in the logfile.", MsgBoxStyle.Critical) Return False Else Return True @@ -54,9 +55,6 @@ Public Class ClassInit Throw New Exception("Unexpected error while initializing basic-settings. More info in the log.") End If End If - - - End Sub Public Sub Init_Folderwatch() Try diff --git a/Global_Indexer/frmSplash.vb b/Global_Indexer/frmSplash.vb index 1d75d06..d95c909 100644 --- a/Global_Indexer/frmSplash.vb +++ b/Global_Indexer/frmSplash.vb @@ -11,54 +11,28 @@ Public NotInheritable Class frmSplash Private bw As New BackgroundWorker() Private Sub frmSplash_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load - 'Richten Sie den Dialogtext zur Laufzeit gemäß den Assemblyinformationen der Anwendung ein. - - 'TODO: Die Assemblyinformationen der Anwendung im Bereich "Anwendung" des Dialogfelds für die - ' Projekteigenschaften (im Menü "Projekt") anpassen. - 'Anwendungstitel If My.Application.Info.Title <> "" Then ApplicationTitle.Text = My.Application.Info.Title Else 'Wenn der Anwendungstitel fehlt, Anwendungsnamen ohne Erweiterung verwenden - ApplicationTitle.Text = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName) + ApplicationTitle.Text = IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName) End If - 'Verwenden Sie zum Formatieren der Versionsinformationen den Text, der zur Entwurfszeit in der Versionskontrolle festgelegt wurde, als - ' Formatierungszeichenfolge. Dies ermöglicht ggf. eine effektive Lokalisierung. - ' Build- und Revisionsinformationen können durch Verwendung des folgenden Codes und durch Ändern - ' des Entwurfszeittexts der Versionskontrolle in "Version {0}.{1:00}.{2}.{3}" oder einen ähnlichen Text eingeschlossen werden. Weitere Informationen erhalten Sie unter - ' String.Format() in der Hilfe. - ' - ' Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor, My.Application.Info.Version.Build, My.Application.Info.Version.Revision) - Version.Text = String.Format("Version {0}", My.Application.Info.Version.ToString) 'Copyrightinformationen Copyright.Text = My.Application.Info.Copyright & " " & My.Application.Info.CompanyName Me.BringToFront() - Dim p As Process Dim RunCount = 0 - For Each p In Process.GetProcesses + For Each p As Process In Process.GetProcesses If p.ProcessName.Contains("lobal_Indexe") Then RunCount += 1 End If Next - 'If RunCount = 2 Then - ' MsgBox("Application already running. " & "GLOBIX will be closed!", MsgBoxStyle.Exclamation) - ' My.Settings.AppTerminate = True - ' My.Settings.Save() - ' Me.Close() - 'Else - ' InitProgram() - 'End If InitProgram() - - - - End Sub Private Sub InitProgram() @@ -81,39 +55,39 @@ Public NotInheritable Class frmSplash bw.ReportProgress(CalcProgress(1), "Initialize Logging") Init.InitLogger() - System.Threading.Thread.Sleep(600) + Thread.Sleep(600) bw.ReportProgress(CalcProgress(2), "Initialize Database") If Init.InitDatabase() = True Then - System.Threading.Thread.Sleep(600) + Thread.Sleep(600) bw.ReportProgress(CalcProgress(3), "Initialize UserConfiguration") Init.InitUserLogin() - System.Threading.Thread.Sleep(600) + Thread.Sleep(600) bw.ReportProgress(CalcProgress(4), "Initialize windream-Settings") Init.InitBasics() - System.Threading.Thread.Sleep(500) + Thread.Sleep(500) + Else + Throw New Exception("Database could not be reached! Application will be closed now!") End If - - End Sub - Private Sub bw_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs) + Private Sub bw_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) pbStatus.Value = e.ProgressPercentage lblStatus.Text = e.UserState.ToString() End Sub - Private Sub bw_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) + Private Sub bw_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) ' Bei Fehler MsgBox anzeigen und Programm beenden If e.Error IsNot Nothing Then - MsgBox(e.Error.Message, MsgBoxStyle.Critical, "Unexpected error in Initializing application") + MsgBox(e.Error.Message, MsgBoxStyle.Critical, "Error while Initializing application") Application.Exit() End If ' Wenn kein Fehler, Splashscreen schließen - Me.Close() + Close() End Sub Public Sub New()