Zooflow: Massive Clean up
This commit is contained in:
@@ -100,195 +100,195 @@ Public Class clsPatterns
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
Public Shared Function ReplaceInternalValues(pInput As String) As String
|
||||
Dim oResult = pInput
|
||||
'Public Shared Function ReplaceInternalValues(pInput As String) As String
|
||||
' Dim oResult = pInput
|
||||
|
||||
Try
|
||||
' Replace Username(s)
|
||||
While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_USERNAME)
|
||||
oResult = ReplacePattern(oResult, PATTERN_INT, My.Application.User.UserName)
|
||||
End While
|
||||
' Try
|
||||
' ' Replace Username(s)
|
||||
' While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_USERNAME)
|
||||
' oResult = ReplacePattern(oResult, PATTERN_INT, My.Application.User.UserName)
|
||||
' End While
|
||||
|
||||
' Replace Machinename(s)
|
||||
While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_MACHINE)
|
||||
oResult = ReplacePattern(oResult, PATTERN_INT, Environment.MachineName)
|
||||
End While
|
||||
' ' Replace Machinename(s)
|
||||
' While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_MACHINE)
|
||||
' oResult = ReplacePattern(oResult, PATTERN_INT, Environment.MachineName)
|
||||
' End While
|
||||
|
||||
' Replace Domainname(s)
|
||||
While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_DOMAIN)
|
||||
oResult = ReplacePattern(oResult, PATTERN_INT, Environment.UserDomainName)
|
||||
End While
|
||||
' ' Replace Domainname(s)
|
||||
' While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_DOMAIN)
|
||||
' oResult = ReplacePattern(oResult, PATTERN_INT, Environment.UserDomainName)
|
||||
' End While
|
||||
|
||||
' Replace CurrentDate(s)
|
||||
While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_DATE)
|
||||
oResult = ReplacePattern(oResult, PATTERN_INT, Now.ToShortDateString)
|
||||
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.Info("Error in ReplaceInternalValues:" & ex.Message)
|
||||
Return oResult
|
||||
End Try
|
||||
End Function
|
||||
' Return oResult
|
||||
' Catch ex As Exception
|
||||
' LOGGER.Error(ex)
|
||||
' LOGGER.Info("Error in ReplaceInternalValues:" & ex.Message)
|
||||
' Return oResult
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
Public Shared Function ReplaceUserValues(input As String) As String
|
||||
Try
|
||||
Dim result = input
|
||||
'Public Shared Function ReplaceUserValues(input As String) As String
|
||||
' Try
|
||||
' Dim result = input
|
||||
|
||||
While ContainsPatternAndValue(result, PATTERN_USER, USER_VALUE_PRENAME)
|
||||
result = ReplacePattern(result, PATTERN_USER, My.Application.User.GivenName)
|
||||
End While
|
||||
' While ContainsPatternAndValue(result, PATTERN_USER, USER_VALUE_PRENAME)
|
||||
' result = ReplacePattern(result, PATTERN_USER, My.Application.User.GivenName)
|
||||
' End While
|
||||
|
||||
While ContainsPatternAndValue(result, PATTERN_USER, USER_VALUE_USER_ID)
|
||||
result = ReplacePattern(result, PATTERN_USER, My.Application.User.UserId)
|
||||
End While
|
||||
' While ContainsPatternAndValue(result, PATTERN_USER, USER_VALUE_USER_ID)
|
||||
' result = ReplacePattern(result, PATTERN_USER, My.Application.User.UserId)
|
||||
' End While
|
||||
|
||||
While ContainsPatternAndValue(result, PATTERN_USER, USER_VALUE_SURNAME)
|
||||
result = ReplacePattern(result, PATTERN_USER, My.Application.User.Surname)
|
||||
End While
|
||||
' While ContainsPatternAndValue(result, PATTERN_USER, USER_VALUE_SURNAME)
|
||||
' result = ReplacePattern(result, PATTERN_USER, My.Application.User.Surname)
|
||||
' End While
|
||||
|
||||
While ContainsPatternAndValue(result, PATTERN_USER, USER_VALUE_SHORTNAME)
|
||||
result = ReplacePattern(result, PATTERN_USER, My.Application.User.ShortName)
|
||||
End While
|
||||
' While ContainsPatternAndValue(result, PATTERN_USER, USER_VALUE_SHORTNAME)
|
||||
' result = ReplacePattern(result, PATTERN_USER, My.Application.User.ShortName)
|
||||
' End While
|
||||
|
||||
While ContainsPatternAndValue(result, PATTERN_USER, USER_VALUE_LANGUAGE)
|
||||
result = ReplacePattern(result, PATTERN_USER, My.Application.User.Language)
|
||||
End While
|
||||
' While ContainsPatternAndValue(result, PATTERN_USER, USER_VALUE_LANGUAGE)
|
||||
' result = ReplacePattern(result, PATTERN_USER, My.Application.User.Language)
|
||||
' End While
|
||||
|
||||
While ContainsPatternAndValue(result, PATTERN_USER, USER_VALUE_EMAIL)
|
||||
result = ReplacePattern(result, PATTERN_USER, My.Application.User.Email)
|
||||
End While
|
||||
' While ContainsPatternAndValue(result, PATTERN_USER, USER_VALUE_EMAIL)
|
||||
' result = ReplacePattern(result, PATTERN_USER, My.Application.User.Email)
|
||||
' End While
|
||||
|
||||
Return result
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
LOGGER.Info("Error in ReplaceUserValues:" & ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
' Return result
|
||||
' Catch ex As Exception
|
||||
' LOGGER.Error(ex)
|
||||
' LOGGER.Info("Error in ReplaceUserValues:" & ex.Message)
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
Public Shared Function ReplaceControlValues(pInput As String, oPanel As Panel, oIsSQL As Boolean) As String
|
||||
Dim oResult = pInput
|
||||
'Public Shared Function ReplaceControlValues(pInput As String, oPanel As Panel, oIsSQL As Boolean) As String
|
||||
' Dim oResult = pInput
|
||||
|
||||
Try
|
||||
' Try
|
||||
|
||||
Dim oTryCounter = 0
|
||||
' Dim oTryCounter = 0
|
||||
|
||||
While ContainsPattern(oResult, PATTERN_CTRL)
|
||||
If oTryCounter > MAX_TRY_COUNT Then
|
||||
LOGGER.Warn($"Max tries in ReplaceControlValues exceeded - Replacing with [0]")
|
||||
oResult = ReplacePattern(oResult, PATTERN_CTRL, 0)
|
||||
Throw New Exception($"Max tries in ReplaceControlValues exceeded - Result so far [{oResult}].")
|
||||
End If
|
||||
' While ContainsPattern(oResult, PATTERN_CTRL)
|
||||
' If oTryCounter > MAX_TRY_COUNT Then
|
||||
' LOGGER.Warn($"Max tries in ReplaceControlValues exceeded - Replacing with [0]")
|
||||
' oResult = ReplacePattern(oResult, PATTERN_CTRL, 0)
|
||||
' Throw New Exception($"Max tries in ReplaceControlValues exceeded - Result so far [{oResult}].")
|
||||
' End If
|
||||
|
||||
Dim oControlName As String = GetNextPattern(oResult, PATTERN_CTRL).Value
|
||||
Dim oColumnName As String = String.Empty
|
||||
' Dim oControlName As String = GetNextPattern(oResult, PATTERN_CTRL).Value
|
||||
' Dim oColumnName As String = String.Empty
|
||||
|
||||
If oControlName.Contains("::") Then
|
||||
Dim oSplitName = Split(oControlName, "::").ToList()
|
||||
oControlName = oSplitName.First()
|
||||
oColumnName = oSplitName.Last()
|
||||
End If
|
||||
' If oControlName.Contains("::") Then
|
||||
' Dim oSplitName = Split(oControlName, "::").ToList()
|
||||
' oControlName = oSplitName.First()
|
||||
' oColumnName = oSplitName.Last()
|
||||
' End If
|
||||
|
||||
LOGGER.Debug("Found placeholder for control [{0}].", oControlName)
|
||||
' LOGGER.Debug("Found placeholder for control [{0}].", oControlName)
|
||||
|
||||
Dim oControl As Control = oPanel.Controls.Find(oControlName, False).FirstOrDefault()
|
||||
' Dim oControl As Control = oPanel.Controls.Find(oControlName, False).FirstOrDefault()
|
||||
|
||||
If oControl IsNot Nothing Then
|
||||
Dim oReplaceValue As String
|
||||
Select Case oControl.GetType
|
||||
Case GetType(TextBox)
|
||||
oReplaceValue = oControl.Text
|
||||
' If oControl IsNot Nothing Then
|
||||
' Dim oReplaceValue As String
|
||||
' Select Case oControl.GetType
|
||||
' Case GetType(TextBox)
|
||||
' oReplaceValue = oControl.Text
|
||||
|
||||
Case GetType(LookupControl3)
|
||||
Dim oLookupControl3 As LookupControl3 = oControl
|
||||
If oLookupControl3.Properties.SelectedValues.Count = 1 Then
|
||||
oReplaceValue = oLookupControl3.Properties.SelectedValues.Item(0)
|
||||
Else
|
||||
oReplaceValue = ERROR_REPLACE_VALUE
|
||||
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 = ERROR_REPLACE_VALUE
|
||||
' End If
|
||||
|
||||
Case GetType(ComboBox)
|
||||
oReplaceValue = oControl.Text
|
||||
' Case GetType(ComboBox)
|
||||
' oReplaceValue = oControl.Text
|
||||
|
||||
Case GetType(CheckBox)
|
||||
Dim oCheckBox As CheckBox = oControl
|
||||
oReplaceValue = oCheckBox.Checked
|
||||
' Case GetType(CheckBox)
|
||||
' Dim oCheckBox As CheckBox = oControl
|
||||
' oReplaceValue = oCheckBox.Checked
|
||||
|
||||
Case GetType(GridControl)
|
||||
Dim oGrid As GridControl = oControl
|
||||
Dim oView As GridView = oGrid.FocusedView
|
||||
' Case GetType(GridControl)
|
||||
' Dim oGrid As GridControl = oControl
|
||||
' Dim oView As GridView = oGrid.FocusedView
|
||||
|
||||
If oColumnName = String.Empty Then
|
||||
LOGGER.Warn("Used placeholder for Table [{0}] but without Column Name!", oControlName)
|
||||
oReplaceValue = ERROR_REPLACE_VALUE
|
||||
End If
|
||||
' If oColumnName = String.Empty Then
|
||||
' LOGGER.Warn("Used placeholder for Table [{0}] but without Column Name!", oControlName)
|
||||
' oReplaceValue = ERROR_REPLACE_VALUE
|
||||
' End If
|
||||
|
||||
Dim oColumn As GridColumn = oView.Columns.
|
||||
Where(Function(c) c.FieldName = oColumnName).
|
||||
SingleOrDefault()
|
||||
' Dim oColumn As GridColumn = oView.Columns.
|
||||
' Where(Function(c) c.FieldName = oColumnName).
|
||||
' SingleOrDefault()
|
||||
|
||||
If oColumn?.SummaryItem?.SummaryValue Is Nothing Then
|
||||
LOGGER.Warn("Column [{0}] not found in Grid!", oColumnName)
|
||||
oReplaceValue = ERROR_REPLACE_VALUE
|
||||
Else
|
||||
oReplaceValue = oColumn.SummaryItem.SummaryValue
|
||||
End If
|
||||
' If oColumn?.SummaryItem?.SummaryValue Is Nothing Then
|
||||
' LOGGER.Warn("Column [{0}] not found in Grid!", oColumnName)
|
||||
' oReplaceValue = ERROR_REPLACE_VALUE
|
||||
' Else
|
||||
' oReplaceValue = oColumn.SummaryItem.SummaryValue
|
||||
' End If
|
||||
|
||||
Case Else
|
||||
oReplaceValue = ERROR_REPLACE_VALUE
|
||||
End Select
|
||||
If oIsSQL = True Then
|
||||
'LOGGER.Debug($"IS_SQL = True - oReplaceValue = {oReplaceValue}")
|
||||
'LOGGER.Debug($"oReplaceValue = {oReplaceValue}")
|
||||
oReplaceValue = oReplaceValue.Replace("'", "''")
|
||||
End If
|
||||
oResult = ReplacePattern(oResult, PATTERN_CTRL, oReplaceValue)
|
||||
End If
|
||||
' Case Else
|
||||
' oReplaceValue = ERROR_REPLACE_VALUE
|
||||
' End Select
|
||||
' If oIsSQL = True Then
|
||||
' 'LOGGER.Debug($"IS_SQL = True - oReplaceValue = {oReplaceValue}")
|
||||
' 'LOGGER.Debug($"oReplaceValue = {oReplaceValue}")
|
||||
' oReplaceValue = oReplaceValue.Replace("'", "''")
|
||||
' End If
|
||||
' oResult = ReplacePattern(oResult, PATTERN_CTRL, oReplaceValue)
|
||||
' End If
|
||||
|
||||
oTryCounter += 1
|
||||
End While
|
||||
Return oResult
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
LOGGER.Warn("Error in ReplaceControlValues:" & ex.Message)
|
||||
Return oResult
|
||||
End Try
|
||||
End Function
|
||||
' oTryCounter += 1
|
||||
' End While
|
||||
' Return oResult
|
||||
' Catch ex As Exception
|
||||
' LOGGER.Error(ex)
|
||||
' LOGGER.Warn("Error in ReplaceControlValues:" & ex.Message)
|
||||
' Return oResult
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
Public Shared Function ReplaceAttributes(pInput As String, pIDBOBJ_ID As Long, pIsSQL As Boolean) As String
|
||||
Try
|
||||
Dim oResult = pInput
|
||||
Dim oTryCounter As Integer = 0
|
||||
'Public Shared Function ReplaceAttributes(pInput As String, pIDBOBJ_ID As Long, pIsSQL As Boolean) As String
|
||||
' Try
|
||||
' Dim oResult = pInput
|
||||
' Dim oTryCounter As Integer = 0
|
||||
|
||||
While ContainsPattern(oResult, PATTERN_ZFATTRIBUTE)
|
||||
' While ContainsPattern(oResult, PATTERN_ZFATTRIBUTE)
|
||||
|
||||
Dim oIndexName As String = GetNextPattern(oResult, PATTERN_ZFATTRIBUTE).Value
|
||||
Dim oValue As String '= pDocument.GetVariableValue(oIndexName)
|
||||
' Dim oIndexName As String = GetNextPattern(oResult, PATTERN_ZFATTRIBUTE).Value
|
||||
' Dim oValue As String '= pDocument.GetVariableValue(oIndexName)
|
||||
|
||||
If IsNothing(oValue) And oTryCounter = MAX_TRY_COUNT Then
|
||||
Throw New Exception("Max tries in ReplaceWindreamIndicies exceeded.")
|
||||
End If
|
||||
' If IsNothing(oValue) And oTryCounter = MAX_TRY_COUNT Then
|
||||
' Throw New Exception("Max tries in ReplaceWindreamIndicies exceeded.")
|
||||
' End If
|
||||
|
||||
If oValue IsNot Nothing Then
|
||||
If pIsSQL = True Then
|
||||
LOGGER.Debug($"IS_SQL = True - oReplaceValue = {oValue}")
|
||||
oValue = oValue.ToString().Replace("'", "''")
|
||||
LOGGER.Debug($"oReplaceValue = {oValue}")
|
||||
End If
|
||||
oResult = ReplacePattern(oResult, PATTERN_ZFATTRIBUTE, oValue)
|
||||
End If
|
||||
' If oValue IsNot Nothing Then
|
||||
' If pIsSQL = True Then
|
||||
' LOGGER.Debug($"IS_SQL = True - oReplaceValue = {oValue}")
|
||||
' oValue = oValue.ToString().Replace("'", "''")
|
||||
' LOGGER.Debug($"oReplaceValue = {oValue}")
|
||||
' End If
|
||||
' oResult = ReplacePattern(oResult, PATTERN_ZFATTRIBUTE, oValue)
|
||||
' End If
|
||||
|
||||
' Increase counter by 10 to avoid DDOSing the Windream Service
|
||||
oTryCounter += 10
|
||||
End While
|
||||
Return oResult
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
LOGGER.Info("Error in ReplaceWindreamIndicies:" & ex.Message)
|
||||
Return pInput
|
||||
End Try
|
||||
End Function
|
||||
' ' Increase counter by 10 to avoid DDOSing the Windream Service
|
||||
' oTryCounter += 10
|
||||
' End While
|
||||
' Return oResult
|
||||
' Catch ex As Exception
|
||||
' LOGGER.Error(ex)
|
||||
' LOGGER.Info("Error in ReplaceWindreamIndicies:" & ex.Message)
|
||||
' Return pInput
|
||||
' End Try
|
||||
'End Function
|
||||
'Public Shared Function ReplaceIDBAttributes(input As String, IS_SQL As Boolean) As String
|
||||
' Try
|
||||
' Dim result = input
|
||||
@@ -347,35 +347,35 @@ Public Class clsPatterns
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
Private Shared Function ContainsPattern(input As String, type As String) As String
|
||||
Dim elements As MatchCollection = MyRegex.Matches(input)
|
||||
'Private Shared Function ContainsPattern(input As String, type As String) As String
|
||||
' Dim elements As MatchCollection = MyRegex.Matches(input)
|
||||
|
||||
For Each element As Match In elements
|
||||
Dim t As String = element.Groups(1).Value
|
||||
' For Each element As Match In elements
|
||||
' Dim t As String = element.Groups(1).Value
|
||||
|
||||
If t = type Then
|
||||
Return True
|
||||
End If
|
||||
Next
|
||||
' If t = type Then
|
||||
' Return True
|
||||
' End If
|
||||
' Next
|
||||
|
||||
Return False
|
||||
End Function
|
||||
' Return False
|
||||
'End Function
|
||||
|
||||
Public Shared Function GetNextPattern(input As String, type As String) As Pattern
|
||||
Dim elements As MatchCollection = MyRegex.Matches(input)
|
||||
'Public Shared Function GetNextPattern(input As String, type As String) As Pattern
|
||||
' Dim elements As MatchCollection = MyRegex.Matches(input)
|
||||
|
||||
For Each element As Match In elements
|
||||
' Pattern in pInput
|
||||
Dim t As String = element.Groups(1).Value
|
||||
Dim v As String = element.Groups(2).Value
|
||||
' For Each element As Match In elements
|
||||
' ' Pattern in pInput
|
||||
' Dim t As String = element.Groups(1).Value
|
||||
' Dim v As String = element.Groups(2).Value
|
||||
|
||||
If t = type Then
|
||||
Return New Pattern(t, v)
|
||||
End If
|
||||
Next
|
||||
' If t = type Then
|
||||
' Return New Pattern(t, v)
|
||||
' End If
|
||||
' Next
|
||||
|
||||
Return Nothing
|
||||
End Function
|
||||
' Return Nothing
|
||||
'End Function
|
||||
|
||||
Public Shared Function GetAllPatterns(input As String) As List(Of Pattern)
|
||||
Dim elements As MatchCollection = MyRegex.Matches(input)
|
||||
@@ -411,51 +411,51 @@ Public Class clsPatterns
|
||||
Return input
|
||||
End Function
|
||||
|
||||
Private Shared Function ContainsPatternAndValue(input As String, type As String, value As String) As Boolean
|
||||
Dim elements As MatchCollection = MyRegex.Matches(input)
|
||||
'Private Shared Function ContainsPatternAndValue(input As String, type As String, value As String) As Boolean
|
||||
' Dim elements As MatchCollection = MyRegex.Matches(input)
|
||||
|
||||
For Each element As Match In elements
|
||||
' Pattern in pInput
|
||||
Dim t As String = element.Groups(1).Value
|
||||
Dim v As String = element.Groups(2).Value
|
||||
' For Each element As Match In elements
|
||||
' ' Pattern in pInput
|
||||
' Dim t As String = element.Groups(1).Value
|
||||
' Dim v As String = element.Groups(2).Value
|
||||
|
||||
If t = type And v = value Then
|
||||
Return True
|
||||
End If
|
||||
Next
|
||||
' If t = type And v = value Then
|
||||
' Return True
|
||||
' End If
|
||||
' Next
|
||||
|
||||
Return False
|
||||
End Function
|
||||
' Return False
|
||||
'End Function
|
||||
|
||||
Public Shared Function HasAnyPatterns(input) As Boolean
|
||||
Return allPatterns.Any(Function(p)
|
||||
Return HasPattern(input, p)
|
||||
End Function)
|
||||
End Function
|
||||
'Public Shared Function HasAnyPatterns(input) As Boolean
|
||||
' Return allPatterns.Any(Function(p)
|
||||
' Return HasPattern(input, p)
|
||||
' End Function)
|
||||
'End Function
|
||||
|
||||
Public Shared Function HasOnlySimplePatterns(input As String) As Boolean
|
||||
Return Not HasComplexPatterns(input)
|
||||
End Function
|
||||
'Public Shared Function HasOnlySimplePatterns(input As String) As Boolean
|
||||
' Return Not HasComplexPatterns(input)
|
||||
'End Function
|
||||
|
||||
Public Shared Function HasComplexPatterns(input As String) As Boolean
|
||||
Return complexPatterns.Any(Function(p)
|
||||
Return HasPattern(input, p)
|
||||
End Function)
|
||||
End Function
|
||||
'Public Shared Function HasComplexPatterns(input As String) As Boolean
|
||||
' Return complexPatterns.Any(Function(p)
|
||||
' Return HasPattern(input, p)
|
||||
' End Function)
|
||||
'End Function
|
||||
|
||||
Public Shared Function HasPattern(input As String, type As String) As Boolean
|
||||
Dim matches = MyRegex.Matches(input)
|
||||
'Public Shared Function HasPattern(input As String, type As String) As Boolean
|
||||
' Dim matches = MyRegex.Matches(input)
|
||||
|
||||
For Each match As Match In matches
|
||||
For Each group As Group In match.Groups
|
||||
If group.Value = type Then
|
||||
Return True
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
' For Each match As Match In matches
|
||||
' For Each group As Group In match.Groups
|
||||
' If group.Value = type Then
|
||||
' Return True
|
||||
' End If
|
||||
' Next
|
||||
' Next
|
||||
|
||||
Return False
|
||||
End Function
|
||||
' Return False
|
||||
'End Function
|
||||
|
||||
Public Class Pattern
|
||||
Public ReadOnly Property Type As String
|
||||
|
||||
Reference in New Issue
Block a user