diff --git a/app/TaskFlow/My Project/AssemblyInfo.vb b/app/TaskFlow/My Project/AssemblyInfo.vb index e42023f..e3f03da 100644 --- a/app/TaskFlow/My Project/AssemblyInfo.vb +++ b/app/TaskFlow/My Project/AssemblyInfo.vb @@ -1,4 +1,5 @@ -Imports System +Imports System.Resources +Imports System Imports System.Reflection Imports System.Runtime.InteropServices @@ -33,3 +34,4 @@ Imports System.Runtime.InteropServices + diff --git a/app/TaskFlow/TaskFlow.vbproj b/app/TaskFlow/TaskFlow.vbproj index 8271227..5a61b3b 100644 --- a/app/TaskFlow/TaskFlow.vbproj +++ b/app/TaskFlow/TaskFlow.vbproj @@ -533,6 +533,7 @@ True frmValidator_Strings.resx + XtraReport1.vb diff --git a/app/TaskFlow/Validator/Validator.vb b/app/TaskFlow/Validator/Validator.vb new file mode 100644 index 0000000..7b2c494 --- /dev/null +++ b/app/TaskFlow/Validator/Validator.vb @@ -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 diff --git a/app/TaskFlow/frmValidator.vb b/app/TaskFlow/frmValidator.vb index 477a4c5..3e08830 100644 --- a/app/TaskFlow/frmValidator.vb +++ b/app/TaskFlow/frmValidator.vb @@ -4274,6 +4274,7 @@ Public Class frmValidator 'Readonly felder werden über finale indexe gefüllt, nicht mit SetControlData If oIsReadOnly = True And oSaveChangeEnabledFalse = False Then + Logger.Debug("ReadOnly field, Skipping.") Continue For End If @@ -4483,13 +4484,11 @@ Public Class frmValidator End Try Case GetType(DevExpress.XtraEditors.TextEdit) - - Try 'Dim oWrongInputMessage = ClassAllgemeineFunktionen.GUI_LANGUAGE_INFO("frmValidator.WrongInputControl") Dim oWrongInputMessage = S.Falsche_Eingabe - + Logger.Debug("Validating Textbox..") If oRegexMatch <> String.Empty AndAlso Not Regex.IsMatch(oControl.Text, oRegexMatch) Then oMissing = True @@ -4513,12 +4512,17 @@ Public Class frmValidator oControl.BackColor = Color.Red Exit For Else + Logger.Debug("Reading current value from Textbox") + Dim oTextEdit As TextEdit = DirectCast(oControl, TextEdit) oMyInput = ClassFormat.GetStringValue(oTextEdit.EditValue) + Logger.Debug("Form Value: [{0}]", oMyInput) + 'den aktuellen Wert in windream auslesen Dim oSourceValue = GetVariableValuefromSource(oIndexName, oIDBTyp) + Logger.Debug("Current Value: [{0}]", oSourceValue) If oIndexName.StartsWith("[%VKT") Then oSourceValue = ReturnVektor_IndexValue(oIndexName) @@ -4554,8 +4558,10 @@ Public Class frmValidator Catch ex As Exception oSetValue = True End Try - End If + + Logger.Debug("Preparing Indexing for Textbox") + 'wenn Wert in Windream <> der Eingabe darf indexiert werden If oSetValue = True Then 'Wenn der Wert in ein Vektorfeld geschrieben wird @@ -4573,6 +4579,9 @@ Public Class frmValidator Dim result() As String ReDim Preserve result(0) result(0) = oMyInput + + Logger.Debug("Indexing Index [{0}] with value [{1}]", oMyInput, oIndexName) + If Indexiere_File(CURRENT_WMFILE, oIndexName, result) = False Then oMissing = True oErrMsgMissingInput = "Error while indexing Textbox - ERROR: " & idxerr_message @@ -4590,15 +4599,9 @@ Public Class frmValidator WMIndexVectofield(oMyLogString, PROFIL_LOGINDEX) 'Else 'IDBData.SetVariableValue(PROFIL_LOGINDEX, oMyLogString) - - End If End If - End If - - - End If End If Catch ex As Exception