zooflow: msgbox

This commit is contained in:
Jonathan Jenne 2022-05-24 12:16:23 +02:00
parent 6cefffc2a6
commit ba3b4c7bf5
12 changed files with 117 additions and 90 deletions

View File

@ -15,18 +15,15 @@ Public Class FormHelper
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)
Return ShowMessage(pMessage, pTitle, frmDialog.DialogType.Info)
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)
Dim oMethodName = GetMethodName()
Dim oBaseMessage = "In der Funktion '{0}' ist folgender Fehler aufgetreten: {1}"
Dim oMessage = String.Format(oBaseMessage, oMethodName, vbNewLine & vbNewLine & pException.Message)
If LogConfig.Debug Then
oMessage &= vbNewLine & vbNewLine & "=== Debug Information ==="
@ -34,14 +31,32 @@ Public Class FormHelper
oMessage &= vbNewLine & pException.StackTrace
End If
Dim oForm As New frmDialog(oMessage, pTitle, frmDialog.DialogType.Error)
Return oForm.ShowDialog()
Return ShowMessage(oMessage, pTitle, frmDialog.DialogType.Error)
End Function
Public Function ShowWarningMessage(pMessage As String, pTitle As String) As DialogResult
Logger.Warn(pMessage)
Logger.Info(pTitle & " - " & pMessage)
Return ShowMessage(pMessage, pTitle, frmDialog.DialogType.Warning)
End Function
Dim oForm As New frmDialog(pMessage, pTitle, frmDialog.DialogType.Error)
Public Function ShowQuestionMessage(pMessage As String, pTitle As String) As DialogResult
Logger.Info(pTitle & " - " & pMessage)
Return ShowMessage(pMessage, pTitle, frmDialog.DialogType.Question)
End Function
Public Function ShowSuccessMessage(pMessage As String, pTitle As String) As DialogResult
Logger.Info(pTitle & " - " & pMessage)
Return ShowMessage(pMessage, pTitle, frmDialog.DialogType.Success)
End Function
Private Function ShowMessage(pMessage As String, pTitle As String, pType As frmDialog.DialogType) As DialogResult
Dim oForm As New frmDialog(pMessage, pTitle, pType)
Return oForm.ShowDialog()
End Function
Private Function GetMethodName() As String
Dim oStackTrace As New StackTrace()
Dim oMethodName As String = oStackTrace.GetFrame(2).GetMethod.Name
Return oMethodName
End Function
End Class

View File

