performance fixes for drawing group header, log (to database on) unhandled exceptions

This commit is contained in:
Jonathan Jenne
2020-10-21 12:21:51 +02:00
parent 856aa7c298
commit b0b144098b
3 changed files with 110 additions and 93 deletions

View File

@@ -13,10 +13,20 @@ Namespace My
"The errormessage was:" & vbNewLine & e.Exception.Message & vbNewLine & "The errormessage was:" & vbNewLine & e.Exception.Message & vbNewLine &
"The stacktrace was:" & vbNewLine & e.Exception.StackTrace "The stacktrace was:" & vbNewLine & e.Exception.StackTrace
If IsNothing(LOGGER) = False Then LOGGER.Error(e.Exception)
LOGGER.Info(oMessage)
LOGGER.Error(e.Exception) Try
End If If USER_DEBUG_LOG = True Then
Dim oLogMessage = LOGCONFIG.Logs.Last()
Dim oLogSplit As String() = oLogMessage.Split("|")
Dim oDBMessage = PrepareLogMessage(oLogMessage)
Dim oSQL = $"INSERT INTO [dbo].[TBPM_LOG_DEBUG] ([USERID], [LOGMSG], [ADDED_WHEN], DATE_STR) VALUES({USER_ID},'{oDBMessage}',GETDATE(),'{Now}')"
ClassDatabase.Execute_non_Query(oSQL)
End If
Catch ex As Exception
LOGGER.Error(ex)
End Try
MsgBox(oMessage, MsgBoxStyle.Critical, "Process Manager") MsgBox(oMessage, MsgBoxStyle.Critical, "Process Manager")
End Sub End Sub

View File

@@ -44,6 +44,22 @@
Public Function IntToColor(int As Integer) As Color Public Function IntToColor(int As Integer) As Color
Return ColorTranslator.FromWin32(int) Return ColorTranslator.FromWin32(int)
End Function End Function
Public Function PrepareLogMessage(LogMessage As String) As String
Dim oLogSplit As String()
oLogSplit = LogMessage.Split("|")
If oLogSplit.Count < 3 Then
Return LogMessage
Else
Dim omsg = oLogSplit(2).
Replace("'", "''").
Replace("\\n", "").
Replace(Chr(13), "").
Replace(Chr(10), "")
Return omsg
End If
End Function
End Module End Module

View File

