Add max retries to pattern replacer
This commit is contained in:
parent
aab9f309b3
commit
84b340e026
@ -31,6 +31,8 @@ Public Class clsPatterns
|
|||||||
Public Const INT_VALUE_MACHINE = "MACHINE"
|
Public Const INT_VALUE_MACHINE = "MACHINE"
|
||||||
Public Const INT_VALUE_DOMAIN = "DOMAIN"
|
Public Const INT_VALUE_DOMAIN = "DOMAIN"
|
||||||
|
|
||||||
|
Public Const MAX_TRY_COUNT = 100
|
||||||
|
|
||||||
Private Shared regex As Regex = New Regex("{#(\w+)#([\w\s_-]+)}+")
|
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}
|
||||||
Private Shared complexPatterns As New List(Of String) From {PATTERN_WMI, PATTERN_CTRL}
|
Private Shared complexPatterns As New List(Of String) From {PATTERN_WMI, PATTERN_CTRL}
|
||||||
@ -118,8 +120,13 @@ Public Class clsPatterns
|
|||||||
Public Shared Function ReplaceControlValues(input As String, panel As Panel) As String
|
Public Shared Function ReplaceControlValues(input As String, panel As Panel) As String
|
||||||
Try
|
Try
|
||||||
Dim result = input
|
Dim result = input
|
||||||
|
Dim oTryCounter = 0
|
||||||
|
|
||||||
While ContainsPattern(result, PATTERN_CTRL)
|
While ContainsPattern(result, PATTERN_CTRL)
|
||||||
|
If oTryCounter > MAX_TRY_COUNT Then
|
||||||
|
Throw New Exception("Max tries in ReplaceControlValues exceeded.")
|
||||||
|
End If
|
||||||
|
|
||||||
Dim controlName As String = GetNextPattern(result, PATTERN_CTRL).Value
|
Dim controlName As String = GetNextPattern(result, PATTERN_CTRL).Value
|
||||||
Dim control As Control = panel.Controls.Find(controlName, False).FirstOrDefault()
|
Dim control As Control = panel.Controls.Find(controlName, False).FirstOrDefault()
|
||||||
|
|
||||||
@ -127,6 +134,8 @@ Public Class clsPatterns
|
|||||||
Dim value As String = control.Text
|
Dim value As String = control.Text
|
||||||
result = ReplacePattern(result, PATTERN_CTRL, value)
|
result = ReplacePattern(result, PATTERN_CTRL, value)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
oTryCounter += 1
|
||||||
End While
|
End While
|
||||||
|
|
||||||
Return result
|
Return result
|
||||||
|
|||||||
@ -1004,6 +1004,7 @@ Public Class frmValidator
|
|||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
Public Sub onLookUp1(sender As Object, SelectedValues As List(Of String))
|
Public Sub onLookUp1(sender As Object, SelectedValues As List(Of String))
|
||||||
|
LOGGER.Debug("onLookup1")
|
||||||
If FormLoaded = False Then
|
If FormLoaded = False Then
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
@ -1033,6 +1034,7 @@ Public Class frmValidator
|
|||||||
Try
|
Try
|
||||||
'Dim oDependingLookup As LookupControl2 = pnldesigner.Controls.Find(oDEPENDING_CtrlName, False).FirstOrDefault()
|
'Dim oDependingLookup As LookupControl2 = pnldesigner.Controls.Find(oDEPENDING_CtrlName, False).FirstOrDefault()
|
||||||
For Each oControl As Control In pnldesigner.Controls
|
For Each oControl As Control In pnldesigner.Controls
|
||||||
|
|
||||||
If oControl.Tag = oDEPENDING_GUID Then
|
If oControl.Tag = oDEPENDING_GUID Then
|
||||||
Dim oDependingLookup As LookupControl2 = oControl
|
Dim oDependingLookup As LookupControl2 = oControl
|
||||||
oDependingLookup.DataSource = oDTDEPENDING_RESULT
|
oDependingLookup.DataSource = oDTDEPENDING_RESULT
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user