This commit is contained in:
SchreiberM 2016-06-02 12:19:02 +02:00
commit f60d30572c
4 changed files with 56 additions and 23 deletions

View File

@ -96,9 +96,10 @@
final = ClassDatabase.Return_Datatable(sqlCommand) final = ClassDatabase.Return_Datatable(sqlCommand)
End If End If
ClassControlValueCache.SaveToCache(sqlCommand, final) ClassControlValueCache.SaveToCache(sqlCommand, final)
Console.WriteLine("CACHE MISS")
Else Else
final = cached final = cached
' Console.WriteLine("CACHE HIT") Console.WriteLine("CACHE HIT")
End If End If
Return final Return final
@ -127,10 +128,11 @@
End Sub End Sub
Overloads Shared Sub SetDataSource(control As CustomComboBox, dt As DataTable) Overloads Shared Sub SetDataSource(control As CustomComboBox, dt As DataTable)
Dim sw As Stopwatch = Stopwatch.StartNew() Dim sw As New SW("SetDataSource CustomComboBox")
Dim columnCount As Integer = dt.Columns.Count Dim columnCount As Integer = dt.Columns.Count
control.BeginUpdate() control.BeginUpdate()
PerfomanceHelper.SuspendDraw(control)
' Damit beim Setzen von DisplayMember und ValueMember kein Fehler auftritt, ' Damit beim Setzen von DisplayMember und ValueMember kein Fehler auftritt,
' muss die Datasource zunächst geleert werden und der selected index auf -1 gesetzt werden. ' muss die Datasource zunächst geleert werden und der selected index auf -1 gesetzt werden.
@ -150,10 +152,10 @@
' Als letztes setzen wir die DataSource ' Als letztes setzen wir die DataSource
control.DataSource = dt control.DataSource = dt
PerfomanceHelper.ResumeDraw(control)
control.EndUpdate() control.EndUpdate()
sw.Stop() sw.Done()
' Console.WriteLine("SetDataSource for {0} took {1}ms", control.Name, sw.ElapsedMilliseconds)
End Sub End Sub
Overloads Shared Sub SetDataSource(control As DevExpress.XtraEditors.CheckedListBoxControl, dt As DataTable) Overloads Shared Sub SetDataSource(control As DevExpress.XtraEditors.CheckedListBoxControl, dt As DataTable)
@ -367,7 +369,10 @@
Public Shared Sub LoadList(control As CustomComboBox, formId As Integer, connID As Object, SQLCommand As String) Public Shared Sub LoadList(control As CustomComboBox, formId As Integer, connID As Object, SQLCommand As String)
Try Try
Dim sw As New SW("LoadList CustomComboBox")
Dim sw1 As New SW("GetDynamicValue CustomComboBox")
Dim dynamic As DynamicValue = GetDynamicValue(DirectCast(control.Tag, ClassControlMetadata).Id, formId, connID, SQLCommand) Dim dynamic As DynamicValue = GetDynamicValue(DirectCast(control.Tag, ClassControlMetadata).Id, formId, connID, SQLCommand)
sw1.Done()
If dynamic.StaticList IsNot Nothing Then If dynamic.StaticList IsNot Nothing Then
control.DataSource = dynamic.StaticList control.DataSource = dynamic.StaticList
@ -377,6 +382,7 @@
SetDataSource(control, dynamic.DataTable) SetDataSource(control, dynamic.DataTable)
CalculateDropdownWidth(control, dynamic.DataTable) CalculateDropdownWidth(control, dynamic.DataTable)
End If End If
sw.Done()
Catch ex As Exception Catch ex As Exception
MsgBox("Error in Combobox.LoadList:" & vbNewLine & ex.Message) MsgBox("Error in Combobox.LoadList:" & vbNewLine & ex.Message)
End Try End Try
@ -444,6 +450,8 @@
Public Shared Sub LoadList(control As DevExpress.XtraEditors.CheckedListBoxControl, formId As Integer, conn_Id As Object, SQLCommand As String) Public Shared Sub LoadList(control As DevExpress.XtraEditors.CheckedListBoxControl, formId As Integer, conn_Id As Object, SQLCommand As String)
Try Try
Dim sw As New SW("LoadList CheckedListBoxControl")
Dim dynamic As DynamicValue = GetDynamicValue(DirectCast(control.Tag, ClassControlMetadata).Id, formId, conn_Id, SQLCommand) Dim dynamic As DynamicValue = GetDynamicValue(DirectCast(control.Tag, ClassControlMetadata).Id, formId, conn_Id, SQLCommand)
If dynamic.StaticList IsNot Nothing Then If dynamic.StaticList IsNot Nothing Then
@ -459,6 +467,7 @@
SetDataSource(control, dynamic.DataTable) SetDataSource(control, dynamic.DataTable)
End If End If
sw.Done()
Catch ex As Exception Catch ex As Exception
MsgBox("Error in CheckedListBox.LoadList:" & vbNewLine & ex.Message) MsgBox("Error in CheckedListBox.LoadList:" & vbNewLine & ex.Message)
End Try End Try
@ -477,6 +486,8 @@
End Sub End Sub
Public Shared Sub LoadList(control As DevExpress.XtraEditors.ListBoxControl, formId As Integer, ConnId As Object, SQLCommand As String) Public Shared Sub LoadList(control As DevExpress.XtraEditors.ListBoxControl, formId As Integer, ConnId As Object, SQLCommand As String)
Dim sw As New SW("LoadList ListBoxControl")
Dim dynamic As DynamicValue = GetDynamicValue(DirectCast(control.Tag, ClassControlMetadata).Id, formId, ConnId, SQLCommand) Dim dynamic As DynamicValue = GetDynamicValue(DirectCast(control.Tag, ClassControlMetadata).Id, formId, ConnId, SQLCommand)
If dynamic.StaticList IsNot Nothing Then If dynamic.StaticList IsNot Nothing Then
@ -486,6 +497,8 @@
If dynamic.DataTable IsNot Nothing AndAlso dynamic.DataTable.Rows.Count > 0 Then If dynamic.DataTable IsNot Nothing AndAlso dynamic.DataTable.Rows.Count > 0 Then
SetDataSource(control, dynamic.DataTable) SetDataSource(control, dynamic.DataTable)
End If End If
sw.Done()
End Sub End Sub
End Class End Class
@ -503,6 +516,8 @@
Public Class DataGridViewCheckable : Inherits _ListControl Public Class DataGridViewCheckable : Inherits _ListControl
Public Shared Sub LoadList(control As DevExpress.XtraGrid.GridControl, formId As Integer, ConnId As Object, SQLCommand As String) Public Shared Sub LoadList(control As DevExpress.XtraGrid.GridControl, formId As Integer, ConnId As Object, SQLCommand As String)
Dim sw As New SW("LoadList GridControl")
Dim dynamic As DynamicValue = GetDynamicValue(DirectCast(control.Tag, ClassControlMetadata).Id, formId, ConnId, SQLCommand) Dim dynamic As DynamicValue = GetDynamicValue(DirectCast(control.Tag, ClassControlMetadata).Id, formId, ConnId, SQLCommand)
If dynamic.StaticList IsNot Nothing Then If dynamic.StaticList IsNot Nothing Then

