MS IDB GridControl with ConnID

This commit is contained in:
SchreiberM 2020-03-18 14:05:40 +01:00
parent ffa0017f4a
commit f713856975

View File

@ -666,7 +666,7 @@ Public Class frmValidator
pnldesigner.Controls.Clear()
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 AND T.LOAD_AFT_LOAD_CONTROL = 0 ORDER BY T.SEQUENCE"
oSQL = $"SELECT T1.GUID As CONTROL_ID, T1.PROFIL_ID, T.CONNECTION_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 AND T.LOAD_AFT_LOAD_CONTROL = 0 ORDER BY T.SEQUENCE"
DTGRID_COLUMNS_WITH_SQL = ClassDatabase.Return_Datatable(oSQL)
oSQL = $"SELECT T.* from TBPM_CONTROL_TABLE T, TBPM_PROFILE_CONTROLS T1 WHERE T.CONTROL_ID = T1.GUID AND T1.PROFIL_ID = {CURRENT_ProfilGUID} ORDER BY T.SEQUENCE"
DTGRID_COLUMNS = ClassDatabase.Return_Datatable(oSQL)
@ -1228,6 +1228,8 @@ Public Class frmValidator
Case "Override_Direct".ToUpper
Override = True
Finish_WFStep()
Case "Override incFinal".ToUpper
Finish_WFStep(False)
Case Else
MsgBox($"No configured action provided for onCustomButtonClick [{oAction}]", MsgBoxStyle.Exclamation, ADDITIONAL_TITLE)
LOGGER.Warn($"No configured action provided for onCustomButtonClick [{oAction}]")
@ -1624,6 +1626,7 @@ Public Class frmValidator
If oSQLColumnDatatable.Rows.Count > 0 Then
For Each oRow As DataRow In oSQLColumnDatatable.Rows
Dim oDEPENDING_GUID = DTGRID_COLUMNS_WITH_SQL.Rows(0).Item("CONTROL_ID")
Dim oCONNID = DTGRID_COLUMNS_WITH_SQL.Rows(0).Item("CONNECTION_ID")
Dim oDEPENDING_COLUMN = DTGRID_COLUMNS_WITH_SQL.Rows(0).Item("SPALTENNAME")
Dim oSqlCommand = DTGRID_COLUMNS_WITH_SQL.Rows(0).Item("SQL_COMMAND")
If _dependingColumn_in_action = True Then
@ -1633,14 +1636,19 @@ Public Class frmValidator
_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)
_dependingColumn_in_action = False
Exit For
End If
Next
Dim oDTDEPENDING_RESULT As DataTable = ClassDatabase.Return_Datatable_ConId(oSqlCommand, oCONNID)
If Not IsNothing(oDTDEPENDING_RESULT) Then
LOGGER.Debug($"Trying to fill the DropDown (DC) for GridColumnGuid [{oDEPENDING_GUID}]..RowCount: [{oDTDEPENDING_RESULT.Rows.Count}] ")
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)
_dependingColumn_in_action = False
Exit For
End If
Next
End If
Catch ex As Exception
LOGGER.Error(ex)
_dependingColumn_in_action = False
@ -2659,22 +2667,26 @@ Public Class frmValidator
For Each oRow As DataRow In DTGRID_SQL_DEFINITION.Rows
Dim oDEPENDING_GUID = oRow.Item("CONTROL_ID")
Dim oDEPENDING_COLUMN = oRow.Item("SPALTENNAME")
Dim oCONNID = oRow.Item("CONNECTION_ID")
Dim oSqlCommand = oRow.Item("SQL_COMMAND")
Dim oCONNID = oRow.Item("CONNECTION_ID")
oSqlCommand = clsPatterns.ReplaceAllValues(oSqlCommand, pnldesigner, Nothing, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_LANGUAGE, USER_EMAIL, USER_ID, CURRENT_CLICKED_PROFILE_ID)
Try
Dim oDTDEPENDING_RESULT As DataTable = ClassDatabase.Return_Datatable_ConId(oSqlCommand, oCONNID)
If Not IsNothing(oDTDEPENDING_RESULT) Then
Dim oDTRESULT_FOR_COLUMN As DataTable = ClassDatabase.Return_Datatable_ConId(oSqlCommand, oCONNID)
If Not IsNothing(oDTRESULT_FOR_COLUMN) Then
LOGGER.Debug($"Trying to create a DropDown(FI) for GridColumnGuid [{oDEPENDING_GUID}]..RowCount: [{oDTRESULT_FOR_COLUMN.Rows.Count}] ")
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)
ClassControlCreator.GridTables.Add(oDEPENDING_COLUMN, oDTRESULT_FOR_COLUMN)
Exit For
End If
Next
Else
LOGGER.Warn($"oDTRESULT_FOR_COLUMN is nothing!")
End If
Catch ex As Exception
LOGGER.Warn($"Unexpected error in creating dropdown for oDEPENDING_GUID {oDEPENDING_GUID} an Column {oDEPENDING_COLUMN} " & ex.Message)
LOGGER.Warn($"Unexpected error in creating dropdown(FI) for oDEPENDING_GUID {oDEPENDING_GUID} an Column {oDEPENDING_COLUMN} " & ex.Message)
End Try
Next
@ -2849,7 +2861,7 @@ Public Class frmValidator
Return False
End Try
End Function
Sub Finish_WFStep()
Sub Finish_WFStep(Optional includeFI As Boolean = True)
btnSave.Enabled = False
LOGGER.Debug("Abschluss für Dok: " & CURRENT_DOC_PATH & " gestartet")
ItemWorked = True
@ -2864,81 +2876,89 @@ Public Class frmValidator
End If
End If
'lblerror.Visible = False
Try
TBPM_PROFILE_FINAL_INDEXINGTableAdapter.Fill(FinalIndexDataSet.TBPM_PROFILE_FINAL_INDEXING, CURRENT_ProfilName)
Dim oDTFinalIndexes As DataTable = FinalIndexDataSet.TBPM_PROFILE_FINAL_INDEXING
If oDTFinalIndexes?.Rows.Count > 0 Then
'Jetzt finale Indexe setzen
LOGGER.Debug("FINAL INDEXING STARTING...")
For Each oFinalIndexRow As DataRow In oDTFinalIndexes.Rows
Dim oValue As String = oFinalIndexRow.Item("VALUE").ToString
Dim oIndexType = 0
If oValue.ToUpper = "SQL-Command".ToUpper Then '###### Indexierung mit variablen SQL ###
LOGGER.Debug("Indexing wih dynamic sql...")
Dim oSQLCommand = oFinalIndexRow.Item("SQL_COMMAND")
If includeFI = True Then
Try
TBPM_PROFILE_FINAL_INDEXINGTableAdapter.Fill(FinalIndexDataSet.TBPM_PROFILE_FINAL_INDEXING, CURRENT_ProfilName)
Dim oDTFinalIndexes As DataTable = FinalIndexDataSet.TBPM_PROFILE_FINAL_INDEXING
If oDTFinalIndexes?.Rows.Count > 0 Then
'Jetzt finale Indexe setzen
LOGGER.Debug("FINAL INDEXING STARTING...")
For Each oFinalIndexRow As DataRow In oDTFinalIndexes.Rows
Dim oValue As String = oFinalIndexRow.Item("VALUE").ToString
Dim oIndexType = 0
oSQLCommand = clsPatterns.ReplaceAllValues(oSQLCommand, pnldesigner, Nothing, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_LANGUAGE, USER_EMAIL, USER_ID, CURRENT_CLICKED_PROFILE_ID)
If IsNothing(oSQLCommand) Then
errormessage = "Error while replacing Values in final indexing - Check the log"
If oValue.ToUpper = "SQL-Command".ToUpper Then '###### Indexierung mit variablen SQL ###
LOGGER.Debug("Indexing wih dynamic sql...")
Dim oSQLCommand = oFinalIndexRow.Item("SQL_COMMAND")
oSQLCommand = clsPatterns.ReplaceAllValues(oSQLCommand, pnldesigner, Nothing, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_LANGUAGE, USER_EMAIL, USER_ID, CURRENT_CLICKED_PROFILE_ID)
If IsNothing(oSQLCommand) Then
errormessage = "Error while replacing Values in final indexing - Check the log"
My.Settings.Save()
frmError.ShowDialog()
oErrorOcurred = True
ItemWorked = False
End If
If Not IsNothing(oSQLCommand) Then
Dim oResultfromSQL = ClassDatabase.Execute_Scalar(oSQLCommand, CONNECTION_STRING, True)
If Not IsNothing(oResultfromSQL) Then
LOGGER.Debug($"oResultfromSQL is [{oResultfromSQL.ToString}]")
oValue = oResultfromSQL
Else
LOGGER.Info("ATTENTION: DYNAMIC VALUE IS NOTHING!")
End If
End If
Else
If oValue.StartsWith("v") Then
Select Case oFinalIndexRow.Item("VALUE").ToString
Case "vDate"
oValue = Now.ToShortDateString
Case "vUserName"
oValue = USER_USERNAME
Case Else
oValue = oFinalIndexRow.Item("VALUE")
End Select
End If
End If
If oErrorOcurred Then
Exit For
End If
Dim oResult() As String
ReDim Preserve oResult(0)
oResult(0) = oValue
LOGGER.Debug($"oIndexType {oIndexType.ToString}")
LOGGER.Debug("Now the final indexing...")
Dim oFIResult As Boolean = False
If IDBData.SetVariableValue(oFinalIndexRow.Item("INDEXNAME"), oValue) = True Then
oFIResult = True
LOGGER.Debug("Final index IDB '" & oFinalIndexRow.Item("INDEXNAME") & "' was updated.")
End If
If oFIResult = False Then
errormessage = "Error in final indexing:" & vbNewLine & idxerr_message
My.Settings.Save()
frmError.ShowDialog()
oErrorOcurred = True
ItemWorked = False
End If
If Not IsNothing(oSQLCommand) Then
Dim oResultfromSQL = ClassDatabase.Execute_Scalar(oSQLCommand, CONNECTION_STRING, True)
If Not IsNothing(oResultfromSQL) Then
LOGGER.Debug($"oResultfromSQL is [{oResultfromSQL.ToString}]")
oValue = oResultfromSQL
Else
LOGGER.Info("ATTENTION: DYNAMIC VALUE IS NOTHING!")
End If
If oErrorOcurred = True Then
ItemWorked = False
Exit For
End If
Next
End If
Catch ex As Exception
LOGGER.Warn($"Error in finalIndexing: {ex.Message}")
oErrorOcurred = True
End Try
End If
Try
Else
If oValue.StartsWith("v") Then
Select Case oFinalIndexRow.Item("VALUE").ToString
Case "vDate"
oValue = Now.ToShortDateString
Case "vUserName"
oValue = USER_USERNAME
Case Else
oValue = oFinalIndexRow.Item("VALUE")
End Select
End If
End If
If oErrorOcurred Then
Exit For
End If
Dim oResult() As String
ReDim Preserve oResult(0)
oResult(0) = oValue
LOGGER.Debug($"oIndexType {oIndexType.ToString}")
LOGGER.Debug("Now the final indexing...")
Dim oFIResult As Boolean = False
If IDBData.SetVariableValue(oFinalIndexRow.Item("INDEXNAME"), oValue) = True Then
oFIResult = True
LOGGER.Debug("Final index IDB '" & oFinalIndexRow.Item("INDEXNAME") & "' was updated.")
End If
If oFIResult = False Then
errormessage = "Error in final indexing:" & vbNewLine & idxerr_message
My.Settings.Save()
frmError.ShowDialog()
oErrorOcurred = True
ItemWorked = False
End If
If oErrorOcurred = True Then
ItemWorked = False
Exit For
End If
Next
End If
''Wenn kein Fehler nach der finalen Indexierung gesetzt wurde
If Override = True And Override_SQLCommand <> "" Then
ClassDatabase.Execute_non_Query(Override_SQLCommand)