MONSTER: Rename Monorepo to Modules, only keep Projects under Modules.*
This commit is contained in:
3
Patterns/Constants.vb
Normal file
3
Patterns/Constants.vb
Normal file
@@ -0,0 +1,3 @@
|
||||
Public Class Constants
|
||||
|
||||
End Class
|
||||
13
Patterns/IModule.vb
Normal file
13
Patterns/IModule.vb
Normal file
@@ -0,0 +1,13 @@
|
||||
Public Interface IModule
|
||||
''' <summary>
|
||||
''' The short identifier which identifies all placeholders of this module
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Property PatternIdentifier As String
|
||||
|
||||
''' <summary>
|
||||
''' Does this Module have outside dependencies like a database or a library like windream
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Property IsComplex As Boolean
|
||||
End Interface
|
||||
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
|
||||
13
Patterns/My Project/Application.Designer.vb
generated
Normal file
13
Patterns/My Project/Application.Designer.vb
generated
Normal file
@@ -0,0 +1,13 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' Dieser Code wurde von einem Tool generiert.
|
||||
' Laufzeitversion:4.0.30319.42000
|
||||
'
|
||||
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
' der Code erneut generiert wird.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
10
Patterns/My Project/Application.myapp
Normal file
10
Patterns/My Project/Application.myapp
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<MySubMain>false</MySubMain>
|
||||
<SingleInstance>false</SingleInstance>
|
||||
<ShutdownMode>0</ShutdownMode>
|
||||
<EnableVisualStyles>true</EnableVisualStyles>
|
||||
<AuthenticationMode>0</AuthenticationMode>
|
||||
<ApplicationType>1</ApplicationType>
|
||||
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
|
||||
</MyApplicationData>
|
||||
35
Patterns/My Project/AssemblyInfo.vb
Normal file
35
Patterns/My Project/AssemblyInfo.vb
Normal file
@@ -0,0 +1,35 @@
|
||||
Imports System
|
||||
Imports System.Reflection
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
' Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
' die einer Assembly zugeordnet sind.
|
||||
|
||||
' Werte der Assemblyattribute überprüfen
|
||||
|
||||
<Assembly: AssemblyTitle("Patterns")>
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("")>
|
||||
<Assembly: AssemblyProduct("Patterns")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2022")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird.
|
||||
<Assembly: Guid("2c58f8de-3fd4-41c2-98c8-b453bbc9ad3a")>
|
||||
|
||||
' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
'
|
||||
' Hauptversion
|
||||
' Nebenversion
|
||||
' Buildnummer
|
||||
' Revision
|
||||
'
|
||||
' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.1.0.1")>
|
||||
<Assembly: AssemblyFileVersion("1.1.0.1")>
|
||||
63
Patterns/My Project/Resources.Designer.vb
generated
Normal file
63
Patterns/My Project/Resources.Designer.vb
generated
Normal file
@@ -0,0 +1,63 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' Dieser Code wurde von einem Tool generiert.
|
||||
' Laufzeitversion:4.0.30319.42000
|
||||
'
|
||||
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
' der Code erneut generiert wird.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
|
||||
Namespace My.Resources
|
||||
|
||||
'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
|
||||
'-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
||||
'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
||||
'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
|
||||
'''<summary>
|
||||
''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
||||
'''</summary>
|
||||
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0"), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
|
||||
Friend Module Resources
|
||||
|
||||
Private resourceMan As Global.System.Resources.ResourceManager
|
||||
|
||||
Private resourceCulture As Global.System.Globalization.CultureInfo
|
||||
|
||||
'''<summary>
|
||||
''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
|
||||
Get
|
||||
If Object.ReferenceEquals(resourceMan, Nothing) Then
|
||||
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("DigitalData.Modules.Patterns.Resources", GetType(Resources).Assembly)
|
||||
resourceMan = temp
|
||||
End If
|
||||
Return resourceMan
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'''<summary>
|
||||
''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
||||
''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend Property Culture() As Global.System.Globalization.CultureInfo
|
||||
Get
|
||||
Return resourceCulture
|
||||
End Get
|
||||
Set
|
||||
resourceCulture = value
|
||||
End Set
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
117
Patterns/My Project/Resources.resx
Normal file
117
Patterns/My Project/Resources.resx
Normal file
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
73
Patterns/My Project/Settings.Designer.vb
generated
Normal file
73
Patterns/My Project/Settings.Designer.vb
generated
Normal file
@@ -0,0 +1,73 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' Dieser Code wurde von einem Tool generiert.
|
||||
' Laufzeitversion:4.0.30319.42000
|
||||
'
|
||||
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
' der Code erneut generiert wird.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0"), _
|
||||
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Partial Friend NotInheritable Class MySettings
|
||||
Inherits Global.System.Configuration.ApplicationSettingsBase
|
||||
|
||||
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
|
||||
|
||||
#Region "Automatische My.Settings-Speicherfunktion"
|
||||
#If _MyType = "WindowsForms" Then
|
||||
Private Shared addedHandler As Boolean
|
||||
|
||||
Private Shared addedHandlerLockObject As New Object
|
||||
|
||||
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs)
|
||||
If My.Application.SaveMySettingsOnExit Then
|
||||
My.Settings.Save()
|
||||
End If
|
||||
End Sub
|
||||
#End If
|
||||
#End Region
|
||||
|
||||
Public Shared ReadOnly Property [Default]() As MySettings
|
||||
Get
|
||||
|
||||
#If _MyType = "WindowsForms" Then
|
||||
If Not addedHandler Then
|
||||
SyncLock addedHandlerLockObject
|
||||
If Not addedHandler Then
|
||||
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
|
||||
addedHandler = True
|
||||
End If
|
||||
End SyncLock
|
||||
End If
|
||||
#End If
|
||||
Return defaultInstance
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
|
||||
Friend Module MySettingsProperty
|
||||
|
||||
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
|
||||
Friend ReadOnly Property Settings() As Global.DigitalData.Modules.Patterns.My.MySettings
|
||||
Get
|
||||
Return Global.DigitalData.Modules.Patterns.My.MySettings.Default
|
||||
End Get
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
7
Patterns/My Project/Settings.settings
Normal file
7
Patterns/My Project/Settings.settings
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
21
Patterns/Pattern.vb
Normal file
21
Patterns/Pattern.vb
Normal file
@@ -0,0 +1,21 @@
|
||||
Public Class Pattern
|
||||
Public ReadOnly Property Type As String
|
||||
Public ReadOnly Property Value As String
|
||||
|
||||
Public Sub New(pType As String, pValue As String)
|
||||
Me.Type = pType
|
||||
Me.Value = pValue
|
||||
End Sub
|
||||
|
||||
Public Overrides Function ToString() As String
|
||||
Return $"{{#{Type}#{Value}}}"
|
||||
End Function
|
||||
|
||||
Public Overrides Function GetHashCode() As Integer
|
||||
Return (Value.GetHashCode & Type.GetHashCode).GetHashCode
|
||||
End Function
|
||||
|
||||
Public Overrides Function Equals(obj As Object) As Boolean
|
||||
Return Me.GetHashCode = DirectCast(obj, Pattern).GetHashCode
|
||||
End Function
|
||||
End Class
|
||||
294
Patterns/Patterns.vb
Normal file
294
Patterns/Patterns.vb
Normal file
@@ -0,0 +1,294 @@
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports System.Windows.Forms
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.ZooFlow
|
||||
|
||||
''' <summary>
|
||||
''' Defines common Functions for Checking for and replacing placeholders.
|
||||
''' This Class also includes a child class `Pattern` for passing around Patterns.
|
||||
'''
|
||||
''' The format of all placeholders is:
|
||||
''' {#TYPE#VALUE}
|
||||
'''
|
||||
''' Some Examples:
|
||||
''' {#INT#USERNAME}
|
||||
''' {#CTRL#CMB_2}
|
||||
''' {#WMI#String 39}
|
||||
''' </summary>
|
||||
Public Class ClassPatterns
|
||||
' Complex patterns that rely on a datasource like a Database or Windream
|
||||
Public Const PATTERN_WMI = "WMI"
|
||||
Public Const PATTERN_CTRL = "CTRL"
|
||||
' Simple patterns that only rely on .NET functions
|
||||
Public Const PATTERN_INT = "INT"
|
||||
' Simple patterns that rely on Data from the TBDD_USER table
|
||||
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_USER_ID = "USER_ID"
|
||||
Public Const USER_VALUE_PROFILE_ID = "PROFILE_ID"
|
||||
|
||||
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 CLIPBOARD_VALUE_DE = "@Zwischenablage"
|
||||
Public Const CLIPBOARD_VALUE_EN = "@Clipboard"
|
||||
|
||||
Public Const MAX_TRY_COUNT = 100
|
||||
|
||||
Public ReadOnly Property PatternRegex As Regex
|
||||
Get
|
||||
Return _Regex
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private ReadOnly _Logger As Logger
|
||||
Private ReadOnly _LogConfig As LogConfig
|
||||
|
||||
Private ReadOnly _Regex As Regex = New Regex("{#(\w+)#([\w\s_-]+)}+")
|
||||
Private ReadOnly _AllPatterns As New List(Of String) From {PATTERN_WMI, PATTERN_CTRL, PATTERN_USER, PATTERN_INT}
|
||||
Private ReadOnly _ComplexPatterns As New List(Of String) From {PATTERN_WMI, PATTERN_CTRL}
|
||||
Private ReadOnly _SimplePatterns As New List(Of String) From {PATTERN_USER, PATTERN_INT}
|
||||
|
||||
''' <summary>
|
||||
''' Wraps a pattern-type and -value in the common format: {#type#value}
|
||||
''' </summary>
|
||||
Public Function WrapPatternValue(pType As String, pValue As String) As String
|
||||
Return New Pattern(pType, pValue).ToString
|
||||
End Function
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
_LogConfig = pLogConfig
|
||||
_Logger = pLogConfig.GetLogger
|
||||
End Sub
|
||||
|
||||
Public Function ReplaceAllValues(pInput As String, pUser As State.UserState, pClipboardContents As String) As String
|
||||
Try
|
||||
Dim result = pInput
|
||||
|
||||
result = ReplaceClipboardContents(result, pClipboardContents)
|
||||
result = ReplaceInternalValues(result)
|
||||
result = ReplaceUserValues(result, pUser)
|
||||
|
||||
Return result
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("Error in ReplaceAllValues:" & ex.Message)
|
||||
Return pInput
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ReplaceClipboardContents(pInput As String, pClipboardContents As String) As String
|
||||
Dim oResult = pInput
|
||||
|
||||
oResult = oResult.Replace(CLIPBOARD_VALUE_DE.ToLower, pClipboardContents)
|
||||
oResult = oResult.Replace(CLIPBOARD_VALUE_DE.ToUpper, pClipboardContents)
|
||||
oResult = oResult.Replace(CLIPBOARD_VALUE_EN.ToLower, pClipboardContents)
|
||||
oResult = oResult.Replace(CLIPBOARD_VALUE_EN.ToUpper, pClipboardContents)
|
||||
oResult = oResult.Replace(CLIPBOARD_VALUE_DE, pClipboardContents)
|
||||
oResult = oResult.Replace(CLIPBOARD_VALUE_EN, pClipboardContents)
|
||||
|
||||
Return oResult
|
||||
End Function
|
||||
|
||||
Public Function ReplaceInternalValues(pInput As String) As String
|
||||
Try
|
||||
Dim oResult = pInput
|
||||
|
||||
' Replace Username(s)
|
||||
While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_USERNAME)
|
||||
oResult = ReplacePattern(oResult, PATTERN_INT, System.Environment.UserName)
|
||||
End While
|
||||
|
||||
' Replace Machinename(s)
|
||||
While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_MACHINE)
|
||||
oResult = ReplacePattern(oResult, PATTERN_INT, System.Environment.MachineName)
|
||||
End While
|
||||
|
||||
' Replace Domainname(s)
|
||||
While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_DOMAIN)
|
||||
oResult = ReplacePattern(oResult, PATTERN_INT, System.Environment.UserDomainName)
|
||||
End While
|
||||
|
||||
' Replace CurrentDate(s)
|
||||
While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_DATE)
|
||||
oResult = ReplacePattern(oResult, PATTERN_INT, Now.ToShortDateString)
|
||||
End While
|
||||
|
||||
Return oResult
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("Error in ReplaceInternalValues:" & ex.Message)
|
||||
Return pInput
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ReplaceUserValues(pInput As String, pUser As State.UserState) As String
|
||||
Try
|
||||
Dim oResult = pInput
|
||||
|
||||
While ContainsPatternAndValue(oResult, PATTERN_USER, USER_VALUE_PRENAME)
|
||||
oResult = ReplacePattern(pInput, PATTERN_USER, pUser.GivenName)
|
||||
End While
|
||||
|
||||
While ContainsPatternAndValue(oResult, PATTERN_USER, USER_VALUE_USER_ID)
|
||||
oResult = ReplacePattern(pInput, PATTERN_USER, pUser.UserId.ToString)
|
||||
End While
|
||||
|
||||
While ContainsPatternAndValue(oResult, PATTERN_USER, USER_VALUE_SURNAME)
|
||||
oResult = ReplacePattern(pInput, PATTERN_USER, pUser.Surname)
|
||||
End While
|
||||
|
||||
While ContainsPatternAndValue(oResult, PATTERN_USER, USER_VALUE_SHORTNAME)
|
||||
oResult = ReplacePattern(pInput, PATTERN_USER, pUser.ShortName)
|
||||
End While
|
||||
|
||||
While ContainsPatternAndValue(oResult, PATTERN_USER, USER_VALUE_EMAIL)
|
||||
oResult = ReplacePattern(pInput, PATTERN_USER, pUser.Email)
|
||||
End While
|
||||
|
||||
Return oResult
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("Error in ReplaceUserValues:" & ex.Message)
|
||||
Return pInput
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ReplaceControlValues(pInput As String, pPanel As Panel) As String
|
||||
Try
|
||||
Dim oResult = pInput
|
||||
Dim oTryCounter = 0
|
||||
|
||||
While ContainsPattern(oResult, PATTERN_CTRL)
|
||||
If oTryCounter > MAX_TRY_COUNT Then
|
||||
Throw New Exception("Max tries in ReplaceControlValues exceeded.")
|
||||
End If
|
||||
|
||||
Dim controlName As String = GetNextPattern(oResult, PATTERN_CTRL).Value
|
||||
Dim control As Control = pPanel.Controls.Find(controlName, False).FirstOrDefault()
|
||||
|
||||
If control IsNot Nothing Then
|
||||
Dim value As String = control.Text
|
||||
oResult = ReplacePattern(oResult, PATTERN_CTRL, value)
|
||||
End If
|
||||
|
||||
oTryCounter += 1
|
||||
End While
|
||||
|
||||
Return oResult
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("Error in ReplaceControlValues:" & ex.Message)
|
||||
Return pInput
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function ContainsPattern(pInput As String, pType As String) As Boolean
|
||||
Dim elements As MatchCollection = _Regex.Matches(pInput)
|
||||
|
||||
For Each element As Match In elements
|
||||
Dim t As String = element.Groups(1).Value
|
||||
|
||||
If t = pType Then
|
||||
Return True
|
||||
End If
|
||||
Next
|
||||
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Public Function GetNextPattern(pInput As String, pType As String) As Pattern
|
||||
Dim oElements As MatchCollection = _Regex.Matches(pInput)
|
||||
|
||||
For Each oElement As Match In oElements
|
||||
' Pattern in input
|
||||
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
|
||||
Public Function GetAllPatterns(pInput As String) As List(Of Pattern)
|
||||
Dim elements As MatchCollection = _Regex.Matches(pInput)
|
||||
Dim results As New List(Of Pattern)
|
||||
|
||||
For Each element As Match In elements
|
||||
' Pattern in input
|
||||
Dim t As String = element.Groups(1).Value
|
||||
Dim v As String = element.Groups(2).Value
|
||||
|
||||
results.Add(New Pattern(t, v))
|
||||
Next
|
||||
|
||||
Return results
|
||||
End Function
|
||||
Public Function ReplacePattern(pInput As String, pType As String, pReplacement As String) As String
|
||||
Dim oElements As MatchCollection = _Regex.Matches(pInput)
|
||||
|
||||
If IsNothing(pReplacement) Or pReplacement = String.Empty Then
|
||||
Return pInput
|
||||
End If
|
||||
|
||||
For Each element As Match In oElements
|
||||
' if group 1 contains the 'pattern' the replace whole group with 'replacement'
|
||||
' and return it
|
||||
If element.Groups(1).Value = pType Then
|
||||
Return Regex.Replace(pInput, element.Groups(0).Value, pReplacement)
|
||||
End If
|
||||
Next
|
||||
|
||||
' no replacement made
|
||||
Return pInput
|
||||
End Function
|
||||
Private Function ContainsPatternAndValue(pInput As String, pType As String, pValue As String) As Boolean
|
||||
Dim oElements As MatchCollection = _Regex.Matches(pInput)
|
||||
|
||||
For Each oElement As Match In oElements
|
||||
' Pattern in input
|
||||
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 HasAnyPatterns(pInput As String) As Boolean
|
||||
Return _AllPatterns.Any(Function(pPattern) HasPattern(pInput, pPattern))
|
||||
End Function
|
||||
|
||||
Public Function HasOnlySimplePatterns(pInput As String) As Boolean
|
||||
Return Not HasComplexPatterns(pInput)
|
||||
End Function
|
||||
|
||||
Public Function HasComplexPatterns(pInput As String) As Boolean
|
||||
Return _ComplexPatterns.Any(Function(oPattern) HasPattern(pInput, oPattern))
|
||||
End Function
|
||||
|
||||
Public Function HasPattern(pInput As String, pType As String) As Boolean
|
||||
Dim oMatches = _Regex.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
|
||||
End Class
|
||||
153
Patterns/Patterns.vbproj
Normal file
153
Patterns/Patterns.vbproj
Normal file
@@ -0,0 +1,153 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{7C3B0C7E-59FE-4E1A-A655-27AE119F9444}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>DigitalData.Modules.Patterns</RootNamespace>
|
||||
<AssemblyName>DigitalData.Modules.Patterns</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MyType>Windows</MyType>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DocumentationFile>DigitalData.Modules.Patterns.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DefineDebug>false</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DocumentationFile>DigitalData.Modules.Patterns.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionExplicit>On</OptionExplicit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionCompare>Binary</OptionCompare>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionStrict>Off</OptionStrict>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionInfer>On</OptionInfer>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||
<Reference Include="DevExpress.Data.Desktop.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||
<Reference Include="DevExpress.Utils.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||
<Reference Include="DevExpress.XtraEditors.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||
<Reference Include="DevExpress.XtraGrid.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||
<Reference Include="DigitalData.Controls.LookupGrid, Version=3.3.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\DDMonorepo\Controls.LookupGrid\bin\Debug\DigitalData.Controls.LookupGrid.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Interop.WINDREAMLib">
|
||||
<HintPath>P:\Visual Studio Projekte\Bibliotheken\windream\Interop.WINDREAMLib.dll</HintPath>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.7.15\lib\net45\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Import Include="Microsoft.VisualBasic" />
|
||||
<Import Include="System" />
|
||||
<Import Include="System.Collections" />
|
||||
<Import Include="System.Collections.Generic" />
|
||||
<Import Include="System.Data" />
|
||||
<Import Include="System.Diagnostics" />
|
||||
<Import Include="System.Linq" />
|
||||
<Import Include="System.Xml.Linq" />
|
||||
<Import Include="System.Threading.Tasks" />
|
||||
</ItemGroup>
|
||||
<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\GlobixManual.vb" />
|
||||
<Compile Include="Modules\Windream.vb" />
|
||||
<Compile Include="Modules\User.vb" />
|
||||
<Compile Include="IModule.vb" />
|
||||
<Compile Include="Modules\Clipboard.vb" />
|
||||
<Compile Include="Modules\Controls.vb" />
|
||||
<Compile Include="Modules\Internal.vb" />
|
||||
<Compile Include="Modules\BaseModule.vb" />
|
||||
<Compile Include="Pattern.vb" />
|
||||
<Compile Include="Patterns.vb" />
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Application.myapp</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Resources.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Settings.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="Patterns2.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="My Project\Resources.resx">
|
||||
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
|
||||
<CustomToolNamespace>My.Resources</CustomToolNamespace>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="My Project\Application.myapp">
|
||||
<Generator>MyApplicationCodeGenerator</Generator>
|
||||
<LastGenOutput>Application.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
<None Include="My Project\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<CustomToolNamespace>My</CustomToolNamespace>
|
||||
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Logging\Logging.vbproj">
|
||||
<Project>{903b2d7d-3b80-4be9-8713-7447b704e1b0}</Project>
|
||||
<Name>Logging</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ZooFlow\ZooFlow.vbproj">
|
||||
<Project>{81cac44f-3711-4c8f-ae98-e02a7448782a}</Project>
|
||||
<Name>ZooFlow</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||
</Project>
|
||||
151
Patterns/Patterns.vbproj.bak
Normal file
151
Patterns/Patterns.vbproj.bak
Normal file
@@ -0,0 +1,151 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{7C3B0C7E-59FE-4E1A-A655-27AE119F9444}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>DigitalData.Modules.Patterns</RootNamespace>
|
||||
<AssemblyName>DigitalData.Modules.Patterns</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MyType>Windows</MyType>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DocumentationFile>DigitalData.Modules.Patterns.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DefineDebug>false</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DocumentationFile>DigitalData.Modules.Patterns.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionExplicit>On</OptionExplicit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionCompare>Binary</OptionCompare>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionStrict>Off</OptionStrict>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionInfer>On</OptionInfer>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DevExpress.Utils.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||
<Reference Include="DevExpress.XtraEditors.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||
<Reference Include="DevExpress.XtraGrid.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||
<Reference Include="Interop.WINDREAMLib">
|
||||
<HintPath>P:\Visual Studio Projekte\Bibliotheken\windream\Interop.WINDREAMLib.dll</HintPath>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.7.10\lib\net45\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Import Include="Microsoft.VisualBasic" />
|
||||
<Import Include="System" />
|
||||
<Import Include="System.Collections" />
|
||||
<Import Include="System.Collections.Generic" />
|
||||
<Import Include="System.Data" />
|
||||
<Import Include="System.Diagnostics" />
|
||||
<Import Include="System.Linq" />
|
||||
<Import Include="System.Xml.Linq" />
|
||||
<Import Include="System.Threading.Tasks" />
|
||||
</ItemGroup>
|
||||
<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\GlobixManual.vb" />
|
||||
<Compile Include="Modules\Windream.vb" />
|
||||
<Compile Include="Modules\User.vb" />
|
||||
<Compile Include="IModule.vb" />
|
||||
<Compile Include="Modules\Clipboard.vb" />
|
||||
<Compile Include="Modules\Controls.vb" />
|
||||
<Compile Include="Modules\Internal.vb" />
|
||||
<Compile Include="Modules\BaseModule.vb" />
|
||||
<Compile Include="Pattern.vb" />
|
||||
<Compile Include="Patterns.vb" />
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Application.myapp</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Resources.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Settings.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="Patterns2.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="My Project\Resources.resx">
|
||||
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
|
||||
<CustomToolNamespace>My.Resources</CustomToolNamespace>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="My Project\Application.myapp">
|
||||
<Generator>MyApplicationCodeGenerator</Generator>
|
||||
<LastGenOutput>Application.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
<None Include="My Project\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<CustomToolNamespace>My</CustomToolNamespace>
|
||||
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Controls.LookupGrid\LookupControl.vbproj">
|
||||
<Project>{3dcd6d1a-c830-4241-b7e4-27430e7ea483}</Project>
|
||||
<Name>LookupControl</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Modules.Logging\Logging.vbproj">
|
||||
<Project>{903B2D7D-3B80-4BE9-8713-7447B704E1B0}</Project>
|
||||
<Name>Logging</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Modules.ZooFlow\ZooFlow.vbproj">
|
||||
<Project>{81cac44f-3711-4c8f-ae98-e02a7448782a}</Project>
|
||||
<Name>ZooFlow</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||
</Project>
|
||||
165
Patterns/Patterns2.vb
Normal file
165
Patterns/Patterns2.vb
Normal file
@@ -0,0 +1,165 @@
|
||||
Imports System.IO
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports System.Windows.Forms
|
||||
Imports DigitalData.Controls.LookupGrid
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.ZooFlow
|
||||
Imports WINDREAMLib
|
||||
|
||||
''' <summary>
|
||||
''' Defines common Functions for Checking for and replacing placeholders.
|
||||
''' This Class also includes a child class `Pattern` for passing around Patterns.
|
||||
'''
|
||||
''' The format of all placeholders is:
|
||||
''' {#TYPE#VALUE}
|
||||
'''
|
||||
''' Some Examples:
|
||||
''' {#INT#USERNAME}
|
||||
''' {#CTRL#CMB_2}
|
||||
''' {#WMI#String 39}
|
||||
''' </summary>
|
||||
Public Class Patterns2
|
||||
Private ReadOnly LogConfig As LogConfig
|
||||
Private ReadOnly Logger As Logger
|
||||
Private ReadOnly Base As Modules.BaseModule
|
||||
Private ReadOnly Modules As New List(Of IModule)
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
LogConfig = pLogConfig
|
||||
Logger = pLogConfig.GetLogger()
|
||||
Base = New Modules.BaseModule(LogConfig)
|
||||
|
||||
Modules.AddRange({
|
||||
New Modules.Internal(LogConfig),
|
||||
New Modules.Clipboard(LogConfig),
|
||||
New Modules.Controls(LogConfig),
|
||||
New Modules.User(LogConfig),
|
||||
New Modules.FileInformation(LogConfig),
|
||||
New Modules.IDB(LogConfig),
|
||||
New Modules.Globix.GlobixAutomatic(LogConfig),
|
||||
New Modules.Globix.GlobixManual(LogConfig)
|
||||
})
|
||||
End Sub
|
||||
|
||||
Public Function ReplaceUserValues(pInput As String, pUser As State.UserState) As String
|
||||
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
|
||||
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
|
||||
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 ReplaceControlValues(pInput As String, pControls As List(Of Control)) As String
|
||||
Try
|
||||
Logger.Debug("Replacing Control Values")
|
||||
Dim oModule = New Modules.Controls(LogConfig)
|
||||
Return oModule.Replace(pInput, pControls)
|
||||
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
|
||||
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, Optional pClipboardContents As String = "") As String
|
||||
Logger.Debug("Replacing Internal Values")
|
||||
Dim oResult = pInput
|
||||
|
||||
Try
|
||||
Dim oInternal = New Modules.Internal(LogConfig)
|
||||
Dim oClipboard = New Modules.Clipboard(LogConfig)
|
||||
|
||||
oResult = oInternal.Replace(oResult)
|
||||
oResult = oClipboard.Replace(oResult, pClipboardContents)
|
||||
|
||||
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, pManualIndexes As Dictionary(Of String, List(Of String)), pAutomaticIndexes As Dictionary(Of String, List(Of String))) As String
|
||||
Logger.Debug("Replacing Globix Values")
|
||||
Dim oResult = pInput
|
||||
|
||||
Try
|
||||
Dim oAutomatic = New Modules.Globix.GlobixAutomatic(LogConfig)
|
||||
Dim oManual = New Modules.Globix.GlobixManual(LogConfig)
|
||||
|
||||
oResult = oAutomatic.Replace(oResult, pAutomaticIndexes)
|
||||
oResult = oManual.Replace(oResult, pManualIndexes)
|
||||
|
||||
Return oResult
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Error occurred while replacing Globix Values")
|
||||
Logger.Error(ex)
|
||||
Return oResult
|
||||
End Try
|
||||
End Function
|
||||
|
||||
#Region "Helper Functions"
|
||||
''' <summary>
|
||||
''' Wraps a pattern-type and -value in the common format: {#type#value}
|
||||
''' </summary>
|
||||
Public Function WrapPatternValue(pType As String, pValue As String) As String
|
||||
Return New Pattern(pType, pValue).ToString
|
||||
End Function
|
||||
|
||||
Public Function HasAnyPatterns(input) As Boolean
|
||||
Return Modules.Any(Function(m) Base.HasPattern(input, m.PatternIdentifier))
|
||||
End Function
|
||||
|
||||
Public Function HasComplexPatterns(input As String) As Boolean
|
||||
Return Modules.
|
||||
Where(Function(m) m.IsComplex = True).
|
||||
Any(Function(m) Base.HasPattern(input, m.PatternIdentifier))
|
||||
End Function
|
||||
|
||||
Public Function HasOnlySimplePatterns(input As String) As Boolean
|
||||
Return Not HasComplexPatterns(input)
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
11
Patterns/app.config
Normal file
11
Patterns/app.config
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="FirebirdSql.Data.FirebirdClient" publicKeyToken="3750abcc3150b00c" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.5.0.0" newVersion="7.5.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
4
Patterns/packages.config
Normal file
4
Patterns/packages.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NLog" version="4.7.15" targetFramework="net461" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user