Add Common Queries, Load User & Module Info from DB

This commit is contained in:
Jonathan Jenne
2019-09-10 16:27:31 +02:00
parent 5c7375d124
commit 13da64c6ad
22 changed files with 598 additions and 102 deletions

View File

@@ -14,7 +14,7 @@ Public Class ClassInitLoader
_Logger = My.LogConfig.GetLogger()
End Sub
Public Sub AddStep(Name As String, Action As Action, Optional Fatal As Boolean = False)
Public Sub AddStep(Name As String, Action As Action(Of Object), Optional Fatal As Boolean = False)
Steps.Add(New InitStep() With {
.Name = Name,
.Action = Action,
@@ -38,26 +38,27 @@ Public Class ClassInitLoader
RaiseEvent InitCompleted(sender, e)
End Sub
_Worker.RunWorkerAsync()
_Worker.RunWorkerAsync(My.Application)
Return True
End Function
Private Sub DoWork(sender As Object, e As DoWorkEventArgs)
Dim oMyApplication As My.MyApplication = DirectCast(e.Argument, My.MyApplication)
Dim oStepCounter = 0
For Each oStep In Steps
_CurrentStep = oStep
Try
oStep.Action.Invoke()
oStep.Action.Invoke(oMyApplication)
Catch ex As Exception
_Logger.Error(ex)
_Logger.Warn("Init Step '{0}' failed!", oStep.Name)
If oStep.Fatal Then
_Logger.Warn("Fatal error in '{0}'. Init will be aborted!", oStep.Name)
e.Cancel = True
Throw ex
End If
End Try
@@ -68,6 +69,8 @@ Public Class ClassInitLoader
Threading.Thread.Sleep(600)
Next
e.Result = oMyApplication
End Sub
Public Class InitProgress
@@ -83,10 +86,18 @@ Public Class ClassInitLoader
''' <summary>
''' The function to execute
''' </summary>
Public Action As Action
Public Action As Action(Of Object)
''' <summary>
''' Should init be aborted if this step fails?
''' </summary>
Public Fatal As Boolean
End Class
Public Class InitException
Inherits ApplicationException
Public Sub New(message As String)
MyBase.New(message)
End Sub
End Class
End Class