@ -26,13 +26,13 @@ Partial Class frmDialog
Me.btnPositive = New DevExpress.XtraEditors.SimpleButton()
Me.btnNegative = New DevExpress.XtraEditors.SimpleButton()
Me.pnlContent = New DevExpress.XtraEditors.PanelControl()
Me.txtContent = New DevExpress.XtraEditors.LabelControl()
Me.SvgImageBox1 = New DevExpress.XtraEditors.SvgImageBox()
Me.PanelControl1 = New DevExpress.XtraEditors.PanelControl()
Me.pnlHeader = New DevExpress.XtraEditors.PanelControl()
Me.txtTitle = New DevExpress.XtraEditors.LabelControl()
Me.pnlFooter = New DevExpress.XtraEditors.PanelControl()
Me.SvgImageCollection1 = New DevExpress.Utils.SvgImageCollection(Me.components)
Me.txtContent2 = New DevExpress.XtraEditors.LabelControl()
CType(Me.pnlContent, System.ComponentModel.ISupportInitialize).BeginInit()
Me.pnlContent.SuspendLayout()
CType(Me.SvgImageBox1, System.ComponentModel.ISupportInitialize).BeginInit()
@ -70,7 +70,7 @@ Partial Class frmDialog
'
'pnlContent
'
Me.pnlContent.Controls.Add(Me.txtContent)
Me.pnlContent.Controls.Add(Me.txtContent2)
Me.pnlContent.Controls.Add(Me.SvgImageBox1)
Me.pnlContent.Controls.Add(Me.PanelControl1)
Me.pnlContent.Dock = System.Windows.Forms.DockStyle.Fill
@ -79,24 +79,6 @@ Partial Class frmDialog
Me.pnlContent.Size = New System.Drawing.Size(498, 145)
Me.pnlContent.TabIndex = 3
'
'txtContent
'
Me.txtContent.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.txtContent.Appearance.Font = New System.Drawing.Font("Segoe UI", 9.75!)
Me.txtContent.Appearance.Options.UseFont = True
Me.txtContent.Appearance.Options.UseTextOptions = True
Me.txtContent.Appearance.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Top
Me.txtContent.AutoEllipsis = True
Me.txtContent.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.None
Me.txtContent.Location = New System.Drawing.Point(98, 6)
Me.txtContent.Name = "txtContent"
Me.txtContent.Padding = New System.Windows.Forms.Padding(10)
Me.txtContent.Size = New System.Drawing.Size(388, 133)
Me.txtContent.TabIndex = 1
Me.txtContent.Text = "txtContent"
'
'SvgImageBox1
'
Me.SvgImageBox1.BackColor = System.Drawing.Color.Transparent
@ -144,6 +126,9 @@ Partial Class frmDialog
'
'pnlFooter
'
Me.pnlFooter.Appearance.BackColor = System.Drawing.Color.FromArgb(CType(CType(230, Byte), Integer), CType(CType(230, Byte), Integer), CType(CType(230, Byte), Integer))
Me.pnlFooter.Appearance.Options.UseBackColor = True
Me.pnlFooter.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder
Me.pnlFooter.Controls.Add(Me.btnPositive)
Me.pnlFooter.Controls.Add(Me.btnNegative)
Me.pnlFooter.Dock = System.Windows.Forms.DockStyle.Bottom
@ -160,6 +145,20 @@ Partial Class frmDialog
Me.SvgImageCollection1.Add("info", "image://svgimages/outlook inspired/about.svg")
Me.SvgImageCollection1.Add("question", "image://svgimages/icon builder/actions_question.svg")
'
'txtContent2
'
Me.txtContent2.Appearance.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.txtContent2.Appearance.Options.UseFont = True
Me.txtContent2.Appearance.Options.UseTextOptions = True
Me.txtContent2.Appearance.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Top
Me.txtContent2.Appearance.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap
Me.txtContent2.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.None
Me.txtContent2.Location = New System.Drawing.Point(98, 16)
Me.txtContent2.Name = "txtContent2"
Me.txtContent2.Size = New System.Drawing.Size(388, 124)
Me.txtContent2.TabIndex = 3
Me.txtContent2.Text = "LabelControl1"
'
'frmDialog
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
@ -195,7 +194,7 @@ Partial Class frmDialog
Friend WithEvents pnlFooter As DevExpress.XtraEditors.PanelControl
Friend WithEvents SvgImageBox1 As DevExpress.XtraEditors.SvgImageBox
Friend WithEvents SvgImageCollection1 As DevExpress.Utils.SvgImageCollection
Friend WithEvents txtContent As DevExpress.XtraEditors.LabelControl
Friend WithEvents txtTitle As DevExpress.XtraEditors.LabelControl
Friend WithEvents PanelControl1 As DevExpress.XtraEditors.PanelControl
Friend WithEvents txtContent2 As DevExpress.XtraEditors.LabelControl
End Class

View File

@ -28,7 +28,7 @@ Public Class frmDialog
InitializeComponent()
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
txtContent.Text = pMessageText
txtContent2.Text = pMessageText
txtTitle.Text = pTitle
Select Case pDialogType
@ -62,7 +62,7 @@ Public Class frmDialog
End Select
Dim oLineBreaks = txtContent.Text.Split(vbNewLine).Count
Dim oLineBreaks = txtContent2.Text.Split(vbNewLine).Count
If oLineBreaks > 6 Then
Dim oHeightOffset = oLineBreaks * 20

View File

@ -288,7 +288,7 @@ Public Class frmDocumentResultList
DocumentViewer1.LoadFile(oFileName, New MemoryStream(oDocument.Contents))
If IsNothing(oDocument) Then
DocumentViewer1.CloseDocument()
FormHelper.ShowErrorMessage("File could not be loaded!", "GridView_FocusedRowChanged")
FormHelper.ShowErrorMessage(New IOException("File could not be loaded!"), "GridView_FocusedRowChanged")
Exit Sub
End If

View File

