Compare commits
3 Commits
72e639dc0c
...
2bf8a18277
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bf8a18277 | ||
|
|
af040e4ee9 | ||
|
|
18786bee33 |
@@ -14,9 +14,14 @@ Namespace Base
|
||||
_Form = Form
|
||||
End Sub
|
||||
|
||||
Public Sub ShowErrorMessage(Exception As Exception)
|
||||
Public Sub ShowErrorMessage(Exception As Exception, Origin As String)
|
||||
Dim oMessage = GetMessage(Exception, Origin)
|
||||
ShowErrorMessage(Exception, Origin, oMessage)
|
||||
End Sub
|
||||
|
||||
Public Sub ShowErrorMessage(Exception As Exception, Origin As String, Message As String)
|
||||
_Logger.Error(Exception)
|
||||
MessageBox.Show(GetMessage(Exception), _Form.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
||||
MessageBox.Show(Message, _Form.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
End Sub
|
||||
|
||||
Public Sub ShowInfoMessage(Text As String)
|
||||
@@ -24,8 +29,7 @@ Namespace Base
|
||||
MessageBox.Show(Text, _Form.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
|
||||
End Sub
|
||||
|
||||
Private Function GetMessage(Exception As Exception) As String
|
||||
Dim oCallingClass = LogConfig.GetClassFullName(IncludeMethodNames:=True, Parts:=2)
|
||||
Private Function GetMessage(Exception As Exception, Origin As String) As String
|
||||
Dim oMessage As String = String.Empty
|
||||
|
||||
If TypeOf Exception Is SqlClient.SqlException Then
|
||||
@@ -37,13 +41,13 @@ Namespace Base
|
||||
ElseIf TypeOf Exception Is NoNullAllowedException Then
|
||||
oMessage = "Einige benötigte Felder wurde nicht ausgefüllt."
|
||||
Else
|
||||
oMessage = $"Es ist ein unerwarteter Fehler in {oCallingClass} aufgetreten. Mehr Informationen finden Sie im Log."
|
||||
oMessage = $"An unhandled exception occurred in {Origin}: " & vbNewLine &
|
||||
Exception.Message & vbNewLine & vbNewLine &
|
||||
"More information can be found in the Application Log."
|
||||
End If
|
||||
|
||||
If _LogConfig.Debug Then
|
||||
oMessage &= vbNewLine & vbNewLine & "== Debug Informationen =="
|
||||
oMessage &= vbNewLine & vbNewLine & "Die ursprüngliche Fehlermeldung lautet:"
|
||||
oMessage &= vbNewLine & Exception.Message
|
||||
oMessage &= vbNewLine & vbNewLine & "=== Debug Information ==="
|
||||
oMessage &= vbNewLine & vbNewLine & "Stacktrace:"
|
||||
oMessage &= vbNewLine & Exception.StackTrace
|
||||
End If
|
||||
|
||||
51
GUIs.Common/Base/BaseForm.vb
Normal file
51
GUIs.Common/Base/BaseForm.vb
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace Base
|
||||
Public Class BaseForm
|
||||
Inherits XtraForm
|
||||
|
||||
Private ReadOnly _Logger As Logger
|
||||
Private ReadOnly _ErrorHandler As BaseErrorHandler
|
||||
|
||||
Protected ReadOnly Property Logger As Logger
|
||||
Get
|
||||
Return _Logger
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub New()
|
||||
End Sub
|
||||
|
||||
Public Sub New(LogConfig As LogConfig)
|
||||
' Get the full name of the inheriting form
|
||||
' so the log messages have the right classname
|
||||
Dim oClassName = [GetType]().FullName
|
||||
|
||||
' My.LogConfig is undefined in the designer
|
||||
_Logger = LogConfig.GetLogger(oClassName)
|
||||
_ErrorHandler = New BaseErrorHandler(LogConfig, _Logger, Me)
|
||||
|
||||
' When you add something, be careful if it
|
||||
' depends on a global var like My.LogConfig
|
||||
' you might need to check for its existence with ?
|
||||
End Sub
|
||||
|
||||
''' ============== PUBLIC METHODS ==============
|
||||
Public Sub ShowInfoMessage(Message As String)
|
||||
_ErrorHandler.ShowInfoMessage(Message)
|
||||
End Sub
|
||||
|
||||
Public Sub ShowErrorMessage(Exception As Exception)
|
||||
Dim oCallingClass = LogConfig.GetClassFullName(IncludeMethodNames:=True, Parts:=2)
|
||||
_ErrorHandler.ShowErrorMessage(Exception, oCallingClass)
|
||||
End Sub
|
||||
|
||||
Public Sub ShowErrorMessage(ErrorMessage As String)
|
||||
Dim oCallingClass = LogConfig.GetClassFullName(IncludeMethodNames:=True, Parts:=2)
|
||||
_ErrorHandler.ShowErrorMessage(New ApplicationException(ErrorMessage), oCallingClass)
|
||||
End Sub
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
@@ -5,14 +5,16 @@ Imports DigitalData.Modules.Logging
|
||||
Namespace Base
|
||||
''' <summary>
|
||||
''' This BaseClass is used to provide common functionality like the Logger or ErrorHandler to all Forms
|
||||
''' To use it, create a form and change the `Inherits` statement in FormName.Designer.vb to this form, eg.:
|
||||
''' </summary>
|
||||
''' <example>
|
||||
''' To use it, create a form and change the `Inherits` statement in FormName.Designer.vb to this form.
|
||||
'''
|
||||
''' Partial Class frmExample
|
||||
''' Inherits BaseRibbonForm
|
||||
'''
|
||||
''' ...
|
||||
''' End Class
|
||||
''' </summary>
|
||||
''' </example>
|
||||
Public Class BaseRibbonForm
|
||||
Inherits RibbonForm
|
||||
|
||||
@@ -43,13 +45,18 @@ Namespace Base
|
||||
End Sub
|
||||
|
||||
''' ============== PUBLIC METHODS ==============
|
||||
Public Sub ShowInfoMessage(Message As String)
|
||||
_ErrorHandler.ShowInfoMessage(Message)
|
||||
End Sub
|
||||
|
||||
Public Sub ShowErrorMessage(Exception As Exception)
|
||||
_ErrorHandler.ShowErrorMessage(Exception)
|
||||
Dim oCallingClass = LogConfig.GetClassFullName(IncludeMethodNames:=True, Parts:=2)
|
||||
_ErrorHandler.ShowErrorMessage(Exception, oCallingClass)
|
||||
End Sub
|
||||
|
||||
Public Sub ShowErrorMessage(ErrorMessage As String)
|
||||
_ErrorHandler.ShowErrorMessage(New ApplicationException(ErrorMessage))
|
||||
Dim oCallingClass = LogConfig.GetClassFullName(IncludeMethodNames:=True, Parts:=2)
|
||||
_ErrorHandler.ShowErrorMessage(New ApplicationException(ErrorMessage), oCallingClass)
|
||||
End Sub
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
@@ -89,6 +89,9 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Base\BaseErrorHandler.vb" />
|
||||
<Compile Include="Base\BaseForm.vb">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Base\BaseResult.vb" />
|
||||
<Compile Include="Base\BaseRibbonForm.vb">
|
||||
<SubType>Form</SubType>
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.7.3.0")>
|
||||
<Assembly: AssemblyFileVersion("1.7.3.0")>
|
||||
<Assembly: AssemblyVersion("1.7.4.0")>
|
||||
<Assembly: AssemblyFileVersion("1.7.4.0")>
|
||||
|
||||
8
GUIs.ZooFlow/frmFlowForm.Designer.vb
generated
8
GUIs.ZooFlow/frmFlowForm.Designer.vb
generated
@@ -1,6 +1,8 @@
|
||||
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
|
||||
Imports DigitalData.GUIs.Common.Base
|
||||
|
||||
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
|
||||
Partial Class frmFlowForm
|
||||
Inherits DevExpress.XtraEditors.XtraForm
|
||||
Inherits BaseForm
|
||||
|
||||
'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
|
||||
<System.Diagnostics.DebuggerNonUserCode()>
|
||||
@@ -23,7 +25,7 @@ Partial Class frmFlowForm
|
||||
<System.Diagnostics.DebuggerStepThrough()>
|
||||
Private Sub InitializeComponent()
|
||||
Me.components = New System.ComponentModel.Container()
|
||||
Dim SplashScreenManager As DevExpress.XtraSplashScreen.SplashScreenManager = New DevExpress.XtraSplashScreen.SplashScreenManager(Me, Nothing, true, true)
|
||||
Dim SplashScreenManager As DevExpress.XtraSplashScreen.SplashScreenManager = New DevExpress.XtraSplashScreen.SplashScreenManager(Me, Nothing, True, True)
|
||||
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmFlowForm))
|
||||
Me.NotifyIcon = New System.Windows.Forms.NotifyIcon(Me.components)
|
||||
Me.ContextMenuSystray = New System.Windows.Forms.ContextMenuStrip(Me.components)
|
||||
|
||||
@@ -18,7 +18,6 @@ Public Class frmFlowForm
|
||||
Private Const OPACITY_HIDDEN = 0.65
|
||||
Private Const OPACITY_SHOWN = 0.85
|
||||
|
||||
Private Logger As Logger
|
||||
Private DTIDB_SEARCHES As DataTable
|
||||
|
||||
' Common Helpers Classes
|
||||
@@ -58,6 +57,8 @@ Public Class frmFlowForm
|
||||
Private WithEvents Watcher As ClipboardWatcher.Watcher = ClipboardWatcher.Watcher.Singleton
|
||||
|
||||
Public Sub New()
|
||||
MyBase.New(My.LogConfig)
|
||||
|
||||
' Dieser Aufruf ist für den Designer erforderlich.
|
||||
InitializeComponent()
|
||||
|
||||
@@ -66,9 +67,6 @@ Public Class frmFlowForm
|
||||
End Sub
|
||||
|
||||
Private Sub frmFlowForm_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
' === Initialize Logger ===
|
||||
Logger = My.LogConfig.GetLogger()
|
||||
|
||||
' === Show Splash Screen ===
|
||||
SplashScreenManager.ShowForm(Me, GetType(frmSplash), False, False)
|
||||
|
||||
@@ -250,8 +248,7 @@ Public Class frmFlowForm
|
||||
ProfileLoader = New ClassProfileLoader(My.LogConfig, AppServerOrDB)
|
||||
ProfileLoader.LoadProfiles()
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
MsgBox("Error while initializing Clipboard Watcher!", MsgBoxStyle.Critical, Text)
|
||||
ShowErrorMessage(ex)
|
||||
End Try
|
||||
Else
|
||||
My.Application.ClipboardWatcher.MonitoringActive = False
|
||||
@@ -291,6 +288,8 @@ Public Class frmFlowForm
|
||||
|
||||
If oDT.Rows.Count = 0 Then
|
||||
Throw New ApplicationException("No Default Path configured for User!")
|
||||
'Logger.Warn("No Default Path configured for User. Skipping.")
|
||||
'Exit Sub
|
||||
End If
|
||||
|
||||
Dim oFolderWatchPath = oDT.Rows.Item(0).Item("FOLDER_PATH")
|
||||
@@ -319,9 +318,7 @@ Public Class frmFlowForm
|
||||
'FWFunction_STARTED = True
|
||||
FolderWatch.StartStop_FolderWatch()
|
||||
Catch ex As Exception
|
||||
MsgBox($"Init_Folderwatch: Unexpected error while starting FolderWatch: {ex.Message}", MsgBoxStyle.Critical)
|
||||
Logger.Error(ex)
|
||||
Logger.Info($"Init_Folderwatch: Unexpected error: {ex.Message}")
|
||||
ShowErrorMessage(ex)
|
||||
End Try
|
||||
|
||||
Try
|
||||
@@ -350,8 +347,7 @@ Public Class frmFlowForm
|
||||
'FWFunction_STARTED = True
|
||||
FolderWatch.StartStop_FolderWatchSCAN()
|
||||
Catch ex As Exception
|
||||
MsgBox($"Init_Folderwatch: Unexpected error while starting FolderWatchScan: {ex.Message}", MsgBoxStyle.Critical)
|
||||
Logger.Info($"Init_Folderwatch: Unexpected error: {ex.Message}")
|
||||
ShowErrorMessage(ex)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
@@ -529,12 +525,12 @@ Public Class frmFlowForm
|
||||
Private Function FormLoaded_Visible() As Boolean
|
||||
For Each frm As Form In Application.OpenForms
|
||||
If frm.Name.Equals("frmSearchStart") Or frm.Name.Equals("frmGlobix_Index") Or frm.Name.Equals("frmAdmin_Start") Then
|
||||
Me.Visible = False
|
||||
Exit Function
|
||||
Return False
|
||||
End If
|
||||
Next
|
||||
Me.Visible = True
|
||||
|
||||
TimerCheckActiveForms.Enabled = False
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Sub DatenbankverbindungToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DatenbankverbindungToolStripMenuItem.Click
|
||||
@@ -542,13 +538,13 @@ Public Class frmFlowForm
|
||||
End Sub
|
||||
|
||||
Private Sub TimerCheckActiveForms_Tick(sender As Object, e As EventArgs) Handles TimerCheckActiveForms.Tick
|
||||
FormLoaded_Visible()
|
||||
If Me.Visible = False Then Exit Sub
|
||||
Visible = FormLoaded_Visible()
|
||||
If Visible = False Then Exit Sub
|
||||
End Sub
|
||||
|
||||
Private Sub NotifyIcon_DoubleClick(sender As Object, e As EventArgs) Handles NotifyIcon.DoubleClick
|
||||
If Me.Visible = False Then
|
||||
Me.Visible = True
|
||||
If Visible = False Then
|
||||
Visible = True
|
||||
TimerCheckActiveForms.Enabled = False
|
||||
End If
|
||||
End Sub
|
||||
@@ -657,7 +653,7 @@ Public Class frmFlowForm
|
||||
Next
|
||||
Show()
|
||||
Catch ex As Exception
|
||||
MsgBox("Unexpected Error in Check_Dropped_Files:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
||||
ShowErrorMessage(ex)
|
||||
Show()
|
||||
End Try
|
||||
|
||||
@@ -673,8 +669,7 @@ Public Class frmFlowForm
|
||||
TimerCheckActiveForms.Enabled = True
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
MsgBox(ex.Message, MsgBoxStyle.Critical)
|
||||
ShowErrorMessage(ex)
|
||||
End Try
|
||||
End Sub
|
||||
Sub NotifyIconReset()
|
||||
@@ -696,7 +691,7 @@ Public Class frmFlowForm
|
||||
End Select
|
||||
NotifyIcon.ShowBalloonTip(30000, NI_TITLE, NI_MESSAGE, oNIType)
|
||||
Catch ex As Exception
|
||||
|
||||
ShowErrorMessage(ex)
|
||||
End Try
|
||||
End Sub
|
||||
Sub Start_Folderwatch()
|
||||
@@ -749,8 +744,7 @@ Public Class frmFlowForm
|
||||
Logger.Info("FWSCAN not started")
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Info("Error while starting folderwatch scan: " & ex.Message)
|
||||
Logger.Error(ex.Message)
|
||||
ShowErrorMessage(ex)
|
||||
End Try
|
||||
|
||||
Try
|
||||
@@ -786,8 +780,7 @@ Public Class frmFlowForm
|
||||
Logger.Info("Folderwatch not started")
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Info("Error while starting folderwatch: " & ex.Message)
|
||||
Logger.Error(ex.Message)
|
||||
ShowErrorMessage(ex)
|
||||
End Try
|
||||
|
||||
If TimerFolderwatch.Enabled = False Then
|
||||
|
||||
Reference in New Issue
Block a user