106 lines
3.7 KiB
VB.net
106 lines
3.7 KiB
VB.net
Imports System.ComponentModel
|
|
Imports System.ServiceModel
|
|
Imports System.Threading
|
|
Imports DigitalData.Modules.Logging
|
|
Imports DigitalData.Modules.Logging.LogConfig
|
|
Imports EDMI_ClientSuite.NetworkService_DDEDM
|
|
|
|
Public NotInheritable Class frmSplash
|
|
Private _Worker As New BackgroundWorker()
|
|
Private _ChannelFactory As ChannelFactory(Of IEDMServiceChannel)
|
|
Private _Channel As IEDMServiceChannel
|
|
Private _Logger As Logger
|
|
|
|
Private _CurrentRetry As Integer = 0
|
|
|
|
Private Const SLEEP_TIME = 600
|
|
Private Const INIT_STEPS = 4
|
|
Private Const MAX_RETRIES = 10
|
|
Private Const OPEN_TIMEOUT = 10
|
|
|
|
Private Sub frmSplash_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
|
|
lblProductName.Text = My.Application.Info.ProductName
|
|
lblCopyright.Text = My.Application.Info.Copyright
|
|
lblVersion.Text = String.Format("Version {0}", My.Application.Info.Version.ToString)
|
|
|
|
BringToFront()
|
|
|
|
Dim oService As New ClassService(My.LogConfig)
|
|
Dim oConnectionURLExists As Boolean = My.Config.ServiceConnection <> String.Empty
|
|
|
|
'Dim oInit As New ClassInit()
|
|
'Dim oConnectionURLExists = oInit.TestConnectionURLExists()
|
|
|
|
If Not oConnectionURLExists Then
|
|
Dim oResult = frmConfigService.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
|
|
AddHandler _Worker.RunWorkerCompleted, AddressOf bw_RunWorkerCompleted
|
|
|
|
_Worker.WorkerReportsProgress = True
|
|
_Worker.RunWorkerAsync()
|
|
End Sub
|
|
|
|
Private Sub bw_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs)
|
|
Dim oService As New ClassService(My.LogConfig)
|
|
|
|
_Worker.ReportProgress(SetProgress(1), "Connecting to service..")
|
|
|
|
Dim oChannelFactory As ChannelFactory(Of IEDMServiceChannel)
|
|
Dim oChannel As IEDMServiceChannel
|
|
Dim oConnectionSuccessful = False
|
|
|
|
oChannelFactory = oService.GetChannelFactory()
|
|
oChannel = oChannelFactory.CreateChannel()
|
|
|
|
Thread.Sleep(SLEEP_TIME)
|
|
|
|
' TODO: Initialize Usersettings and populate My.Application.User
|
|
|
|
_Worker.ReportProgress(SetProgress(2), "Initializing User Settings..")
|
|
Thread.Sleep(SLEEP_TIME)
|
|
|
|
_Worker.ReportProgress(SetProgress(3), "Connecting to mainframe..")
|
|
Thread.Sleep(SLEEP_TIME)
|
|
|
|
_Worker.ReportProgress(SetProgress(4), "Setting up neural network..")
|
|
Thread.Sleep(SLEEP_TIME)
|
|
End Sub
|
|
|
|
Private Sub bw_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs)
|
|
pbStatus.Value = e.ProgressPercentage
|
|
lblStatus.Text = e.UserState.ToString()
|
|
End Sub
|
|
|
|
Private Sub bw_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs)
|
|
' Bei Fehler MsgBox anzeigen und Programm beenden
|
|
If e.Error IsNot Nothing Then
|
|
'ClassLogger.Add("Unexpected error in Initializing application....")
|
|
MsgBox(e.Error.Message, MsgBoxStyle.Critical, "Critical Error")
|
|
Application.Exit()
|
|
End If
|
|
|
|
' Wenn kein Fehler, Splashscreen schließen
|
|
Me.Close()
|
|
End Sub
|
|
#End Region
|
|
End Class
|