Patterns: Add Controls and Windream Modules
This commit is contained in:
53
Modules.Patterns/Modules/Windream.vb
Normal file
53
Modules.Patterns/Modules/Windream.vb
Normal file
@@ -0,0 +1,53 @@
|
||||
Imports System.Windows.Forms
|
||||
Imports DigitalData.Controls.LookupGrid
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace [PatternModule]
|
||||
''' <summary>
|
||||
''' Patterns for Windream Indicies
|
||||
''' </summary>
|
||||
Public Class Windream
|
||||
Inherits BaseModule
|
||||
Implements IModule
|
||||
|
||||
Public Const WM_VALUE_DOCUMENT = "WM_DOCUMENT"
|
||||
|
||||
Public Property PatternIdentifier As String = "WMI" 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 pWMObject As WINDREAMLib.WMObject = pReplaceMap.Item(WM_VALUE_DOCUMENT)
|
||||
|
||||
While ContainsPattern(oResult, PatternIdentifier)
|
||||
Try
|
||||
Dim oIndexName As String = GetNextPattern(oResult, PatternIdentifier).Value
|
||||
Dim oWMValue As Object = pWMObject.GetVariableValue(oIndexName)
|
||||
|
||||
If oWMValue Is Nothing Then
|
||||
Logger.Warn("Value for Index [{0}] is empty and will not be used for replacing. Skipping.")
|
||||
Return oResult
|
||||
End If
|
||||
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oWMValue.ToString)
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return oResult
|
||||
Finally
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End Try
|
||||
End While
|
||||
|
||||
Return oResult
|
||||
End Function
|
||||
End Class
|
||||
End Namespace
|
||||
Reference in New Issue
Block a user