@ -87,7 +87,7 @@ Public Class frmMonitor
ConfigManager.Save()
Application.Restart()
Else
FormHelper.ShowErrorMessage("No Database configured. Application will close!", "frmStart_Load")
FormHelper.ShowErrorMessage(New ApplicationException("No Database configured. Application will close!"), "frmStart_Load")
Application.Exit()
End If

View File

@ -3,23 +3,28 @@ Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Public Class frmMsgBox
Private LogConfig As LogConfig
Private SQLServer As MSSQLServer
Private ReadOnly LogConfig As LogConfig
Private ReadOnly SQLServer As MSSQLServer
Public ReadOnly FormHelper As FormHelper
Public Sub New(LogConfig As LogConfig, SQLServer As MSSQLServer)
InitializeComponent()
Me.LogConfig = LogConfig
Me.SQLServer = SQLServer
Me.FormHelper = New FormHelper(LogConfig, Me)
End Sub
Private Sub SimpleButton1_Click(sender As Object, e As EventArgs) Handles SimpleButton1.Click
Dim oMsgbox = New frmDialog("Diese Datei ist hier unerwünscht!", "Zooflow", frmDialog.DialogType.Error)
oMsgbox.ShowDialog()
FormHelper.ShowErrorMessage(New ApplicationException("Diese Datei ist hier unerwünscht!"), "Mein Titel")
End Sub
Private Sub SimpleButton2_Click(sender As Object, e As EventArgs) Handles SimpleButton2.Click
Dim oMsgbox = New frmDialog("Der Fluxkompensator ist leer. Bitte auffüllen!", "File Flow", frmDialog.DialogType.Warning)
oMsgbox.ShowDialog()
End Sub
Private Sub frmMsgBox_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class

View File

@ -1,4 +1,6 @@
Public Class frmAdmin_IDBAttribute
Imports DigitalData.GUIs.Common
Public Class frmAdmin_IDBAttribute
Implements IAdminForm
Public Property HasChanges As Boolean = False Implements IAdminForm.HasChanges
@ -7,15 +9,16 @@
Private Const ConstDetail = "Detail"
Private Const ConstTranslate = "Translate"
Private Property oMode As String = "Detail"
Private Property FormHelper As FormHelper
Public Sub New(PrimaryKey As Integer, Optional IsInsert As Boolean = False)
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
InitializeBaseForm(My.LogConfig)
Me.PrimaryKey = PrimaryKey
Me.IsInsert = IsInsert
FormHelper = New FormHelper(My.LogConfig, Me)
End Sub
Private Sub frmAdmin_Attribute_Load(sender As Object, e As EventArgs) Handles MyBase.Load
@ -30,7 +33,7 @@
DSIDB_Stammdaten.VWIDB_BE_ATTRIBUTE.ADDED_WHOColumn.DefaultValue = My.Application.User.UserName
End If
Catch ex As Exception
ShowErrorMessage(ex)
FormHelper.ShowErrorMessage(ex, "frmAdmin_Attribute_Load")
End Try
End Sub
Private Sub FillAttribute()
@ -113,7 +116,7 @@
FillAttribute()
Return True
Catch ex As Exception
ShowErrorMessage(ex)
FormHelper.ShowErrorMessage(ex, "SaveData")
ShowStatus($"Unexpeced error saving attribute {TextEdit2.Text} - {ex.Message}", Color.Red)
Return False
End Try
@ -128,7 +131,7 @@
End If
Catch ex As Exception
ShowErrorMessage(ex)
FormHelper.ShowErrorMessage(ex, "DeleteAttribute")
Return False
End Try
End Function

View File

@ -1,4 +1,5 @@
Imports System.IO.Path
Imports System.Runtime
Imports DigitalData.Modules.Config
Imports DigitalData.Modules.EDMI.API
Imports DigitalData.Modules.Logging
@ -74,6 +75,9 @@ Namespace My
Logger = LogConfig.GetLogger()
Logger.Debug("Starting ZooFlow...")
ProfileOptimization.SetProfileRoot("E:\Zooflow")
ProfileOptimization.StartProfile("Startup.Profile")
If oConfigManager.Config.AppServerConfig <> String.Empty Then
Try
Dim oSplit() As String = oConfigManager.Config.AppServerConfig.ToString.Split(":"c)

View File

