Zooflow: Onboarding, check for ECM and IDB Database connections, Service Connection

This commit is contained in:
Jonathan Jenne
2021-11-03 11:59:29 +01:00
parent 7064978ecb
commit 85ddf68794
9 changed files with 555 additions and 63 deletions

View File

@@ -12,6 +12,7 @@ Imports DigitalData.Modules.Encryption
Imports DigitalData.GUIs.ZooFlow.ClassConstants
Imports DigitalData.GUIs.ZooFlow.ClassInitLoader
Imports DigitalData.Controls.SQLConfig
Imports System.Data.SqlClient
Public Class ClassInit
Inherits Base.BaseClass
@@ -75,9 +76,20 @@ Public Class ClassInit
Dim oDatatable As DataTable = My.DatabaseECM.GetDatatable(oSQl)
If IsNothing(oDatatable) OrElse oDatatable.Rows.Count = 0 Then
MsgBox("No IDB connection entries in TBDD_CONNECTION found!", MsgBoxStyle.Exclamation)
Logger.Warn("No IDB connection entries in TBDD_CONNECTION found!")
Throw New InitException("Fehler beim Laden der IDB Verbindungsdaten!")
Dim oForm As New frmSQLConfig(My.LogConfig) With {.FormTitle = "IDB Datenbank"}
Dim oResult = oForm.ShowDialog()
If oResult = DialogResult.OK Then
Dim oConnectionStringSaved = SaveConnectionString(oForm.ConnectionString)
If oConnectionStringSaved = False Then
Throw New InitException("Fehler beim Laden der IDB Verbindungsdaten!")
End If
oDatatable = My.DatabaseECM.GetDatatable(oSQl)
End If
End If
If oDatatable.Rows.Count > 1 Then
@@ -90,7 +102,8 @@ Public Class ClassInit
oDataRow.Item("SERVER").ToString,
oDataRow.Item("DATENBANK").ToString,
oDataRow.Item("USERNAME").ToString,
oDataRow.Item("PASSWORD").ToString)
oDataRow.Item("PASSWORD").ToString
)
My.DatabaseIDB = New MSSQLServer(My.LogConfig, oConString)
End If
@@ -102,6 +115,15 @@ Public Class ClassInit
End Sub
Private Sub InitializeService(MyApplication As My.MyApplication)
Try
If My.SystemConfig.AppServerConfig = String.Empty Then
Dim oForm As New frmServiceConfig()
Dim oResult = oForm.ShowDialog()
If oResult <> DialogResult.OK Then
Throw New InitException("Could not initialize IDB-Service!")
End If
End If
MyApplication.Service.Address = My.SystemConfig.AppServerConfig
Dim oServerData = Client.ParseServiceAddress(My.SystemConfig.AppServerConfig)
@@ -211,17 +233,18 @@ Public Class ClassInit
Private Function SetupDatabase() As Boolean
If My.SystemConfig.ConnectionString = String.Empty Then
Dim oConnectionString = My.SystemConfig.ConnectionString
Dim ofrmSQLConfig As New frmSQLConfig(My.LogConfig) With {.ConnectionString = oConnectionString}
Dim oResult = ofrmSQLConfig.ShowDialog()
Dim oForm As New frmSQLConfig(My.LogConfig) With {
.ConnectionString = oConnectionString,
.FormTitle = "ECM Datenbank"
}
Dim oResult = oForm.ShowDialog()
If oResult = DialogResult.OK Then
My.SystemConfig.ConnectionString = ofrmSQLConfig.ConnectionString
My.SystemConfig.ConnectionString = oForm.ConnectionString
My.SystemConfigManager.Save()
Return True
Else
MsgBox("Es wurde keine Datenbank hinterlegt. Die Anwendung wird beendet.")
Return False
End If
End If
@@ -229,6 +252,21 @@ Public Class ClassInit
Return True
End Function
Private Function SaveConnectionString(pConnectionString As String) As Boolean
Try
Dim oBuilder As New SqlConnectionStringBuilder(pConnectionString)
Dim oSql = $"
INSERT INTO TBDD_CONNECTION
(BEZEICHNUNG, SQL_PROVIDER, SERVER, DATENBANK, USERNAME, PASSWORD, BEMERKUNG, AKTIV, ERSTELLTWER)
VALUES ('IDB', 'MS-SQLServer', '{oBuilder.DataSource}', '{oBuilder.InitialCatalog}', '{oBuilder.UserID}', '{oBuilder.Password}', 'Created by Zooflow', 1, '{Environment.UserName}')"
Return My.DatabaseECM.ExecuteNonQuery(oSql)
Catch ex As Exception
Logger.Error(ex)
Return False
End Try
End Function
Private Sub ProgressChanged(sender As Object, Progress As InitProgress)
SplashScreenManager.Default.SendCommand(frmSplash.SplashScreenCommand.SetProgress, Progress.CurrentPercent)
SplashScreenManager.Default.SendCommand(frmSplash.SplashScreenCommand.SetActionName, Progress.CurrentStep.Name)