jj: add service config form

This commit is contained in:
Jonathan Jenne
2019-01-29 16:32:37 +01:00
parent 94376068d6
commit 6ede3e1be9
14 changed files with 521 additions and 40 deletions

View File

@@ -1,5 +1,6 @@
Imports System.ComponentModel
Imports System.ServiceModel
Imports System.Threading
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Logging.LogConfig
Imports EDMI_ClientSuite.NetworkService_DDEDM
@@ -13,7 +14,7 @@ Public NotInheritable Class frmSplash
Private _CurrentRetry As Integer = 0
Private Const SLEEP_TIME = 600
Private Const INIT_STEPS = 1
Private Const INIT_STEPS = 2
Private Const MAX_RETRIES = 10
Private Const OPEN_TIMEOUT = 10
@@ -23,13 +24,29 @@ Public NotInheritable Class frmSplash
lblVersion.Text = String.Format("Version {0}", My.Application.Info.Version.ToString)
BringToFront()
StartWorker()
Dim oInit As New ClassInit()
Dim oConnectionURLExists = oInit.TestConnectionURLExists
If Not oConnectionURLExists Then
Dim oResult = frmServiceConfig.ShowDialog()
If oResult = DialogResult.Cancel Then
MsgBox("Es wurde keine Dienst Verbindungsurl hinterlegt. Die Anwendung wird beendet.")
Application.Exit()
Else
StartWorker()
End If
Else
StartWorker()
End If
End Sub
Private Function SetProgress(_step As Integer)
Return _step * (100 / INIT_STEPS)
End Function
#Region "Worker"
Private Sub StartWorker()
AddHandler _Worker.DoWork, AddressOf bw_DoWork
AddHandler _Worker.ProgressChanged, AddressOf bw_ProgressChanged
@@ -39,33 +56,21 @@ Public NotInheritable Class frmSplash
_Worker.RunWorkerAsync()
End Sub
#Region "Worker"
Private Sub bw_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs)
Dim oInit As ClassInit
Try
oInit = New ClassInit()
My.LogConfig = oInit._LogConfig
_Logger = My.LogConfig.GetLogger()
Catch ex As Exception
Throw New Exception($"Error while initializing Logger: {ex.Message}", ex)
End Try
Dim oInit As New ClassInit()
'------------------
_Worker.ReportProgress(SetProgress(1), "Connecting to service..")
Try
My.ChannelFactory = oInit.CreateService()
My.Channel = My.ChannelFactory.CreateChannel()
AddHandler My.Channel.Faulted, Sub()
_Logger.Error("Could not connect to service")
Throw New Exception("Could not connect to service")
End Sub
My.Channel.Open()
Catch ex As Exception
Throw New Exception($"Error while connectiong to service: {ex.Message}", ex)
End Try
System.Threading.Thread.Sleep(SLEEP_TIME)
Dim oChannelFactory As ChannelFactory(Of IEDMServiceChannel)
Dim oChannel As IEDMServiceChannel
Dim oConnectionSuccessful = False
oChannelFactory = oInit.GetChannelFactory()
oChannel = oChannelFactory.CreateChannel()
Thread.Sleep(SLEEP_TIME)
' TODO: Initialize Usersettings and populate My.Application.User
End Sub