TaskFlow/app/DD_PM_WINDREAM/ApplicationEvents.vb

35 lines
1.9 KiB
VB.net

Imports Microsoft.VisualBasic.ApplicationServices
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 Sub MyApplication_UnhandledException(sender As Object, e As UnhandledExceptionEventArgs) Handles Me.UnhandledException
Dim oMessage = "Application encountered an unhandled error!" & vbNewLine & vbNewLine &
"The errormessage was:" & vbNewLine & e.Exception.Message & vbNewLine &
"The stacktrace was:" & vbNewLine & e.Exception.StackTrace
LOGGER.Error(e.Exception)
Try
If DEBUG = True Then
Dim oLogMessage = LOGCONFIG.Logs.Last()
Dim oLogSplit As String() = oLogMessage.Split("|")
Dim oDBMessage = PrepareLogMessage(oLogMessage) & $" [Machinename: {Environment.MachineName}]"
Dim oSQL = $"INSERT INTO [dbo].[TBPM_LOG_DEBUG] ([USERID], [LOGMSG], [ADDED_WHEN], DATE_STR) VALUES({USER_ID},'{oDBMessage}',GETDATE(),'{Now}')"
DatabaseFallback.ExecuteNonQueryECM(oSQL)
End If
Catch ex As Exception
LOGGER.Error(ex)
End Try
MsgBox(oMessage, MsgBoxStyle.Critical, "Process Manager")
End Sub
End Class
End Namespace