jj
This commit is contained in:
parent
1ed569f7b0
commit
94376068d6
10
EDMI_ClientSuite/ApplicationEvents.vb
Normal file
10
EDMI_ClientSuite/ApplicationEvents.vb
Normal file
@ -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
|
||||||
@ -2,67 +2,39 @@
|
|||||||
Imports DigitalData.Modules.Logging.LogConfig
|
Imports DigitalData.Modules.Logging.LogConfig
|
||||||
Imports System.ServiceModel
|
Imports System.ServiceModel
|
||||||
Imports EDMI_ClientSuite.NetworkService_DDEDM
|
Imports EDMI_ClientSuite.NetworkService_DDEDM
|
||||||
Imports System.IO
|
|
||||||
|
|
||||||
|
|
||||||
Public Class ClassInit
|
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 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()
|
Public Sub New()
|
||||||
_LogConfig = New LogConfig(PathType.AppData)
|
_LogConfig = New LogConfig(PathType.AppData)
|
||||||
_Logger = _LogConfig.GetLogger()
|
|
||||||
MyLogger = _Logger
|
|
||||||
MyLogConfig = _LogConfig
|
|
||||||
|
|
||||||
|
|
||||||
_ChannelFactory = ConfigureChannelFactory()
|
|
||||||
_Logger.Debug("Service channelfactory created")
|
|
||||||
|
|
||||||
Connect()
|
|
||||||
End Sub
|
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()
|
Dim oBinding As New NetTcpBinding()
|
||||||
oBinding.Security.Mode = SecurityMode.Transport
|
oBinding.Security.Mode = SecurityMode.Transport
|
||||||
oBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows
|
oBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows
|
||||||
oBinding.MaxReceivedMessageSize = 2147483647
|
oBinding.MaxReceivedMessageSize = MAX_MESSAGE_SIZE
|
||||||
oBinding.MaxBufferSize = 2147483647
|
oBinding.MaxBufferSize = MAX_BUFFER_SIZE
|
||||||
oBinding.MaxBufferPoolSize = 2147483647
|
oBinding.MaxBufferPoolSize = MAX_BUFFER_SIZE
|
||||||
oBinding.MaxConnections = 10000
|
oBinding.MaxConnections = MAX_CONNECTIONS
|
||||||
oBinding.ReaderQuotas.MaxArrayLength = 2147483647
|
oBinding.ReaderQuotas.MaxArrayLength = MAX_ARRAY_LENGTH
|
||||||
oBinding.ReaderQuotas.MaxStringContentLength = 2147483647
|
oBinding.ReaderQuotas.MaxStringContentLength = MAX_STRING_LENGTH
|
||||||
'oBinding.OpenTimeout = New TimeSpan(0, 0, OPEN_TIMEOUT)
|
oBinding.OpenTimeout = New TimeSpan(0, 0, OPEN_TIMEOUT)
|
||||||
Dim oEndpointAddress = New EndpointAddress(My.Settings.EDM_NetworkService_Adress)
|
Dim oEndpointAddress = New EndpointAddress(My.Settings.EDM_NetworkService_Adress)
|
||||||
|
|
||||||
Return New ChannelFactory(Of IEDMServiceChannel)(oBinding, oEndpointAddress)
|
Return New ChannelFactory(Of IEDMServiceChannel)(oBinding, oEndpointAddress)
|
||||||
End Function
|
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
|
End Class
|
||||||
|
|||||||
@ -164,6 +164,7 @@
|
|||||||
<Import Include="System.Threading.Tasks" />
|
<Import Include="System.Threading.Tasks" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="ApplicationEvents.vb" />
|
||||||
<Compile Include="ClassInit.vb" />
|
<Compile Include="ClassInit.vb" />
|
||||||
<Compile Include="ClassLayout.vb" />
|
<Compile Include="ClassLayout.vb" />
|
||||||
<Compile Include="ClassUtils.vb" />
|
<Compile Include="ClassUtils.vb" />
|
||||||
@ -251,6 +252,7 @@
|
|||||||
<DependentUpon>Settings.settings</DependentUpon>
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="MyApplication.vb" />
|
||||||
<Compile Include="MyAppSettings.vb" />
|
<Compile Include="MyAppSettings.vb" />
|
||||||
<Compile Include="Strings\ControlProperties.Designer.vb">
|
<Compile Include="Strings\ControlProperties.Designer.vb">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
|
|||||||
@ -34,5 +34,10 @@ Namespace My
|
|||||||
Protected Overrides Sub OnCreateMainForm()
|
Protected Overrides Sub OnCreateMainForm()
|
||||||
Me.MainForm = Global.EDMI_ClientSuite.frmMain
|
Me.MainForm = Global.EDMI_ClientSuite.frmMain
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
|
||||||
|
Protected Overrides Sub OnCreateSplashScreen()
|
||||||
|
Me.SplashScreen = Global.EDMI_ClientSuite.frmSplash
|
||||||
|
End Sub
|
||||||
End Class
|
End Class
|
||||||
End Namespace
|
End Namespace
|
||||||
|
|||||||
@ -6,5 +6,6 @@
|
|||||||
<ShutdownMode>0</ShutdownMode>
|
<ShutdownMode>0</ShutdownMode>
|
||||||
<EnableVisualStyles>true</EnableVisualStyles>
|
<EnableVisualStyles>true</EnableVisualStyles>
|
||||||
<AuthenticationMode>0</AuthenticationMode>
|
<AuthenticationMode>0</AuthenticationMode>
|
||||||
|
<SplashScreen>frmSplash</SplashScreen>
|
||||||
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
|
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
|
||||||
</MyApplicationData>
|
</MyApplicationData>
|
||||||
@ -1,8 +1,10 @@
|
|||||||
Imports DigitalData.Modules.Logging
|
Imports DigitalData.Modules.Logging
|
||||||
Module MyAppSettings
|
|
||||||
Public APP_DB_VERSION As String
|
|
||||||
|
|
||||||
Public USER_LANGUAGE As String = "de-DE"
|
Module MyAppSettings
|
||||||
Public MyLogger As Logger
|
Public APP_DB_VERSION As String
|
||||||
Public MyLogConfig As LogConfig
|
|
||||||
End Module
|
Public USER_LANGUAGE As String = "de-DE"
|
||||||
|
Public MyLogger As Logger
|
||||||
|
Public MyLogConfig As LogConfig
|
||||||
|
End Module
|
||||||
|
|
||||||
|
|||||||
38
EDMI_ClientSuite/MyApplication.vb
Normal file
38
EDMI_ClientSuite/MyApplication.vb
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
Imports System.ServiceModel
|
||||||
|
Imports DigitalData.Modules.Logging
|
||||||
|
Imports EDMI_ClientSuite.NetworkService_DDEDM
|
||||||
|
|
||||||
|
Namespace My
|
||||||
|
''' <summary>
|
||||||
|
''' Helper Class to hold User State
|
||||||
|
''' </summary>
|
||||||
|
Public Class User
|
||||||
|
Public Username As String
|
||||||
|
Public MachineName As String
|
||||||
|
|
||||||
|
Public Sub New()
|
||||||
|
Username = Environment.UserName
|
||||||
|
MachineName = Environment.MachineName
|
||||||
|
End Sub
|
||||||
|
End Class
|
||||||
|
|
||||||
|
''' <summary>
|
||||||
|
''' Extends the My Namespace
|
||||||
|
''' </summary>
|
||||||
|
<HideModuleName()>
|
||||||
|
Module Extension
|
||||||
|
Property LogConfig As LogConfig
|
||||||
|
Property ChannelFactory As ChannelFactory(Of IEDMServiceChannel)
|
||||||
|
Property Channel As IEDMServiceChannel
|
||||||
|
End Module
|
||||||
|
|
||||||
|
''' <summary>
|
||||||
|
''' Extends the My.Application Namespace
|
||||||
|
''' </summary>
|
||||||
|
Partial Class MyApplication
|
||||||
|
' User Config
|
||||||
|
Public User As New User()
|
||||||
|
End Class
|
||||||
|
End Namespace
|
||||||
|
|
||||||
|
|
||||||
@ -6,13 +6,6 @@ Imports EDMI_ClientSuite.ClassLayout
|
|||||||
Imports System.IO
|
Imports System.IO
|
||||||
|
|
||||||
Public Class frmMain
|
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
|
Private Sub FrmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||||
LabelCurrentUser.Caption = Environment.UserName
|
LabelCurrentUser.Caption = Environment.UserName
|
||||||
LabelCurrentMachine.Caption = Environment.MachineName
|
LabelCurrentMachine.Caption = Environment.MachineName
|
||||||
@ -33,8 +26,8 @@ Public Class frmMain
|
|||||||
oDataTable.Rows.Add(oRow)
|
oDataTable.Rows.Add(oRow)
|
||||||
|
|
||||||
ProcessManagerOverview.DataSource = oDataTable
|
ProcessManagerOverview.DataSource = oDataTable
|
||||||
AddHandler ProcessManagerOverview.RowDoubleClicked, Sub(Row As DataRowView)
|
AddHandler ProcessManagerOverview.RowDoubleClicked, Sub(RowView As DataRowView)
|
||||||
MsgBox($"Clicked on Document {Row.Row.Item("DocName")}")
|
MsgBox($"Clicked on Document {RowView.Row.Item("DocName")}")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,44 +1,73 @@
|
|||||||
Imports System.ComponentModel
|
Imports System.ComponentModel
|
||||||
Imports System.Diagnostics
|
Imports System.ServiceModel
|
||||||
Imports System.Threading
|
Imports DigitalData.Modules.Logging
|
||||||
Imports System.Globalization
|
Imports DigitalData.Modules.Logging.LogConfig
|
||||||
|
Imports EDMI_ClientSuite.NetworkService_DDEDM
|
||||||
|
|
||||||
Public NotInheritable Class frmSplash
|
Public NotInheritable Class frmSplash
|
||||||
Private InitSteps As Integer = 2
|
Private _Worker As New BackgroundWorker()
|
||||||
Private bw 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
|
Private Sub frmSplash_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
|
||||||
lblProductName.Text = My.Application.Info.ProductName
|
lblProductName.Text = My.Application.Info.ProductName
|
||||||
lblCopyright.Text = My.Application.Info.Copyright
|
lblCopyright.Text = My.Application.Info.Copyright
|
||||||
lblVersion.Text = String.Format("Version {0}", My.Application.Info.Version.ToString)
|
lblVersion.Text = String.Format("Version {0}", My.Application.Info.Version.ToString)
|
||||||
|
|
||||||
Me.BringToFront()
|
BringToFront()
|
||||||
|
StartWorker()
|
||||||
InitProgram()
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub InitProgram()
|
Private Function SetProgress(_step As Integer)
|
||||||
bw.WorkerReportsProgress = True
|
Return _step * (100 / INIT_STEPS)
|
||||||
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)
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
<STAThread()>
|
Private Sub StartWorker()
|
||||||
Private Sub bw_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs)
|
AddHandler _Worker.DoWork, AddressOf bw_DoWork
|
||||||
bw.ReportProgress(CalcProgress(1), "Connecting to service..")
|
AddHandler _Worker.ProgressChanged, AddressOf bw_ProgressChanged
|
||||||
Dim Init = New ClassInit()
|
AddHandler _Worker.RunWorkerCompleted, AddressOf bw_RunWorkerCompleted
|
||||||
System.Threading.Thread.Sleep(600)
|
|
||||||
|
|
||||||
bw.ReportProgress(CalcProgress(2), "Initialize User Settings")
|
_Worker.WorkerReportsProgress = True
|
||||||
' Init.InitUserConfig()
|
_Worker.RunWorkerAsync()
|
||||||
System.Threading.Thread.Sleep(600)
|
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
|
End Sub
|
||||||
|
|
||||||
Private Sub bw_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs)
|
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
|
' Bei Fehler MsgBox anzeigen und Programm beenden
|
||||||
If e.Error IsNot Nothing Then
|
If e.Error IsNot Nothing Then
|
||||||
'ClassLogger.Add("Unexpected error in Initializing application....")
|
'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()
|
Application.Exit()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Wenn kein Fehler, Splashscreen schließen
|
' Wenn kein Fehler, Splashscreen schließen
|
||||||
Me.Close()
|
Me.Close()
|
||||||
End Sub
|
End Sub
|
||||||
|
#End Region
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@ -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_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 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 failSafePath As String = Path.GetTempPath()
|
||||||
Private ReadOnly basePath As String = failSafePath
|
Private ReadOnly basePath As String = failSafePath
|
||||||
|
|
||||||
@ -167,11 +170,11 @@ Public Class LogConfig
|
|||||||
|
|
||||||
If logPath = PathType.AppData Then
|
If logPath = PathType.AppData Then
|
||||||
Dim appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
|
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
|
ElseIf logPath = PathType.CurrentDirectory Then
|
||||||
Dim currentDirectory As String = My.Application.Info.DirectoryPath
|
Dim currentDirectory As String = My.Application.Info.DirectoryPath
|
||||||
|
|
||||||
basePath = Path.Combine(currentDirectory, "Log")
|
basePath = Path.Combine(currentDirectory, FOLDER_NAME_LOG)
|
||||||
Else 'Custom Path
|
Else 'Custom Path
|
||||||
basePath = customLogPath
|
basePath = customLogPath
|
||||||
End If
|
End If
|
||||||
@ -188,7 +191,7 @@ Public Class LogConfig
|
|||||||
|
|
||||||
' Try to create a file in `basePath` to check write permissions
|
' Try to create a file in `basePath` to check write permissions
|
||||||
Try
|
Try
|
||||||
Dim fileAccessPath = Path.Combine(basePath, "accessTest.txt")
|
Dim fileAccessPath = Path.Combine(basePath, FILE_NAME_ACCESS_TEST)
|
||||||
Using fs As FileStream = File.Create(fileAccessPath)
|
Using fs As FileStream = File.Create(fileAccessPath)
|
||||||
fs.WriteByte(0)
|
fs.WriteByte(0)
|
||||||
End Using
|
End Using
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user