From c7c48394d592fd39435a897154503c2ba1800c8f Mon Sep 17 00:00:00 2001 From: Developer01 Date: Tue, 30 Dec 2025 07:39:42 +0100 Subject: [PATCH] Commit changes before fixing errors. --- Patterns/Modules/Controls.vb | 83 ++++++++++++++++-------------------- Patterns/Modules/IDB.vb | 1 - Patterns/Modules/Windream.vb | 20 ++++++--- Patterns/Patterns2.vb | 3 +- 4 files changed, 53 insertions(+), 54 deletions(-) diff --git a/Patterns/Modules/Controls.vb b/Patterns/Modules/Controls.vb index d39ea976..d1af2ed9 100644 --- a/Patterns/Modules/Controls.vb +++ b/Patterns/Modules/Controls.vb @@ -1,5 +1,4 @@ Imports System.Windows.Forms -Imports DigitalData.Controls.LookupGrid Imports DigitalData.Modules.Logging Namespace Modules @@ -38,55 +37,25 @@ Namespace Modules If oControl IsNot Nothing Then Dim oReplaceValue As String - Select Case oControl.GetType - Case GetType(TextBox) - oReplaceValue = oControl.Text - ' Case GetType(DevExpress.XtraEditors.TextEdit) ' Type not found: DevExpress.XtraEditors.TextEdit - ' Dim oTextEdit As DevExpress.XtraEditors.TextEdit = oControl - ' oReplaceValue = oTextEdit.EditValue + If TryGetDevExpressCheckEditValue(oControl, oReplaceValue) Then + ' value already determined by helper + Else + Select Case True + Case TypeOf oControl Is TextBox + oReplaceValue = oControl.Text - ' Case GetType(DevExpress.XtraEditors.DateEdit) ' Type not found: DevExpress.XtraEditors.DateEdit - ' Dim oDateEdit As DevExpress.XtraEditors.DateEdit = oControl - ' Dim oDateValue As Date = oDateEdit.EditValue - ' oReplaceValue = oDateValue.ToString("yyyyMMdd") + Case TypeOf oControl Is ComboBox + oReplaceValue = oControl.Text - ' Case GetType(DevExpress.XtraEditors.LookUpEdit) ' Type not found: DevExpress.XtraEditors.LookUpEdit - ' Dim oLookupEdit As DevExpress.XtraEditors.LookUpEdit = oControl + Case TypeOf oControl Is CheckBox + Dim oCheckBox As CheckBox = DirectCast(oControl, CheckBox) + oReplaceValue = oCheckBox.Checked.ToString() - ' If IsNothing(oLookupEdit.EditValue) Then - ' oReplaceValue = String.Empty - ' Else - ' oReplaceValue = oLookupEdit.EditValue - ' End If - - ' Case GetType(LookupControl3) ' Type LookupControl3 is not defined or referenced in the project - ' Dim oLookupControl3 As LookupControl3 = oControl - ' If oLookupControl3.Properties.SelectedValues.Count = 1 Then - ' oReplaceValue = oLookupControl3.Properties.SelectedValues.Item(0) - ' Else - ' oReplaceValue = "0" - ' End If - - Case GetType(ComboBox) - oReplaceValue = oControl.Text - - ' Case GetType(DevExpress.XtraEditors.ComboBoxEdit) ' Type not found: DevExpress.XtraEditors.ComboBoxEdit - ' Dim oCombobox As DevExpress.XtraEditors.ComboBoxEdit = oControl - ' oReplaceValue = oCombobox.EditValue - - Case GetType(CheckBox) - Dim oCheckBox As CheckBox = oControl - oReplaceValue = oCheckBox.Checked - - Case GetType(DevExpress.XtraEditors.CheckEdit) - Dim oCheckEdit As DevExpress.XtraEditors.CheckEdit = oControl - oReplaceValue = oCheckEdit.Checked - - Case Else - oReplaceValue = "0" - - End Select + Case Else + oReplaceValue = "0" + End Select + End If oResult = ReplacePattern(oResult, PatternIdentifier, oReplaceValue) Else @@ -106,3 +75,25 @@ Namespace Modules End Class End Namespace + +Module DevExpressCheckEditCompatibility + Friend Function TryGetDevExpressCheckEditValue(control As Control, ByRef value As String) As Boolean + If control Is Nothing Then + Return False + End If + + Dim controlType = control.GetType() + If controlType.FullName <> "DevExpress.XtraEditors.CheckEdit" Then + Return False + End If + + Dim checkedProperty = controlType.GetProperty("Checked") + If checkedProperty Is Nothing Then + Return False + End If + + Dim checkedValue = checkedProperty.GetValue(control) + value = Convert.ToString(checkedValue, Globalization.CultureInfo.InvariantCulture) + Return True + End Function +End Module diff --git a/Patterns/Modules/IDB.vb b/Patterns/Modules/IDB.vb index e22a12c4..5c334e38 100644 --- a/Patterns/Modules/IDB.vb +++ b/Patterns/Modules/IDB.vb @@ -1,5 +1,4 @@ Imports System.Windows.Forms -Imports DigitalData.Controls.LookupGrid Imports DigitalData.Modules.Logging Namespace Modules diff --git a/Patterns/Modules/Windream.vb b/Patterns/Modules/Windream.vb index 98d14ebb..75e8c1f8 100644 --- a/Patterns/Modules/Windream.vb +++ b/Patterns/Modules/Windream.vb @@ -1,6 +1,4 @@ -Imports System.Windows.Forms -Imports DigitalData.Controls.LookupGrid -Imports DigitalData.Modules.Logging +Imports DigitalData.Modules.Logging Namespace Modules ''' @@ -19,14 +17,26 @@ Namespace Modules MyBase.New(pLogConfig) End Sub - Public Function Replace(pInput As String, pWMObject As WINDREAMLib.WMObject) As String + Public Function Replace(pInput As String, pWMObject As Object) As String Dim oResult = pInput Dim oCounter = 0 + If pWMObject Is Nothing Then + Logger.Warn("No windream object provided for replacement.") + Return oResult + End If + + Dim objectType = pWMObject.GetType() + Dim getVariableValueMethod = objectType.GetMethod("GetVariableValue") + + If getVariableValueMethod Is Nothing Then + Logger.Warn("Provided object does not expose a GetVariableValue method. Skipping windream replacements.") + Return oResult + End If While ContainsPattern(oResult, PatternIdentifier) Try Dim oIndexName As String = GetNextPattern(oResult, PatternIdentifier).Value - Dim oWMValue As Object = pWMObject.GetVariableValue(oIndexName) + Dim oWMValue As Object = getVariableValueMethod.Invoke(pWMObject, New Object() {oIndexName}) If oWMValue Is Nothing Then Logger.Warn("Value for Index [{0}] is empty and will not be used for replacing. Skipping.") diff --git a/Patterns/Patterns2.vb b/Patterns/Patterns2.vb index 95132028..7e9f2fe2 100644 --- a/Patterns/Patterns2.vb +++ b/Patterns/Patterns2.vb @@ -1,7 +1,6 @@ Imports System.IO Imports System.Text.RegularExpressions Imports System.Windows.Forms -Imports DigitalData.Controls.LookupGrid Imports DigitalData.Modules.Logging Imports DigitalData.Modules.ZooFlow @@ -88,7 +87,7 @@ Public Class Patterns2 End Try End Function - Public Function ReplaceWindreamValues(pInput As String, pWMObject As WMObject) As String + Public Function ReplaceWindreamValues(pInput As String, pWMObject As Object) As String Try Logger.Debug("Replacing Windream Values") Dim oModule = New Modules.Windream(LogConfig)