improve init, clean up code

This commit is contained in:
Jonathan Jenne
2020-10-28 15:47:20 +01:00
parent e11e52faba
commit 1d976b6ab3
8 changed files with 133 additions and 127 deletions

View File

@@ -23,6 +23,7 @@ Public Class ClassInit
' - Database / Service / Application Server
' (Init Licensing)
' Init User
' Init IDB
' Zeile -> Objekt / NameValue List
If Not SetupDatabase() Then
@@ -34,7 +35,9 @@ Public Class ClassInit
' === Init Schritte definieren
oInit.AddStep("Checking connectivity..", AddressOf CheckConnectivity, True)
oInit.AddStep("Initializing User..", AddressOf InitializeUser, True)
oInit.AddStep("Initializing IDB..", AddressOf InitializeIDB, True)
oInit.AddStep("Loading 3rd-party licenses", AddressOf Initialize3rdParty, False)
' === Init Schritte definieren
AddHandler oInit.ProgressChanged, AddressOf ProgressChanged
@@ -44,8 +47,6 @@ Public Class ClassInit
End If
End Sub
Private Function SetupDatabase() As Boolean
If My.SystemConfig.ConnectionString = String.Empty Then
Dim oResult = frmConfigDatabase.ShowDialog()
@@ -76,29 +77,13 @@ Public Class ClassInit
My.Application.User = oMyApplication.User
My.Application.Modules = oMyApplication.Modules
My.Application.ModulesActive = oMyApplication.ModulesActive
If My.Application.ModulesActive.Contains(ClassConstants.MODULE_ZOOFLOW) Then
If My.Database.DBInitialized Then
Dim oSQl = "SELECT * FROM TBDD_CONNECTION WHERE BEZEICHNUNG = 'IDB'"
Dim oDTCONN_IDB As DataTable = My.Database.GetDatatable(oSQl)
If oDTCONN_IDB.Rows.Count = 1 Then
Dim oConString = My.Database.GetConnectionString(oDTCONN_IDB.Rows(0).Item("SERVER"), oDTCONN_IDB.Rows(0).Item("DATENBANK"), oDTCONN_IDB.Rows(0).Item("USERNAME"), oDTCONN_IDB.Rows(0).Item("PASSWORD"))
My.Database_IDB = New MSSQLServer(My.LogConfig, oConString)
If My.Database.DBInitialized = False Then
_Logger.Warn("Could not initialize IDB-Database!")
Throw New InitException("Could not initialize IDB-Database!")
End If
End If
End If
End If
RaiseEvent Completed(sender, Nothing)
End If
End Sub
Private Sub CheckConnectivity(MyApplication As My.MyApplication)
Dim oCrypt As New EncryptionLegacy("!35452didalog=")
Dim oCrypt As New EncryptionLegacy(CRYPTO_LEGACY_ENCRYPTION_KEY)
Dim oBuilder = My.SystemConfig.GetConnectionStringBuilder(My.SystemConfig.ConnectionString)
oBuilder.Password = oCrypt.DecryptData(oBuilder.Password)
Dim oDecryptedConnectionString = oBuilder.ToString
@@ -129,11 +114,44 @@ Public Class ClassInit
End Try
End Sub
Private Sub InitializeIDB(MyApplication As My.MyApplication)
If MyApplication.ModulesActive.Contains(MODULE_ZOOFLOW) Then
If My.Database.DBInitialized Then
Dim oSQl = "SELECT * FROM TBDD_CONNECTION WHERE BEZEICHNUNG = 'IDB'"
Dim oDatatable As DataTable = My.Database.GetDatatable(oSQl)
If IsNothing(oDatatable) OrElse oDatatable.Rows.Count = 0 Then
_Logger.Warn("No IDB connection entries in TBDD_CONNECTION found!")
Throw New InitException("Fehler beim Laden der IDB Verbindungsdaten!")
End If
If oDatatable.Rows.Count > 1 Then
_Logger.Warn("Multiple IDB connection entries in TBDD_CONNECTION found!")
Throw New InitException("Fehler beim Laden der IDB Verbindungsdaten!")
End If
Dim oConString = My.Database.GetConnectionString(oDatatable.Rows(0).Item("SERVER"), oDatatable.Rows(0).Item("DATENBANK"), oDatatable.Rows(0).Item("USERNAME"), oDatatable.Rows(0).Item("PASSWORD"))
My.Database_IDB = New MSSQLServer(My.LogConfig, oConString)
If My.Database_IDB.DBInitialized = False Then
_Logger.Warn("Could not initialize IDB-Database!")
Throw New InitException("Could not initialize IDB-Database!")
End If
End If
Else
_Logger.Warn("ZooFlow missing from Active Modules!")
Throw New InitException("ZooFlow Modult ist nicht aktiv oder nicht lizensiert!")
End If
End Sub
Private Sub InitializeUser(MyApplication As My.MyApplication)
Try
Dim oSql As String = My.Queries.Common.FNDD_MODULE_INIT(Environment.UserName)
Dim oDatatable As DataTable = My.Database.GetDatatable(oSql)
If oDatatable Is Nothing Then
Throw New InitException("Benutzer konnte nicht geladen werden!")
End If
If oDatatable.Rows.Count <= 1 Then
Throw New InitException("Benutzer konnte nicht gefunden werden!")
End If
@@ -147,7 +165,6 @@ Public Class ClassInit
Case MODULE_CLIPBOARDWATCHER
HandleModuleInfo(MyApplication, oType, oRow)
Case MODULE_GLOBAL_INDEXER
HandleModuleInfo(MyApplication, oType, oRow)
Case MODULE_ZOOFLOW
@@ -157,7 +174,7 @@ Public Class ClassInit
Catch ex As Exception
_Logger.Error(ex)
Throw New InitException("Fehler beim Laden des Benutzers!")
Throw ex
End Try
End Sub