Monorepo/GUIs.ZooFlow/ApplicationEvents.vb
2020-11-18 16:38:41 +01:00

56 lines
3.1 KiB
VB.net

Imports DigitalData.Modules.Config
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Logging.LogConfig
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
Private _Logger As Logger
Private _BaseUserConfigPath As String = Windows.Forms.Application.UserAppDataPath
Private _BaseLocalUserConfigPath As String = Windows.Forms.Application.LocalUserAppDataPath
Private _BaseMachineConfigPath As String = Windows.Forms.Application.CommonAppDataPath
Private _BaseStartupPath As String = Windows.Forms.Application.StartupPath
Public Sub App_Startup() Handles Me.Startup
Dim oLogConfig As New LogConfig(LogPath:=PathType.AppData, CompanyName:="Digital Data", ProductName:="ZooFlow") With {.Debug = True}
' System Config files like Service Url will be saved in %LocalAppdata% so they will remain on the machine
Dim oSystemConfigManager As New ConfigManager(Of ClassConfig)(oLogConfig,
_BaseLocalUserConfigPath,
_BaseMachineConfigPath,
_BaseStartupPath)
' Layout files will be saved in %Appdata% (Roaming) so they will be syncronized with the user profile
Dim oUIConfigPath = IO.Path.Combine(_BaseUserConfigPath, ClassConstants.FOLDER_NAME_LAYOUT)
Dim oUIConfigAlternatePath = IO.Path.Combine(_BaseStartupPath, ClassConstants.FOLDER_NAME_LAYOUT)
Dim oUIConfigManager As New ConfigManager(Of ClassUIConfig)(oLogConfig, oUIConfigPath, oUIConfigPath, oUIConfigAlternatePath)
LogConfig = oLogConfig
LogConfig.Debug = True
SystemConfigManager = oSystemConfigManager
UIConfigManager = oUIConfigManager
_Logger = LogConfig.GetLogger()
_Logger.Debug("Starting Client Suite..")
Dim oCommandLineArgs As New ClassCommandlineArgs(LogConfig)
Dim oArgs = Environment.GetCommandLineArgs().Skip(1).ToList()
oCommandLineArgs.Parse(oArgs)
CommandLineFunction = oCommandLineArgs.FunctionName
CommandLineArguments = oCommandLineArgs.FunctionArgs
End Sub
Public Sub App_Shutdown(sender As Object, e As EventArgs) Handles Me.Shutdown
_Logger.Debug("Shutting down Client Suite..")
End Sub
End Class
End Namespace