Patterns: Add Controls and Windream Modules
This commit is contained in:
@@ -4,55 +4,62 @@ Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace [PatternModule]
|
||||
''' <summary>
|
||||
''' Simple patterns that only rely on .NET functions
|
||||
''' Patterns for control values on a panel
|
||||
''' </summary>
|
||||
Public Class Controls
|
||||
Inherits BaseModule
|
||||
Implements IModule
|
||||
|
||||
Public Const CTRL_VALUE_PANEL = "PANEL"
|
||||
Public Const CTRL_VALUE_PANEL = "CTRL_VALUE_PANEL"
|
||||
|
||||
Public Property PatternIdentifier As String = "CTRL" Implements IModule.PatternIdentifier
|
||||
Public Property IsComplex As Boolean = True Implements IModule.IsComplex
|
||||
Private ReadOnly Logger As Logger
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
Logger = pLogConfig.GetLogger()
|
||||
End Sub
|
||||
|
||||
Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
|
||||
Dim oResult = pInput
|
||||
Dim oCounter = 0
|
||||
Dim oPanel As Panel = pReplaceMap.Item("CTRL_VALUE_PANEL")
|
||||
Dim oPanel As Panel = pReplaceMap.Item(CTRL_VALUE_PANEL)
|
||||
|
||||
While ContainsPattern(oResult, PatternIdentifier)
|
||||
Dim oControlName As String = GetNextPattern(oResult, PatternIdentifier).Value
|
||||
Dim oControl As Control = oPanel.Controls.Find(oControlName, False).FirstOrDefault()
|
||||
Try
|
||||
Dim oControlName As String = GetNextPattern(oResult, PatternIdentifier).Value
|
||||
Dim oControl As Control = oPanel.Controls.Find(oControlName, False).FirstOrDefault()
|
||||
|
||||
If oControl IsNot Nothing Then
|
||||
Dim oReplaceValue As String
|
||||
Select Case oControl.GetType.ToString
|
||||
Case GetType(TextBox).ToString
|
||||
oReplaceValue = oControl.Text
|
||||
Case GetType(LookupControl3).ToString
|
||||
Dim oLookupControl3 As LookupControl3 = oControl
|
||||
If oLookupControl3.Properties.SelectedValues.Count = 1 Then
|
||||
oReplaceValue = oLookupControl3.Properties.SelectedValues.Item(0)
|
||||
Else
|
||||
If oControl IsNot Nothing Then
|
||||
Dim oReplaceValue As String
|
||||
Select Case oControl.GetType.ToString
|
||||
Case GetType(TextBox).ToString
|
||||
oReplaceValue = oControl.Text
|
||||
Case GetType(LookupControl3).ToString
|
||||
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).ToString
|
||||
oReplaceValue = oControl.Text
|
||||
Case GetType(CheckBox).ToString
|
||||
Dim oCheckBox As CheckBox = oControl
|
||||
oReplaceValue = oCheckBox.Checked
|
||||
Case Else
|
||||
oReplaceValue = "0"
|
||||
End If
|
||||
Case GetType(ComboBox).ToString
|
||||
oReplaceValue = oControl.Text
|
||||
Case GetType(CheckBox).ToString
|
||||
Dim oCheckBox As CheckBox = oControl
|
||||
oReplaceValue = oCheckBox.Checked
|
||||
Case Else
|
||||
oReplaceValue = "0"
|
||||
End Select
|
||||
End Select
|
||||
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oReplaceValue)
|
||||
End If
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oReplaceValue)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Finally
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End Try
|
||||
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
Return oResult
|
||||
|
||||
Reference in New Issue
Block a user