@@ -31,8 +31,11 @@ Public Class frmMain
Private NO_WORKFLOWITEMS As Boolean = False Private NO_WORKFLOWITEMS As Boolean = False
Private InResetlayout As Boolean = False Private InResetlayout As Boolean = False
Private RefreshHelper As RefreshHelper Private RefreshHelper As RefreshHelper
Private formopenClose As Boolean = False
Private formShown As Boolean = False Private FormOpenClose As Boolean = False
Private FormShown As Boolean = False
Private GridIsLoaded As Boolean = False
Private allgFunk As New ClassAllgemeineFunktionen Private allgFunk As New ClassAllgemeineFunktionen
Private _Init As New ClassInit Private _Init As New ClassInit
Private CurrNavBarGroup As NavBarGroup Private CurrNavBarGroup As NavBarGroup
@@ -43,7 +46,7 @@ Public Class frmMain
Private Sub frmMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing Private Sub frmMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Try Try
formopenClose = True FormOpenClose = True
' Position und Größe speichern ' Position und Größe speichern
My.Settings.frmMainSize = Me.Size My.Settings.frmMainSize = Me.Size
My.Settings.frmMainPosition = Me.Location My.Settings.frmMainPosition = Me.Location
@@ -86,7 +89,7 @@ Public Class frmMain
bbtniMetadataFile.Visibility = DevExpress.XtraBars.BarItemVisibility.Never bbtniMetadataFile.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
End If End If
formopenClose = True FormOpenClose = True
LOGGER.Debug("Initializing MainForm....") LOGGER.Debug("Initializing MainForm....")
' Create helper to save/load expanded GroupColumns at runtime ' Create helper to save/load expanded GroupColumns at runtime
@@ -200,7 +203,7 @@ Public Class frmMain
End If End If
Check_Timer_Notification() Check_Timer_Notification()
Check_Timer_Inactivity() Check_Timer_Inactivity()
formShown = True FormShown = True
Restore_Form_Position() Restore_Form_Position()
@@ -239,7 +242,7 @@ Public Class frmMain
End If End If
LOGGER.Debug("MainForm initialized!") LOGGER.Debug("MainForm initialized!")
End If End If
formopenClose = False FormOpenClose = False
End Sub End Sub
Sub Check_Timer_Notification() Sub Check_Timer_Notification()
Try Try
@@ -597,7 +600,6 @@ Public Class frmMain
Catch ex As Exception Catch ex As Exception
LOGGER.Error(ex) LOGGER.Error(ex)
End Try End Try
End Sub End Sub
@@ -884,7 +886,7 @@ Public Class frmMain
Exit Sub Exit Sub
End If End If
If GridControl_Docs.Visible = True And formopenClose = False Then RefreshHelper.SaveViewInfo() If GridControl_Docs.Visible = True And FormOpenClose = False Then RefreshHelper.SaveViewInfo()
'If Not Application.OpenForms().OfType(Of frmValidator).Any Then 'If Not Application.OpenForms().OfType(Of frmValidator).Any Then
' Dim oUpdate = "Not Defined" ' Dim oUpdate = "Not Defined"
' Try ' Try
@@ -913,7 +915,7 @@ Public Class frmMain
Else Else
bsilastsync.Caption = "Letzte Synchronisation: " & Now.ToLongTimeString bsilastsync.Caption = "Letzte Synchronisation: " & Now.ToLongTimeString
End If End If
If GridControl_Docs.Visible = True And formopenClose = False Then RefreshHelper.LoadViewInfo() If GridControl_Docs.Visible = True And FormOpenClose = False Then RefreshHelper.LoadViewInfo()
Handling_DEBUG_USER() Handling_DEBUG_USER()
Catch ex As Exception Catch ex As Exception
@@ -935,17 +937,21 @@ Public Class frmMain
End Sub End Sub
Private Sub Decide_Load(FormLoad As Boolean) Private Sub Decide_Load(FormLoad As Boolean)
Try Try
GridIsLoaded = False
If USER_EXISTS = False Then If USER_EXISTS = False Then
Exit Sub Exit Sub
End If End If
If TimerRefresh.Enabled = True Then If TimerRefresh.Enabled = True Then
TimerRefresh.Enabled = False TimerRefresh.Enabled = False
End If End If
If GRID_LOAD_TYPE = "OVERVIEW" Then If GRID_LOAD_TYPE = "OVERVIEW" Then
Load_Grid_Overview(FormLoad) Load_Grid_Overview(FormLoad)
ElseIf GRID_LOAD_TYPE.StartsWith("PROFILE#") Then ElseIf GRID_LOAD_TYPE.StartsWith("PROFILE#") Then
Load_single_Profile() Load_single_Profile()
End If End If
If SHOW_MASS_VALIDATOR = False Then If SHOW_MASS_VALIDATOR = False Then
GridView_Docs.OptionsSelection.MultiSelect = False GridView_Docs.OptionsSelection.MultiSelect = False
GridView_Docs.OptionsSelection.MultiSelectMode = GridMultiSelectMode.RowSelect GridView_Docs.OptionsSelection.MultiSelectMode = GridMultiSelectMode.RowSelect
@@ -958,7 +964,10 @@ Public Class frmMain
GridView_Docs.OptionsSelection.MultiSelect = True GridView_Docs.OptionsSelection.MultiSelect = True
GridView_Docs.OptionsSelection.MultiSelectMode = GridMultiSelectMode.CheckBoxRowSelect GridView_Docs.OptionsSelection.MultiSelectMode = GridMultiSelectMode.CheckBoxRowSelect
End If End If
GridIsLoaded = True
Catch ex As Exception Catch ex As Exception
GridIsLoaded = True
LOGGER.Error(ex) LOGGER.Error(ex)
LOGGER.Info("Unexpected error in Decide_load: " & ex.Message) LOGGER.Info("Unexpected error in Decide_load: " & ex.Message)
End Try End Try
@@ -1691,7 +1700,7 @@ Public Class frmMain
End Sub End Sub
Sub Reset_GridLayout(FormLoad As Boolean) Sub Reset_GridLayout(FormLoad As Boolean)
If GridControl_Docs.Visible = True And formopenClose = False Then RefreshHelper.SaveViewInfo() If GridControl_Docs.Visible = True And FormOpenClose = False Then RefreshHelper.SaveViewInfo()
InResetlayout = True InResetlayout = True
' Layout zurücksetzen ' Layout zurücksetzen
ResetLayout() ResetLayout()
@@ -1710,91 +1719,80 @@ Public Class frmMain
Private Sub GridView_Docs_CustomDrawGroupRow(sender As Object, e As Views.Base.RowObjectCustomDrawEventArgs) Handles GridView_Docs.CustomDrawGroupRow Private Sub GridView_Docs_CustomDrawGroupRow(sender As Object, e As Views.Base.RowObjectCustomDrawEventArgs) Handles GridView_Docs.CustomDrawGroupRow
Try Try
If formShown = False Then ' Added
If FormOpenClose = True And GridIsLoaded = False Then
Exit Sub Exit Sub
End If End If
Dim info As GridGroupRowInfo = TryCast(e.Info, GridGroupRowInfo) Dim info As GridGroupRowInfo = TryCast(e.Info, GridGroupRowInfo)
Dim view As GridView = sender Dim view As GridView = sender
Dim oGroupItem As GridGroupSummaryItem = CType(view.GroupSummary(Tag), GridGroupSummaryItem)
' Dim value As Object = view.GetGroupSummaryValue(e.RowHandle, item)
If info.Column.FieldName = "GROUP_TEXT" Then If info.Column.FieldName = "GROUP_TEXT" Then
info.GroupText = info.GroupValueText info.GroupText = info.GroupValueText
Dim _color As String = "LightGray" Dim oColorString As String = "LightGray"
Dim _FontColor As String = "Black" Dim oFontColorString As String = "Black"
Dim oFoundConfig As Boolean = False Dim oFoundConfig As Boolean = False
For Each row As DataRow In CURR_DT_VWPM_PROFILE_ACTIVE.Rows For Each row As DataRow In CURR_DT_VWPM_PROFILE_ACTIVE.Rows
'LOGGER.Debug($"CustomDrawGroupRow: Working on ProfileID [{row.Item("GUID")}]...")
If row.Item("GROUP_TEXT") = info.GroupValueText Then If row.Item("GROUP_TEXT") = info.GroupValueText Then
oFoundConfig = True oFoundConfig = True
_color = row.Item("GROUP_COLOR") oColorString = row.Item("GROUP_COLOR")
_FontColor = row.Item("GROUP_FONT_COLOR") oFontColorString = row.Item("GROUP_FONT_COLOR")
' Added
Exit For
End If End If
Next Next
If oFoundConfig = False Then If oFoundConfig = False Then
LOGGER.Debug($"CustomDrawGroupRow: Could not find a ColorConfig for ProfileGroupValueText [{info.GroupValueText}]...") LOGGER.Debug($"CustomDrawGroupRow: Could not find a ColorConfig for ProfileGroupValueText [{info.GroupValueText}]...")
' Added
Exit Sub
End If End If
Dim oColor As Color
Dim oFontColor As Color
Try
If _color.Contains(";") Or _color.Contains(".") Then
Dim oColorSplit As String()
If _color.Contains(";") Then
oColorSplit = _color.Split(";")
ElseIf _color.Contains(".") Then
oColorSplit = _color.Split(".")
End If
Dim oColor As Color = ParseColorString(oColorString, Color.LightGray, "Background Color")
Dim oFontColor As Color = ParseColorString(oFontColorString, Color.Black, "Font Color")
Try
oColor = Color.FromArgb(oColorSplit(0), oColorSplit(1), oColorSplit(2))
Catch ex As Exception
LOGGER.Info($"CustomDrawGroupRow: Could not get Color.FromArgb [{_color}]")
oColor = Color.LightGray
End Try
Else
Try
oColor = Color.FromName(_color)
Catch ex As Exception
LOGGER.Info($"CustomDrawGroupRow: Could not get Color.FromName [{_color}]")
oColor = Color.LightGray
End Try
End If
If _FontColor.Contains(";") Then
Try
oFontColor = Color.FromArgb(_FontColor)
Catch ex As Exception
LOGGER.Info($"CustomDrawGroupRow: Could not get Color.FromArgb [{_FontColor}]")
oFontColor = Color.Black
End Try
Else
Try
oFontColor = Color.FromName(_FontColor)
Catch ex As Exception
LOGGER.Info($"CustomDrawGroupRow(FC): Could not get Color.FromName [{_FontColor}]")
oFontColor = Color.Black
End Try
End If
Catch ex As Exception
LOGGER.Info($"CustomDrawGroupRow(FC): Error getting Color [{_FontColor}]")
oColor = Color.LightGray
End Try
info.Appearance.BackColor = oColor info.Appearance.BackColor = oColor
info.Appearance.ForeColor = oFontColor info.Appearance.ForeColor = oFontColor
End If End If
Catch ex As Exception Catch ex As Exception
LOGGER.Error(ex) LOGGER.Error(ex)
End Try End Try
End Sub End Sub
Private Function ParseColorString(ColorString As String, DefaultColor As Color, ColorDescription As String) As Color
Dim oResultColor As Color
If ColorString.Contains(";") Or ColorString.Contains(".") Then
Dim oSplitColorString As String()
If ColorString.Contains(";") Then
oSplitColorString = ColorString.Split(";")
Else
oSplitColorString = ColorString.Split(".")
End If
Try
oResultColor = Color.FromArgb(oSplitColorString(0), oSplitColorString(1), oSplitColorString(2))
Catch ex As Exception
oResultColor = DefaultColor
LOGGER.Info("ParseColorString: Could not get Color.FromArgb [{0}] for {1}", ColorString, ColorDescription)
End Try
Else
Try
oResultColor = Color.FromName(ColorString)
Catch ex As Exception
LOGGER.Info("ParseColorString: Could not get Color.FromArgb [{0}] for {1}", ColorString, ColorDescription)
oResultColor = DefaultColor
End Try
End If
Return oResultColor
End Function
Private Sub GridView_Docs_MouseDown(sender As Object, e As MouseEventArgs) Handles GridView_Docs.MouseDown Private Sub GridView_Docs_MouseDown(sender As Object, e As MouseEventArgs) Handles GridView_Docs.MouseDown
Dim view As GridView = sender Dim view As GridView = sender
Dim hi As GridHitInfo = view.CalcHitInfo(e.Location) Dim hi As GridHitInfo = view.CalcHitInfo(e.Location)
@@ -1826,7 +1824,7 @@ Public Class frmMain
Private Sub GridView_Docs_LostFocus(sender As Object, e As EventArgs) Handles GridView_Docs.LostFocus Private Sub GridView_Docs_LostFocus(sender As Object, e As EventArgs) Handles GridView_Docs.LostFocus
' Save expanded GroupRows ' Save expanded GroupRows
If GridControl_Docs.Visible = True And formopenClose = False Then RefreshHelper.SaveViewInfo() If GridControl_Docs.Visible = True And FormOpenClose = False Then RefreshHelper.SaveViewInfo()
End Sub End Sub
Sub LoadCURRENT_DT_PROFILES() Sub LoadCURRENT_DT_PROFILES()
CURRENT_DT_PROFILES = ClassDatabase.Return_Datatable("select * from TBPM_PROFILE where ACTIVE = 1", "LoadCURRENT_DT_PROFILES") CURRENT_DT_PROFILES = ClassDatabase.Return_Datatable("select * from TBPM_PROFILE where ACTIVE = 1", "LoadCURRENT_DT_PROFILES")
@@ -1919,15 +1917,10 @@ Public Class frmMain
Dim oSQL As String = "None" Dim oSQL As String = "None"
Try Try
For Each oSLogstring As String In LOGCONFIG.Logs For Each oSLogstring As String In LOGCONFIG.Logs
Dim oLogSplit As String() Dim oLogSplit As String() = oSLogstring.Split("|")
oLogSplit = oSLogstring.Split("|") Dim oMessage = PrepareLogMessage(oSLogstring)
'Console.WriteLine(oLogSplit(2)) Dim oDateTime As Date = CDate(oLogSplit(0))
Dim omsg = oLogSplit(2).Replace("'", "''") oSQL = $"INSERT INTO [dbo].[TBPM_LOG_DEBUG] ([USERID] , [LOGMSG], [ADDED_WHEN],DATE_STR) VALUES({USER_ID},'{oMessage}',GetDate(),'{oDateTime}')"
omsg = omsg.Replace("\\n", "")
omsg = omsg.Replace(Chr(10), "")
omsg = omsg.Replace(Chr(13), "")
Dim odatetime As Date = CDate(oLogSplit(0))
oSQL = $"INSERT INTO [dbo].[TBPM_LOG_DEBUG] ([USERID] , [LOGMSG], [ADDED_WHEN],DATE_STR) VALUES({USER_ID},'{omsg}',GetDate(),'{odatetime}')"
ClassDatabase.Execute_non_Query(oSQL) ClassDatabase.Execute_non_Query(oSQL)
Next Next
LOGCONFIG.ClearLogs() LOGCONFIG.ClearLogs()
@@ -1935,7 +1928,6 @@ Public Class frmMain
LOGGER.Error(ex) LOGGER.Error(ex)
LOGGER.Warn($"oSQL so far [{oSQL}]") LOGGER.Warn($"oSQL so far [{oSQL}]")
End Try End Try
End Sub End Sub
Private Sub tsslblDEBUG_LOG_MouseHover(sender As Object, e As EventArgs) Private Sub tsslblDEBUG_LOG_MouseHover(sender As Object, e As EventArgs)
MsgBox("UserDebugMode is activated remotely. Debugdata will be transferred to database and will be deleted after 10 days!!", MsgBoxStyle.Information, ADDITIONAL_TITLE) MsgBox("UserDebugMode is activated remotely. Debugdata will be transferred to database and will be deleted after 10 days!!", MsgBoxStyle.Information, ADDITIONAL_TITLE)
@@ -1948,7 +1940,6 @@ Public Class frmMain
End If End If
End Sub End Sub
Private Sub LöscheAlleFilterToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LöscheAlleFilterToolStripMenuItem.Click Private Sub LöscheAlleFilterToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LöscheAlleFilterToolStripMenuItem.Click
Try Try
GridView_Docs.ClearFindFilter() GridView_Docs.ClearFindFilter()
@@ -1986,7 +1977,7 @@ Public Class frmMain
Private Sub frmMain_Resize(sender As Object, e As EventArgs) Handles Me.Resize Private Sub frmMain_Resize(sender As Object, e As EventArgs) Handles Me.Resize
Try Try
If formShown = False Then If FormShown = False Then
Exit Sub Exit Sub
End If End If
@@ -2014,14 +2005,14 @@ Public Class frmMain
Private Sub bbtniRefresh_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles bbtniRefresh.ItemClick Private Sub bbtniRefresh_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles bbtniRefresh.ItemClick
If GridControl_Docs.Visible = True And formopenClose = False Then If GridControl_Docs.Visible = True And FormOpenClose = False Then
RefreshHelper.SaveViewInfo() RefreshHelper.SaveViewInfo()
SaveGridLayout() SaveGridLayout()
End If End If
LoadNavBar() LoadNavBar()
Decide_Load(False) Decide_Load(False)
If GridControl_Docs.Visible = True And formopenClose = False Then RefreshHelper.LoadViewInfo() If GridControl_Docs.Visible = True And FormOpenClose = False Then RefreshHelper.LoadViewInfo()
End Sub End Sub
Private Sub bbtniMonitor_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles bbtniMonitor.ItemClick Private Sub bbtniMonitor_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles bbtniMonitor.ItemClick
@@ -2119,7 +2110,7 @@ Public Class frmMain
End Sub End Sub
Private Sub GridView_Docs_RowStyle(sender As Object, e As RowStyleEventArgs) Handles GridView_Docs.RowStyle Private Sub GridView_Docs_RowStyle(sender As Object, e As RowStyleEventArgs) Handles GridView_Docs.RowStyle
If formShown = False Then If FormShown = False Then
Exit Sub Exit Sub
End If End If
If e.RowHandle = -1 Then If e.RowHandle = -1 Then
@@ -2187,7 +2178,7 @@ Public Class frmMain
GetBaseData("Load") GetBaseData("Load")
LoadNavBar() LoadNavBar()
Decide_Load(False) Decide_Load(False)
If GridControl_Docs.Visible = True And formopenClose = False Then RefreshHelper.LoadViewInfo() If GridControl_Docs.Visible = True And FormOpenClose = False Then RefreshHelper.LoadViewInfo()
End If End If
End Sub End Sub
@@ -2214,7 +2205,7 @@ Public Class frmMain
_Init.InitUserLogin() _Init.InitUserLogin()
LoadNavBar() LoadNavBar()
Decide_Load(False) Decide_Load(False)
If GridControl_Docs.Visible = True And formopenClose = False Then RefreshHelper.LoadViewInfo() If GridControl_Docs.Visible = True And FormOpenClose = False Then RefreshHelper.LoadViewInfo()
End Sub End Sub
Private Sub GridView_Docs_ColumnFilterChanged(sender As Object, e As EventArgs) Handles GridView_Docs.ColumnFilterChanged Private Sub GridView_Docs_ColumnFilterChanged(sender As Object, e As EventArgs) Handles GridView_Docs.ColumnFilterChanged
@@ -2236,12 +2227,12 @@ Public Class frmMain
XtraSaveFileDialog1.FileName = "OverviewProcessManager.xlsx" XtraSaveFileDialog1.FileName = "OverviewProcessManager.xlsx"
XtraSaveFileDialog1.DefaultExt = ".xlsx" XtraSaveFileDialog1.DefaultExt = ".xlsx"
If XtraSaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then If XtraSaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim oOptions As New XlsxExportOptions() With { Dim oOptions As New XlsxExportOptions() With {
.ExportMode = XlsxExportMode.SingleFile .ExportMode = XlsxExportMode.SingleFile
} }
GridView_Docs.ExportToXlsx(XtraSaveFileDialog1.FileName, oOptions) GridView_Docs.ExportToXlsx(XtraSaveFileDialog1.FileName, oOptions)
End If End If
End Sub End Sub