@ -20,6 +20,7 @@ Public Class ClassInit
Private ReadOnly _MainForm As frmFlowForm
Private ReadOnly _Database As DatabaseWithFallback
Private ReadOnly _FormHelper As FormHelper
Private _Loader As ClassInitLoader
Public Event Completed As EventHandler
@ -27,6 +28,7 @@ Public Class ClassInit
Public Sub New(LogConfig As LogConfig, ParentForm As frmFlowForm)
MyBase.New(LogConfig)
_MainForm = ParentForm
_FormHelper = New FormHelper(LogConfig, ParentForm)
End Sub
Public Sub InitializeApplication()
@ -49,6 +51,37 @@ Public Class ClassInit
_Loader.Run()
End Sub
Private Sub InitCompleted(sender As Object, e As RunWorkerCompletedEventArgs)
If Not IsNothing(e.Error) Then
Dim oMessageStart = $"Beim Initialisieren des Programms ist folgender Fehler aufgetreten:"
Dim oMessageEnd = "Das Program wird nun beendet"
Dim oMessage1 = $"{vbNewLine}{vbNewLine}{e.Error.Message}"
Dim oMessage2 = ""
If TypeOf e.Error Is InitException Then
Dim oException As InitException = DirectCast(e.Error, InitException)
oMessage2 = $"{vbNewLine}{vbNewLine}Details: {oException?.InnerException?.Message}"
End If
Dim oMessage = $"{oMessageStart}{oMessage1}{oMessage2}{oMessageEnd}"
Dim oMsgBox As New frmDialog(oMessage, _MainForm.Text, frmDialog.DialogType.Error)
oMsgBox.ShowDialog()
Application.ExitThread()
Else
' Copy back state from MyApplication Helper to My.Application
Dim oMyApplication As My.MyApplication = DirectCast(e.Result, My.MyApplication)
My.Application.Settings = oMyApplication.Settings
My.Application.User = oMyApplication.User
My.Application.Modules = oMyApplication.Modules
My.Application.ModulesActive = oMyApplication.ModulesActive
My.Application.ClipboardWatcher = oMyApplication.ClipboardWatcher
RaiseEvent Completed(sender, Nothing)
End If
End Sub
#Region "=== Init Steps ==="
Private Sub InitializeBase(MyApplication As My.MyApplication)
@ -358,37 +391,6 @@ Public Class ClassInit
SplashScreenManager.Default.SendCommand(frmSplash.SplashScreenCommand.SetActionName, Progress.CurrentStep.Name)
End Sub
Private Sub InitCompleted(sender As Object, e As RunWorkerCompletedEventArgs)
If Not IsNothing(e.Error) Then
Dim oMessageStart = $"Beim Initialisieren des Programms ist folgender Fehler aufgetreten:"
Dim oMessageEnd = "Das Program wird nun beendet"
Dim oMessage1 = $"{vbNewLine}{vbNewLine}{e.Error.Message}"
Dim oMessage2 = ""
If TypeOf e.Error Is InitException Then
Dim oException As InitException = DirectCast(e.Error, InitException)
oMessage2 = $"{vbNewLine}{vbNewLine}Details: {oException?.InnerException?.Message}"
End If
Dim oMessage = $"{oMessageStart}{oMessage1}{oMessage2}{oMessageEnd}"
Dim oMsgBox As New frmDialog(oMessage, _MainForm.Text, frmDialog.DialogType.Error)
oMsgBox.ShowDialog()
Application.ExitThread()
Else
' Copy back state from MyApplication Helper to My.Application
Dim oMyApplication As My.MyApplication = DirectCast(e.Result, My.MyApplication)
My.Application.Settings = oMyApplication.Settings
My.Application.User = oMyApplication.User
My.Application.Modules = oMyApplication.Modules
My.Application.ModulesActive = oMyApplication.ModulesActive
My.Application.ClipboardWatcher = oMyApplication.ClipboardWatcher
RaiseEvent Completed(sender, Nothing)
End If
End Sub
Private Sub HandleUserInfo(MyApplication As My.MyApplication, Row As DataRow)
Dim oValue As Object = Row.Item("VALUE")
Dim oName As String = Row.Item("NAME").ToString

View File

