fix depending controls crashing because of missing tag for datetimepicker

This commit is contained in:
Jonathan Jenne
2020-03-17 11:02:48 +01:00
parent ed5a1233ae
commit 3659055597
3 changed files with 83 additions and 56 deletions

View File

@@ -176,12 +176,24 @@ Public Class ClassPatterns
Continue For
End If
LOGGER.Debug("Getting control metadata..")
LOGGER.Debug("Getting control metadata from object: [{0}]", oControl?.Tag?.ToString())
Dim oMeta = DirectCast(oControl.Tag, ClassControls.ControlMeta)
If oControl.Tag Is Nothing Then
LOGGER.Warn("No Metadata object found for control [{0}]. Skipping.", oControl.Name)
Continue For
End If
Dim oMeta = TryCast(oControl.Tag, ClassControls.ControlMeta)
LOGGER.Debug("Metadata IndexName: [{0}]", oMeta.IndexName)
LOGGER.Debug("Metadata IndexType: [{0}]", oMeta.IndexType)
LOGGER.Debug("Checking Control Name matches..")
If oMeta Is Nothing Then
LOGGER.Warn("No Metadata found for control [{0}]. Skipping.", oControl.Name)
Continue For
End If
If oMeta.IndexName = controlName Then
LOGGER.Debug("Control Name matches! Matching Control: [{0}]", controlName)
@@ -194,6 +206,8 @@ Public Class ClassPatterns
If oFoundControl IsNot Nothing Then
Dim oValue As String = String.Empty
LOGGER.Debug("Found Control [{0}], continuing with setting value..", oFoundControl.Name)
If TypeOf oFoundControl Is TextBox Then
Try
oValue = DirectCast(oFoundControl, TextBox).Text
@@ -219,6 +233,8 @@ Public Class ClassPatterns
Case "VARCHAR"
Dim oWrapped = oLookupControl.SelectedValues.Select(Function(v) $"'{v}'")
oValue = String.Join(",", oWrapped)
Case Else
LOGGER.Warn("Lookup Control with [{0}] is not supported!", oFoundType)
End Select
Else
oValue = NotNull(oLookupControl.SelectedValues.Item(0), "")
@@ -228,10 +244,11 @@ Public Class ClassPatterns
LOGGER.Warn("Control Value for LookupControl2 [{0}] could not be retrieved!", oFoundControl.Name)
End Try
Else
LOGGER.Debug("Unknown Control type for type [{0}], setting value to empty string.", oFoundControl.Name)
oValue = ""
End If
LOGGER.Debug("Retrieved Value from Control [{0}] is: [{1}]", oFoundControl.Name, oValue)
LOGGER.Debug("Retrieved Value from Control [{0}] is: [{1}]", controlName, oValue)
result = ReplacePattern(result, PATTERN_CTRL, oValue)
Else