2.4.1.7 Logging SQL from Task, replacing '
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports WINDREAMLib
|
||||
|
||||
Imports DigitalData.Controls.LookupGrid
|
||||
''' <summary>
|
||||
''' Defines common Functions for Checking for and replacing placeholders.
|
||||
''' This Class also includes a child class `Pattern` for passing around Patterns.
|
||||
@@ -51,18 +51,17 @@ 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, language As Object, email As Object, userId As Object, profileId As Object) As String
|
||||
Public Shared Function ReplaceAllValues(input As String, panel As Panel, is_SQL As Boolean) As String
|
||||
Try
|
||||
Dim result = input
|
||||
LOGGER.Debug($"input BEFORE replacing: [{result}]")
|
||||
result = ReplaceInternalValues(result)
|
||||
result = ReplaceControlValues(result, panel)
|
||||
If Not IsNothing(document) Then result = ReplaceWindreamIndicies(result, document)
|
||||
result = ReplaceControlValues(result, panel, is_SQL)
|
||||
If Not IsNothing(CURRENT_WMFILE) Then result = ReplaceWindreamIndicies(result, CURRENT_WMFILE, is_SQL)
|
||||
If IDB_ACTIVE = True Then
|
||||
result = ReplaceIDBAttributes(result)
|
||||
result = ReplaceIDBAttributes(result, is_SQL)
|
||||
End If
|
||||
|
||||
result = ReplaceUserValues(result, prename, surname, shortname, language, email, userId, profileId)
|
||||
result = ReplaceUserValues(result, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_LANGUAGE, USER_EMAIL, USER_ID, CURRENT_CLICKED_PROFILE_ID)
|
||||
LOGGER.Debug($"input AFTER replacing: [{result}]")
|
||||
Return result
|
||||
Catch ex As Exception
|
||||
@@ -143,7 +142,7 @@ Public Class clsPatterns
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Shared Function ReplaceControlValues(input As String, panel As Panel) As String
|
||||
Public Shared Function ReplaceControlValues(input As String, panel As Panel, IS_SQL As Boolean) As String
|
||||
Try
|
||||
Dim result = input
|
||||
Dim oTryCounter = 0
|
||||
@@ -156,10 +155,33 @@ Public Class clsPatterns
|
||||
End If
|
||||
|
||||
Dim controlName As String = GetNextPattern(result, PATTERN_CTRL).Value
|
||||
Dim control As Control = panel.Controls.Find(controlName, False).FirstOrDefault()
|
||||
Dim oControl As Control = panel.Controls.Find(controlName, False).FirstOrDefault()
|
||||
|
||||
If control IsNot Nothing Then
|
||||
Dim oReplaceValue As String = control.Text
|
||||
If oControl IsNot Nothing Then
|
||||
Dim oReplaceValue As String
|
||||
Select Case oControl.GetType.ToString
|
||||
Case GetType(TextBox).ToString
|
||||
oReplaceValue = oControl.Text
|
||||
Case GetType(LookupControl2).ToString
|
||||
Dim oLookupControl2 As LookupControl2 = oControl
|
||||
If oLookupControl2.SelectedValues.Count = 1 Then
|
||||
oReplaceValue = oLookupControl2.SelectedValues.Item(0)
|
||||
Else
|
||||
oReplaceValue = "0"
|
||||
End If
|
||||
Case GetType(ComboBox).ToString
|
||||
oReplaceValue = oControl.Text
|
||||
Case GetType(CheckBox).ToString
|
||||
Dim oCheckBox As CheckBox = oControl
|
||||
oReplaceValue = oCheckBox.Checked
|
||||
Case Else
|
||||
oReplaceValue = "0"
|
||||
End Select
|
||||
If IS_SQL = True Then
|
||||
LOGGER.Debug($"IS_SQL = True - oReplaceValue = {oReplaceValue}")
|
||||
oReplaceValue = oReplaceValue.Replace("'", "''")
|
||||
LOGGER.Debug($"oReplaceValue = {oReplaceValue}")
|
||||
End If
|
||||
result = ReplacePattern(result, PATTERN_CTRL, oReplaceValue)
|
||||
End If
|
||||
|
||||
@@ -173,7 +195,7 @@ Public Class clsPatterns
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Shared Function ReplaceWindreamIndicies(input As String, document As WMObject) As String
|
||||
Public Shared Function ReplaceWindreamIndicies(input As String, document As WMObject, IS_SQL As Boolean) As String
|
||||
Try
|
||||
Dim result = input
|
||||
Dim oTryCounter As Integer = 0
|
||||
@@ -188,6 +210,11 @@ Public Class clsPatterns
|
||||
|
||||
End If
|
||||
If oWMValue IsNot Nothing Then
|
||||
If IS_SQL = True Then
|
||||
LOGGER.Debug($"IS_SQL = True - oReplaceValue = {oWMValue}")
|
||||
oWMValue = oWMValue.Replace("'", "''")
|
||||
LOGGER.Debug($"oReplaceValue = {oWMValue}")
|
||||
End If
|
||||
result = ReplacePattern(result, PATTERN_WMI, oWMValue)
|
||||
End If
|
||||
oTryCounter += 100
|
||||
@@ -199,7 +226,7 @@ Public Class clsPatterns
|
||||
LOGGER.Info("Error in ReplaceWindreamIndicies:" & ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
Public Shared Function ReplaceIDBAttributes(input As String) As String
|
||||
Public Shared Function ReplaceIDBAttributes(input As String, IS_SQL As Boolean) As String
|
||||
Try
|
||||
Dim result = input
|
||||
Dim oTryCounter As Integer = 0
|
||||
@@ -227,6 +254,11 @@ Public Class clsPatterns
|
||||
End If
|
||||
If oIDBValue IsNot Nothing Then
|
||||
Dim oReplaceValue = "{" + $"#{PATTERN_IDBA}#{indexName}" + "}"
|
||||
If IS_SQL = True Then
|
||||
LOGGER.Debug($"IS_SQL = True - oReplaceValue = {oIDBValue}")
|
||||
oIDBValue = oIDBValue.Replace("'", "''")
|
||||
LOGGER.Debug($"oReplaceValue = {oIDBValue}")
|
||||
End If
|
||||
result = result.Replace(oReplaceValue, oIDBValue)
|
||||
'result = ReplacePattern(result, oReplaceValue, oIDBValue)
|
||||
End If
|
||||
|
||||
Reference in New Issue
Block a user