View File

@ -1,22 +1,7 @@
Imports DevExpress.XtraEditors.Controls Imports DevExpress.XtraEditors.Controls
Imports System.Runtime.InteropServices
Public Class ClassControlValues Public Class ClassControlValues
<DllImport("user32.dll")> _
Public Shared Function SendMessage(hWnd As IntPtr, msg As Int32, wParam As Boolean, lParam As Int32) As Integer
End Function
Private Const WM_SETREDRAW As Int32 = 11
Private Sub SuspendDraw(c As Control)
SendMessage(c.Handle, WM_SETREDRAW, False, 0)
End Sub
Private Sub ResumeDraw(c As Control)
SendMessage(c.Handle, WM_SETREDRAW, True, 0)
c.Refresh()
End Sub
Public Shared Function ControlHasValue(control As Control) As Boolean Public Shared Function ControlHasValue(control As Control) As Boolean
Select Case control.GetType() Select Case control.GetType()
@ -194,6 +179,8 @@ Public Class ClassControlValues
If LogErrorsOnly = False Then ClassLogger.Add(String.Format(" >> LoadControlHints took {0} to load", Format(elapsed, "0.000000000") & " seconds"), False) If LogErrorsOnly = False Then ClassLogger.Add(String.Format(" >> LoadControlHints took {0} to load", Format(elapsed, "0.000000000") & " seconds"), False)
sw.Start() sw.Start()
For Each control As Control In controls For Each control As Control In controls
PerfomanceHelper.SuspendDraw(control)
Dim ControlId As Integer = DirectCast(control.Tag, ClassControlMetadata).Id Dim ControlId As Integer = DirectCast(control.Tag, ClassControlMetadata).Id
' Wert per LINQ aus DT_ControlValues suchen der zur aktuellen controlId passt ' Wert per LINQ aus DT_ControlValues suchen der zur aktuellen controlId passt
Dim values As List(Of Object) = (From row In DT_ControlValues.AsEnumerable() Dim values As List(Of Object) = (From row In DT_ControlValues.AsEnumerable()
@ -205,6 +192,8 @@ Public Class ClassControlValues
Else Else
LoadControlValue(RecordId, ParentRecordId, ControlId, control, values, Entity_ID) LoadControlValue(RecordId, ParentRecordId, ControlId, control, values, Entity_ID)
End If End If
PerfomanceHelper.ResumeDraw(control)
Next Next
elapsed = sw.Elapsed.TotalSeconds elapsed = sw.Elapsed.TotalSeconds
@ -348,7 +337,7 @@ Public Class ClassControlValues
For Each Ctrl As Control In controls For Each Ctrl As Control In controls
Dim controlTagId = DirectCast(Ctrl.Tag, ClassControlMetadata).Id Dim controlTagId = DirectCast(Ctrl.Tag, ClassControlMetadata).Id
PerfomanceHelper.SuspendDraw(Ctrl)
'If controlTagId = 474 Then 'If controlTagId = 474 Then
' MsgBox("Thats it") ' MsgBox("Thats it")
@ -376,10 +365,9 @@ Public Class ClassControlValues
Case GetType(DevExpress.XtraGrid.GridControl) Case GetType(DevExpress.XtraGrid.GridControl)
Dim grid = DirectCast(Ctrl, DevExpress.XtraGrid.GridControl) Dim grid = DirectCast(Ctrl, DevExpress.XtraGrid.GridControl)
ControlLoader.DataGridViewCheckable.LoadList(grid, FormID, ConnID, sqlcommand) ControlLoader.DataGridViewCheckable.LoadList(grid, FormID, ConnID, sqlcommand)
End Select End Select
PerfomanceHelper.ResumeDraw(Ctrl)
Next Next
sw.Stop() sw.Stop()
@ -426,6 +414,8 @@ Public Class ClassControlValues
sqlcommand = ReplaceSqlCommandPlaceholders(sqlcommand, RecordId, ParentRecordId, entity_ID) sqlcommand = ReplaceSqlCommandPlaceholders(sqlcommand, RecordId, ParentRecordId, entity_ID)
PerfomanceHelper.SuspendDraw(Ctrl)
Select Case Ctrl.GetType() Select Case Ctrl.GetType()
Case GetType(CustomComboBox) Case GetType(CustomComboBox)
Dim combobox = DirectCast(Ctrl, CustomComboBox) Dim combobox = DirectCast(Ctrl, CustomComboBox)
@ -440,6 +430,8 @@ Public Class ClassControlValues
ControlLoader.CheckedListBox.LoadList(chlistbox, FormId, connID, sqlcommand) ControlLoader.CheckedListBox.LoadList(chlistbox, FormId, connID, sqlcommand)
End Select End Select
PerfomanceHelper.ResumeDraw(Ctrl)
Next Next
Dim elapsed As Double Dim elapsed As Double
elapsed = SW.Elapsed.TotalSeconds elapsed = SW.Elapsed.TotalSeconds

View File

@ -416,4 +416,30 @@
End Class End Class
Public Class PerfomanceHelper
<Runtime.InteropServices.DllImport("user32.dll")> _
Public Shared Function SendMessage(hWnd As IntPtr, msg As Int32, wParam As Boolean, lParam As Int32) As Integer
End Function
Private Const WM_SETREDRAW As Int32 = &HB
''' <summary>
''' Verhindert Draw-Events. Am Ende sollte ResumeDraw `aufgerufen` werden.
''' </summary>
''' <param name="c"></param>
''' <remarks></remarks>
Public Shared Sub SuspendDraw(c As Control)
SendMessage(c.Handle, WM_SETREDRAW, False, 0)
End Sub
''' <summary>
''' Lässt die Draw-Events wieder zu. Davor sollte `SuspendDraw` aufgerufen werden
''' </summary>
''' <param name="c"></param>
''' <remarks></remarks>
Public Shared Sub ResumeDraw(c As Control)
SendMessage(c.Handle, WM_SETREDRAW, True, 0)
c.Refresh()
End Sub
End Class
End Module End Module

View File

@ -2907,7 +2907,7 @@ Public Class frmConstructor_Main
Dim str = String.Empty Dim str = String.Empty
If DT_VWPMO_CONSTRUCTOR_FORMS.Rows.Count >= 3 Then If DT_VWPMO_CONSTRUCTOR_FORMS.Rows.Count >= 3 Then
str &= ACT_EBENE_STRING str &= System.Text.RegularExpressions.Regex.Replace(ACT_EBENE_STRING, "\s\(\d+\)", "")
str &= " - " str &= " - "
End If End If