From bc61e8960d9c227c87e7dd6dd62b3411d7c5023d Mon Sep 17 00:00:00 2001 From: Developer01 Date: Fri, 5 Jun 2026 10:50:31 +0200 Subject: [PATCH] Verbesserung der SQL-Logik und Datenbindung MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In `frmColumn_Detail` wurde die `SQLConnection`-Eigenschaft auf `1` gesetzt und neue Eigenschaften wie `PlaceholdersManualPrefix`, `PlaceholdersManualTitle` und `PlaceholdersManual` hinzugefügt. Eine Bedingung für `ATTRIBUTE_STORE` wurde basierend auf `IDB_ACTIVE` eingeführt. Die Behandlung von SQL-Befehlen wurde erweitert. In `frmFormDesigner.Designer.vb` und `frmFormDesigner.resx` wurden Bindings für `TBPM_CONTROL_TABLEBindingSource` und `DD_DMSLiteDataSet` entfernt und wieder hinzugefügt, um die Datenbindung zu aktualisieren. In `frmMain` wurde die Variable `COCKPIT_PROFILE_SQL` eingeführt, um SQL-Befehle für Cockpit-Profile zu speichern. Zusätzliche Debugging-Logs und Prüfungen wurden hinzugefügt, um SQL-Befehle zu überwachen und Fehler zu protokollieren. Die Methode `PrepareIconColumn` wurde erweitert, um sicherzustellen, dass die Spalte `TL_STATE` vorhanden ist, bevor sie verwendet wird. Fehlerbehandlungen wurden verbessert. --- app/TaskFlow/frmColumn_Detail.vb | 34 +++++++++++-- app/TaskFlow/frmFormDesigner.Designer.vb | 32 ++++++------ app/TaskFlow/frmFormDesigner.resx | 24 ++++----- app/TaskFlow/frmFormDesigner.vb | 7 +++ app/TaskFlow/frmMain.vb | 62 +++++++++++++++++------- 5 files changed, 110 insertions(+), 49 deletions(-) diff --git a/app/TaskFlow/frmColumn_Detail.vb b/app/TaskFlow/frmColumn_Detail.vb index c9ba846..c1fffbf 100644 --- a/app/TaskFlow/frmColumn_Detail.vb +++ b/app/TaskFlow/frmColumn_Detail.vb @@ -137,8 +137,17 @@ Public Class frmColumn_Detail CURRENT_INDEX_ID = GUIDTextBox.Text Dim oForm2 As New frmSQLEditor(LOGCONFIG, DatabaseECM) With { .SQLCommand = SQL_COMMANDTextBox.Text, - .SQLConnection = 0 + .SQLConnection = 1, + .PlaceholdersManualPrefix = "CTRL", + .PlaceholdersManualTitle = "Controls", + .PlaceholdersManual = CURRENT_CONTROL_NAME_LIST.ToDictionary(Function(name) name, Function(name) name) } + If IDB_ACTIVE = False Then + oForm2.ATTRIBUTE_STORE = "WM" + oForm2.PlaceholdersWindream = MVSource_AllIndicies + Else + oForm2.ATTRIBUTE_STORE = "IDB" + End If oForm2.ShowDialog() If oForm2.DialogResult = DialogResult.OK Then @@ -186,8 +195,18 @@ Public Class frmColumn_Detail CURRENT_INDEX_ID = GUIDTextBox.Text Dim oForm2 As New frmSQLEditor(LOGCONFIG, DatabaseECM) With { .SQLCommand = SQL_COMMANDTextBox.Text, - .SQLConnection = 0 + .SQLConnection = 1, + .PlaceholdersManualPrefix = "CTRL", + .PlaceholdersManualTitle = "Controls", + .PlaceholdersManual = CURRENT_CONTROL_NAME_LIST.ToDictionary(Function(name) name, Function(name) name) } + If IDB_ACTIVE = False Then + oForm2.ATTRIBUTE_STORE = "WM" + oForm2.PlaceholdersWindream = MVSource_AllIndicies + Else + oForm2.ATTRIBUTE_STORE = "IDB" + End If + oForm2.ShowDialog() If oForm2.DialogResult = DialogResult.OK Then @@ -232,8 +251,17 @@ Public Class frmColumn_Detail CURRENT_INDEX_ID = GUIDTextBox.Text Dim oForm2 As New frmSQLEditor(LOGCONFIG, DatabaseECM) With { .SQLCommand = FORMULA_SQLTextBox.Text, - .SQLConnection = 0 + .SQLConnection = 1, + .PlaceholdersManualPrefix = "CTRL", + .PlaceholdersManualTitle = "Controls", + .PlaceholdersManual = CURRENT_CONTROL_NAME_LIST.ToDictionary(Function(name) name, Function(name) name) } + If IDB_ACTIVE = False Then + oForm2.ATTRIBUTE_STORE = "WM" + oForm2.PlaceholdersWindream = MVSource_AllIndicies + Else + oForm2.ATTRIBUTE_STORE = "IDB" + End If oForm2.ShowDialog() If oForm2.DialogResult = DialogResult.OK Then diff --git a/app/TaskFlow/frmFormDesigner.Designer.vb b/app/TaskFlow/frmFormDesigner.Designer.vb index 499609c..6a0c029 100644 --- a/app/TaskFlow/frmFormDesigner.Designer.vb +++ b/app/TaskFlow/frmFormDesigner.Designer.vb @@ -25,8 +25,6 @@ Partial Class frmFormDesigner Me.components = New System.ComponentModel.Container() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmFormDesigner)) Me.SplitContainerDesigner = New System.Windows.Forms.SplitContainer() - Me.TBPM_CONTROL_TABLEBindingSource = New System.Windows.Forms.BindingSource(Me.components) - Me.DD_DMSLiteDataSet = New taskFLOW.DD_DMSLiteDataSet() Me.pnldesigner = New DigitalData.Controls.SnapPanel.ClassSnapPanel() Me.Panel1 = New System.Windows.Forms.Panel() Me.pgControlsNew = New DevExpress.XtraVerticalGrid.PropertyGridControl() @@ -60,6 +58,8 @@ Partial Class frmFormDesigner Me.RibPGCtrlWidth = New DevExpress.XtraBars.Ribbon.RibbonPageGroup() Me.RibPGCtrlheight = New DevExpress.XtraBars.Ribbon.RibbonPageGroup() Me.RibbonStatusBar1 = New DevExpress.XtraBars.Ribbon.RibbonStatusBar() + Me.TBPM_CONTROL_TABLEBindingSource = New System.Windows.Forms.BindingSource(Me.components) + Me.DD_DMSLiteDataSet = New taskFLOW.DD_DMSLiteDataSet() Me.TBPM_PROFILE_CONTROLSBindingSource = New System.Windows.Forms.BindingSource(Me.components) Me.TBDD_CONNECTIONBindingSource = New System.Windows.Forms.BindingSource(Me.components) Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components) @@ -79,11 +79,11 @@ Partial Class frmFormDesigner Me.SplitContainerDesigner.Panel1.SuspendLayout() Me.SplitContainerDesigner.Panel2.SuspendLayout() Me.SplitContainerDesigner.SuspendLayout() - CType(Me.TBPM_CONTROL_TABLEBindingSource, System.ComponentModel.ISupportInitialize).BeginInit() - CType(Me.DD_DMSLiteDataSet, System.ComponentModel.ISupportInitialize).BeginInit() Me.Panel1.SuspendLayout() CType(Me.pgControlsNew, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.RibbonControl1, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.TBPM_CONTROL_TABLEBindingSource, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.DD_DMSLiteDataSet, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.TBPM_PROFILE_CONTROLSBindingSource, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.TBDD_CONNECTIONBindingSource, System.ComponentModel.ISupportInitialize).BeginInit() Me.GridControlContextMenu.SuspendLayout() @@ -104,16 +104,6 @@ Partial Class frmFormDesigner ' Me.SplitContainerDesigner.Panel2.Controls.Add(Me.Panel1) ' - 'TBPM_CONTROL_TABLEBindingSource - ' - Me.TBPM_CONTROL_TABLEBindingSource.DataMember = "TBPM_CONTROL_TABLE" - Me.TBPM_CONTROL_TABLEBindingSource.DataSource = Me.DD_DMSLiteDataSet - ' - 'DD_DMSLiteDataSet - ' - Me.DD_DMSLiteDataSet.DataSetName = "DD_DMSLiteDataSet" - Me.DD_DMSLiteDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema - ' 'pnldesigner ' resources.ApplyResources(Me.pnldesigner, "pnldesigner") @@ -365,6 +355,16 @@ Partial Class frmFormDesigner Me.RibbonStatusBar1.Name = "RibbonStatusBar1" Me.RibbonStatusBar1.Ribbon = Me.RibbonControl1 ' + 'TBPM_CONTROL_TABLEBindingSource + ' + Me.TBPM_CONTROL_TABLEBindingSource.DataMember = "TBPM_CONTROL_TABLE" + Me.TBPM_CONTROL_TABLEBindingSource.DataSource = Me.DD_DMSLiteDataSet + ' + 'DD_DMSLiteDataSet + ' + Me.DD_DMSLiteDataSet.DataSetName = "DD_DMSLiteDataSet" + Me.DD_DMSLiteDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema + ' 'TBPM_PROFILE_CONTROLSBindingSource ' Me.TBPM_PROFILE_CONTROLSBindingSource.DataMember = "TBPM_PROFILE_CONTROLS" @@ -464,11 +464,11 @@ Partial Class frmFormDesigner Me.SplitContainerDesigner.Panel2.ResumeLayout(False) CType(Me.SplitContainerDesigner, System.ComponentModel.ISupportInitialize).EndInit() Me.SplitContainerDesigner.ResumeLayout(False) - CType(Me.TBPM_CONTROL_TABLEBindingSource, System.ComponentModel.ISupportInitialize).EndInit() - CType(Me.DD_DMSLiteDataSet, System.ComponentModel.ISupportInitialize).EndInit() Me.Panel1.ResumeLayout(False) CType(Me.pgControlsNew, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.RibbonControl1, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.TBPM_CONTROL_TABLEBindingSource, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.DD_DMSLiteDataSet, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.TBPM_PROFILE_CONTROLSBindingSource, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.TBDD_CONNECTIONBindingSource, System.ComponentModel.ISupportInitialize).EndInit() Me.GridControlContextMenu.ResumeLayout(False) diff --git a/app/TaskFlow/frmFormDesigner.resx b/app/TaskFlow/frmFormDesigner.resx index 2e07077..19cdcfd 100644 --- a/app/TaskFlow/frmFormDesigner.resx +++ b/app/TaskFlow/frmFormDesigner.resx @@ -1071,18 +1071,6 @@ Formular Designer - - TBPM_CONTROL_TABLEBindingSource - - - System.Windows.Forms.BindingSource, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - DD_DMSLiteDataSet - - - taskFLOW.DD_DMSLiteDataSet, DD_DMSLiteDataSet.Designer.vb.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - bbtnItemFinishSQL @@ -1251,6 +1239,18 @@ DevExpress.XtraBars.Ribbon.RibbonPageGroup, DevExpress.XtraBars.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + + TBPM_CONTROL_TABLEBindingSource + + + System.Windows.Forms.BindingSource, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + DD_DMSLiteDataSet + + + taskFLOW.DD_DMSLiteDataSet, DD_DMSLiteDataSet.Designer.vb.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + TBPM_PROFILE_CONTROLSBindingSource diff --git a/app/TaskFlow/frmFormDesigner.vb b/app/TaskFlow/frmFormDesigner.vb index 24aa955..14a91a7 100644 --- a/app/TaskFlow/frmFormDesigner.vb +++ b/app/TaskFlow/frmFormDesigner.vb @@ -1027,6 +1027,13 @@ Public Class frmFormDesigner .PlaceholdersManualTitle = "Controls", .PlaceholdersManual = CURRENT_CONTROL_NAME_LIST.ToDictionary(Function(name) name, Function(name) name) } + If IDB_ACTIVE = False Then + oForm.ATTRIBUTE_STORE = "WM" + oForm.PlaceholdersWindream = MVSource_AllIndicies + Else + oForm.ATTRIBUTE_STORE = "IDB" + End If + oForm.ShowDialog() If oForm.DialogResult = DialogResult.OK Then diff --git a/app/TaskFlow/frmMain.vb b/app/TaskFlow/frmMain.vb index 972dca9..ed235ca 100644 --- a/app/TaskFlow/frmMain.vb +++ b/app/TaskFlow/frmMain.vb @@ -77,6 +77,7 @@ Public Class frmMain Private CUSTOM_OVERVIEW_SQL As String = String.Empty Private _lastUsedOverviewSQL As String = String.Empty ' ← NEU: persistente Kopie + Private COCKPIT_PROFILE_SQL As String = String.Empty Private COCKPIT_CONFIG_ID As Integer = 0 @@ -1968,6 +1969,13 @@ Public Class frmMain ' ========== SQL VORBEREITEN UND AUSFÜHREN ========== Dim oSQL = foundRow.Item("SQL_VIEW") + If Len(oSQL) = 0 Then + LOGGER.Debug($"LoadProfileData for Profile-ID [{CURRENT_CLICKED_PROFILE_ID}] - Title [{CURRENT_CLICKED_PROFILE_TITLE}] has empty SQL_VIEW ...") + If Len(COCKPIT_PROFILE_SQL) > 0 Then + oSQL = COCKPIT_PROFILE_SQL + LOGGER.Debug($"Using COCKPIT_PROFILE_SQL for Profile-ID [{CURRENT_CLICKED_PROFILE_ID}] - Title [{CURRENT_CLICKED_PROFILE_TITLE}]") + End If + End If oSQL = PrepareSQLWithReplacements(oSQL, CURRENT_CLICKED_PROFILE_ID) DT_CURR_WF_ITEMS = Await DatabaseFallback.GetDatatableECMAsync(oSQL) @@ -2040,6 +2048,12 @@ Public Class frmMain End Function Private Sub PrepareIconColumn() + ' Prüfen, ob TL_STATE-Spalte vorhanden ist + Dim hasTLStateColumn As Boolean = False + If DT_CURR_WF_ITEMS IsNot Nothing Then + hasTLStateColumn = DT_CURR_WF_ITEMS.Columns.Contains("TL_STATE") + End If + If TL_ICON = True AndAlso DT_CURR_WF_ITEMS IsNot Nothing AndAlso DT_CURR_WF_ITEMS.Columns.Contains("ICON") = False Then Dim columnStateIcon As New DataColumn() With { .DataType = GetType(Image), @@ -2053,21 +2067,28 @@ Public Class frmMain YellowDocuments = 0 GreenDocuments = 0 - If TL_ICON = True AndAlso DT_CURR_WF_ITEMS IsNot Nothing Then + If TL_ICON = True AndAlso hasTLStateColumn AndAlso DT_CURR_WF_ITEMS IsNot Nothing Then For Each row As DataRow In DT_CURR_WF_ITEMS.Rows - Dim State As Integer = CInt(row.Item("TL_STATE")) - Select Case State - Case 1 - RedDocuments += 1 - row.Item("ICON") = My.Resources.bullet_red - Case 2 - YellowDocuments += 1 - row.Item("ICON") = My.Resources.bullet_orange - Case 3 - GreenDocuments += 1 - row.Item("ICON") = My.Resources.bullet_green - End Select + Try + Dim State As Integer = CInt(row.Item("TL_STATE")) + Select Case State + Case 1 + RedDocuments += 1 + row.Item("ICON") = My.Resources.bullet_red + Case 2 + YellowDocuments += 1 + row.Item("ICON") = My.Resources.bullet_orange + Case 3 + GreenDocuments += 1 + row.Item("ICON") = My.Resources.bullet_green + End Select + Catch ex As Exception + LOGGER.Warn($"Could not set ICON value: {ex.Message}") + End Try + Next + ElseIf TL_ICON = True AndAlso Not hasTLStateColumn Then + LOGGER.Warn("⚠️ TL_ICON is enabled but TL_STATE column is missing in DT_CURR_WF_ITEMS") End If End Sub @@ -4536,7 +4557,7 @@ FROM VWPM_PROFILE_ACTIVE T WHERE T.GUID IN (SELECT PROFILE_ID FROM [dbo].[FNPM_G FRONTEND_ACTION = NAVBAR_CLICKED Timer_Inactivity_Reset_Disable("TreeList1_FocusedNodeChanged") COCKPIT_CONFIG_ID = oCockpitConfigID - + COCKPIT_PROFILE_SQL = String.Empty Dim oTypeIdInt As Integer = CInt(oTypeId) Select Case oTypeIdInt @@ -4555,6 +4576,8 @@ FROM VWPM_PROFILE_ACTIVE T WHERE T.GUID IN (SELECT PROFILE_ID FROM [dbo].[FNPM_G If IsDBNull(oSqlQuery) OrElse String.IsNullOrWhiteSpace(oSqlQuery?.ToString()) Then LOGGER.Warn($"TreeList_Cockpit: SQL_QUERY for ProfileID {oFkProfileId} is DBNull or empty for overview node - this should not happen, check data integrity of TreeList's DataSource") Exit Function + Else + LOGGER.Debug($"TreeList_Cockpit: Overview SQL query to be used: [{oSqlQuery}]") End If CURRENT_CLICKED_PROFILE_ID = 0 CUSTOM_OVERVIEW_SQL = oSqlQuery.ToString() @@ -4593,10 +4616,6 @@ FROM VWPM_PROFILE_ACTIVE T WHERE T.GUID IN (SELECT PROFILE_ID FROM [dbo].[FNPM_G Dim oProfileId As Integer = CInt(oFkProfileId) LOGGER.Debug($"TreeList_Cockpit: Profile node clicked - FK_PROFILE_ID:[{oProfileId}]") - - - - If CURRENT_CLICKED_PROFILE_ID = oProfileId Then LOGGER.Debug($"TreeList_Cockpit: Profile [{oProfileId}] is already active - ignoring click") Exit Function @@ -4604,6 +4623,13 @@ FROM VWPM_PROFILE_ACTIVE T WHERE T.GUID IN (SELECT PROFILE_ID FROM [dbo].[FNPM_G LOGGER.Debug($"TreeList_Cockpit: Loading profile with ID [{oProfileId}]...") + If IsDBNull(oSqlQuery) OrElse String.IsNullOrWhiteSpace(oSqlQuery?.ToString()) Then + LOGGER.Warn($"TreeList_Cockpit: SQL_QUERY for ProfileID {oFkProfileId} is DBNull or empty for Profile-Node - this should not happen, check data integrity of TreeList's DataSource") + Exit Function + Else + LOGGER.Debug($"TreeList_Cockpit: Profile-SQL query to be used: [{oSqlQuery}]") + End If + COCKPIT_PROFILE_SQL = oSqlQuery.ToString() ' ===== ANZAHL-SUFFIX ENTFERNEN (von AppendCountsToTreeAsync angehängt: "Titel (42)" → "Titel") ===== Dim oCleanProfileTitle As String = oProfileTitle?.ToString() Dim oSuffixMatch = System.Text.RegularExpressions.Regex.Match(oCleanProfileTitle, "^(.*)\s+\(\d+\)$")