MONSTER: Rename Monorepo to Modules, only keep Projects under Modules.*
This commit is contained in:
119
Patterns/Modules/BaseModule.vb
Normal file
119
Patterns/Modules/BaseModule.vb
Normal file
@@ -0,0 +1,119 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports System.Text.RegularExpressions
|
||||
|
||||
Namespace Modules
|
||||
Public Class BaseModule
|
||||
Friend ReadOnly Logger As Logger
|
||||
Private ReadOnly MyRegex As Regex = New Regex("{#(\w+)#([\:\.\w\s_/-]+)}+")
|
||||
Private ReadOnly SqlPhrases As New List(Of String) From {
|
||||
"SELECT ", "UPDATE ", "DELETE ", "EXEC "
|
||||
}
|
||||
|
||||
Private Const MAX_TRY_COUNT = 100
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
Logger = pLogConfig.GetLogger()
|
||||
End Sub
|
||||
|
||||
Public Sub IncrementCounterOrThrow(ByRef pCounter As Integer)
|
||||
If pCounter >= MAX_TRY_COUNT Then
|
||||
Throw New OverflowException("Max tries exceeded while replacing placeholders!")
|
||||
End If
|
||||
|
||||
pCounter += 1
|
||||
End Sub
|
||||
|
||||
Public Function ReplacePattern(pInput As String, pType As String, pReplacement As String) As String
|
||||
Dim oElements As MatchCollection = MyRegex.Matches(pInput)
|
||||
|
||||
If IsNothing(pReplacement) Then
|
||||
Return pInput
|
||||
End If
|
||||
|
||||
Dim oIsSQL As Boolean = False
|
||||
For Each oPhrase In SqlPhrases
|
||||
If pInput.Contains(oPhrase) Then
|
||||
oIsSQL = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
If oIsSQL = True Then
|
||||
Logger.Debug("Input string is most likely an SQL Query, masking quotes in replacement string.")
|
||||
pReplacement = pReplacement.Replace("'", "''")
|
||||
End If
|
||||
|
||||
For Each oElement As Match In oElements
|
||||
' if group 1 contains the 'pattern' the replace whole group with 'replacement'
|
||||
' and return it
|
||||
If oElement.Groups(1).Value = pType Then
|
||||
Logger.Debug("Replacing Placeholder with [{0}]", pReplacement)
|
||||
Return Regex.Replace(pInput, oElement.Groups(0).Value, pReplacement)
|
||||
End If
|
||||
Next
|
||||
|
||||
' no replacement made
|
||||
Return pInput
|
||||
End Function
|
||||
|
||||
Public Function ContainsPatternAndValue(pInput As String, pType As String, pValue As String) As Boolean
|
||||
Dim oElements As MatchCollection = MyRegex.Matches(pInput)
|
||||
|
||||
For Each oElement As Match In oElements
|
||||
' Pattern in pInput
|
||||
Dim oType As String = oElement.Groups(1).Value
|
||||
Dim oValue As String = oElement.Groups(2).Value
|
||||
|
||||
If oType = pType And oValue = pValue Then
|
||||
Return True
|
||||
End If
|
||||
Next
|
||||
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Public Function ContainsPattern(pInput As String, pType As String) As String
|
||||
Dim oElements As MatchCollection = MyRegex.Matches(pInput)
|
||||
|
||||
For Each oElement As Match In oElements
|
||||
Dim t As String = oElement.Groups(1).Value
|
||||
|
||||
If t = pType Then
|
||||
Return True
|
||||
End If
|
||||
Next
|
||||
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Public Function HasPattern(pInput As String, pType As String) As Boolean
|
||||
Dim oMatches = MyRegex.Matches(pInput)
|
||||
|
||||
For Each oMatch As Match In oMatches
|
||||
For Each oGroup As Group In oMatch.Groups
|
||||
If oGroup.Value = pType Then
|
||||
Return True
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Public Function GetNextPattern(pInput As String, pType As String) As Pattern
|
||||
Dim oElements As MatchCollection = MyRegex.Matches(pInput)
|
||||
|
||||
For Each oElement As Match In oElements
|
||||
' Pattern in pInput
|
||||
Dim oType As String = oElement.Groups(1).Value
|
||||
Dim oValue As String = oElement.Groups(2).Value
|
||||
|
||||
If oType = pType Then
|
||||
Return New Pattern(oType, oValue)
|
||||
End If
|
||||
Next
|
||||
|
||||
Return Nothing
|
||||
End Function
|
||||
End Class
|
||||
End Namespace
|
||||
49
Patterns/Modules/Clipboard.vb
Normal file
49
Patterns/Modules/Clipboard.vb
Normal file
@@ -0,0 +1,49 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace Modules
|
||||
Public Class Clipboard
|
||||
Inherits BaseModule
|
||||
Implements IModule
|
||||
|
||||
Public Const CLIP_VALUE_BOARD As String = "BOARD"
|
||||
|
||||
Public Const CLIPBOARD_VALUE_DE = "@Zwischenablage"
|
||||
Public Const CLIPBOARD_VALUE_EN = "@Clipboard"
|
||||
|
||||
Public Property PatternIdentifier As String = "CLIP" Implements IModule.PatternIdentifier
|
||||
Public Property IsComplex As Boolean = False Implements IModule.IsComplex
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function Replace(pInput As String, pClipboardContents As String) As String
|
||||
Dim oResult = pInput
|
||||
Dim oCounter = 0
|
||||
|
||||
Try
|
||||
' LEGACY: Replace Clipboard Contents
|
||||
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, 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, pClipboardContents)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
Logger.Debug("Input after Clipboard.Replace: [{0}]", pInput)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
|
||||
End Try
|
||||
|
||||
Return oResult
|
||||
End Function
|
||||
End Class
|
||||
End Namespace
|
||||
105
Patterns/Modules/Controls.vb
Normal file
105
Patterns/Modules/Controls.vb
Normal file
@@ -0,0 +1,105 @@
|
||||
Imports System.Windows.Forms
|
||||
Imports DigitalData.Controls.LookupGrid
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace Modules
|
||||
''' <summary>
|
||||
''' Patterns for control values on a panel
|
||||
''' </summary>
|
||||
Public Class Controls
|
||||
Inherits BaseModule
|
||||
Implements IModule
|
||||
|
||||
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
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function Replace(pInput As String, pPanel As Panel) As String
|
||||
Dim oControls As List(Of Control) = pPanel.Controls.Cast(Of Control).ToList()
|
||||
Return Replace(pInput, oControls)
|
||||
End Function
|
||||
|
||||
Public Function Replace(pInput As String, pControls As List(Of Control)) As String
|
||||
Dim oResult = pInput
|
||||
Dim oCounter = 0
|
||||
|
||||
While ContainsPattern(oResult, PatternIdentifier)
|
||||
Try
|
||||
Dim oControlName As String = GetNextPattern(oResult, PatternIdentifier).Value
|
||||
|
||||
Dim oControl As Control = pControls.
|
||||
Where(Function(control) control.Name = oControlName).
|
||||
FirstOrDefault()
|
||||
|
||||
If oControl IsNot Nothing Then
|
||||
Dim oReplaceValue As String
|
||||
Select Case oControl.GetType
|
||||
Case GetType(TextBox)
|
||||
oReplaceValue = oControl.Text
|
||||
|
||||
Case GetType(DevExpress.XtraEditors.TextEdit)
|
||||
Dim oTextEdit As DevExpress.XtraEditors.TextEdit = oControl
|
||||
oReplaceValue = oTextEdit.EditValue
|
||||
|
||||
Case GetType(DevExpress.XtraEditors.DateEdit)
|
||||
Dim oDateEdit As DevExpress.XtraEditors.DateEdit = oControl
|
||||
Dim oDateValue As Date = oDateEdit.EditValue
|
||||
oReplaceValue = oDateValue.ToString("yyyyMMdd")
|
||||
|
||||
Case GetType(DevExpress.XtraEditors.LookUpEdit)
|
||||
Dim oLookupEdit As DevExpress.XtraEditors.LookUpEdit = oControl
|
||||
|
||||
If IsNothing(oLookupEdit.EditValue) Then
|
||||
oReplaceValue = String.Empty
|
||||
Else
|
||||
oReplaceValue = oLookupEdit.EditValue
|
||||
End If
|
||||
|
||||
Case GetType(LookupControl3)
|
||||
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)
|
||||
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
|
||||
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oReplaceValue)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Finally
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End Try
|
||||
|
||||
End While
|
||||
|
||||
Return oResult
|
||||
End Function
|
||||
|
||||
End Class
|
||||
End Namespace
|
||||
66
Patterns/Modules/FileInformation.vb
Normal file
66
Patterns/Modules/FileInformation.vb
Normal file
@@ -0,0 +1,66 @@
|
||||
Imports System.IO
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace Modules
|
||||
Public Class FileInformation
|
||||
Inherits BaseModule
|
||||
Implements IModule
|
||||
|
||||
Public Const FILE_VALUE_FILEINFO = "FILEINFO"
|
||||
Public Const FILE_VALUE_FILENAME = "FILENAME"
|
||||
Public Const FILE_VALUE_EXTENSION = "EXTENSION"
|
||||
Public Const FILE_VALUE_FILENAME_EXT = "FILENAME_EXT"
|
||||
Public Const FILE_VALUE_DATE_CREATED = "DATE_CREATED"
|
||||
Public Const FILE_VALUE_DATE_MODIFIED = "DATE_MODIFIED"
|
||||
|
||||
Public Property PatternIdentifier As String = "FILE" Implements IModule.PatternIdentifier
|
||||
Public Property IsComplex As Boolean = False Implements IModule.IsComplex
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function Replace(pInput As String, pFileInfo As FileInfo) As String
|
||||
Dim oResult = pInput
|
||||
Dim oCounter = 0
|
||||
|
||||
' Replace Filename without extension
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, FILE_VALUE_FILENAME)
|
||||
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 = 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 = 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 = 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 = pFileInfo.LastWriteTime.ToString("yyyy-MM-dd")
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oDateModified)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
Return oResult
|
||||
End Function
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
60
Patterns/Modules/Globix/GlobixAutomatic.vb
Normal file
60
Patterns/Modules/Globix/GlobixAutomatic.vb
Normal file
@@ -0,0 +1,60 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace Modules.Globix
|
||||
''' <summary>
|
||||
''' Patterns for Generating a Filename in Global Indexer
|
||||
''' </summary>
|
||||
Public Class GlobixAutomatic
|
||||
Inherits BaseModule
|
||||
Implements IModule
|
||||
|
||||
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, 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 Automatic Indexes. [{0}] Indexes loaded.", pIndexes?.Count)
|
||||
|
||||
While ContainsPattern(oResult, PatternIdentifier)
|
||||
Try
|
||||
Dim oIndexName As String = GetNextPattern(oResult, PatternIdentifier).Value
|
||||
Logger.Info("Replacing value for Index {0}", oIndexName)
|
||||
|
||||
If pIndexes.ContainsKey(oIndexName) = False Then
|
||||
Logger.Warn("Value for Index [{0}] does not exist and will not be used for replacing. Skipping.", oIndexName)
|
||||
|
||||
Else
|
||||
' 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. Skipping.")
|
||||
Return oResult
|
||||
End If
|
||||
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oFirstValue)
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return oResult
|
||||
Finally
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End Try
|
||||
End While
|
||||
|
||||
Return oResult
|
||||
End Function
|
||||
End Class
|
||||
End Namespace
|
||||
59
Patterns/Modules/Globix/GlobixManual.vb
Normal file
59
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
|
||||
28
Patterns/Modules/IDB.vb
Normal file
28
Patterns/Modules/IDB.vb
Normal file
@@ -0,0 +1,28 @@
|
||||
Imports System.Windows.Forms
|
||||
Imports DigitalData.Controls.LookupGrid
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace Modules
|
||||
''' <summary>
|
||||
''' Patterns for IDB Attributes
|
||||
''' </summary>
|
||||
Public Class IDB
|
||||
Inherits BaseModule
|
||||
Implements IModule
|
||||
|
||||
Public Const IDB_OBJECT_ID = "IDB_OBJECT_ID"
|
||||
|
||||
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) As String
|
||||
'TODO: Implement, depends on IDB Data, which is not in monorepo yet
|
||||
|
||||
Return pInput
|
||||
End Function
|
||||
End Class
|
||||
End Namespace
|
||||
86
Patterns/Modules/Internal.vb
Normal file
86
Patterns/Modules/Internal.vb
Normal file
@@ -0,0 +1,86 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace Modules
|
||||
''' <summary>
|
||||
''' Simple patterns that only rely on .NET functions
|
||||
''' </summary>
|
||||
Public Class Internal
|
||||
Inherits BaseModule
|
||||
Implements IModule
|
||||
|
||||
Public Const INT_VALUE_USERNAME = "USERNAME"
|
||||
Public Const INT_VALUE_MACHINE = "MACHINE"
|
||||
Public Const INT_VALUE_DOMAIN = "DOMAIN"
|
||||
Public Const INT_VALUE_DATE = "DATE"
|
||||
|
||||
Public Const INT_VALUE_DATE_YYYY = "YYYY"
|
||||
Public Const INT_VALUE_DATE_MM = "MM"
|
||||
Public Const INT_VALUE_DATE_DD = "DD"
|
||||
Public Const INT_VALUE_DATE_YYYY_MM_DD = "YYYY/MM/DD"
|
||||
Public Const INT_VALUE_DATE_YYYY_MM_DD_2 = "YYYY_MM_DD"
|
||||
|
||||
Public Property PatternIdentifier As String = "INT" Implements IModule.PatternIdentifier
|
||||
Public Property IsComplex As Boolean = False Implements IModule.IsComplex
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function Replace(pInput As String) As String
|
||||
Dim oResult = pInput
|
||||
Dim oCounter = 0
|
||||
Dim oNow As Date = Now
|
||||
|
||||
'TODO: Make date patterns dynamic
|
||||
|
||||
Logger.Trace("Replacing Internal Patterns")
|
||||
|
||||
' Replace CurrentDate(s)
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, INT_VALUE_DATE_YYYY_MM_DD)
|
||||
Logger.Trace("Replacing Pattern [{0}]", INT_VALUE_DATE_YYYY_MM_DD)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oNow.ToString("yyyy\\MM\\dd"))
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
Logger.Trace("Replace Counter: [{0}]", oCounter)
|
||||
|
||||
' Replace CurrentDate(s)
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, INT_VALUE_DATE_YYYY_MM_DD_2)
|
||||
Logger.Trace("Replacing Pattern [{0}]", INT_VALUE_DATE_YYYY_MM_DD_2)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oNow.ToString("yyyy_MM_dd"))
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
Logger.Trace("Replace Counter: [{0}]", oCounter)
|
||||
|
||||
' Replace Year(s)
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, INT_VALUE_DATE_YYYY)
|
||||
Logger.Trace("Replacing Pattern [{0}]", INT_VALUE_DATE_YYYY)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oNow.ToString("yyyy"))
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
Logger.Trace("Replace Counter: [{0}]", oCounter)
|
||||
|
||||
' Replace Month(s)
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, INT_VALUE_DATE_MM)
|
||||
Logger.Trace("Replacing Pattern [{0}]", INT_VALUE_DATE_MM)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oNow.ToString("MM"))
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
Logger.Trace("Replace Counter: [{0}]", oCounter)
|
||||
|
||||
' Replace Day(s)
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, INT_VALUE_DATE_DD)
|
||||
Logger.Trace("Replacing Pattern [{0}]", INT_VALUE_DATE_DD)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oNow.ToString("dd"))
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
Logger.Trace("Replace Counter: [{0}]", oCounter)
|
||||
|
||||
Return oResult
|
||||
End Function
|
||||
End Class
|
||||
End Namespace
|
||||
61
Patterns/Modules/User.vb
Normal file
61
Patterns/Modules/User.vb
Normal file
@@ -0,0 +1,61 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.ZooFlow
|
||||
|
||||
Namespace Modules
|
||||
Public Class User
|
||||
Inherits BaseModule
|
||||
Implements IModule
|
||||
|
||||
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 USER_VALUE_USER_NAME = "USER_NAME"
|
||||
|
||||
Public Property PatternIdentifier As String = "USER" 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, pUser As State.UserState) As String
|
||||
Dim oResult = pInput
|
||||
Dim oCounter = 0
|
||||
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, USER_VALUE_PRENAME)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, pUser.GivenName)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, USER_VALUE_SURNAME)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, pUser.Surname)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, USER_VALUE_EMAIL)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, pUser.Email)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, USER_VALUE_SHORTNAME)
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, pUser.ShortName)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
While ContainsPatternAndValue(oResult, PatternIdentifier, 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, pUser.UserId)
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
Return oResult
|
||||
End Function
|
||||
End Class
|
||||
End Namespace
|
||||
49
Patterns/Modules/Windream.vb
Normal file
49
Patterns/Modules/Windream.vb
Normal file
@@ -0,0 +1,49 @@
|
||||
Imports System.Windows.Forms
|
||||
Imports DigitalData.Controls.LookupGrid
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace Modules
|
||||
''' <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
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function Replace(pInput As String, pWMObject As WINDREAMLib.WMObject) As String
|
||||
Dim oResult = pInput
|
||||
Dim oCounter = 0
|
||||
|
||||
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