Zooflow: round up the search form
This commit is contained in:
@@ -1,77 +0,0 @@
|
||||
Imports System.Reflection
|
||||
Imports System.Windows.Forms
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace Base
|
||||
Public Class NNBaseErrorHandler
|
||||
Private ReadOnly _LogConfig As LogConfig
|
||||
Private ReadOnly _Logger As Logger
|
||||
Private ReadOnly _Form As Form
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Logger As Logger, Form As Form)
|
||||
_LogConfig = LogConfig
|
||||
_Logger = Logger
|
||||
_Form = Form
|
||||
End Sub
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pForm As Form)
|
||||
_LogConfig = pLogConfig
|
||||
_Logger = pLogConfig.GetLogger(LogConfig.GetClassFullName())
|
||||
_Form = pForm
|
||||
End Sub
|
||||
|
||||
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(Message & vbNewLine & Exception?.Message, _Form.Text & Origin, MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
End Sub
|
||||
|
||||
Public Sub ShowErrorMessage(Text As String)
|
||||
_Logger.Info(Text)
|
||||
MessageBox.Show(Text, _Form.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
End Sub
|
||||
|
||||
Public Sub ShowWarningMessage(Text As String)
|
||||
_Logger.Info(Text)
|
||||
MessageBox.Show(Text, _Form.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning)
|
||||
End Sub
|
||||
|
||||
Public Sub ShowInfoMessage(Text As String)
|
||||
_Logger.Info(Text)
|
||||
MessageBox.Show(Text, _Form.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
|
||||
End Sub
|
||||
|
||||
Private Function GetMessage(Exception As Exception, Origin As String) As String
|
||||
Dim oMessage As String = String.Empty
|
||||
|
||||
If TypeOf Exception Is SqlClient.SqlException Then
|
||||
Dim oNumber As Integer = DirectCast(Exception, SqlClient.SqlException).Number
|
||||
Select Case oNumber
|
||||
Case 2627
|
||||
oMessage = "Es wurde ein Doppelter Wert in eine Spalte eingetragen, die einzigartig sein muss."
|
||||
Case Else
|
||||
oMessage = Exception.Message
|
||||
End Select
|
||||
ElseIf TypeOf Exception Is NoNullAllowedException Then
|
||||
oMessage = "Einige benötigte Felder wurde nicht ausgefüllt."
|
||||
Else
|
||||
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 Information ==="
|
||||
oMessage &= vbNewLine & vbNewLine & "Stacktrace:"
|
||||
oMessage &= vbNewLine & Exception.StackTrace
|
||||
End If
|
||||
|
||||
Return oMessage
|
||||
End Function
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -1,49 +0,0 @@
|
||||
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace Base
|
||||
Public Class NNBaseForm
|
||||
Inherits XtraForm
|
||||
|
||||
Private ReadOnly _Logger As Logger
|
||||
|
||||
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)
|
||||
'_ErrorHandler.ShowErrorMessage(ErrorMessage)
|
||||
End Sub
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
@@ -107,10 +107,6 @@
|
||||
<Import Include="System.Threading.Tasks" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Base\BaseErrorHandler.vb" />
|
||||
<Compile Include="Base\BaseForm.vb">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Base\BaseResult.vb" />
|
||||
<Compile Include="Constants.vb" />
|
||||
<Compile Include="DataResultList\DataResultConfig.vb" />
|
||||
|
||||
@@ -66,7 +66,7 @@ Public Class ctrlObjectPropertyDialog
|
||||
})
|
||||
Next
|
||||
|
||||
FormHelper.ShowInfoMessage($"{Changes.Count} Änderungen gespeichert!")
|
||||
FormHelper.ShowInfoMessage($"{Changes.Count} Änderungen gespeichert!", "SaveChanges")
|
||||
Changes.Clear()
|
||||
Catch ex As Exception
|
||||
FormHelper.ShowErrorMessage(ex, "SaveChanges")
|
||||
|
||||
Reference in New Issue
Block a user