Vor ClassFolderwatcher delete

This commit is contained in:
Developer01
2026-03-02 11:24:56 +01:00
parent a88af162b5
commit 570d1161f8
5 changed files with 243 additions and 40 deletions

View File

@@ -2,7 +2,7 @@
Imports System.Text.RegularExpressions
Public Class ClassControlValues
Public Shared Function ControlHasValue(control As Control) As Boolean
Try
Select Case control.GetType()
@@ -390,6 +390,83 @@ Public Class ClassControlValues
End Sub
Public Shared Sub LoadControlValues_Optimized(RecordId As Integer, ParentRecordId As Integer, FormId As Integer, controls As Control.ControlCollection, Entity_ID As Integer, Optional isGroupbox As Boolean = False)
Try
If RecordId = 0 Then Exit Sub
' 1. Alle Daten in EINEM Rutsch laden
' EINE Query für Values + Hints via JOIN
Dim SQL = $"
SELECT
cv.CONTROL_ID,
cv.VALUE,
ch.HINT
FROM VWPMO_VALUES cv
LEFT JOIN VWPMO_CONTROL_HINT ch ON cv.CONTROL_ID = ch.CONTROL_ID
AND ch.FORM_ID = {FormId}
WHERE cv.RECORD_ID = {RecordId}"
Dim dtBatch = MYDB_ECM.GetDatatable(SQL)
' ✅ 2. Dictionary für O(1) Lookups statt O(n) LINQ
Dim valueDict As New Dictionary(Of Integer, List(Of Object))
Dim hintDict As New Dictionary(Of Integer, String)
For Each row As DataRow In dtBatch.Rows
Dim ctrlId = row.Field(Of Integer)("CONTROL_ID")
' Values gruppieren
If Not valueDict.ContainsKey(ctrlId) Then
valueDict(ctrlId) = New List(Of Object)
End If
valueDict(ctrlId).Add(row.Item("VALUE"))
' Hints cachen
Dim hint = row.Field(Of String)("HINT")
If Not String.IsNullOrEmpty(hint) Then
hintDict(ctrlId) = hint
ClassControlValueCache.SaveHint(ctrlId, hint)
End If
Next
' ✅ 3. Paralleles UI-Update mit BeginUpdate/EndUpdate
' GroupBox separat behandeln
Dim regularControls As New List(Of Control)
Dim groupBoxes As New List(Of GroupBox)
For Each ctrl As Control In controls
If TypeOf ctrl Is GroupBox Then
groupBoxes.Add(DirectCast(ctrl, GroupBox))
Else
regularControls.Add(ctrl)
End If
Next
' Batch-Update für reguläre Controls
For Each control As Control In regularControls
Dim ctrlId = DirectCast(control.Tag, ClassControlMetadata).Id
PerfomanceHelper.SuspendDraw(control)
' Dictionary-Lookup statt LINQ (O(1) vs O(n))
Dim values As List(Of Object) = Nothing
If valueDict.TryGetValue(ctrlId, values) Then
LoadControlValue(RecordId, ParentRecordId, ctrlId, control, values, Entity_ID)
End If
PerfomanceHelper.ResumeDraw(control)
Next
' Rekursiv für GroupBoxes
For Each gb As GroupBox In groupBoxes
LoadControlValues_Optimized(RecordId, ParentRecordId, FormId, gb.Controls, Entity_ID, True)
Next
Catch ex As Exception
LOGGER.Error(ex, "LoadControlValues_Optimized failed")
Throw
End Try
End Sub
Public Shared Sub LoadControlValuesListWithPlaceholders(FormId As Integer, RecordId As Integer, ParentRecordId As Integer, controls As Control.ControlCollection, entity_ID As Integer)
Try