@ -40,6 +40,7 @@ Public Class frmGlobix_Index
Private Property WindowLocation As ClassWindowLayout
Private Property Database As DatabaseWithFallback
Private Property Patterns2 As Patterns2
Private ReadOnly FormHelper As FormHelper
Private Property OverlayHandle As IOverlaySplashScreenHandle
Public Property oSuccess As Boolean = False
@ -62,6 +63,7 @@ Public Class frmGlobix_Index
Database = New DatabaseWithFallback(pLogConfig, My.Application.Service.Client, My.DatabaseECM, My.DatabaseIDB)
WindowLocation = New ClassWindowLayout(pLogConfig)
Patterns2 = New Patterns2(pLogConfig)
FormHelper = New FormHelper(pLogConfig, Me)
Localizer.Active = New LookupGridLocalizer()
End Sub
@ -183,6 +185,8 @@ Public Class frmGlobix_Index
Catch ex As Exception
Logger.Warn("Unexpected error DTTBGI_REGEX_DOCTYPE - ErrorMessage: " & vbNewLine & ex.Message)
FormHelper.ShowErrorMessage(ex, "Laden des Formulars")
Finally
SplashScreenManager.CloseOverlayForm(OverlayHandle)
FormLoaded = True
@ -271,8 +275,7 @@ Public Class frmGlobix_Index
Try
DocumentViewer1.LoadFile(My.Application.Globix.CurrentWorkfile.FilePath)
Catch ex As Exception
Logger.Error(ex)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Fehler in PreviewFile:")
FormHelper.ShowErrorMessage(ex, "Laden der Vorschau")
End Try
End Sub
@ -326,8 +329,7 @@ INNER JOIN IDB.dbo.VWIDB_DOCTYPE_LANGUAGE DL ON DT.IDB_DOCTYPE_ID = DL.Doctype_I
DocTypes = oDocTypes
Catch ex As Exception
Logger.Warn("Unexpected error in Refresh_Dokart: " & vbNewLine & ex.Message)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error in Laden der Dokumentarten:")
FormHelper.ShowErrorMessage(ex, "Laden des Profils")
End Try
End Sub

View File

@ -315,8 +315,8 @@ Public Class frmFlowForm
Else
oMsg = "File-Exclusions in Folderwatch could not be created!"
End If
Dim oMsgBox As New frmDialog(oMsg, Text, frmDialog.DialogType.Warning)
oMsgBox.ShowDialog()
FormHelper.ShowWarningMessage(oMsg, Text)
End If
Init_Folderwatch()
@ -508,10 +508,10 @@ Public Class frmFlowForm
If My.Application.User.Language <> "de-DE" Then
oTitle = "Exit Zooflow"
End If
Dim oMsgBox As New frmDialog(oMessage, oTitle, frmDialog.DialogType.Question)
oMsgBox.ShowDialog()
If oMsgBox.DialogResult = DialogResult.Yes Then
Dim oResult = FormHelper.ShowQuestionMessage(oMessage, oTitle)
If oResult = DialogResult.Yes Then
Close()
Else
ESCHitCount = 0
@ -613,8 +613,7 @@ Public Class frmFlowForm
End If
If TheFormIsAlreadyLoaded("frmIndexFileList") Then
Cursor = Cursors.Default
Dim oMsgBox As New frmDialog("Please index the active file first!", "Drag 'n Drop not allowed!", frmDialog.DialogType.Warning)
oMsgBox.ShowDialog()
FormHelper.ShowWarningMessage("Please index the active file first!", "Drag 'n Drop not allowed!")
Exit Function
End If
@ -917,8 +916,7 @@ Public Class frmFlowForm
If ex.Message.Contains("Sammlung wurde geändert") Or ex.Message.Contains("Enumeration") Then
Else
Dim oMsgBox As New frmDialog("Error in Work FolderWatch-File:" & vbNewLine & ex.Message, "Drag 'n Drop not allowed!", frmDialog.DialogType.Error)
oMsgBox.ShowDialog()
FormHelper.ShowErrorMessage(ex, "Drag 'n Drop not allowed!")
End If
End Try

View File

@ -34,7 +34,6 @@ Public Class frmServiceConfig
Try
Dim oIPAddress = txtServiceAddress.Text
Dim oPort = Integer.Parse(txtServicePort.Text)
Dim oEndpointURL = $"net.tcp://{oIPAddress}:{oPort}/DigitalData/Services/Main"
Client = New Client(My.LogConfig, oIPAddress, oPort)