jj: new place holders

This commit is contained in:
Jonathan Jenne
2019-06-13 12:44:15 +02:00
parent 1b0729c2e3
commit 726d79ef3b
11 changed files with 181 additions and 85 deletions

View File

@@ -17,6 +17,7 @@ Public Class clsPatterns
' Complex patterns that rely on a datasource like a Database or Windream
Public Const PATTERN_WMI = "WMI"
Public Const PATTERN_CTRL = "CTRL"
Public Const PATTERN_PRO = "PRO"
' Simple patterns that only rely on .NET functions
Public Const PATTERN_INT = "INT"
' Simple patterns that rely on Data from the TBDD_USER table
@@ -26,17 +27,21 @@ Public Class clsPatterns
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 INT_VALUE_USERNAME = "USERNAME"
Public Const INT_VALUE_MACHINE = "MACHINE"
Public Const INT_VALUE_DOMAIN = "DOMAIN"
Public Const INT_VALUE_DATE = "DATE"
Public Const PRO_VALUE_PROFILE_ID = "PROFILE_ID"
Public Const MAX_TRY_COUNT = 100
Private Shared regex As Regex = New Regex("{#(\w+)#([\w\s_-]+)}+")
Private Shared allPatterns As New List(Of String) From {PATTERN_WMI, PATTERN_CTRL, PATTERN_USER, PATTERN_INT}
Private Shared allPatterns As New List(Of String) From {PATTERN_WMI, PATTERN_CTRL, PATTERN_USER, PATTERN_INT, PATTERN_PRO}
Private Shared complexPatterns As New List(Of String) From {PATTERN_WMI, PATTERN_CTRL}
Private Shared simplePatterns As New List(Of String) From {PATTERN_USER, PATTERN_INT}
Private Shared simplePatterns As New List(Of String) From {PATTERN_USER, PATTERN_INT, PATTERN_PRO}
''' <summary>
''' Wraps a pattern-type and -value in the common format: {#type#value}
@@ -46,14 +51,15 @@ Public Class clsPatterns
End Function
Public Shared Function ReplaceAllValues(input As String, panel As Panel, document As WMObject, prename As Object, surname As Object, shortname As Object, email As Object) As String
Public Shared Function ReplaceAllValues(input As String, panel As Panel, document As WMObject, prename As Object, surname As Object, shortname As Object, email As Object, userId As Object, profileId As Object) As String
Try
Dim result = input
result = ReplaceInternalValues(result)
result = ReplaceControlValues(result, panel)
If Not IsNothing(document) Then result = ReplaceWindreamIndicies(result, document)
result = ReplaceUserValues(result, prename, surname, shortname, email)
If Not IsNothing(profileId) AndAlso profileId > 0 Then result = ReplaceProfileValues(result, profileId)
result = ReplaceUserValues(result, prename, surname, shortname, email, userId)
Return result
Catch ex As Exception
@@ -81,6 +87,11 @@ Public Class clsPatterns
result = ReplacePattern(result, PATTERN_INT, Environment.UserDomainName)
End While
' Replace CurrentDate(s)
While ContainsPatternAndValue(result, PATTERN_INT, INT_VALUE_DATE)
result = ReplacePattern(result, PATTERN_INT, Now.ToShortDateString)
End While
Return result
Catch ex As Exception
LOGGER.Error(ex)
@@ -88,7 +99,7 @@ Public Class clsPatterns
End Try
End Function
Public Shared Function ReplaceUserValues(input As String, prename As Object, surname As Object, shortname As Object, email As Object) As String
Public Shared Function ReplaceUserValues(input As String, prename As Object, surname As Object, shortname As Object, email As Object, userId As Object) As String
Try
Dim result = input
@@ -96,6 +107,9 @@ Public Class clsPatterns
result = ReplacePattern(input, PATTERN_USER, prename)
End While
While ContainsPatternAndValue(result, PATTERN_USER, USER_VALUE_USER_ID)
result = ReplacePattern(input, PATTERN_USER, userId)
End While
While ContainsPatternAndValue(result, PATTERN_USER, USER_VALUE_SURNAME)
result = ReplacePattern(input, PATTERN_USER, surname)
@@ -116,6 +130,21 @@ Public Class clsPatterns
End Try
End Function
Public Shared Function ReplaceProfileValues(Input As String, profileId As Object)
Try
Dim result = Input
While ContainsPatternAndValue(result, PATTERN_PRO, PRO_VALUE_PROFILE_ID)
ReplacePattern(result, PATTERN_PRO, profileId)
End While
Return result
Catch ex As Exception
LOGGER.Error(ex)
LOGGER.Info("Error in ReplaceProfileValues:" & ex.Message)
End Try
End Function
Public Shared Function ReplaceControlValues(input As String, panel As Panel) As String
Try