48 lines
1.7 KiB
VB.net
48 lines
1.7 KiB
VB.net
Imports DigitalData.Modules.Logging
|
|
Imports System.Windows.Forms
|
|
|
|
Public Class FormHelper
|
|
Private ReadOnly LogConfig As LogConfig
|
|
Private ReadOnly Logger As Logger
|
|
Private ReadOnly Form As Form
|
|
|
|
Public Sub New(pLogConfig As LogConfig, pForm As Form)
|
|
LogConfig = pLogConfig
|
|
Logger = pLogConfig.GetLogger()
|
|
Form = pForm
|
|
End Sub
|
|
|
|
Public Function ShowInfoMessage(pMessage As String, pTitle As String) As DialogResult
|
|
Logger.Info(pMessage)
|
|
|
|
Dim oForm As New frmDialog(pMessage, pTitle, frmDialog.DialogType.Info)
|
|
Return oForm.ShowDialog()
|
|
End Function
|
|
|
|
Public Function ShowErrorMessage(pMessage As String, pTitle As String) As DialogResult
|
|
Return ShowErrorMessage(New ApplicationException(pMessage), pTitle)
|
|
End Function
|
|
|
|
Public Function ShowErrorMessage(pException As Exception, pTitle As String) As DialogResult
|
|
Logger.Error(pException)
|
|
|
|
Dim oMessage = String.Format("In der Funktion '{0}' ist folgender Fehler aufgetreten: {1}", pTitle, vbNewLine & vbNewLine & pException.Message)
|
|
|
|
If LogConfig.Debug Then
|
|
oMessage &= vbNewLine & vbNewLine & "=== Debug Information ==="
|
|
oMessage &= vbNewLine & vbNewLine & "Stacktrace:"
|
|
oMessage &= vbNewLine & pException.StackTrace
|
|
End If
|
|
|
|
Dim oForm As New frmDialog(oMessage, pTitle, frmDialog.DialogType.Error)
|
|
Return oForm.ShowDialog()
|
|
End Function
|
|
|
|
Public Function ShowWarningMessage(pMessage As String, pTitle As String) As DialogResult
|
|
Logger.Warn(pMessage)
|
|
|
|
Dim oForm As New frmDialog(pMessage, pTitle, frmDialog.DialogType.Error)
|
|
Return oForm.ShowDialog()
|
|
End Function
|
|
End Class
|