Patterns: Completeley rework Patterns2 structure
This commit is contained in:
parent
2a6fd3555b
commit
d75272a17f
@ -10,10 +10,4 @@
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Property IsComplex As Boolean
|
||||
|
||||
''' <summary>
|
||||
''' Main Replace Function
|
||||
''' </summary>
|
||||
''' <returns>The replaced string</returns>
|
||||
Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String
|
||||
End Interface
|
||||
|
||||
@ -17,24 +17,23 @@ Namespace Modules
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
|
||||
Public Function Replace(pInput As String, pClipboardContents As String) As String
|
||||
Dim oResult = pInput
|
||||
Dim oCounter = 0
|
||||
Dim oClipboardContents = pReplaceMap.Item(CLIP_VALUE_BOARD)
|
||||
|
||||
Try
|
||||
' LEGACY: Replace Clipboard Contents
|
||||
oResult = oResult.Replace(CLIPBOARD_VALUE_DE.ToLower, oClipboardContents)
|
||||
oResult = oResult.Replace(CLIPBOARD_VALUE_DE.ToUpper, oClipboardContents)
|
||||
oResult = oResult.Replace(CLIPBOARD_VALUE_DE, oClipboardContents)
|
||||
oResult = oResult.Replace(CLIPBOARD_VALUE_DE.ToLower, pClipboardContents)
|
||||
oResult = oResult.Replace(CLIPBOARD_VALUE_DE.ToUpper, pClipboardContents)
|
||||
oResult = oResult.Replace(CLIPBOARD_VALUE_DE, pClipboardContents)
|
||||
|
||||
oResult = oResult.Replace(CLIPBOARD_VALUE_EN.ToLower, oClipboardContents)
|
||||
oResult = oResult.Replace(CLIPBOARD_VALUE_EN.ToUpper, oClipboardContents)
|
||||
oResult = oResult.Replace(CLIPBOARD_VALUE_EN, oClipboardContents)
|
||||
oResult = oResult.Replace(CLIPBOARD_VALUE_EN.ToLower, pClipboardContents)
|
||||
oResult = oResult.Replace(CLIPBOARD_VALUE_EN.ToUpper, pClipboardContents)
|
||||
oResult = oResult.Replace(CLIPBOARD_VALUE_EN, pClipboardContents)
|
||||
|
||||
' Replace Clipboard Contents
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, CLIP_VALUE_BOARD)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oClipboardContents)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, pClipboardContents)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
|
||||
@ -19,15 +19,14 @@ Namespace Modules
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
|
||||
Public Function Replace(pInput As String, pPanel As Panel) As String
|
||||
Dim oResult = pInput
|
||||
Dim oCounter = 0
|
||||
Dim oPanel As Panel = pReplaceMap.Item(CTRL_VALUE_PANEL)
|
||||
|
||||
While ContainsPattern(oResult, PatternIdentifier)
|
||||
Try
|
||||
Dim oControlName As String = GetNextPattern(oResult, PatternIdentifier).Value
|
||||
Dim oControl As Control = oPanel.Controls.Find(oControlName, False).FirstOrDefault()
|
||||
Dim oControl As Control = pPanel.Controls.Find(oControlName, False).FirstOrDefault()
|
||||
|
||||
If oControl IsNot Nothing Then
|
||||
Dim oReplaceValue As String
|
||||
|
||||
@ -20,42 +20,41 @@ Namespace Modules
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
|
||||
Public Function Replace(pInput As String, pFileInfo As FileInfo) As String
|
||||
Dim oResult = pInput
|
||||
Dim oCounter = 0
|
||||
Dim oFileInfo As FileInfo = pReplaceMap.Item(FILE_VALUE_FILEINFO)
|
||||
|
||||
' Replace Filename without extension
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, FILE_VALUE_FILENAME)
|
||||
Dim oFilenameWithoutExtension = Path.GetFileNameWithoutExtension(oFileInfo.Name)
|
||||
Dim oFilenameWithoutExtension = Path.GetFileNameWithoutExtension(pFileInfo.Name)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oFilenameWithoutExtension)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
' Replace Filename with extension
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, FILE_VALUE_FILENAME_EXT)
|
||||
Dim oFilename As String = oFileInfo.Name
|
||||
Dim oFilename As String = pFileInfo.Name
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oFilename)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
' Replace Extension
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, FILE_VALUE_FILENAME_EXT)
|
||||
Dim oExtension As String = oFileInfo.Extension.Substring(1)
|
||||
Dim oExtension As String = pFileInfo.Extension.Substring(1)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oExtension)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
' Replace creation date
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, FILE_VALUE_DATE_CREATED)
|
||||
Dim oDateCreated = oFileInfo.CreationTime.ToString("yyyy-MM-dd")
|
||||
Dim oDateCreated = pFileInfo.CreationTime.ToString("yyyy-MM-dd")
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oDateCreated)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
' Replace last modification date
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, FILE_VALUE_DATE_CREATED)
|
||||
Dim oDateModified = oFileInfo.LastWriteTime.ToString("yyyy-MM-dd")
|
||||
Dim oDateModified = pFileInfo.LastWriteTime.ToString("yyyy-MM-dd")
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oDateModified)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
@ -1,26 +1,29 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace Modules
|
||||
Namespace Modules.Globix
|
||||
''' <summary>
|
||||
''' Patterns for Generating a Filename in Global Indexer
|
||||
''' </summary>
|
||||
Public Class Globix
|
||||
Public Class GlobixAutomatic
|
||||
Inherits BaseModule
|
||||
Implements IModule
|
||||
|
||||
Public Const GBX_VALUE_INDICIES = "GLOBIX_INDICIES"
|
||||
|
||||
Public Property PatternIdentifier As String = "GBX" Implements IModule.PatternIdentifier
|
||||
Public Property PatternIdentifier As String = "ATTR_A" Implements IModule.PatternIdentifier
|
||||
Public Property IsComplex As Boolean = True Implements IModule.IsComplex
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
|
||||
Public Function Replace(pInput As String, pIndexes As Dictionary(Of String, List(Of String))) As String
|
||||
Dim oResult = pInput
|
||||
Dim oCounter = 0
|
||||
Dim pIndexes As Dictionary(Of String, List(Of String)) = pReplaceMap.Item(GBX_VALUE_INDICIES)
|
||||
|
||||
If pIndexes Is Nothing Then
|
||||
Throw New ArgumentNullException("pIndexes")
|
||||
End If
|
||||
|
||||
Logger.Debug("Replacing Automatic Indexes. [{0}] Indexes loaded.", pIndexes?.Count)
|
||||
|
||||
While ContainsPattern(oResult, PatternIdentifier)
|
||||
Try
|
||||
59
Modules.Patterns/Modules/Globix/GlobixManual.vb
Normal file
59
Modules.Patterns/Modules/Globix/GlobixManual.vb
Normal file
@ -0,0 +1,59 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace Modules.Globix
|
||||
''' <summary>
|
||||
''' Patterns for Generating a Filename in Global Indexer
|
||||
''' </summary>
|
||||
Public Class GlobixManual
|
||||
Inherits BaseModule
|
||||
Implements IModule
|
||||
|
||||
Public Property PatternIdentifier As String = "ATTR_M" Implements IModule.PatternIdentifier
|
||||
Public Property IsComplex As Boolean = True Implements IModule.IsComplex
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function Replace(pInput As String, pIndexes As Dictionary(Of String, List(Of String))) As String
|
||||
Dim oResult = pInput
|
||||
Dim oCounter = 0
|
||||
|
||||
If pIndexes Is Nothing Then
|
||||
Throw New ArgumentNullException("pIndexes")
|
||||
End If
|
||||
|
||||
Logger.Debug("Replacing Manual Indexes. [{0}] Indexes loaded.", pIndexes?.Count)
|
||||
|
||||
While ContainsPattern(oResult, PatternIdentifier)
|
||||
Try
|
||||
Dim oIndexName As String = GetNextPattern(oResult, PatternIdentifier).Value
|
||||
|
||||
If pIndexes.ContainsKey(oIndexName) = False Then
|
||||
Logger.Warn("Value for Index [{0}] does not exist and will not be used for replacing. Exiting.", oIndexName)
|
||||
Return oResult
|
||||
End If
|
||||
|
||||
' TODO: If Index contains multiple values, only the first value will be used as value
|
||||
Dim oIndexValues As List(Of String) = pIndexes.Item(oIndexName)
|
||||
Dim oFirstValue As String = oIndexValues.FirstOrDefault()
|
||||
|
||||
If oFirstValue Is Nothing Then
|
||||
Logger.Warn("Value for Index [{0}] is empty and will not be used for replacing. Exiting.")
|
||||
Return oResult
|
||||
End If
|
||||
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oFirstValue)
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return oResult
|
||||
Finally
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End Try
|
||||
End While
|
||||
|
||||
Return oResult
|
||||
End Function
|
||||
End Class
|
||||
End Namespace
|
||||
@ -4,7 +4,7 @@ Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace Modules
|
||||
''' <summary>
|
||||
''' Patterns for Windream Indicies
|
||||
''' Patterns for IDB Attributes
|
||||
''' </summary>
|
||||
Public Class IDB
|
||||
Inherits BaseModule
|
||||
@ -12,14 +12,14 @@ Namespace Modules
|
||||
|
||||
Public Const IDB_OBJECT_ID = "IDB_OBJECT_ID"
|
||||
|
||||
Public Property PatternIdentifier As String = "IDB" Implements IModule.PatternIdentifier
|
||||
Public Property PatternIdentifier As String = "ATTR" Implements IModule.PatternIdentifier
|
||||
Public Property IsComplex As Boolean = True Implements IModule.IsComplex
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
|
||||
Public Function Replace(pInput As String) As String
|
||||
'TODO: Implement, depends on IDB Data, which is not in monorepo yet
|
||||
|
||||
Return pInput
|
||||
|
||||
@ -23,7 +23,7 @@ Namespace Modules
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
|
||||
Public Function Replace(pInput As String) As String
|
||||
Dim oResult = pInput
|
||||
Dim oCounter = 0
|
||||
Dim oNow As Date = Now
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.ZooFlow
|
||||
|
||||
Namespace Modules
|
||||
Public Class User
|
||||
@ -20,37 +21,37 @@ Namespace Modules
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
|
||||
Public Function Replace(pInput As String, pUser As State.UserState) As String
|
||||
Dim oResult = pInput
|
||||
Dim oCounter = 0
|
||||
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, USER_VALUE_PRENAME)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, pReplaceMap.Item(USER_VALUE_PRENAME))
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, pUser.GivenName)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, USER_VALUE_SURNAME)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, pReplaceMap.Item(USER_VALUE_SURNAME))
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, pUser.Surname)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, USER_VALUE_EMAIL)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, pReplaceMap.Item(USER_VALUE_EMAIL))
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, pUser.Email)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, USER_VALUE_SHORTNAME)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, pReplaceMap.Item(USER_VALUE_SHORTNAME))
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, pUser.ShortName)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, USER_VALUE_LANGUAGE)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, pReplaceMap.Item(USER_VALUE_LANGUAGE))
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, pUser.Language)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, USER_VALUE_USER_ID)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, pReplaceMap.Item(USER_VALUE_USER_ID))
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, pUser.UserId)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
|
||||
@ -19,10 +19,9 @@ Namespace Modules
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
|
||||
Public Function Replace(pInput As String, pWMObject As WINDREAMLib.WMObject) As String
|
||||
Dim oResult = pInput
|
||||
Dim oCounter = 0
|
||||
Dim pWMObject As WINDREAMLib.WMObject = pReplaceMap.Item(WM_VALUE_DOCUMENT)
|
||||
|
||||
While ContainsPattern(oResult, PatternIdentifier)
|
||||
Try
|
||||
|
||||
@ -82,8 +82,9 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Constants.vb" />
|
||||
<Compile Include="Modules\FileInformation.vb" />
|
||||
<Compile Include="Modules\Globix\GlobixAutomatic.vb" />
|
||||
<Compile Include="Modules\IDB.vb" />
|
||||
<Compile Include="Modules\Globix.vb" />
|
||||
<Compile Include="Modules\Globix\GlobixManual.vb" />
|
||||
<Compile Include="Modules\Windream.vb" />
|
||||
<Compile Include="Modules\User.vb" />
|
||||
<Compile Include="IModule.vb" />
|
||||
|
||||
@ -19,42 +19,9 @@ Imports WINDREAMLib
|
||||
''' {#WMI#String 39}
|
||||
''' </summary>
|
||||
Public Class Patterns2
|
||||
''' <summary>
|
||||
''' Complex patterns that rely on Windream
|
||||
''' </summary>
|
||||
Public Const PATTERN_WMI = "WMI"
|
||||
|
||||
''' <summary>
|
||||
''' Complex patterns that rely on IDB Attribute values
|
||||
''' </summary>
|
||||
Public Const PATTERN_IDBA = "IDBA"
|
||||
|
||||
''' <summary>
|
||||
''' Complex patterns that rely on Control Values
|
||||
''' </summary>
|
||||
Public Const PATTERN_CTRL = "CTRL"
|
||||
|
||||
''' <summary>
|
||||
''' Simple patterns that rely on Data from the TBDD_USER table
|
||||
''' </summary>
|
||||
Public Const PATTERN_USER = "USER"
|
||||
|
||||
Public Const USER_VALUE_PRENAME = "PRENAME"
|
||||
Public Const USER_VALUE_SURNAME = "SURNAME"
|
||||
Public Const USER_VALUE_EMAIL = "EMAIL"
|
||||
Public Const USER_VALUE_SHORTNAME = "SHORTNAME"
|
||||
Public Const USER_VALUE_LANGUAGE = "LANGUAGE"
|
||||
Public Const USER_VALUE_USER_ID = "USER_ID"
|
||||
Public Const VALUE_PROFILE_ID = "PROFILE_ID"
|
||||
Public Const VALUE_PROFILE_TITLE = "PROFILE_TITLE"
|
||||
|
||||
Private ReadOnly LogConfig As LogConfig
|
||||
Private ReadOnly Logger As Logger
|
||||
Private ReadOnly Base As Modules.BaseModule
|
||||
|
||||
Private ReadOnly ControlPanel As Panel
|
||||
Private ReadOnly IDBActive As Boolean
|
||||
|
||||
Private ReadOnly Modules As New List(Of IModule)
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
@ -67,192 +34,97 @@ Public Class Patterns2
|
||||
New Modules.Clipboard(LogConfig),
|
||||
New Modules.Controls(LogConfig),
|
||||
New Modules.User(LogConfig),
|
||||
New Modules.FileInformation(LogConfig)
|
||||
New Modules.FileInformation(LogConfig),
|
||||
New Modules.IDB(LogConfig),
|
||||
New Modules.Globix.GlobixAutomatic(LogConfig),
|
||||
New Modules.Globix.GlobixManual(LogConfig)
|
||||
})
|
||||
End Sub
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pControlPanel As Panel, pIDBActive As Boolean)
|
||||
MyClass.New(pLogConfig)
|
||||
ControlPanel = pControlPanel
|
||||
IDBActive = pIDBActive
|
||||
End Sub
|
||||
|
||||
Public Function ReplaceAllValues(pInput As String, pPanel As Panel, pUser As State.UserState, pFIleinfo As FileInfo) As String
|
||||
Dim oResult = pInput
|
||||
|
||||
For Each oModule In Modules
|
||||
Try
|
||||
Dim oArgs = GetReplaceMapForModule(oModule, pPanel:=pPanel, pUser:=pUser, pFileInfo:=pFIleinfo)
|
||||
oResult = oModule.Replace(oResult, oArgs)
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Placeholders for String [{0}] could not be replaced completely in Module [{1}]. Skipping.", pInput, oModule.GetType.Name)
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
Next
|
||||
|
||||
Return oResult
|
||||
End Function
|
||||
|
||||
Public Function ReplaceUserValues(pInput As String, pUser As State.UserState) As String
|
||||
Logger.Debug("Replacing User Values")
|
||||
Dim oResult = pInput
|
||||
|
||||
Dim oModule = GetModule(Of Modules.User)()
|
||||
Dim oArgs = GetReplaceMapForModule(oModule, pUser:=pUser)
|
||||
oResult = DoReplaceForModule(oResult, oModule, oArgs)
|
||||
|
||||
Return oResult
|
||||
Try
|
||||
Logger.Debug("Replacing User Values")
|
||||
Dim oModule = New Modules.User(LogConfig)
|
||||
Return oModule.Replace(pInput, pUser)
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Error occurred while replacing User Values")
|
||||
Logger.Error(ex)
|
||||
Return pInput
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ReplaceFileValues(pInput As String, pFileInfo As FileInfo) As String
|
||||
Logger.Debug("Replacing File Values")
|
||||
Dim oResult = pInput
|
||||
|
||||
Dim oModule = GetModule(Of Modules.FileInformation)()
|
||||
Dim oArgs = GetReplaceMapForModule(oModule, pFileInfo:=pFileInfo)
|
||||
oResult = DoReplaceForModule(oResult, oModule, oArgs)
|
||||
|
||||
Return oResult
|
||||
Try
|
||||
Logger.Debug("Replacing File Values")
|
||||
Dim oModule = New Modules.FileInformation(LogConfig)
|
||||
Return oModule.Replace(pInput, pFileInfo)
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Error occurred while replacing File Values")
|
||||
Logger.Error(ex)
|
||||
Return pInput
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ReplaceControlValues(pInput As String, pPanel As Panel) As String
|
||||
Logger.Debug("Replacing Control Values")
|
||||
Dim oResult = pInput
|
||||
|
||||
Dim oModule = GetModule(Of Modules.Controls)()
|
||||
Dim oArgs = GetReplaceMapForModule(oModule, pPanel:=pPanel)
|
||||
oResult = DoReplaceForModule(oResult, oModule, oArgs)
|
||||
|
||||
Return oResult
|
||||
Try
|
||||
Logger.Debug("Replacing Control Values")
|
||||
Dim oModule = New Modules.Controls(LogConfig)
|
||||
Return oModule.Replace(pInput, pPanel)
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Error occurred while replacing Control Values")
|
||||
Logger.Error(ex)
|
||||
Return pInput
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ReplaceWindreamValues(pInput As String, pWMObject As WMObject) As String
|
||||
Logger.Debug("Replacing Windream Values")
|
||||
Dim oResult = pInput
|
||||
|
||||
Dim oModule = GetModule(Of Modules.Windream)()
|
||||
Dim oArgs = GetReplaceMapForModule(oModule, pWMObject:=pWMObject)
|
||||
oResult = DoReplaceForModule(oResult, oModule, oArgs)
|
||||
|
||||
Return oResult
|
||||
Try
|
||||
Logger.Debug("Replacing Windream Values")
|
||||
Dim oModule = New Modules.Windream(LogConfig)
|
||||
Return oModule.Replace(pInput, pWMObject)
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Error occurred while replacing Windream Values")
|
||||
Logger.Error(ex)
|
||||
Return pInput
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ReplaceInternalValues(pInput As String) As String
|
||||
Public Function ReplaceInternalValues(pInput As String, Optional pClipboardContents As String = "") As String
|
||||
Logger.Debug("Replacing Internal Values")
|
||||
Dim oResult = pInput
|
||||
|
||||
Dim oInternalModule = GetModule(Of Modules.Internal)()
|
||||
Dim oInternalArgs = GetReplaceMapForModule(oInternalModule)
|
||||
oResult = DoReplaceForModule(oResult, oInternalModule, oInternalArgs)
|
||||
Try
|
||||
Dim oInternal = New Modules.Internal(LogConfig)
|
||||
Dim oClipboard = New Modules.Clipboard(LogConfig)
|
||||
|
||||
Dim oClipboardModule = GetModule(Of Modules.Clipboard)()
|
||||
Dim oClipboardArgs = GetReplaceMapForModule(oClipboardModule)
|
||||
oResult = DoReplaceForModule(oResult, oClipboardModule, oClipboardArgs)
|
||||
oResult = oInternal.Replace(oResult)
|
||||
oResult = oClipboard.Replace(oResult, pClipboardContents)
|
||||
|
||||
Return oResult
|
||||
Return oResult
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Error occurred while replacing Internal Values")
|
||||
Logger.Error(ex)
|
||||
Return oResult
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ReplaceGlobixValues(pInput As String, pGlobixIndexes As Dictionary(Of String, List(Of String))) As String
|
||||
Public Function ReplaceGlobixValues(pInput As String, pAutomaticIndexes As Dictionary(Of String, List(Of String)), pManualIndexes As Dictionary(Of String, List(Of String))) As String
|
||||
Logger.Debug("Replacing Globix Values")
|
||||
Dim oResult = pInput
|
||||
|
||||
Dim oGlobixModule = GetModule(Of Modules.Globix)()
|
||||
Dim oGlobixArgs = GetReplaceMapForModule(oGlobixModule, pGlobixIndexes:=pGlobixIndexes)
|
||||
oResult = DoReplaceForModule(oResult, oGlobixModule, oGlobixArgs)
|
||||
|
||||
Return oResult
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Private Function DoReplaceForModule(pInput As String, pModule As IModule, pArgs As Dictionary(Of String, Object)) As String
|
||||
Try
|
||||
If pModule IsNot Nothing AndAlso pModule?.GetType?.Name IsNot Nothing Then
|
||||
Logger.Debug("Calling Replace for Module [{0}]", pModule.GetType.Name)
|
||||
End If
|
||||
Dim oAutomatic = New Modules.Globix.GlobixAutomatic(LogConfig)
|
||||
Dim oManual = New Modules.Globix.GlobixManual(LogConfig)
|
||||
|
||||
Logger.Debug("Calling Replace for Input String [{0}]", pInput)
|
||||
oResult = oAutomatic.Replace(oResult, pAutomaticIndexes)
|
||||
oResult = oManual.Replace(oResult, pManualIndexes)
|
||||
|
||||
pInput = pModule.Replace(pInput, pArgs)
|
||||
Return oResult
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Placeholders for String [{0}] could not be replaced completely in Module [{1}]. Skipping.", pInput, pModule.GetType.Name)
|
||||
Logger.Warn("Error occurred while replacing Globix Values")
|
||||
Logger.Error(ex)
|
||||
Return oResult
|
||||
End Try
|
||||
|
||||
Return pInput
|
||||
End Function
|
||||
|
||||
Private Function GetModule(Of ModuleT)() As IModule
|
||||
Return Modules.
|
||||
Where(Function(m) TypeOf m Is ModuleT).
|
||||
SingleOrDefault()
|
||||
End Function
|
||||
|
||||
Private Function GetReplaceMapForModule(pModule As IModule,
|
||||
Optional pPanel As Panel = Nothing,
|
||||
Optional pUser As State.UserState = Nothing,
|
||||
Optional pWMObject As WMObject = Nothing,
|
||||
Optional pGlobixIndexes As Dictionary(Of String, List(Of String)) = Nothing,
|
||||
Optional pFileInfo As FileInfo = Nothing
|
||||
) As Dictionary(Of String, Object)
|
||||
Dim oArgs As New Dictionary(Of String, Object)
|
||||
|
||||
If TypeOf pModule Is Modules.Clipboard Then
|
||||
Logger.Debug("Adding Arguments for Clipboard Module")
|
||||
Try
|
||||
oArgs.Add(Patterns.Modules.Clipboard.CLIP_VALUE_BOARD, My.Computer.Clipboard.GetText())
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
|
||||
ElseIf TypeOf pModule Is Modules.FileInformation Then
|
||||
Logger.Debug("Adding Arguments for File Module")
|
||||
Try
|
||||
oArgs.Add(Patterns.Modules.FileInformation.FILE_VALUE_FILEINFO, pFileInfo)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
|
||||
ElseIf TypeOf pModule Is Modules.User Then
|
||||
Logger.Debug("Adding Arguments for User Module")
|
||||
Try
|
||||
oArgs.Add(Patterns.Modules.User.USER_VALUE_EMAIL, pUser.Email)
|
||||
oArgs.Add(Patterns.Modules.User.USER_VALUE_LANGUAGE, pUser.Language)
|
||||
oArgs.Add(Patterns.Modules.User.USER_VALUE_PRENAME, pUser.GivenName)
|
||||
oArgs.Add(Patterns.Modules.User.USER_VALUE_SHORTNAME, pUser.ShortName)
|
||||
oArgs.Add(Patterns.Modules.User.USER_VALUE_SURNAME, pUser.Surname)
|
||||
oArgs.Add(Patterns.Modules.User.USER_VALUE_USER_ID, pUser.UserId)
|
||||
oArgs.Add(Patterns.Modules.User.USER_VALUE_USER_NAME, pUser.UserName)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
|
||||
ElseIf TypeOf pModule Is Modules.Controls Then
|
||||
Logger.Debug("Adding Arguments for Controls Module")
|
||||
Try
|
||||
oArgs.Add(Patterns.Modules.Controls.CTRL_VALUE_PANEL, pPanel)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
|
||||
ElseIf TypeOf pModule Is Modules.Windream Then
|
||||
Logger.Debug("Adding Arguments for Windream Module")
|
||||
Try
|
||||
oArgs.Add(Patterns.Modules.Windream.WM_VALUE_DOCUMENT, pWMObject)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
|
||||
ElseIf TypeOf pModule Is Modules.Globix Then
|
||||
Logger.Debug("Adding Arguments for Globix Module")
|
||||
Try
|
||||
oArgs.Add(Patterns.Modules.Globix.GBX_VALUE_INDICIES, pGlobixIndexes)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End If
|
||||
|
||||
Return oArgs
|
||||
End Function
|
||||
|
||||
#Region "Helper Functions"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user