Compare commits
4 Commits
e5f7fcd05a
...
cbab70c288
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cbab70c288 | ||
|
|
fe3f9c5156 | ||
|
|
a900379704 | ||
|
|
bd176e3de0 |
@@ -47,15 +47,15 @@ Public Class DatabaseWithFallback
|
|||||||
End If
|
End If
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function GetDatatable(DataTable As String, FallbackSQL As String, FallbackType As Constants.DatabaseType, Optional FilterExpression As String = "", Optional SortByColumn As String = "", Optional ForceFallback As Boolean = False) As DataTable
|
Public Function GetDatatable(pDataTableName As String, pFallbackSQL As String, pFallbackType As Constants.DatabaseType, Optional pFilterExpression As String = "", Optional pSortByColumn As String = "", Optional pForceFallback As Boolean = False) As DataTable
|
||||||
Try
|
Try
|
||||||
Dim oResult As DataTable = Nothing
|
Dim oResult As DataTable = Nothing
|
||||||
|
|
||||||
If ForceFallback = False Then
|
If pForceFallback = False Then
|
||||||
Dim oTableResult As TableResult
|
Dim oTableResult As TableResult
|
||||||
|
|
||||||
Try
|
Try
|
||||||
oTableResult = _Client.GetDatatableByName(DataTable, FilterExpression, SortByColumn)
|
oTableResult = _Client.GetDatatableByName(pDataTableName, pFilterExpression, pSortByColumn)
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_Logger.Error(ex)
|
_Logger.Error(ex)
|
||||||
oTableResult = Nothing
|
oTableResult = Nothing
|
||||||
@@ -63,12 +63,12 @@ Public Class DatabaseWithFallback
|
|||||||
|
|
||||||
If oTableResult Is Nothing OrElse oTableResult.OK = False Then
|
If oTableResult Is Nothing OrElse oTableResult.OK = False Then
|
||||||
_Logger.Warn("Datatable [{0}] could not be fetched from AppServer Cache. Falling back to direct Database Access.")
|
_Logger.Warn("Datatable [{0}] could not be fetched from AppServer Cache. Falling back to direct Database Access.")
|
||||||
Return GetDatatableFromDatabase(FallbackSQL, FallbackType)
|
Return GetDatatableFromDatabase(pFallbackSQL, pFallbackType)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Return oTableResult.Table
|
Return oTableResult.Table
|
||||||
Else
|
Else
|
||||||
Return GetDatatableFromDatabase(FallbackSQL, FallbackType)
|
Return GetDatatableFromDatabase(pFallbackSQL, pFallbackType)
|
||||||
End If
|
End If
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_Logger.Error(ex)
|
_Logger.Error(ex)
|
||||||
@@ -95,32 +95,5 @@ Public Class DatabaseWithFallback
|
|||||||
|
|
||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function GetUserData(UserName As String, ModuleCode As String, Client As Integer) As UserData
|
|
||||||
'Dim oSQL = $"SELECT * FROM FNDD_CHECK_USER_MODULE('{UserName}','{ModuleCode}',{Client})"
|
|
||||||
'Dim oTable As DataTable = GetDatatable("TBDD_USER_MODULE", $"USERNAME = '{UserName.ToLower}' AND MODULE_SHORT = '{ModuleCode}'", "", oSQL, DatabaseType.ECM)
|
|
||||||
|
|
||||||
'If oTable Is Nothing Then
|
|
||||||
' Return Nothing
|
|
||||||
'End If
|
|
||||||
|
|
||||||
'If oTable.Rows.Count = 0 Then
|
|
||||||
' Return Nothing
|
|
||||||
'End If
|
|
||||||
|
|
||||||
'Dim oRow As DataRow = oTable.Rows.Item(0)
|
|
||||||
'Dim oUserData As New UserData With {
|
|
||||||
' .Id = NotNull(oRow, "USER_ID", -1),
|
|
||||||
' .Surname = NotNull(oRow, "USER_SURNAME", String.Empty),
|
|
||||||
' .Prename = NotNull(oRow, "USER_PRENAME", String.Empty),
|
|
||||||
' .Shortname = NotNull(oRow, "USER_SHORTNAME", String.Empty),
|
|
||||||
' .Email = NotNull(oRow, "USER_EMAIL", String.Empty),
|
|
||||||
' .Language = NotNull(oRow, "USER_LANGUAGE", "de-DE"),
|
|
||||||
' .DateFormat = NotNull(oRow, "USER_DATE_FORMAT", "dd.MM.yyyy")
|
|
||||||
'}
|
|
||||||
|
|
||||||
Throw New NotImplementedException()
|
|
||||||
End Function
|
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
Public Class UserData
|
|
||||||
Public Id As Integer
|
|
||||||
Public Surname As String
|
|
||||||
Public Prename As String
|
|
||||||
Public Shortname As String
|
|
||||||
Public Email As String
|
|
||||||
Public Language As String
|
|
||||||
Public DateFormat As String
|
|
||||||
|
|
||||||
Public IsAdmin As Boolean
|
|
||||||
Public HasAccess As Boolean
|
|
||||||
|
|
||||||
Public ModuleName As String
|
|
||||||
End Class
|
|
||||||
@@ -97,7 +97,6 @@
|
|||||||
<DependentUpon>Settings.settings</DependentUpon>
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="DatabaseWithFallback\UserData.vb" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="My Project\Resources.resx">
|
<EmbeddedResource Include="My Project\Resources.resx">
|
||||||
|
|||||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
|||||||
' übernehmen, indem Sie "*" eingeben:
|
' übernehmen, indem Sie "*" eingeben:
|
||||||
' <Assembly: AssemblyVersion("1.0.*")>
|
' <Assembly: AssemblyVersion("1.0.*")>
|
||||||
|
|
||||||
<Assembly: AssemblyVersion("1.2.3.0")>
|
<Assembly: AssemblyVersion("1.2.4.0")>
|
||||||
<Assembly: AssemblyFileVersion("1.2.3.0")>
|
<Assembly: AssemblyFileVersion("1.2.4.0")>
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ Imports System.Text.RegularExpressions
|
|||||||
|
|
||||||
Namespace [PatternModule]
|
Namespace [PatternModule]
|
||||||
Public Class BaseModule
|
Public Class BaseModule
|
||||||
Friend ReadOnly Logger As Logger
|
Private ReadOnly Logger As Logger
|
||||||
|
|
||||||
Private ReadOnly MyRegex As Regex = New Regex("{#(\w+)#([\:\.\w\s_-]+)}+")
|
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 = 500
|
Private Const MAX_TRY_COUNT = 500
|
||||||
|
|
||||||
@@ -21,23 +23,37 @@ Namespace [PatternModule]
|
|||||||
pCounter += 1
|
pCounter += 1
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Function ReplacePattern(input As String, type As String, replacement As String) As String
|
Public Function ReplacePattern(pInput As String, pType As String, pReplacement As String) As String
|
||||||
Dim elements As MatchCollection = MyRegex.Matches(input)
|
Dim oElements As MatchCollection = MyRegex.Matches(pInput)
|
||||||
|
|
||||||
If IsNothing(replacement) Then
|
If IsNothing(pReplacement) Then
|
||||||
Return input
|
Return pInput
|
||||||
End If
|
End If
|
||||||
|
|
||||||
For Each element As Match In elements
|
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'
|
' if group 1 contains the 'pattern' the replace whole group with 'replacement'
|
||||||
' and return it
|
' and return it
|
||||||
If element.Groups(1).Value = type Then
|
If oElement.Groups(1).Value = pType Then
|
||||||
Return Regex.Replace(input, element.Groups(0).Value, replacement)
|
Logger.Debug("Replacing Placeholder with [{0}]", pReplacement)
|
||||||
|
Return Regex.Replace(pInput, oElement.Groups(0).Value, pReplacement)
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
|
||||||
' no replacement made
|
' no replacement made
|
||||||
Return input
|
Return pInput
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function ContainsPatternAndValue(pInput As String, pType As String, pValue As String) As Boolean
|
Public Function ContainsPatternAndValue(pInput As String, pType As String, pValue As String) As Boolean
|
||||||
@@ -45,10 +61,10 @@ Namespace [PatternModule]
|
|||||||
|
|
||||||
For Each oElement As Match In oElements
|
For Each oElement As Match In oElements
|
||||||
' Pattern in pInput
|
' Pattern in pInput
|
||||||
Dim t As String = oElement.Groups(1).Value
|
Dim oType As String = oElement.Groups(1).Value
|
||||||
Dim v As String = oElement.Groups(2).Value
|
Dim oValue As String = oElement.Groups(2).Value
|
||||||
|
|
||||||
If t = pType And v = pValue Then
|
If oType = pType And oValue = pValue Then
|
||||||
Return True
|
Return True
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
@@ -84,16 +100,16 @@ Namespace [PatternModule]
|
|||||||
Return False
|
Return False
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function GetNextPattern(input As String, type As String) As Pattern
|
Public Function GetNextPattern(pInput As String, pType As String) As Pattern
|
||||||
Dim elements As MatchCollection = MyRegex.Matches(input)
|
Dim oElements As MatchCollection = MyRegex.Matches(pInput)
|
||||||
|
|
||||||
For Each element As Match In elements
|
For Each oElement As Match In oElements
|
||||||
' Pattern in pInput
|
' Pattern in pInput
|
||||||
Dim t As String = element.Groups(1).Value
|
Dim oType As String = oElement.Groups(1).Value
|
||||||
Dim v As String = element.Groups(2).Value
|
Dim oValue As String = oElement.Groups(2).Value
|
||||||
|
|
||||||
If t = type Then
|
If oType = pType Then
|
||||||
Return New Pattern(t, v)
|
Return New Pattern(oType, oValue)
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
|
||||||
|
|||||||
@@ -4,27 +4,30 @@ Imports DigitalData.Modules.Logging
|
|||||||
|
|
||||||
Namespace [PatternModule]
|
Namespace [PatternModule]
|
||||||
''' <summary>
|
''' <summary>
|
||||||
''' Simple patterns that only rely on .NET functions
|
''' Patterns for control values on a panel
|
||||||
''' </summary>
|
''' </summary>
|
||||||
Public Class Controls
|
Public Class Controls
|
||||||
Inherits BaseModule
|
Inherits BaseModule
|
||||||
Implements IModule
|
Implements IModule
|
||||||
|
|
||||||
Public Const CTRL_VALUE_PANEL = "PANEL"
|
Public Const CTRL_VALUE_PANEL = "CTRL_VALUE_PANEL"
|
||||||
|
|
||||||
Public Property PatternIdentifier As String = "CTRL" Implements IModule.PatternIdentifier
|
Public Property PatternIdentifier As String = "CTRL" Implements IModule.PatternIdentifier
|
||||||
Public Property IsComplex As Boolean = True Implements IModule.IsComplex
|
Public Property IsComplex As Boolean = True Implements IModule.IsComplex
|
||||||
|
Private ReadOnly Logger As Logger
|
||||||
|
|
||||||
Public Sub New(pLogConfig As LogConfig)
|
Public Sub New(pLogConfig As LogConfig)
|
||||||
MyBase.New(pLogConfig)
|
MyBase.New(pLogConfig)
|
||||||
|
Logger = pLogConfig.GetLogger()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
|
Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
|
||||||
Dim oResult = pInput
|
Dim oResult = pInput
|
||||||
Dim oCounter = 0
|
Dim oCounter = 0
|
||||||
Dim oPanel As Panel = pReplaceMap.Item("CTRL_VALUE_PANEL")
|
Dim oPanel As Panel = pReplaceMap.Item(CTRL_VALUE_PANEL)
|
||||||
|
|
||||||
While ContainsPattern(oResult, PatternIdentifier)
|
While ContainsPattern(oResult, PatternIdentifier)
|
||||||
|
Try
|
||||||
Dim oControlName As String = GetNextPattern(oResult, PatternIdentifier).Value
|
Dim oControlName As String = GetNextPattern(oResult, PatternIdentifier).Value
|
||||||
Dim oControl As Control = oPanel.Controls.Find(oControlName, False).FirstOrDefault()
|
Dim oControl As Control = oPanel.Controls.Find(oControlName, False).FirstOrDefault()
|
||||||
|
|
||||||
@@ -51,8 +54,12 @@ Namespace [PatternModule]
|
|||||||
|
|
||||||
oResult = ReplacePattern(oResult, PatternIdentifier, oReplaceValue)
|
oResult = ReplacePattern(oResult, PatternIdentifier, oReplaceValue)
|
||||||
End If
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Error(ex)
|
||||||
|
Finally
|
||||||
IncrementCounterOrThrow(oCounter)
|
IncrementCounterOrThrow(oCounter)
|
||||||
|
End Try
|
||||||
|
|
||||||
End While
|
End While
|
||||||
|
|
||||||
Return oResult
|
Return oResult
|
||||||
|
|||||||
31
Modules.Patterns/Modules/IDB.vb
Normal file
31
Modules.Patterns/Modules/IDB.vb
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
Imports System.Windows.Forms
|
||||||
|
Imports DigitalData.Controls.LookupGrid
|
||||||
|
Imports DigitalData.Modules.Logging
|
||||||
|
|
||||||
|
Namespace [PatternModule]
|
||||||
|
''' <summary>
|
||||||
|
''' Patterns for Windream Indicies
|
||||||
|
''' </summary>
|
||||||
|
Public Class IDB
|
||||||
|
Inherits BaseModule
|
||||||
|
Implements IModule
|
||||||
|
|
||||||
|
Public Const IDB_OBJECT_ID = "IDB_OBJECT_ID"
|
||||||
|
|
||||||
|
Public Property PatternIdentifier As String = "IDB" Implements IModule.PatternIdentifier
|
||||||
|
Public Property IsComplex As Boolean = True Implements IModule.IsComplex
|
||||||
|
|
||||||
|
Private ReadOnly Logger As Logger
|
||||||
|
|
||||||
|
Public Sub New(pLogConfig As LogConfig)
|
||||||
|
MyBase.New(pLogConfig)
|
||||||
|
Logger = pLogConfig.GetLogger()
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
|
||||||
|
'TODO: Implement, depends on IDB Data, which is not in monorepo yet
|
||||||
|
|
||||||
|
Return pInput
|
||||||
|
End Function
|
||||||
|
End Class
|
||||||
|
End Namespace
|
||||||
53
Modules.Patterns/Modules/Windream.vb
Normal file
53
Modules.Patterns/Modules/Windream.vb
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
Imports System.Windows.Forms
|
||||||
|
Imports DigitalData.Controls.LookupGrid
|
||||||
|
Imports DigitalData.Modules.Logging
|
||||||
|
|
||||||
|
Namespace [PatternModule]
|
||||||
|
''' <summary>
|
||||||
|
''' Patterns for Windream Indicies
|
||||||
|
''' </summary>
|
||||||
|
Public Class Windream
|
||||||
|
Inherits BaseModule
|
||||||
|
Implements IModule
|
||||||
|
|
||||||
|
Public Const WM_VALUE_DOCUMENT = "WM_DOCUMENT"
|
||||||
|
|
||||||
|
Public Property PatternIdentifier As String = "WMI" Implements IModule.PatternIdentifier
|
||||||
|
Public Property IsComplex As Boolean = True Implements IModule.IsComplex
|
||||||
|
|
||||||
|
Private ReadOnly Logger As Logger
|
||||||
|
|
||||||
|
Public Sub New(pLogConfig As LogConfig)
|
||||||
|
MyBase.New(pLogConfig)
|
||||||
|
Logger = pLogConfig.GetLogger()
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
|
||||||
|
Dim oResult = pInput
|
||||||
|
Dim oCounter = 0
|
||||||
|
Dim pWMObject As WINDREAMLib.WMObject = pReplaceMap.Item(WM_VALUE_DOCUMENT)
|
||||||
|
|
||||||
|
While ContainsPattern(oResult, PatternIdentifier)
|
||||||
|
Try
|
||||||
|
Dim oIndexName As String = GetNextPattern(oResult, PatternIdentifier).Value
|
||||||
|
Dim oWMValue As Object = pWMObject.GetVariableValue(oIndexName)
|
||||||
|
|
||||||
|
If oWMValue Is Nothing Then
|
||||||
|
Logger.Warn("Value for Index [{0}] is empty and will not be used for replacing. Skipping.")
|
||||||
|
Return oResult
|
||||||
|
End If
|
||||||
|
|
||||||
|
oResult = ReplacePattern(oResult, PatternIdentifier, oWMValue.ToString)
|
||||||
|
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Error(ex)
|
||||||
|
Return oResult
|
||||||
|
Finally
|
||||||
|
IncrementCounterOrThrow(oCounter)
|
||||||
|
End Try
|
||||||
|
End While
|
||||||
|
|
||||||
|
Return oResult
|
||||||
|
End Function
|
||||||
|
End Class
|
||||||
|
End Namespace
|
||||||
@@ -12,7 +12,7 @@ Imports System.Runtime.InteropServices
|
|||||||
<Assembly: AssemblyDescription("")>
|
<Assembly: AssemblyDescription("")>
|
||||||
<Assembly: AssemblyCompany("")>
|
<Assembly: AssemblyCompany("")>
|
||||||
<Assembly: AssemblyProduct("Patterns")>
|
<Assembly: AssemblyProduct("Patterns")>
|
||||||
<Assembly: AssemblyCopyright("Copyright © 2019")>
|
<Assembly: AssemblyCopyright("Copyright © 2021")>
|
||||||
<Assembly: AssemblyTrademark("")>
|
<Assembly: AssemblyTrademark("")>
|
||||||
|
|
||||||
<Assembly: ComVisible(False)>
|
<Assembly: ComVisible(False)>
|
||||||
|
|||||||
@@ -81,6 +81,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Constants.vb" />
|
<Compile Include="Constants.vb" />
|
||||||
|
<Compile Include="Modules\IDB.vb" />
|
||||||
|
<Compile Include="Modules\Windream.vb" />
|
||||||
<Compile Include="Modules\User.vb" />
|
<Compile Include="Modules\User.vb" />
|
||||||
<Compile Include="Modules\IModule.vb" />
|
<Compile Include="Modules\IModule.vb" />
|
||||||
<Compile Include="Modules\Clipboard.vb" />
|
<Compile Include="Modules\Clipboard.vb" />
|
||||||
|
|||||||
@@ -91,19 +91,89 @@ Public Class Patterns2
|
|||||||
Return oResult
|
Return oResult
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Function GetReplaceMapForModule(pModule As IModule, pPanel As Panel, pUser As State.UserState) As Dictionary(Of String, Object)
|
Public Function ReplaceUserValues(pInput As String, pUser As State.UserState) As String
|
||||||
|
Dim oResult = pInput
|
||||||
|
|
||||||
|
Dim oModule = GetModule(Of PatternModule.User)()
|
||||||
|
Dim oArgs = GetReplaceMapForModule(oModule, pUser:=pUser)
|
||||||
|
oResult = DoReplaceForModule(oResult, oModule, oArgs)
|
||||||
|
|
||||||
|
Return oResult
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Function ReplaceControlValues(pInput As String, pPanel As Panel) As String
|
||||||
|
Dim oResult = pInput
|
||||||
|
|
||||||
|
Dim oModule = GetModule(Of PatternModule.Controls)()
|
||||||
|
Dim oArgs = GetReplaceMapForModule(oModule, pPanel:=pPanel)
|
||||||
|
oResult = DoReplaceForModule(oResult, oModule, oArgs)
|
||||||
|
|
||||||
|
Return oResult
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Function ReplaceWindreamValues(pInput As String, pWMObject As WMObject) As String
|
||||||
|
Dim oResult = pInput
|
||||||
|
|
||||||
|
Dim oModule = GetModule(Of PatternModule.Windream)()
|
||||||
|
Dim oArgs = GetReplaceMapForModule(oModule, pWMObject:=pWMObject)
|
||||||
|
oResult = DoReplaceForModule(oResult, oModule, oArgs)
|
||||||
|
|
||||||
|
Return oResult
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Function ReplaceInternalValues(pInput As String) As String
|
||||||
|
Dim oResult = pInput
|
||||||
|
|
||||||
|
Dim oInternalModule = GetModule(Of PatternModule.Internal)()
|
||||||
|
Dim oInternalArgs = GetReplaceMapForModule(oInternalModule)
|
||||||
|
oResult = DoReplaceForModule(oResult, oInternalModule, oInternalArgs)
|
||||||
|
|
||||||
|
Dim oClipboardModule = GetModule(Of PatternModule.Clipboard)()
|
||||||
|
Dim oClipboardArgs = GetReplaceMapForModule(oClipboardModule)
|
||||||
|
oResult = DoReplaceForModule(oResult, oClipboardModule, oClipboardArgs)
|
||||||
|
|
||||||
|
Return oResult
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Function DoReplaceForModule(pInput As String, pModule As IModule, pArgs As Dictionary(Of String, Object)) As String
|
||||||
|
Try
|
||||||
|
pInput = pModule.Replace(pInput, pArgs)
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Warn("Placeholders for String [{0}] could not be replaced completely in Module [{1}]. Skipping.", pInput, pModule.GetType.Name)
|
||||||
|
Logger.Error(ex)
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Return pInput
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Function GetModule(Of ModuleT)() As IModule
|
||||||
|
Return Modules.
|
||||||
|
Where(Function(m) TypeOf m Is ModuleT).
|
||||||
|
SingleOrDefault()
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Function GetReplaceMapForModule(pModule As IModule, Optional pPanel As Panel = Nothing, Optional pUser As State.UserState = Nothing, Optional pWMObject As WMObject = Nothing) As Dictionary(Of String, Object)
|
||||||
Dim oArgs As New Dictionary(Of String, Object)
|
Dim oArgs As New Dictionary(Of String, Object)
|
||||||
|
|
||||||
If TypeOf pModule Is PatternModule.Clipboard Then
|
If TypeOf pModule Is PatternModule.Clipboard Then
|
||||||
|
Try
|
||||||
oArgs.Add(PatternModule.Clipboard.CLIP_VALUE_BOARD, My.Computer.Clipboard.GetText())
|
oArgs.Add(PatternModule.Clipboard.CLIP_VALUE_BOARD, My.Computer.Clipboard.GetText())
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Error(ex)
|
||||||
|
End Try
|
||||||
|
|
||||||
ElseIf TypeOf pModule Is PatternModule.Internal Then
|
ElseIf TypeOf pModule Is PatternModule.Internal Then
|
||||||
|
Try
|
||||||
oArgs.Add(PatternModule.Internal.INT_VALUE_USERNAME, System.Environment.UserName)
|
oArgs.Add(PatternModule.Internal.INT_VALUE_USERNAME, System.Environment.UserName)
|
||||||
oArgs.Add(PatternModule.Internal.INT_VALUE_MACHINE, System.Environment.MachineName)
|
oArgs.Add(PatternModule.Internal.INT_VALUE_MACHINE, System.Environment.MachineName)
|
||||||
oArgs.Add(PatternModule.Internal.INT_VALUE_DOMAIN, System.Environment.UserDomainName)
|
oArgs.Add(PatternModule.Internal.INT_VALUE_DOMAIN, System.Environment.UserDomainName)
|
||||||
oArgs.Add(PatternModule.Internal.INT_VALUE_DATE, Now.ToShortDateString)
|
oArgs.Add(PatternModule.Internal.INT_VALUE_DATE, Now.ToShortDateString)
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Error(ex)
|
||||||
|
End Try
|
||||||
|
|
||||||
ElseIf TypeOf pModule Is PatternModule.User Then
|
ElseIf TypeOf pModule Is PatternModule.User Then
|
||||||
|
Try
|
||||||
oArgs.Add(PatternModule.User.USER_VALUE_EMAIL, pUser.Email)
|
oArgs.Add(PatternModule.User.USER_VALUE_EMAIL, pUser.Email)
|
||||||
oArgs.Add(PatternModule.User.USER_VALUE_LANGUAGE, pUser.Language)
|
oArgs.Add(PatternModule.User.USER_VALUE_LANGUAGE, pUser.Language)
|
||||||
oArgs.Add(PatternModule.User.USER_VALUE_PRENAME, pUser.GivenName)
|
oArgs.Add(PatternModule.User.USER_VALUE_PRENAME, pUser.GivenName)
|
||||||
@@ -111,9 +181,23 @@ Public Class Patterns2
|
|||||||
oArgs.Add(PatternModule.User.USER_VALUE_SURNAME, pUser.Surname)
|
oArgs.Add(PatternModule.User.USER_VALUE_SURNAME, pUser.Surname)
|
||||||
oArgs.Add(PatternModule.User.USER_VALUE_USER_ID, pUser.UserId)
|
oArgs.Add(PatternModule.User.USER_VALUE_USER_ID, pUser.UserId)
|
||||||
oArgs.Add(PatternModule.User.USER_VALUE_USER_NAME, pUser.UserName)
|
oArgs.Add(PatternModule.User.USER_VALUE_USER_NAME, pUser.UserName)
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Error(ex)
|
||||||
|
End Try
|
||||||
|
|
||||||
ElseIf TypeOf pModule Is PatternModule.Controls Then
|
ElseIf TypeOf pModule Is PatternModule.Controls Then
|
||||||
|
Try
|
||||||
oArgs.Add(PatternModule.Controls.CTRL_VALUE_PANEL, pPanel)
|
oArgs.Add(PatternModule.Controls.CTRL_VALUE_PANEL, pPanel)
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Error(ex)
|
||||||
|
End Try
|
||||||
|
|
||||||
|
ElseIf TypeOf pModule Is PatternModule.Windream Then
|
||||||
|
Try
|
||||||
|
oArgs.Add(PatternModule.Windream.WM_VALUE_DOCUMENT, pWMObject)
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Error(ex)
|
||||||
|
End Try
|
||||||
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user