DigitalData.GUIs.Globix added
This commit is contained in:
@@ -6,6 +6,7 @@ Imports System.Security.AccessControl
|
||||
Imports System.Security.Principal
|
||||
Imports System.DirectoryServices
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Controls.LookupGrid
|
||||
|
||||
Public Class frmIndex
|
||||
#Region "+++++ Variablen ++++++"
|
||||
@@ -42,6 +43,14 @@ Public Class frmIndex
|
||||
|
||||
#End Region
|
||||
|
||||
Public Class DocType
|
||||
Public Property Guid
|
||||
Public Property Name
|
||||
|
||||
Public Overrides Function ToString() As String
|
||||
Return Name
|
||||
End Function
|
||||
End Class
|
||||
Private Sub ShowErrorMessage(Exception As Exception, MethodTitle As String, Optional MoreInfo As String = "")
|
||||
Dim oMessage As String
|
||||
Dim oMoreInfo As String = IIf(MoreInfo = "", "", "(" & MoreInfo & ")")
|
||||
@@ -1560,7 +1569,16 @@ Public Class frmIndex
|
||||
checkItemPreselection.Checked = True
|
||||
|
||||
If CURRENT_LASTDOKART <> "" Then
|
||||
cmbDokumentart.SelectedIndex = cmbDokumentart.FindStringExact(CURRENT_LASTDOKART)
|
||||
Dim oFoundDocType = ComboBoxEdit1.Properties.Items.
|
||||
Cast(Of DocType)().
|
||||
Where(Function(dt) dt.Name = CURRENT_LASTDOKART).
|
||||
FirstOrDefault()
|
||||
|
||||
If oFoundDocType IsNot Nothing Then
|
||||
ComboBoxEdit1.SelectedItem = oFoundDocType
|
||||
End If
|
||||
|
||||
'cmbDokumentart.SelectedIndex = cmbDokumentart.FindStringExact(CURRENT_LASTDOKART)
|
||||
End If
|
||||
Else
|
||||
If DTTBGI_REGEX_DOCTYPE.Rows.Count > 0 Then
|
||||
@@ -1570,7 +1588,17 @@ Public Class frmIndex
|
||||
|
||||
_Logger.Debug("There is a match on REGEX_DOCTYPE: [{0}]", oRoW.Item("DOCTYPE"))
|
||||
_Logger.Debug("Regex: [{0}], FileName: [{1}]", oRoW.Item("Regex"), oOnlyFilename)
|
||||
cmbDokumentart.SelectedIndex = cmbDokumentart.FindStringExact(oRoW.Item("DOCTYPE"))
|
||||
'cmbDokumentart.SelectedIndex = cmbDokumentart.FindStringExact(oRoW.Item("DOCTYPE"))
|
||||
|
||||
Dim oFoundDocType = ComboBoxEdit1.Properties.Items.
|
||||
Cast(Of DocType)().
|
||||
Where(Function(dt) dt.Name = CURRENT_LASTDOKART).
|
||||
FirstOrDefault()
|
||||
|
||||
If oFoundDocType IsNot Nothing Then
|
||||
ComboBoxEdit1.SelectedItem = oFoundDocType
|
||||
End If
|
||||
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
@@ -1585,39 +1613,71 @@ Public Class frmIndex
|
||||
Dim sql = String.Format("SELECT DISTINCT DOCTYPE_ID, DOCTYPE, SEQUENCE FROM VWGI_DOCTYPE where UPPER(USERNAME) = UPPER('{0}') ORDER BY SEQUENCE", Environment.UserName)
|
||||
_Logger.Info("SQL DoctypeList: " & sql)
|
||||
Dim oDoctypes = ClassDatabase.Return_Datatable(sql)
|
||||
cmbDokumentart.DataSource = oDoctypes
|
||||
cmbDokumentart.ValueMember = oDoctypes.Columns("DOCTYPE_ID").ColumnName
|
||||
cmbDokumentart.DisplayMember = oDoctypes.Columns("DOCTYPE").ColumnName
|
||||
cmbDokumentart.AutoCompleteMode = AutoCompleteMode.Suggest
|
||||
cmbDokumentart.AutoCompleteSource = AutoCompleteSource.ListItems
|
||||
cmbDokumentart.SelectedIndex = -1
|
||||
'cmbDokumentart.DataSource = oDoctypes
|
||||
'cmbDokumentart.ValueMember = oDoctypes.Columns("DOCTYPE_ID").ColumnName
|
||||
'cmbDokumentart.DisplayMember = oDoctypes.Columns("DOCTYPE").ColumnName
|
||||
'cmbDokumentart.AutoCompleteMode = AutoCompleteMode.Suggest
|
||||
'cmbDokumentart.AutoCompleteSource = AutoCompleteSource.ListItems
|
||||
'cmbDokumentart.SelectedIndex = -1
|
||||
|
||||
For Each oRow As DataRow In oDoctypes.Rows
|
||||
ComboBoxEdit1.Properties.Items.Add(New DocType With {
|
||||
.Guid = oRow.Item("DOCTYPE_ID"),
|
||||
.Name = oRow.Item("DOCTYPE")
|
||||
})
|
||||
Next
|
||||
Catch ex As Exception
|
||||
ShowErrorMessage(ex, "Refresh_Dokart")
|
||||
End Try
|
||||
End Sub
|
||||
Private Sub cmbDokumentart_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cmbDokumentart.SelectedIndexChanged
|
||||
If cmbDokumentart.SelectedIndex <> -1 And FormLoaded = True Then
|
||||
If cmbDokumentart.SelectedValue.GetType.ToString = "System.Int32" Then
|
||||
CURRENT_DOKART_ID = cmbDokumentart.SelectedValue
|
||||
|
||||
'lblhinweis.Visible = False
|
||||
ClearNotice()
|
||||
Private Sub ComboBoxEdit1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBoxEdit1.SelectedIndexChanged
|
||||
If ComboBoxEdit1.SelectedIndex <> -1 And FormLoaded = True Then
|
||||
Dim oSelectedItem As DocType = ComboBoxEdit1.SelectedItem
|
||||
|
||||
'lblerror.Visible = False
|
||||
ClearError()
|
||||
CURRENT_DOKART_ID = oSelectedItem.Guid
|
||||
|
||||
'lblhinweis.Visible = False
|
||||
ClearNotice()
|
||||
|
||||
Me.pnlIndex.Controls.Clear()
|
||||
Dim sql As String = "Select WINDREAM_DIRECT, DUPLICATE_HANDLING from TBDD_DOKUMENTART WHERE GUID = " & cmbDokumentart.SelectedValue
|
||||
Dim oDoctypes As DataTable = ClassDatabase.Return_Datatable(sql)
|
||||
'lblerror.Visible = False
|
||||
ClearError()
|
||||
|
||||
pnlIndex.Controls.Clear()
|
||||
Dim sql As String = "Select WINDREAM_DIRECT, DUPLICATE_HANDLING from TBDD_DOKUMENTART WHERE GUID = " & oSelectedItem.Guid
|
||||
Dim oDoctypes As DataTable = ClassDatabase.Return_Datatable(sql)
|
||||
|
||||
WDDirect = oDoctypes.Rows(0).Item("WINDREAM_DIRECT")
|
||||
CURRENT_DOKART_DUPLICATE_HANDLING = oDoctypes.Rows(0).Item("DUPLICATE_HANDLING")
|
||||
Refresh_IndexeMan(oSelectedItem.Guid)
|
||||
|
||||
WDDirect = oDoctypes.Rows(0).Item("WINDREAM_DIRECT")
|
||||
CURRENT_DOKART_DUPLICATE_HANDLING = oDoctypes.Rows(0).Item("DUPLICATE_HANDLING")
|
||||
Refresh_IndexeMan(cmbDokumentart.SelectedValue)
|
||||
End If
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Private Sub cmbDokumentart_SelectedIndexChanged(sender As System.Object, e As System.EventArgs)
|
||||
' If cmbDokumentart.SelectedIndex <> -1 And FormLoaded = True Then
|
||||
' If cmbDokumentart.SelectedValue.GetType.ToString = "System.Int32" Then
|
||||
' CURRENT_DOKART_ID = cmbDokumentart.SelectedValue
|
||||
|
||||
' 'lblhinweis.Visible = False
|
||||
' ClearNotice()
|
||||
|
||||
' 'lblerror.Visible = False
|
||||
' ClearError()
|
||||
|
||||
|
||||
' Me.pnlIndex.Controls.Clear()
|
||||
' Dim sql As String = "Select WINDREAM_DIRECT, DUPLICATE_HANDLING from TBDD_DOKUMENTART WHERE GUID = " & cmbDokumentart.SelectedValue
|
||||
' Dim oDoctypes As DataTable = ClassDatabase.Return_Datatable(sql)
|
||||
|
||||
' WDDirect = oDoctypes.Rows(0).Item("WINDREAM_DIRECT")
|
||||
' CURRENT_DOKART_DUPLICATE_HANDLING = oDoctypes.Rows(0).Item("DUPLICATE_HANDLING")
|
||||
' Refresh_IndexeMan(cmbDokumentart.SelectedValue)
|
||||
' End If
|
||||
|
||||
' End If
|
||||
'End Sub
|
||||
' <STAThread()> _
|
||||
Private Sub Refresh_IndexeMan(dokartid As Integer)
|
||||
Dim sql
|
||||
@@ -1656,11 +1716,20 @@ Public Class frmIndex
|
||||
Dim oControlCount As Integer = 1
|
||||
Dim oLabelPosition As Integer = 11
|
||||
Dim oControlPosition As Integer = 33
|
||||
Dim oControls As New ClassControls(pnlIndex, Me)
|
||||
|
||||
Dim oControls As New DigitalData.GUIs.GlobalIndexer.ControlCreator(LOGCONFIG, pnlIndex, Me) With {
|
||||
.OnControlChanged = AddressOf PrepareDependingControl,
|
||||
.OnLookupData = AddressOf GetLookupData
|
||||
}
|
||||
|
||||
'Dim oControls As New ClassControls(pnlIndex, Me)
|
||||
|
||||
If DT_INDEXEMAN.Rows.Count = 0 Then
|
||||
ShowError("Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & cmbDokumentart.Text & " definiert")
|
||||
_Logger.Info(" - Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & cmbDokumentart.Text & " definiert")
|
||||
' ShowError("Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & cmbDokumentart.Text & " definiert")
|
||||
'_Logger.Info(" - Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & cmbDokumentart.Text & " definiert")
|
||||
|
||||
ShowError("Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & ComboBoxEdit1.Text & " definiert")
|
||||
_Logger.Info(" - Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & ComboBoxEdit1.Text & " definiert")
|
||||
End If
|
||||
|
||||
For Each oRow As DataRow In DT_INDEXEMAN.Rows
|
||||
@@ -1671,6 +1740,7 @@ Public Class frmIndex
|
||||
Dim oControlName As String = oRow.Item("NAME")
|
||||
Dim oConnectionId = NotNull(oRow.Item("CONNECTION_ID"), 0)
|
||||
Dim oSQLSuggestion = oRow.Item("SUGGESTION")
|
||||
Dim oSQLResult = oRow.Item("SQL_RESULT")
|
||||
|
||||
If oDataType <> "BOOLEAN" Then
|
||||
addLabel(oControlName, oRow.Item("COMMENT").ToString, oLabelPosition, oControlCount)
|
||||
@@ -1687,8 +1757,8 @@ Public Class frmIndex
|
||||
pnlIndex.Controls.Add(chk)
|
||||
End If
|
||||
Case "INTEGER"
|
||||
If (oSQLSuggestion = True And oRow.Item("SQL_RESULT").ToString.Length > 0) Or MultiSelect = True Then
|
||||
Dim oControl = oControls.AddVorschlag_ComboBox(oControlName, oControlPosition, oConnectionId, oRow.Item("SQL_RESULT"), MultiSelect, oDataType, DefaultValue, AddNewItems, PreventDuplicates, oSQLSuggestion)
|
||||
If (oSQLSuggestion = True And oSQLResult.ToString.Length > 0) Or MultiSelect = True Then
|
||||
Dim oControl = oControls.AddLookupControl(oControlName, oControlPosition, MultiSelect, oDataType, oSQLResult, oConnectionId, DefaultValue, AddNewItems, PreventDuplicates)
|
||||
If Not IsNothing(oControl) Then
|
||||
pnlIndex.Controls.Add(oControl)
|
||||
End If
|
||||
@@ -1700,8 +1770,8 @@ Public Class frmIndex
|
||||
End If
|
||||
End If
|
||||
Case "VARCHAR"
|
||||
If (oSQLSuggestion = True And oRow.Item("SQL_RESULT").ToString.Length > 0) Or MultiSelect = True Then
|
||||
Dim oControl = oControls.AddVorschlag_ComboBox(oControlName, oControlPosition, oConnectionId, oRow.Item("SQL_RESULT"), MultiSelect, oDataType, DefaultValue, AddNewItems, PreventDuplicates, oSQLSuggestion)
|
||||
If (oSQLSuggestion = True And oSQLResult.ToString.Length > 0) Or MultiSelect = True Then
|
||||
Dim oControl = oControls.AddLookupControl(oControlName, oControlPosition, MultiSelect, oDataType, oSQLResult, oConnectionId, DefaultValue, AddNewItems, PreventDuplicates)
|
||||
If Not IsNothing(oControl) Then
|
||||
pnlIndex.Controls.Add(oControl)
|
||||
End If
|
||||
@@ -1720,7 +1790,7 @@ Public Class frmIndex
|
||||
End If
|
||||
End If
|
||||
Case "DATE"
|
||||
Dim oPicker = oControls.AddDateTimePicker(oControlName, oControlPosition, oDataType, DefaultValue)
|
||||
Dim oPicker = oControls.AddDateTimePicker(oControlName, oControlPosition, DefaultValue)
|
||||
pnlIndex.Controls.Add(oPicker)
|
||||
|
||||
Case Else
|
||||
@@ -1753,6 +1823,123 @@ Public Class frmIndex
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Function GetLookupData(pLookup As LookupControl2, pSQLCommand As String, pConnectionId As Integer)
|
||||
Dim oConnectionString = ClassFormFunctions.GetConnectionString(pConnectionId)
|
||||
|
||||
If oConnectionString IsNot Nothing And pSQLCommand.Length > 0 Then
|
||||
LOGGER.Debug("Connection String (redacted): [{0}]", oConnectionString.Substring(0, 30))
|
||||
|
||||
If ClassPatterns.HasComplexPatterns(pSQLCommand) Then
|
||||
LOGGER.Debug(" >>sql enthält Platzhalter und wird erst während der Laufzeit gefüllt!", False)
|
||||
Return Nothing
|
||||
Else
|
||||
pSQLCommand = ClassPatterns.ReplaceInternalValues(pSQLCommand)
|
||||
pSQLCommand = ClassPatterns.ReplaceUserValues(pSQLCommand, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_LANGUAGE, USER_EMAIL, USER_ID, CURRENT_DOKART_ID)
|
||||
|
||||
Dim oDatatable = ClassDatabase.Return_Datatable_Combined(pSQLCommand, oConnectionString, False)
|
||||
Return oDatatable
|
||||
End If
|
||||
Else
|
||||
LOGGER.Warn("Connection String for control [{0}] is empty!", pLookup.Name)
|
||||
Return Nothing
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Sub PrepareDependingControl(Control As Control)
|
||||
If TypeOf Control Is Label Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Try
|
||||
Dim oMeta = DirectCast(Control.Tag, ClassControls.ControlMeta)
|
||||
Dim oIndexName As String = oMeta.IndexName
|
||||
Dim oSQL = $"SELECT * FROM TBDD_INDEX_MAN WHERE SQL_RESULT LIKE '%{oIndexName}%'"
|
||||
Dim oDatatable As DataTable = ClassDatabase.Return_Datatable(oSQL)
|
||||
|
||||
If Not IsNothing(oDatatable) Then
|
||||
LOGGER.Debug("Found [{0}] depending controls for [{1}]", oDatatable.Rows.Count, Control.Name)
|
||||
|
||||
For Each oRow As DataRow In oDatatable.Rows
|
||||
Dim oControlName As String = NotNull(oRow.Item("NAME"), "")
|
||||
Dim oConnectionId As Integer = NotNull(oRow.Item("CONNECTION_ID"), -1)
|
||||
Dim oControlSql As String = NotNull(oRow.Item("SQL_RESULT"), "")
|
||||
|
||||
If oConnectionId = -1 Or oControlSql = String.Empty Then
|
||||
LOGGER.Warn("Missing SQL Query or ConnectionId for Control [{0}]! Continuing.", oControlName)
|
||||
Continue For
|
||||
End If
|
||||
|
||||
oControlSql = ClassPatterns.ReplaceUserValues(oControlSql, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_LANGUAGE, USER_EMAIL, USER_ID, CURRENT_DOKART_ID)
|
||||
oControlSql = ClassPatterns.ReplaceInternalValues(oControlSql)
|
||||
oControlSql = ClassPatterns.ReplaceControlValues(oControlSql, pnlIndex)
|
||||
LOGGER.Debug("Setting new value for [{0}]", oControlName)
|
||||
SetDependingControlResult(oControlName, oControlSql, oConnectionId)
|
||||
Next
|
||||
End If
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub SetDependingControlResult(IndexName As String, SqlCommand As String, SqlConnectionId As Integer)
|
||||
Try
|
||||
If SqlCommand Is Nothing OrElse SqlCommand = String.Empty Then
|
||||
LOGGER.Warn("New Value for Index [{0}] could not be set. Supplied SQL is empty.")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oConnectionString = ClassFormFunctions.GetConnectionString(SqlConnectionId)
|
||||
Dim oDatatable As DataTable = ClassDatabase.Return_Datatable_CS(SqlCommand, oConnectionString)
|
||||
Dim oFoundControl As Control = Nothing
|
||||
|
||||
For Each oControl As Control In pnlIndex.Controls
|
||||
If TypeOf oControl Is Label Then
|
||||
Continue For
|
||||
End If
|
||||
|
||||
Dim oMeta = DirectCast(oControl.Tag, ClassControls.ControlMeta)
|
||||
Dim oIndex As String = oMeta.IndexName
|
||||
|
||||
If oIndex = IndexName Then
|
||||
oFoundControl = oControl
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
If oFoundControl Is Nothing Then
|
||||
LOGGER.Warn("Depending Control for Index [{0}] not found!", IndexName)
|
||||
End If
|
||||
|
||||
If oDatatable Is Nothing Then
|
||||
LOGGER.Warn("Error in SQL Command: {0}", SqlCommand)
|
||||
End If
|
||||
|
||||
Select Case oFoundControl.GetType.Name
|
||||
Case GetType(DevExpress.XtraEditors.TextEdit).Name
|
||||
If oDatatable.Rows.Count > 0 Then
|
||||
Dim oFirstRow As DataRow = oDatatable.Rows.Item(0)
|
||||
|
||||
If oFirstRow.ItemArray.Length > 0 Then
|
||||
Dim oValue = oFirstRow.Item(0).ToString()
|
||||
|
||||
LOGGER.Debug("Setting Value for TextEdit [{0}]: [{1}]", oFoundControl.Name, oValue)
|
||||
DirectCast(oFoundControl, DevExpress.XtraEditors.TextEdit).Text = oValue
|
||||
End If
|
||||
End If
|
||||
Case GetType(LookupControl2).Name
|
||||
LOGGER.Debug("Setting Value for LookupControl [{0}]: [{1}]", oFoundControl.Name, "DATATABLE")
|
||||
DirectCast(oFoundControl, LookupControl2).DataSource = oDatatable
|
||||
Case GetType(ComboBox).Name
|
||||
LOGGER.Debug("Setting Value for Combobox [{0}]: [{1}]", oFoundControl.Name, "DATATABLE")
|
||||
DirectCast(oFoundControl, ComboBox).DataSource = oDatatable
|
||||
Case Else
|
||||
LOGGER.Debug("Could not set depending control result for [{0}]", oFoundControl.GetType.Name)
|
||||
End Select
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Function GetPlaceholderValue(InputValue As String, FileName As String, UserShortName As String) As String
|
||||
Dim oResult As String
|
||||
|
||||
@@ -1959,11 +2146,13 @@ Public Class frmIndex
|
||||
_Logger.Debug("Manuelle Indexe geladen")
|
||||
|
||||
If MyDataset.VWDDINDEX_MAN.Rows.Count > 0 Then
|
||||
CURRENT_DOKART_ID = Me.cmbDokumentart.SelectedValue
|
||||
If CheckWrite_IndexeMan(Me.cmbDokumentart.SelectedValue) = True Then
|
||||
Dim oDokart As DocType = ComboBoxEdit1.SelectedItem
|
||||
|
||||
CURRENT_DOKART_ID = oDokart.Guid
|
||||
If CheckWrite_IndexeMan(oDokart.Guid) = True Then
|
||||
'##### Manuelle Indexe indexiert #####
|
||||
_Logger.Info("Datei [" & CURRENT_WORKFILE & "] wird nun indexiert...")
|
||||
If FillIndexe_Autom(Me.cmbDokumentart.SelectedValue) = True Then
|
||||
If FillIndexe_Autom(oDokart.Guid) = True Then
|
||||
_Logger.Debug(" ...FillIndexe_Autom durchlaufen")
|
||||
|
||||
'Den Zielnamen zusammenbauen
|
||||
@@ -1976,7 +2165,7 @@ Public Class frmIndex
|
||||
'Die Datei verschieben
|
||||
If Move_File2_Target() = True Then
|
||||
_Logger.Debug(" ...Move_File2_Target durchlaufen")
|
||||
CURRENT_LASTDOKART = cmbDokumentart.Text
|
||||
CURRENT_LASTDOKART = oDokart.Name
|
||||
_Logger.Info("Datei '" & CURRENT_NEWFILENAME & "' erfolgreich erzeugt.")
|
||||
Dim oDEL As String = "DELETE FROM TBGI_FILES_USER WHERE GUID = " & CURRENT_WORKFILE_GUID
|
||||
ClassDatabase.Execute_non_Query(oDEL, True)
|
||||
@@ -2513,4 +2702,6 @@ Public Class frmIndex
|
||||
CONFIG.Config.ProfilePreselection = checkItemPreselection.Checked
|
||||
CONFIG.Save()
|
||||
End Sub
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user