Patterns: Completeley rework Patterns2 structure
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user