Prepare Refactor of frmValidator, add logger for Validator
This commit is contained in:
parent
011aad712b
commit
b03e11937b
@ -1,4 +1,5 @@
|
|||||||
Imports System
|
Imports System.Resources
|
||||||
|
Imports System
|
||||||
Imports System.Reflection
|
Imports System.Reflection
|
||||||
Imports System.Runtime.InteropServices
|
Imports System.Runtime.InteropServices
|
||||||
|
|
||||||
@ -33,3 +34,4 @@ Imports System.Runtime.InteropServices
|
|||||||
|
|
||||||
<Assembly: AssemblyVersion("2.4.6.0")>
|
<Assembly: AssemblyVersion("2.4.6.0")>
|
||||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||||
|
<Assembly: NeutralResourcesLanguage("")>
|
||||||
|
|||||||
@ -533,6 +533,7 @@
|
|||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
<DependentUpon>frmValidator_Strings.resx</DependentUpon>
|
<DependentUpon>frmValidator_Strings.resx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Validator\Validator.vb" />
|
||||||
<Compile Include="XtraReport1.Designer.vb">
|
<Compile Include="XtraReport1.Designer.vb">
|
||||||
<DependentUpon>XtraReport1.vb</DependentUpon>
|
<DependentUpon>XtraReport1.vb</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
164
app/TaskFlow/Validator/Validator.vb
Normal file
164
app/TaskFlow/Validator/Validator.vb
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
Imports System.Text.RegularExpressions
|
||||||
|
Imports DigitalData.Modules.Base
|
||||||
|
Imports DigitalData.Modules.Logging
|
||||||
|
|
||||||
|
Public Class Validator
|
||||||
|
Inherits BaseClass
|
||||||
|
|
||||||
|
Public Sub New(pLogConfig As LogConfig)
|
||||||
|
MyBase.New(pLogConfig)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Class ControlRow
|
||||||
|
Public Id As Integer
|
||||||
|
Public IndexName As String
|
||||||
|
Public Validation As Boolean
|
||||||
|
Public [ReadOnly] As Boolean
|
||||||
|
Public ValidationSql As String
|
||||||
|
Public RegexMatch As String
|
||||||
|
Public RegexMessage As String
|
||||||
|
Public OverwriteData As Boolean
|
||||||
|
Public SaveChangeEnabled As Boolean
|
||||||
|
End Class
|
||||||
|
|
||||||
|
Public Function ConvertToControlRow(pDataRow As DataRow) As ControlRow
|
||||||
|
Return New ControlRow With {
|
||||||
|
.Id = pDataRow.ItemEx("GUID", 0),
|
||||||
|
.IndexName = pDataRow.ItemEx("INDEX_NAME", ""),
|
||||||
|
.Validation = pDataRow.ItemEx("VALIDATION", False),
|
||||||
|
.[ReadOnly] = pDataRow.ItemEx("READ_ONLY", False),
|
||||||
|
.ValidationSql = pDataRow.ItemEx("SQL_UEBERPRUEFUNG", ""),
|
||||||
|
.RegexMatch = pDataRow.ItemEx("REGEX_MATCH", ""),
|
||||||
|
.RegexMessage = pDataRow.ItemEx("REGEX_MESSAGE_DE", ""),
|
||||||
|
.OverwriteData = pDataRow.ItemEx("OVERWRITE_DATA", False),
|
||||||
|
.SaveChangeEnabled = pDataRow.ItemEx("SAVE_CHANGE_ON_ENABLED", True)
|
||||||
|
}
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Function CheckTextbox(oControl As Control, pControlRow As DataRow)
|
||||||
|
Try
|
||||||
|
Dim oControlRow = ConvertToControlRow(pControlRow)
|
||||||
|
|
||||||
|
'Dim oWrongInputMessage = ClassAllgemeineFunktionen.GUI_LANGUAGE_INFO("frmValidator.WrongInputControl")
|
||||||
|
Dim oWrongInputMessage = S.Falsche_Eingabe
|
||||||
|
|
||||||
|
If oControlRow.RegexMatch <> String.Empty AndAlso Not Regex.IsMatch(oControl.Text, oControlRow.RegexMatch) Then
|
||||||
|
oMissing = True
|
||||||
|
|
||||||
|
oErrMsgMissingInput = oWrongInputMessage & " textbox '" & oControl.Name & "'"
|
||||||
|
|
||||||
|
Logger.Warn(oErrMsgMissingInput)
|
||||||
|
If oControlRow.RegexMessage <> String.Empty Then
|
||||||
|
oErrMsgMissingInput &= ":" & vbCrLf & oControlRow.RegexMessage
|
||||||
|
End If
|
||||||
|
|
||||||
|
oControl.BackColor = Color.Red
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
|
||||||
|
'as erstes überprüfen ob überhaupt etwas eingetragen worden ist
|
||||||
|
If Check_Missing_Control_Value(oControl, "txt") = True And oIsRequired = True Then 'NICHTS EINGETRAGEN
|
||||||
|
oMissing = True
|
||||||
|
oErrMsgMissingInput = oWrongInputMessage & " textbox '" & oControl.Name & "'"
|
||||||
|
Logger.Warn(oErrMsgMissingInput)
|
||||||
|
oControl.BackColor = Color.Red
|
||||||
|
Exit For
|
||||||
|
Else
|
||||||
|
Dim oTextEdit As TextEdit = DirectCast(oControl, TextEdit)
|
||||||
|
oMyInput = ClassFormat.GetStringValue(oTextEdit.EditValue)
|
||||||
|
|
||||||
|
'den aktuellen Wert in windream auslesen
|
||||||
|
Dim oSourceValue = GetVariableValuefromSource(oIndexName, oIDBTyp)
|
||||||
|
|
||||||
|
|
||||||
|
If oIndexName.StartsWith("[%VKT") Then
|
||||||
|
oSourceValue = ReturnVektor_IndexValue(oIndexName)
|
||||||
|
Else
|
||||||
|
'wertWD = CURRENT_WMFILE.GetVariableValue(oIndexName)
|
||||||
|
If Not IsNothing(oSourceValue) Then
|
||||||
|
If oSourceValue.ToString = "System.Object[]" Then
|
||||||
|
If oSourceValue.Length = 1 Then
|
||||||
|
oSourceValue = oSourceValue(0)
|
||||||
|
Else '
|
||||||
|
Logger.Info(" >> Vectorfield " & oIndexName & "' contains more then one value - First value will be used")
|
||||||
|
oSourceValue = oSourceValue(0)
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
oSourceValue = ""
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
Dim oSetValue As Boolean = False
|
||||||
|
If IsDBNull(oSourceValue) Then
|
||||||
|
oSetValue = True
|
||||||
|
End If
|
||||||
|
If oSetValue = False Then
|
||||||
|
If IsNothing(oSourceValue) Then
|
||||||
|
oSetValue = True
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
If oSetValue = False Then
|
||||||
|
Try
|
||||||
|
If oSourceValue <> oMyInput Then
|
||||||
|
oSetValue = True
|
||||||
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
oSetValue = True
|
||||||
|
End Try
|
||||||
|
|
||||||
|
End If
|
||||||
|
'wenn Wert in Windream <> der Eingabe darf indexiert werden
|
||||||
|
If oSetValue = True Then
|
||||||
|
'Wenn der Wert in ein Vektorfeld geschrieben wird
|
||||||
|
If oIndexName.StartsWith("[%VKT") Then
|
||||||
|
oMyInput = Return_PM_VEKTOR(oMyInput, oIndexName)
|
||||||
|
'Hier muss nun separat as Vektorfeld indexiert werden
|
||||||
|
If WMIndexVectofield(oMyInput, PROFIL_VEKTORINDEX) = True Then
|
||||||
|
oMissing = True
|
||||||
|
oErrMsgMissingInput = "Error while indexing textbox as VEKTOR - ERROR: " & idxerr_message
|
||||||
|
Logger.Warn(oErrMsgMissingInput)
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
If IDB_ACTIVE = False Then
|
||||||
|
Dim result() As String
|
||||||
|
ReDim Preserve result(0)
|
||||||
|
result(0) = oMyInput
|
||||||
|
If Indexiere_File(CURRENT_WMFILE, oIndexName, result) = False Then
|
||||||
|
oMissing = True
|
||||||
|
oErrMsgMissingInput = "Error while indexing Textbox - ERROR: " & idxerr_message
|
||||||
|
Logger.Warn(oErrMsgMissingInput)
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
If IDBData.SetVariableValue(oIndexName, oMyInput) = False Then
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
If IDB_ACTIVE = False Then
|
||||||
|
If PROFIL_LOGINDEX <> "" Then
|
||||||
|
Dim oMyLogString = Return_LOGString(oMyInput, oSourceValue, oIndexName)
|
||||||
|
WMIndexVectofield(oMyLogString, PROFIL_LOGINDEX)
|
||||||
|
'Else
|
||||||
|
'IDBData.SetVariableValue(PROFIL_LOGINDEX, oMyLogString)
|
||||||
|
|
||||||
|
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
oErrMsgMissingInput = "Unexpected error in Check_UpdateIndexe TextBox '" & oControl.Name & "' - Check the log"
|
||||||
|
Logger.Error(ex)
|
||||||
|
Dim st As New StackTrace(True)
|
||||||
|
st = New StackTrace(ex, True)
|
||||||
|
Logger.Warn("Unexpected error in Check_UpdateIndexe TextBox :" & ex.Message, True)
|
||||||
|
Return False
|
||||||
|
End Try
|
||||||
|
End Function
|
||||||
|
End Class
|
||||||
@ -4274,6 +4274,7 @@ Public Class frmValidator
|
|||||||
|
|
||||||
'Readonly felder werden über finale indexe gefüllt, nicht mit SetControlData
|
'Readonly felder werden über finale indexe gefüllt, nicht mit SetControlData
|
||||||
If oIsReadOnly = True And oSaveChangeEnabledFalse = False Then
|
If oIsReadOnly = True And oSaveChangeEnabledFalse = False Then
|
||||||
|
Logger.Debug("ReadOnly field, Skipping.")
|
||||||
Continue For
|
Continue For
|
||||||
End If
|
End If
|
||||||
|
|
||||||
@ -4483,13 +4484,11 @@ Public Class frmValidator
|
|||||||
End Try
|
End Try
|
||||||
|
|
||||||
Case GetType(DevExpress.XtraEditors.TextEdit)
|
Case GetType(DevExpress.XtraEditors.TextEdit)
|
||||||
|
|
||||||
|
|
||||||
Try
|
Try
|
||||||
'Dim oWrongInputMessage = ClassAllgemeineFunktionen.GUI_LANGUAGE_INFO("frmValidator.WrongInputControl")
|
'Dim oWrongInputMessage = ClassAllgemeineFunktionen.GUI_LANGUAGE_INFO("frmValidator.WrongInputControl")
|
||||||
Dim oWrongInputMessage = S.Falsche_Eingabe
|
Dim oWrongInputMessage = S.Falsche_Eingabe
|
||||||
|
|
||||||
|
Logger.Debug("Validating Textbox..")
|
||||||
|
|
||||||
If oRegexMatch <> String.Empty AndAlso Not Regex.IsMatch(oControl.Text, oRegexMatch) Then
|
If oRegexMatch <> String.Empty AndAlso Not Regex.IsMatch(oControl.Text, oRegexMatch) Then
|
||||||
oMissing = True
|
oMissing = True
|
||||||
@ -4513,12 +4512,17 @@ Public Class frmValidator
|
|||||||
oControl.BackColor = Color.Red
|
oControl.BackColor = Color.Red
|
||||||
Exit For
|
Exit For
|
||||||
Else
|
Else
|
||||||
|
Logger.Debug("Reading current value from Textbox")
|
||||||
|
|
||||||
Dim oTextEdit As TextEdit = DirectCast(oControl, TextEdit)
|
Dim oTextEdit As TextEdit = DirectCast(oControl, TextEdit)
|
||||||
oMyInput = ClassFormat.GetStringValue(oTextEdit.EditValue)
|
oMyInput = ClassFormat.GetStringValue(oTextEdit.EditValue)
|
||||||
|
|
||||||
|
Logger.Debug("Form Value: [{0}]", oMyInput)
|
||||||
|
|
||||||
'den aktuellen Wert in windream auslesen
|
'den aktuellen Wert in windream auslesen
|
||||||
Dim oSourceValue = GetVariableValuefromSource(oIndexName, oIDBTyp)
|
Dim oSourceValue = GetVariableValuefromSource(oIndexName, oIDBTyp)
|
||||||
|
|
||||||
|
Logger.Debug("Current Value: [{0}]", oSourceValue)
|
||||||
|
|
||||||
If oIndexName.StartsWith("[%VKT") Then
|
If oIndexName.StartsWith("[%VKT") Then
|
||||||
oSourceValue = ReturnVektor_IndexValue(oIndexName)
|
oSourceValue = ReturnVektor_IndexValue(oIndexName)
|
||||||
@ -4554,8 +4558,10 @@ Public Class frmValidator
|
|||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
oSetValue = True
|
oSetValue = True
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
Logger.Debug("Preparing Indexing for Textbox")
|
||||||
|
|
||||||
'wenn Wert in Windream <> der Eingabe darf indexiert werden
|
'wenn Wert in Windream <> der Eingabe darf indexiert werden
|
||||||
If oSetValue = True Then
|
If oSetValue = True Then
|
||||||
'Wenn der Wert in ein Vektorfeld geschrieben wird
|
'Wenn der Wert in ein Vektorfeld geschrieben wird
|
||||||
@ -4573,6 +4579,9 @@ Public Class frmValidator
|
|||||||
Dim result() As String
|
Dim result() As String
|
||||||
ReDim Preserve result(0)
|
ReDim Preserve result(0)
|
||||||
result(0) = oMyInput
|
result(0) = oMyInput
|
||||||
|
|
||||||
|
Logger.Debug("Indexing Index [{0}] with value [{1}]", oMyInput, oIndexName)
|
||||||
|
|
||||||
If Indexiere_File(CURRENT_WMFILE, oIndexName, result) = False Then
|
If Indexiere_File(CURRENT_WMFILE, oIndexName, result) = False Then
|
||||||
oMissing = True
|
oMissing = True
|
||||||
oErrMsgMissingInput = "Error while indexing Textbox - ERROR: " & idxerr_message
|
oErrMsgMissingInput = "Error while indexing Textbox - ERROR: " & idxerr_message
|
||||||
@ -4590,15 +4599,9 @@ Public Class frmValidator
|
|||||||
WMIndexVectofield(oMyLogString, PROFIL_LOGINDEX)
|
WMIndexVectofield(oMyLogString, PROFIL_LOGINDEX)
|
||||||
'Else
|
'Else
|
||||||
'IDBData.SetVariableValue(PROFIL_LOGINDEX, oMyLogString)
|
'IDBData.SetVariableValue(PROFIL_LOGINDEX, oMyLogString)
|
||||||
|
|
||||||
|
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user