MS Diverse Verbesserungen beim laden , NOLOCK etc

This commit is contained in:
Developer01
2026-04-30 16:15:00 +02:00
parent 08c6a6c125
commit 11147ca0ff
20 changed files with 311 additions and 202 deletions

View File

@@ -264,64 +264,110 @@ Module ModuleHelperMethods
Public Sub OpenFormConstructor(id As Integer, NodeNav As Boolean, EntityID As Int16, Optional pJumpID As Integer = -1)
Try
LOGGER.Debug($"OpenFormConstructor called: ID={id}, NodeNav={NodeNav}, EntityID={EntityID}, pJumpID={pJumpID}", False)
If pJumpID <> -1 Then
' Wenn JUMP_RECORD_ID gesetzt wurde, wird zu diesem Record gesprungen
JUMP_ID = pJumpID
LOGGER.Debug($"JUMP_ID set to {pJumpID}", False)
End If
' Prüfen ob Form bereits in Liste der geöffneten Forms
If CURRENT_OPEN_CONSTRUCTOR_FORMS.Contains(id) Then
LOGGER.Debug($"Form ID {id} is already in CURRENT_OPEN_CONSTRUCTOR_FORMS list", False)
Dim frm1 As New frmConstructor_Main
frm1.Tag = id
Dim frmCollection = System.Windows.Forms.Application.OpenForms
Dim formFound As Boolean = False
LOGGER.Debug($"Searching through {frmCollection.Count} open forms", False)
For i As Int16 = 0I To frmCollection.Count - 1I
If frmCollection.Item(i).Tag = id Then
formFound = True
LOGGER.Debug($"Found existing form with ID {id} at index {i}, Type: {frmCollection.Item(i).GetType().Name}", False)
frmCollection.Item(i).Activate()
frmCollection.Item(i).BringToFront()
If frmCollection.Item(i).WindowState = FormWindowState.Minimized Then
frmCollection.Item(i).WindowState = FormWindowState.Normal
LOGGER.Debug($"Restored minimized form ID {id}", False)
End If
CURRENT_CONSTRUCTOR_ID = id
CURRENT_OPEN_CONSTRUCTOR_FORMS.Add(id)
If pJumpID <> -1 Then
' Nur ausführen, wenn das Form tatsächlich JumptoNode unterstützt
If TypeOf frmCollection.Item(i) Is frmNodeNavigation Then
LOGGER.Debug($"Calling JumptoNode on existing frmNodeNavigation", False)
DirectCast(frmCollection.Item(i), frmNodeNavigation).JumptoNode()
Else
LOGGER.Warn($"Form ID {id} does not support frmNodeNavigation.JumptoNode - Type is {frmCollection.Item(i).GetType().Name}")
End If
End If
LOGGER.Debug($"Successfully activated existing form ID {id}, exiting method", False)
Exit Sub
End If
Next i
Exit Sub
' KRITISCHER PUNKT: Form war in Liste, wurde aber nicht gefunden
If Not formFound Then
LOGGER.Warn($"Form ID {id} was in CURRENT_OPEN_CONSTRUCTOR_FORMS but not found in OpenForms collection - removing from list and continuing to create new form")
' Form aus Liste entfernen, da sie offensichtlich nicht mehr existiert
CURRENT_OPEN_CONSTRUCTOR_FORMS.Remove(id)
Else
' Form wurde gefunden und aktiviert
Exit Sub
End If
Else
LOGGER.Debug($"Form ID {id} is NOT in CURRENT_OPEN_CONSTRUCTOR_FORMS list", False)
End If
' Neue Form erstellen
CURRENT_CONSTRUCTOR_ID = id
CURRENT_OPEN_CONSTRUCTOR_FORMS.Add(id)
LOGGER.Debug($"Set CURRENT_CONSTRUCTOR_ID={id} and added to CURRENT_OPEN_CONSTRUCTOR_FORMS", False)
If NodeNav Then
LOGGER.Debug($"Creating new frmNodeNavigation for EntityID={EntityID}, ConstructorID={CURRENT_CONSTRUCTOR_ID}", False)
Dim frmNodeNav As New frmNodeNavigation(EntityID, CURRENT_CONSTRUCTOR_ID)
frmNodeNav.Tag = id
If My.Settings.EntFormsChild = True Then
Dim activeChild1 As Form = MAIN_FORM.ActiveMdiChild
If activeChild1 IsNot Nothing Then
activeChild1.WindowState = FormWindowState.Normal
LOGGER.Debug($"Normalized active MDI child: {activeChild1.GetType().Name}", False)
End If
End If
If My.Settings.EntFormsChild = True Then
frmNodeNav.MdiParent = MAIN_FORM
LOGGER.Debug($"Set frmNodeNav.MdiParent to MAIN_FORM", False)
Else
LOGGER.Debug($"frmNodeNav will open as standalone window (EntFormsChild=False)", False)
End If
LOGGER.Debug($"Calling frmNodeNav.Show() for ID {id}", False)
frmNodeNav.Show()
LOGGER.Debug($"frmNodeNav.Show() completed successfully for ID {id}", False)
If pJumpID <> -1 Then
LOGGER.Debug($"Calling JumptoNode on newly created frmNodeNavigation", False)
frmNodeNav.JumptoNode()
End If
Else
LOGGER.Debug($"NodeNav=False - Creating frmConstructor_Main instead (should not happen based on requirements)", False)
Dim frm As New frmConstructor_Main()
frm.Tag = id
If My.Settings.EntFormsChild = True Then
Dim activeChild As Form = MAIN_FORM.ActiveMdiChild
If activeChild IsNot Nothing Then
@@ -329,23 +375,23 @@ Module ModuleHelperMethods
End If
End If
If pJumpID <> -1 Then
' Wenn JUMP_RECORD_ID gesetzt wurde, wird zu diesem Record gesprungen
JUMP_ID = pJumpID
End If
If My.Settings.EntFormsChild = True Then
frm.MdiParent = MAIN_FORM
End If
frm.Show()
LOGGER.Debug($"frmConstructor_Main.Show() completed for ID {id}", False)
End If
LOGGER.Debug($"OpenFormConstructor completed successfully for ID {id}", False)
Catch ex As Exception
LOGGER.Warn("Error in OpenFormConstructor: " & ex.Message)
LOGGER.Warn($"Error in OpenFormConstructor for ID {id}, NodeNav={NodeNav}: {ex.Message}{vbNewLine}StackTrace: {ex.StackTrace}")
MsgBox("Error in OpenFormConstructor: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub