This commit is contained in:
2019-12-10 17:27:39 +01:00
parent 5babf515ee
commit ad1611802a
29 changed files with 4212 additions and 3310 deletions

View File

@@ -52,6 +52,8 @@ Public Class frmValidator
Private _frmValidatorSearch As frmValidatorSearch 'You need a reference to Form1
Private _dependingControl_in_action As Boolean = False
Private _dependingColumn_in_action As Boolean = False
Private _SetControlValue_in_action As Boolean = False
Private DTCONTROLS As DataTable
Private DTGRID_COLUMNS As DataTable
Private DTVWCONTROL_INDEX As DataTable
@@ -193,9 +195,9 @@ Public Class frmValidator
MsgBox("Error loading final profile text:" & vbNewLine & ex.Message, MsgBoxStyle.Critical, "Attention:")
LOGGER.Info(">> Error loading final profile text: " & ex.Message, True)
End Try
ToolStripButtonJumpFile.Enabled = True
ToolStripButtonJumpFile.Visible = True
If CURRENT_JUMP_DOC_GUID <> 0 Then
ToolStripButtonJumpFile.Enabled = False
ToolStripButtonJumpFile.Visible = False
Anzahl_ValDoks = 1
Else
@@ -219,7 +221,11 @@ Public Class frmValidator
Else
ToolStripButtonDeleteFile.Enabled = False
End If
If CBool(CURRENT_DT_PROFILE.Rows(0).Item("ANNOTATE_WORK_HISTORY_ENTRY")) = True Then
ToolStripButtonAnnotation.Visible = True
Else
ToolStripButtonAnnotation.Visible = False
End If
LOGGER.Debug("Right_Delete: " & USER_RIGHT_FILE_DELETE.ToString)
Create_Controls()
@@ -393,7 +399,7 @@ Public Class frmValidator
End If
If oDataResultsExist = True Or oDocResultsExist = True Then
ToolStripButtonSearchesReload.Enabled = True
ToolStripButtonSearchesReload.Visible = True
frmValidatorSearch.Show()
_frmValidatorSearch = frmValidatorSearch
Dim oPnl1Collapsed As Boolean = True
@@ -428,27 +434,36 @@ Public Class frmValidator
End If
Else
LOGGER.Info("Not loading AdditionalSearches...!")
ToolStripButtonSearchesReload.Enabled = False
ToolStripButtonSearchesReload.Visible = False
End If
Else
LOGGER.Info("Not loading AdditionalSearches...!")
ToolStripButtonSearchesReload.Enabled = False
ToolStripButtonSearchesReload.Visible = False
End If
End Sub
Sub LoadSQLData(control As Control, controlId As Integer)
Try
If TypeOf control Is Label Then Exit Sub
Dim sql As String = $"SELECT NAME, CONNECTION_ID, SQL_UEBERPRUEFUNG FROM TBPM_PROFILE_CONTROLS WHERE GUID = {controlId} AND PROFIL_ID = {CURRENT_ProfilGUID} AND LEN(ISNULL(SQL_UEBERPRUEFUNG,'')) > 0 AND CTRL_TYPE <> 'BUTTON' AND SQL_UEBERPRUEFUNG NOT LIKE '%#WMI#%' AND SQL_UEBERPRUEFUNG NOT LIKE '%#CTRL#%'"
Dim dt As DataTable = ClassDatabase.Return_Datatable(sql)
Dim oSql As String = $"SELECT GUID,NAME, CONNECTION_ID, SQL_UEBERPRUEFUNG FROM TBPM_PROFILE_CONTROLS WHERE GUID = {controlId} AND PROFIL_ID = {CURRENT_ProfilGUID} AND LEN(ISNULL(SQL_UEBERPRUEFUNG,'')) > 0 AND CTRL_TYPE <> 'BUTTON'"
' And SQL_UEBERPRUEFUNG Not Like '%#WMI#%' AND SQL_UEBERPRUEFUNG NOT LIKE '%#CTRL#%'
Dim dt As DataTable = ClassDatabase.Return_Datatable(oSql)
If IsNothing(dt) Then Exit Sub
If dt.Rows.Count = 0 Then Exit Sub
For Each row As DataRow In dt.Rows
Dim name As String = row.Item("NAME")
If IsDBNull(row.Item("CONNECTION_ID")) Then Continue For
Dim oGUID As String = row.Item("GUID")
If clsPatterns.HasComplexPatterns(row.Item("SQL_UEBERPRUEFUNG")) Then
LOGGER.Debug($"SQL has complex patterns - GUID: {oGUID}")
Continue For
End If
If IsDBNull(row.Item("CONNECTION_ID")) Then
LOGGER.Info($"No CONNECTION_ID for SQL-Data - oGUID: {oGUID}")
Continue For
End If
If IsDBNull(row.Item("SQL_UEBERPRUEFUNG")) Then Continue For
Dim sqlStatement As String = row.Item("SQL_UEBERPRUEFUNG")
@@ -458,11 +473,11 @@ Public Class frmValidator
Continue For
End If
sql = clsPatterns.ReplaceUserValues(sqlStatement, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_LANGUAGE, USER_EMAIL, USER_ID, CURRENT_CLICKED_PROFILE_ID)
sql = clsPatterns.ReplaceInternalValues(sql)
LOGGER.Debug(">>> sql after ReplaceInternalValues: " & sql)
oSql = clsPatterns.ReplaceUserValues(sqlStatement, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_LANGUAGE, USER_EMAIL, USER_ID, CURRENT_CLICKED_PROFILE_ID)
oSql = clsPatterns.ReplaceInternalValues(oSql)
LOGGER.Debug(">>> sql after ReplaceInternalValues: " & oSql)
'sql = ClassPatterns.ReplaceInternalValues(sqlStatement)
dt = ClassDatabase.Return_Datatable_ConId(sql, connectionId)
dt = ClassDatabase.Return_Datatable_ConId(oSql, connectionId)
If IsNothing(dt) Then
MsgBox($"SQL-Query for control {control.Name} is invalid.")
@@ -557,7 +572,7 @@ Public Class frmValidator
Dim oControlInfo As String
Try
pnldesigner.Controls.Clear()
Dim oSQL = $"SELECT [dbo].[FNPM_LANGUAGE_CONTROL_TEXT] (1,'{USER_LANGUAGE}',CTRL_TEXT) CTRL_CAPTION_LANG, * FROM TBPM_PROFILE_CONTROLS WHERE PROFIL_ID = {CURRENT_ProfilGUID} ORDER BY Y_LOC, X_LOC"
Dim oSQL = $"SELECT [dbo].[FNPM_LANGUAGE_CONTROL_TEXT] (NAME,'{USER_LANGUAGE}',CTRL_TYPE,CTRL_TEXT) CTRL_CAPTION_LANG, * FROM TBPM_PROFILE_CONTROLS WHERE PROFIL_ID = {CURRENT_ProfilGUID} ORDER BY Y_LOC, X_LOC"
DTCONTROLS = ClassDatabase.Return_Datatable(oSQL)
oSQL = $"SELECT T1.GUID As CONTROL_ID, T1.PROFIL_ID, T.SQL_COMMAND, T.SPALTENNAME from TBPM_CONTROL_TABLE T, TBPM_PROFILE_CONTROLS T1 WHERE T.CONTROL_ID = T1.GUID AND T1.PROFIL_ID = {CURRENT_ProfilGUID} AND LEN(T.SQL_COMMAND) > 0"
DTGRID_COLUMNS = ClassDatabase.Return_Datatable(oSQL)
@@ -781,6 +796,15 @@ Public Class frmValidator
'AddHandler lookup.EditValueChanged, AddressOf onLookUp1
AddHandler lookup.SelectedValuesChanged, AddressOf onLookUpselectedValue
End If
filteredData = DTCONTROLS.Clone()
oExpression = $"GUID = {oControlRow.Item("GUID")} and Len(SET_CONTROL_DATA) > 0"
DTCONTROLS.Select(oExpression).CopyToDataTable(filteredData, LoadOption.PreserveChanges)
If filteredData.Rows.Count = 1 Then
'AddHandler lookup.EditValueChanged, AddressOf onLookUp1
AddHandler lookup.SelectedValuesChanged, AddressOf onLookUpselectedValue_Control2Set
End If
filteredData = DTCONTROLS.Clone()
End If
AddHandler lookup.GotFocus, Sub(sender As Control, e As EventArgs)
@@ -1195,7 +1219,7 @@ Public Class frmValidator
End Try
End Sub
Public Sub onLookUpselectedValue(sender As Object, SelectedValues As List(Of String))
LOGGER.Debug("onLookup1")
LOGGER.Debug("onLookUpselectedValue")
If FormLoaded = False Then
Exit Sub
End If
@@ -1205,41 +1229,216 @@ Public Class frmValidator
If SelectedValues.Count = 1 Then
LookupControl_DependingControls(oLookup, SelectedValues)
LookupControl_DependingColumn(oLookup, SelectedValues)
Else
LOGGER.Debug("Uups: SelectedValues.Count <> 1 ")
End If
End If
Catch ex As Exception
LOGGER.Error(ex)
End Try
End Sub
Public Sub onLookUpselectedValue_Control2Set(sender As Object, SelectedValues As List(Of String))
LOGGER.Debug("onLookUpselectedValue_Control2Set")
If FormLoaded = False Then
Exit Sub
End If
Dim oLookup As LookupControl2 = sender
Try
If Not IsNothing(SelectedValues) Then
If SelectedValues.Count = 1 Then
SetControlValues(oLookup, SelectedValues)
Else
LOGGER.Debug("Uups2: SelectedValues.Count <> 1 ")
End If
End If
Catch ex As Exception
LOGGER.Error(ex)
End Try
End Sub
Private Sub SetControlValues(LookupControl As LookupControl2, SelectedValues As List(Of String))
Dim oLOOKUPValue = SelectedValues.Item(0)
Dim oLOOKUPName = LookupControl.Name
LOGGER.Debug($"oLOOKUPValue is [{oLOOKUPValue}]!")
Dim oControlID = DirectCast(LookupControl.Tag, ClassControlCreator.ControlMetadata).Guid
Dim oFilteredDatatable As DataTable = DTCONTROLS.Clone()
Dim oExpression = $"GUID = {oControlID} and LEN(SET_CONTROL_DATA) > 0"
DTCONTROLS.Select(oExpression).CopyToDataTable(oFilteredDatatable, LoadOption.PreserveChanges)
If oFilteredDatatable.Rows.Count = 1 Then
LOGGER.Debug($"We got a definition for SetControlValues!!")
Else
Exit Sub
End If
Dim oControl2Set
Dim oControlGUID2Set = oControlID
Dim oControlname2Set = oFilteredDatatable.Rows(0).Item("NAME")
LOGGER.Debug($"Workin on SetControLValue for {oControlname2Set} ...")
If _SetControlValue_in_action = True Then
LOGGER.Debug($"..but _SetControlValue_in_action = True ==> Exit Sub!")
Exit Sub
End If
If Not IsDBNull(oFilteredDatatable.Rows(0).Item("CONNECTION_ID")) And Not IsDBNull(oFilteredDatatable.Rows(0).Item("SET_CONTROL_DATA")) Then
Dim oSqlCommand = IIf(IsDBNull(oFilteredDatatable.Rows(0).Item("SET_CONTROL_DATA")), "", oFilteredDatatable.Rows(0).Item("SET_CONTROL_DATA"))
oSqlCommand = clsPatterns.ReplaceAllValues(oSqlCommand, pnldesigner, CURRENT_WMFILE, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_LANGUAGE, USER_EMAIL, USER_ID, CURRENT_CLICKED_PROFILE_ID)
_SetControlValue_in_action = True
Dim oDTDEPENDING_RESULT As DataTable = ClassDatabase.Return_Datatable(oSqlCommand)
For Each oRowControl2Set As DataRow In oDTDEPENDING_RESULT.Rows
Try
oControl2Set = oRowControl2Set.Item("Control2Set")
If oControl2Set.ToString.ToUpper = "BTN_FINISH".ToUpper Then
Try
Try
Dim btntext = oRowControl2Set.Item("Caption")
btnSave.Text = btntext & " (F2)"
Catch ex As Exception
End Try
Try
Dim oColor1 = System.Drawing.Color.FromName(oRowControl2Set.Item("BackgroundColor"))
btnSave.BackColor = oColor1
Catch ex As Exception
btnSave.BackColor = Color.Transparent
End Try
Try
Dim oColor2 = System.Drawing.Color.FromName(oRowControl2Set.Item("FontColor"))
btnSave.ForeColor = oColor2
Catch ex As Exception
btnSave.ForeColor = Color.Black
End Try
Catch ex As Exception
End Try
_SetControlValue_in_action = False
Continue For
End If
Dim oFound As Boolean = False
If IsNumeric(oControl2Set) = False Then
LOGGER.Warn("Careful: the oControl2Set contains no CONTROL_GUID")
Exit Sub
End If
'Dim oDependingLookup As LookupControl2 = pnldesigner.Controls.Find(oDEPENDING_CtrlName, False).FirstOrDefault()
For Each oControl As Control In pnldesigner.Controls
If DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).Guid = oControl2Set Then
oFound = True
LOGGER.Debug($"Got the Control22Set: {oControl2Set}..Setting the values..")
Select Case oControl.GetType.ToString
Case GetType(TextBox).ToString
Try
Dim oTEXT = oRowControl2Set.Item("Caption")
oControl.Text = oControl.Text & oTEXT
Catch ex As Exception
End Try
Dim oColor
Try
oColor = System.Drawing.Color.FromName(oRowControl2Set.Item("BackgroundColor"))
oControl.BackColor = oColor
Catch ex As Exception
oControl.BackColor = Color.White
End Try
Try
oColor = System.Drawing.Color.FromName(oRowControl2Set.Item("FontColor"))
oControl.ForeColor = oColor
Catch ex As Exception
oControl.ForeColor = Color.Black
End Try
Case GetType(LookupControl2).ToString
Dim oDependingLookup As LookupControl2 = oControl
oDependingLookup.DataSource = oDTDEPENDING_RESULT
Case GetType(GridControl).ToString
'ClassControlCreator.GridTables
End Select
_SetControlValue_in_action = False
Exit For
End If
Next
If oFound = False Then
LOGGER.Debug($"Could not find the Control2Set with ID {oControlGUID2Set} on panel!!!")
End If
Catch ex As Exception
LOGGER.Warn($"Error while Control2Set for [{oControlname2Set}]: " & ex.Message)
_SetControlValue_in_action = False
End Try
Next
Else
LOGGER.Debug($"Error: Check CoNN ID and SQL on NULL VALUES!")
End If
End Sub
Private Sub LookupControl_DependingControls(LookupControl As LookupControl2, SelectedValues As List(Of String))
Dim oLOOKUPValue = SelectedValues.Item(0)
Dim oLOOKUPName = LookupControl.Name
LOGGER.Debug($"oLOOKUPValue is [{oLOOKUPValue}]!")
Dim oControlID = DirectCast(LookupControl.Tag, ClassControlCreator.ControlMetadata).Guid
Dim oFilteredDatatable As DataTable = DTCONTROLS.Clone()
Dim oExpression = $"SQL_UEBERPRUEFUNG like '%#CTRL#{oLOOKUPName}%'"
DTCONTROLS.Select(oExpression).CopyToDataTable(oFilteredDatatable, LoadOption.PreserveChanges)
If oFilteredDatatable.Rows.Count = 1 Then
Dim oDEPENDING_GUID = oFilteredDatatable.Rows(0).Item("GUID")
Dim oDEPENDING_CtrlName = oFilteredDatatable.Rows(0).Item("NAME")
If oFilteredDatatable.Rows.Count > 0 Then
LOGGER.Debug($"We got {oFilteredDatatable.Rows.Count} depending controls!!")
Else
LOGGER.Debug($"Sorry NO depending controls!!")
End If
For Each oRowDependingControl As DataRow In oFilteredDatatable.Rows
Dim oDEPENDING_GUID = oRowDependingControl.Item("GUID")
Dim oDEPENDING_CtrlName = oRowDependingControl.Item("NAME")
LOGGER.Debug($"Control {oDEPENDING_CtrlName} is depending on lookUp {oLOOKUPName}..")
If _dependingControl_in_action = True Then
LOGGER.Debug($"..but _dependingControl_in_action = True ==> Exit Sub!")
Exit Sub
End If
If Not IsDBNull(oFilteredDatatable.Rows(0).Item("CONNECTION_ID")) And Not IsDBNull(oFilteredDatatable.Rows(0).Item("SQL_UEBERPRUEFUNG")) Then
Dim oSqlCommand = IIf(IsDBNull(oFilteredDatatable.Rows(0).Item("SQL_UEBERPRUEFUNG")), "", oFilteredDatatable.Rows(0).Item("SQL_UEBERPRUEFUNG"))
If Not IsDBNull(oRowDependingControl.Item("CONNECTION_ID")) And Not IsDBNull(oRowDependingControl.Item("SQL_UEBERPRUEFUNG")) Then
Dim oSqlCommand = IIf(IsDBNull(oRowDependingControl.Item("SQL_UEBERPRUEFUNG")), "", oRowDependingControl.Item("SQL_UEBERPRUEFUNG"))
oSqlCommand = clsPatterns.ReplaceAllValues(oSqlCommand, pnldesigner, CURRENT_WMFILE, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_LANGUAGE, USER_EMAIL, USER_ID, CURRENT_CLICKED_PROFILE_ID)
LOGGER.Debug(">>> sql after ReplaceAllValues: " & oSqlCommand)
_dependingControl_in_action = True
Dim oDTDEPENDING_RESULT As DataTable = ClassDatabase.Return_Datatable(oSqlCommand)
Try
Dim oFound As Boolean = False
'Dim oDependingLookup As LookupControl2 = pnldesigner.Controls.Find(oDEPENDING_CtrlName, False).FirstOrDefault()
For Each oControl As Control In pnldesigner.Controls
If DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).Guid = oDEPENDING_GUID Then
oFound = True
LOGGER.Debug($"Got the depending control ID:{oDEPENDING_GUID}..Setting the values..")
Select Case oControl.GetType.ToString
Case GetType(TextBox).ToString
oControl.Text = oDTDEPENDING_RESULT.Rows(0).Item(0)
Try
Dim oTEXT = oDTDEPENDING_RESULT.Rows(0).Item(0)
Try
If Not IsNothing(oTEXT) Then
If Not IsDBNull(oTEXT) Then
oControl.Text = oTEXT
End If
End If
Catch ex As Exception
LOGGER.Warn($"Unexpected error in Checking oTEXT: {ex.Message}")
End Try
Catch ex As Exception
LOGGER.Warn($"Unexpected error in Dim oTEXT = oDTDEPENDING_RESULT.Rows(0).Item(0): {ex.Message}")
End Try
Dim oColor
Try
oColor = System.Drawing.Color.FromName(oDTDEPENDING_RESULT.Rows(0).Item("BackgroundColor"))
oControl.BackColor = oColor
Catch ex As Exception
oControl.BackColor = Color.White
End Try
Try
Dim btntext = oDTDEPENDING_RESULT.Rows(0).Item("btnFinishCaption")
btnSave.Text = btntext & " (F2)"
Catch ex As Exception
End Try
Try
oColor = System.Drawing.Color.FromName(oDTDEPENDING_RESULT.Rows(0).Item("btnFinishColor"))
btnSave.BackColor = oColor
Catch ex As Exception
btnSave.BackColor = Color.Transparent
End Try
Case GetType(LookupControl2).ToString
Dim oDependingLookup As LookupControl2 = oControl
oDependingLookup.DataSource = oDTDEPENDING_RESULT
@@ -1253,14 +1452,24 @@ Public Class frmValidator
Next
If oFound = False Then
LOGGER.Debug($"Could not find the depending Control with ID {oDEPENDING_GUID} on panel!!!")
End If
Catch ex As Exception
LOGGER.Warn($"Error while setting depending control-value for [{oDEPENDING_CtrlName}]: " & ex.Message)
_dependingControl_in_action = False
End Try
SendKeys.Send("{TAB}")
ControlHandleStarted = True
Else
LOGGER.Debug($"Error: Check CoNN ID and SQL on NULL VALUES!")
End If
Next
If oFilteredDatatable.Rows.Count = 1 Then
End If
End Sub
Private Sub LookupControl_DependingColumn(LookupControl As LookupControl2, SelectedValues As List(Of String))
@@ -1272,24 +1481,24 @@ Public Class frmValidator
Dim oDEPENDING_GUID = DTGRID_COLUMNS.Rows(0).Item("CONTROL_ID")
Dim oDEPENDING_COLUMN = DTGRID_COLUMNS.Rows(0).Item("SPALTENNAME")
Dim oSqlCommand = DTGRID_COLUMNS.Rows(0).Item("SQL_COMMAND")
If _dependingControl_in_action = True Then
If _dependingColumn_in_action = True Then
Exit Sub
End If
oSqlCommand = clsPatterns.ReplaceAllValues(oSqlCommand, pnldesigner, CURRENT_WMFILE, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_LANGUAGE, USER_EMAIL, USER_ID, CURRENT_CLICKED_PROFILE_ID)
LOGGER.Debug(">>> sql after ReplaceAllValues: " & oSqlCommand)
_dependingControl_in_action = True
_dependingColumn_in_action = True
Try
Dim oDTDEPENDING_RESULT As DataTable = ClassDatabase.Return_Datatable(oSqlCommand)
For Each oControl As Control In pnldesigner.Controls
If DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata).Guid = oDEPENDING_GUID Then
ClassControlCreator.GridTables.Add(oDEPENDING_COLUMN, oDTDEPENDING_RESULT)
_dependingControl_in_action = False
_dependingColumn_in_action = False
Exit For
End If
Next
Catch ex As Exception
LOGGER.Error(ex)
_dependingControl_in_action = False
_dependingColumn_in_action = False
End Try
Next
End If
@@ -1764,12 +1973,12 @@ Public Class frmValidator
errormessage = oErrorMessage
frmError.ShowDialog()
Else
LOGGER.Info("End of profile - no more document!")
LOGGER.Info("End of profile - no more documents!")
Dim oROW As DataRow = ClassAllgemeineFunktionen.GUI_LANGUAGE_MSGBOX("frmValidator.NoMoreDocument")
Try
MsgBox(oROW.Item("STRING1"), MsgBoxStyle.Information, oROW.Item("STRING2"))
Catch ex As Exception
MsgBox("No more document!" & vbNewLine & "Form will be closed now!", MsgBoxStyle.Information, "")
MsgBox("No more documents!" & vbNewLine & "Form will be closed now!", MsgBoxStyle.Information, "")
End Try
activate_controls(True)
Me.Close()
@@ -2453,6 +2662,8 @@ Public Class frmValidator
oColValuesfromSource = Split(oRow.Item(0).ToString, Delimiter)
Select Case oColValuesfromSource.Length
Case 1
oDataSource.Rows.Add(New String() {oColValuesfromSource(0)})
Case 2
oDataSource.Rows.Add(New String() {oColValuesfromSource(0), oColValuesfromSource(1)})
Case 3
@@ -2761,6 +2972,7 @@ Public Class frmValidator
' Refresh_FileList()
Load_Next_Document(True)
_dependingControl_in_action = False
_dependingColumn_in_action = False
BringToFront()
FormLoaded = True
End Sub
@@ -4062,7 +4274,7 @@ Public Class frmValidator
Try
LOGGER.Debug("Dokument überspringen")
'Das Dokument freigeben
Free_File()
Dim oSQL = $"EXECUTE PRPM_FILES_NOT_INDEXED '{USER_USERNAME}',{CURRENT_ProfilGUID},'{WMDocPathWindows}',{CURRENT_DOC_GUID}"
ClassDatabase.Execute_non_Query(oSQL)