initialize zooflow
This commit is contained in:
78
ZooFlow/ClassInit.vb
Normal file
78
ZooFlow/ClassInit.vb
Normal file
@@ -0,0 +1,78 @@
|
||||
Imports System.ComponentModel
|
||||
Imports DevExpress.XtraSplashScreen
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
|
||||
Public Class ClassInit
|
||||
Private _MainForm As frmMain
|
||||
|
||||
Public Sub New(ParentForm As frmMain)
|
||||
_MainForm = ParentForm
|
||||
End Sub
|
||||
|
||||
Public Sub InitializeApplication()
|
||||
' Init Connectivity
|
||||
' - Database / Service / Application Server
|
||||
' (Init Licensing)
|
||||
' Init User
|
||||
' Zeile -> Objekt / NameValue List
|
||||
|
||||
If Not InitializeDatabase() Then
|
||||
MsgBox("Verbindung konnte nicht hergestellt werden! Anwendung wird beendet", MsgBoxStyle.Critical, _MainForm.Text)
|
||||
Application.Exit()
|
||||
Else
|
||||
Dim oInit As New ClassInitLoader()
|
||||
oInit.AddStep("Checking connectivity..", AddressOf CheckConnectivity, True)
|
||||
oInit.AddStep("Checking connectivity..2", AddressOf CheckConnectivity, True)
|
||||
oInit.AddStep("Checking connectivity..3", AddressOf CheckConnectivity, True)
|
||||
oInit.AddStep("Checking connectivity..4", AddressOf CheckConnectivity, True)
|
||||
oInit.AddStep("Checking connectivity..5", AddressOf CheckConnectivity, True)
|
||||
oInit.AddStep("Checking connectivity..6", AddressOf CheckConnectivity, True)
|
||||
|
||||
AddHandler oInit.ProgressChanged, AddressOf ProgressChanged
|
||||
AddHandler oInit.InitCompleted, AddressOf InitCompleted
|
||||
|
||||
SplashScreenManager.ActivateParentOnSplashFormClosing = True
|
||||
SplashScreenManager.ShowForm(_MainForm, GetType(frmSplash), False, False)
|
||||
|
||||
oInit.Run()
|
||||
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ProgressChanged(sender As Object, Progress As ClassInitLoader.InitProgress)
|
||||
SplashScreenManager.Default.SendCommand(frmSplash.SplashScreenCommand.SetProgress, Progress.CurrentPercent)
|
||||
SplashScreenManager.Default.SendCommand(frmSplash.SplashScreenCommand.SetActionName, Progress.CurrentStep.Name)
|
||||
End Sub
|
||||
|
||||
Private Sub InitCompleted(sender As Object, e As RunWorkerCompletedEventArgs)
|
||||
SplashScreenManager.CloseForm(False)
|
||||
End Sub
|
||||
|
||||
Private Sub CheckConnectivity()
|
||||
Dim oCrypt As New EncryptionLegacy("!35452didalog=")
|
||||
Dim oBuilder = My.SystemConfig.GetConnectionStringBuilder(My.SystemConfig.ConnectionString)
|
||||
oBuilder.Password = oCrypt.DecryptData(oBuilder.Password)
|
||||
Dim oDecryptedConnectionString = oBuilder.ToString
|
||||
|
||||
My.Database = New MSSQLServer(My.LogConfig, oDecryptedConnectionString)
|
||||
|
||||
If My.Database.DBInitialized = False Then
|
||||
Throw New ApplicationException()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function InitializeDatabase() As Boolean
|
||||
If My.SystemConfig.ConnectionString = String.Empty Then
|
||||
Dim oResult = frmConfigDatabase.ShowDialog()
|
||||
|
||||
If oResult = DialogResult.Cancel Then
|
||||
MsgBox("Es wurde keine Datenbank hinterlegt. Die Anwendung wird beendet.")
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
|
||||
Return True
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user