diff --git a/EDMI_ClientSuite/ApplicationEvents.vb b/EDMI_ClientSuite/ApplicationEvents.vb
new file mode 100644
index 00000000..bc254e28
--- /dev/null
+++ b/EDMI_ClientSuite/ApplicationEvents.vb
@@ -0,0 +1,10 @@
+Namespace My
+ ' Für MyApplication sind folgende Ereignisse verfügbar:
+ ' Startup: Wird beim Starten der Anwendung noch vor dem Erstellen des Startformulars ausgelöst.
+ ' Shutdown: Wird nach dem Schließen aller Anwendungsformulare ausgelöst. Dieses Ereignis wird nicht ausgelöst, wenn die Anwendung mit einem Fehler beendet wird.
+ ' UnhandledException: Wird bei einem Ausnahmefehler ausgelöst.
+ ' StartupNextInstance: Wird beim Starten einer Einzelinstanzanwendung ausgelöst, wenn die Anwendung bereits aktiv ist.
+ ' NetworkAvailabilityChanged: Wird beim Herstellen oder Trennen der Netzwerkverbindung ausgelöst.
+ Partial Friend Class MyApplication
+ End Class
+End Namespace
diff --git a/EDMI_ClientSuite/ClassInit.vb b/EDMI_ClientSuite/ClassInit.vb
index e955433b..c2346e4a 100644
--- a/EDMI_ClientSuite/ClassInit.vb
+++ b/EDMI_ClientSuite/ClassInit.vb
@@ -2,67 +2,39 @@
Imports DigitalData.Modules.Logging.LogConfig
Imports System.ServiceModel
Imports EDMI_ClientSuite.NetworkService_DDEDM
-Imports System.IO
-
Public Class ClassInit
- Private _ChannelFactory As ChannelFactory(Of IEDMServiceChannel)
- Private _Channel As IEDMServiceChannel
- Private _Logger As Logger
- Private _LogConfig As LogConfig
-
- Private CurrentRetry As Integer = 0
-
- Private Const MAX_RETRIES = 10
Private Const OPEN_TIMEOUT = 10
+ Private Const MAX_MESSAGE_SIZE = 2147483647
+ Private Const MAX_BUFFER_SIZE = 2147483647
+ Private Const MAX_ARRAY_LENGTH = 2147483647
+ Private Const MAX_STRING_LENGTH = 2147483647
+ Private Const MAX_CONNECTIONS = 10000
+
+ Public Property _LogConfig As LogConfig
Public Sub New()
_LogConfig = New LogConfig(PathType.AppData)
- _Logger = _LogConfig.GetLogger()
- MyLogger = _Logger
- MyLogConfig = _LogConfig
-
-
- _ChannelFactory = ConfigureChannelFactory()
- _Logger.Debug("Service channelfactory created")
-
- Connect()
End Sub
- Public Function ConfigureChannelFactory()
+ Public Function CreateService() As ChannelFactory(Of IEDMServiceChannel)
+ Return CreateChannelFactory()
+ End Function
+
+ Private Function CreateChannelFactory() As ChannelFactory(Of IEDMServiceChannel)
Dim oBinding As New NetTcpBinding()
oBinding.Security.Mode = SecurityMode.Transport
oBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows
- oBinding.MaxReceivedMessageSize = 2147483647
- oBinding.MaxBufferSize = 2147483647
- oBinding.MaxBufferPoolSize = 2147483647
- oBinding.MaxConnections = 10000
- oBinding.ReaderQuotas.MaxArrayLength = 2147483647
- oBinding.ReaderQuotas.MaxStringContentLength = 2147483647
- 'oBinding.OpenTimeout = New TimeSpan(0, 0, OPEN_TIMEOUT)
+ oBinding.MaxReceivedMessageSize = MAX_MESSAGE_SIZE
+ oBinding.MaxBufferSize = MAX_BUFFER_SIZE
+ oBinding.MaxBufferPoolSize = MAX_BUFFER_SIZE
+ oBinding.MaxConnections = MAX_CONNECTIONS
+ oBinding.ReaderQuotas.MaxArrayLength = MAX_ARRAY_LENGTH
+ oBinding.ReaderQuotas.MaxStringContentLength = MAX_STRING_LENGTH
+ oBinding.OpenTimeout = New TimeSpan(0, 0, OPEN_TIMEOUT)
Dim oEndpointAddress = New EndpointAddress(My.Settings.EDM_NetworkService_Adress)
Return New ChannelFactory(Of IEDMServiceChannel)(oBinding, oEndpointAddress)
End Function
- Private Sub Connect()
- Try
- _Channel = _ChannelFactory.CreateChannel()
- _Logger.Debug("Service channel created")
- _Logger.Debug("Opening service channel")
- AddHandler _Channel.Faulted, AddressOf Reconnect
- _Channel.Open()
- _Logger.Debug("Service channel opened")
- _Logger.Info("Connection to service established!")
- Catch ex As Exception
- _Logger.Error(ex)
- Throw ex
- End Try
- End Sub
- Private Sub Reconnect(sender As Object, e As EventArgs)
- _Logger.Warn("Could not connect to service. Retrying.")
- _Channel.Abort()
-
- Connect()
- End Sub
End Class
diff --git a/EDMI_ClientSuite/EDMI_ClientSuite.vbproj b/EDMI_ClientSuite/EDMI_ClientSuite.vbproj
index 654c76d5..573239e6 100644
--- a/EDMI_ClientSuite/EDMI_ClientSuite.vbproj
+++ b/EDMI_ClientSuite/EDMI_ClientSuite.vbproj
@@ -164,6 +164,7 @@
+
@@ -251,6 +252,7 @@
Settings.settings
True
+
True
diff --git a/EDMI_ClientSuite/My Project/Application.Designer.vb b/EDMI_ClientSuite/My Project/Application.Designer.vb
index 55d6a2a9..4d9b26d7 100644
--- a/EDMI_ClientSuite/My Project/Application.Designer.vb
+++ b/EDMI_ClientSuite/My Project/Application.Designer.vb
@@ -34,5 +34,10 @@ Namespace My
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.EDMI_ClientSuite.frmMain
End Sub
+
+ _
+ Protected Overrides Sub OnCreateSplashScreen()
+ Me.SplashScreen = Global.EDMI_ClientSuite.frmSplash
+ End Sub
End Class
End Namespace
diff --git a/EDMI_ClientSuite/My Project/Application.myapp b/EDMI_ClientSuite/My Project/Application.myapp
index 5eb49b3b..b84db44c 100644
--- a/EDMI_ClientSuite/My Project/Application.myapp
+++ b/EDMI_ClientSuite/My Project/Application.myapp
@@ -6,5 +6,6 @@
0
true
0
+ frmSplash
true
\ No newline at end of file
diff --git a/EDMI_ClientSuite/MyAppSettings.vb b/EDMI_ClientSuite/MyAppSettings.vb
index e90b171e..62fd1d39 100644
--- a/EDMI_ClientSuite/MyAppSettings.vb
+++ b/EDMI_ClientSuite/MyAppSettings.vb
@@ -1,8 +1,10 @@
Imports DigitalData.Modules.Logging
-Module MyAppSettings
- Public APP_DB_VERSION As String
- Public USER_LANGUAGE As String = "de-DE"
- Public MyLogger As Logger
- Public MyLogConfig As LogConfig
-End Module
+Module MyAppSettings
+ Public APP_DB_VERSION As String
+
+ Public USER_LANGUAGE As String = "de-DE"
+ Public MyLogger As Logger
+ Public MyLogConfig As LogConfig
+ End Module
+
diff --git a/EDMI_ClientSuite/MyApplication.vb b/EDMI_ClientSuite/MyApplication.vb
new file mode 100644
index 00000000..222d8d84
--- /dev/null
+++ b/EDMI_ClientSuite/MyApplication.vb
@@ -0,0 +1,38 @@
+Imports System.ServiceModel
+Imports DigitalData.Modules.Logging
+Imports EDMI_ClientSuite.NetworkService_DDEDM
+
+Namespace My
+ '''
+ ''' Helper Class to hold User State
+ '''
+ Public Class User
+ Public Username As String
+ Public MachineName As String
+
+ Public Sub New()
+ Username = Environment.UserName
+ MachineName = Environment.MachineName
+ End Sub
+ End Class
+
+ '''
+ ''' Extends the My Namespace
+ '''
+
+ Module Extension
+ Property LogConfig As LogConfig
+ Property ChannelFactory As ChannelFactory(Of IEDMServiceChannel)
+ Property Channel As IEDMServiceChannel
+ End Module
+
+ '''
+ ''' Extends the My.Application Namespace
+ '''
+ Partial Class MyApplication
+ ' User Config
+ Public User As New User()
+ End Class
+End Namespace
+
+
diff --git a/EDMI_ClientSuite/frmMain.vb b/EDMI_ClientSuite/frmMain.vb
index 9cc3e754..317ad4ae 100644
--- a/EDMI_ClientSuite/frmMain.vb
+++ b/EDMI_ClientSuite/frmMain.vb
@@ -6,13 +6,6 @@ Imports EDMI_ClientSuite.ClassLayout
Imports System.IO
Public Class frmMain
- Public Sub New()
- InitializeComponent()
-
- Dim oForm As New frmSplash()
- oForm.ShowDialog()
- End Sub
-
Private Sub FrmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
LabelCurrentUser.Caption = Environment.UserName
LabelCurrentMachine.Caption = Environment.MachineName
@@ -33,8 +26,8 @@ Public Class frmMain
oDataTable.Rows.Add(oRow)
ProcessManagerOverview.DataSource = oDataTable
- AddHandler ProcessManagerOverview.RowDoubleClicked, Sub(Row As DataRowView)
- MsgBox($"Clicked on Document {Row.Row.Item("DocName")}")
+ AddHandler ProcessManagerOverview.RowDoubleClicked, Sub(RowView As DataRowView)
+ MsgBox($"Clicked on Document {RowView.Row.Item("DocName")}")
End Sub
diff --git a/EDMI_ClientSuite/frmSplash.vb b/EDMI_ClientSuite/frmSplash.vb
index ea1d28ca..496e0f6f 100644
--- a/EDMI_ClientSuite/frmSplash.vb
+++ b/EDMI_ClientSuite/frmSplash.vb
@@ -1,44 +1,73 @@
Imports System.ComponentModel
-Imports System.Diagnostics
-Imports System.Threading
-Imports System.Globalization
+Imports System.ServiceModel
+Imports DigitalData.Modules.Logging
+Imports DigitalData.Modules.Logging.LogConfig
+Imports EDMI_ClientSuite.NetworkService_DDEDM
Public NotInheritable Class frmSplash
- Private InitSteps As Integer = 2
- Private bw As New BackgroundWorker()
+ 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 = 1
+ 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)
- Me.BringToFront()
-
- InitProgram()
+ BringToFront()
+ StartWorker()
End Sub
- Private Sub InitProgram()
- bw.WorkerReportsProgress = True
- AddHandler bw.DoWork, AddressOf bw_DoWork
- AddHandler bw.ProgressChanged, AddressOf bw_ProgressChanged
- AddHandler bw.RunWorkerCompleted, AddressOf bw_RunWorkerCompleted
-
- bw.RunWorkerAsync()
- End Sub
-
- Private Function CalcProgress(_step As Integer)
- Return _step * (100 / InitSteps)
+ Private Function SetProgress(_step As Integer)
+ Return _step * (100 / INIT_STEPS)
End Function
-
- Private Sub bw_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs)
- bw.ReportProgress(CalcProgress(1), "Connecting to service..")
- Dim Init = New ClassInit()
- System.Threading.Thread.Sleep(600)
+ Private Sub StartWorker()
+ AddHandler _Worker.DoWork, AddressOf bw_DoWork
+ AddHandler _Worker.ProgressChanged, AddressOf bw_ProgressChanged
+ AddHandler _Worker.RunWorkerCompleted, AddressOf bw_RunWorkerCompleted
- bw.ReportProgress(CalcProgress(2), "Initialize User Settings")
- ' Init.InitUserConfig()
- System.Threading.Thread.Sleep(600)
+ _Worker.WorkerReportsProgress = True
+ _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
+
+ '------------------
+ _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)
+
+ ' TODO: Initialize Usersettings and populate My.Application.User
End Sub
Private Sub bw_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs)
@@ -50,11 +79,12 @@ Public NotInheritable Class frmSplash
' 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, "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
diff --git a/Modules.Logging/LogConfig.vb b/Modules.Logging/LogConfig.vb
index 3accf6cb..9faa6422 100644
--- a/Modules.Logging/LogConfig.vb
+++ b/Modules.Logging/LogConfig.vb
@@ -111,6 +111,9 @@ Public Class LogConfig
Private Const LOG_FORMAT_EXCEPTION As String = LOG_FORMAT_BASE & " >> ${exception:format=Message}${newline}${exception:format=StackTrace}"
Private Const LOG_FORMAT_DEBUG As String = LOG_FORMAT_BASE_LONG_DATE & " >> ${message}"
+ Private Const FOLDER_NAME_LOG = "Log"
+ Private Const FILE_NAME_ACCESS_TEST = "accessTest.txt"
+
Private ReadOnly failSafePath As String = Path.GetTempPath()
Private ReadOnly basePath As String = failSafePath
@@ -167,11 +170,11 @@ Public Class LogConfig
If logPath = PathType.AppData Then
Dim appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
- basePath = Path.Combine(appDataDir, companyName, productName)
+ basePath = Path.Combine(appDataDir, companyName, productName, FOLDER_NAME_LOG)
ElseIf logPath = PathType.CurrentDirectory Then
Dim currentDirectory As String = My.Application.Info.DirectoryPath
- basePath = Path.Combine(currentDirectory, "Log")
+ basePath = Path.Combine(currentDirectory, FOLDER_NAME_LOG)
Else 'Custom Path
basePath = customLogPath
End If
@@ -188,7 +191,7 @@ Public Class LogConfig
' Try to create a file in `basePath` to check write permissions
Try
- Dim fileAccessPath = Path.Combine(basePath, "accessTest.txt")
+ Dim fileAccessPath = Path.Combine(basePath, FILE_NAME_ACCESS_TEST)
Using fs As FileStream = File.Create(fileAccessPath)
fs.WriteByte(0)
End Using