ZooFlow: PropertyDialog, ContextMenu, Async Queries in Database
This commit is contained in:
68
GUIs.Common/ObjectPropertyDialog/PropertyControls.vb
Normal file
68
GUIs.Common/ObjectPropertyDialog/PropertyControls.vb
Normal file
@@ -0,0 +1,68 @@
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DevExpress.XtraLayout
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.ZooFlow
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Controls.LookupGrid
|
||||
|
||||
Public Class PropertyControls
|
||||
Private _LogConfig As LogConfig
|
||||
Private _Logger As Logger
|
||||
Private _Db As MSSQLServer
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Database As MSSQLServer)
|
||||
_LogConfig = LogConfig
|
||||
_Logger = LogConfig.GetLogger()
|
||||
_Db = Database
|
||||
End Sub
|
||||
|
||||
Public Function GetControlForAttribute(Attribute As Attribute) As BaseEdit
|
||||
Select Case Attribute.TypeName
|
||||
Case "BIT"
|
||||
Dim oCheckboxEdit As New CheckEdit With {
|
||||
.Name = Attribute.ID,
|
||||
.Text = Attribute.Title
|
||||
}
|
||||
Return oCheckboxEdit
|
||||
|
||||
Case "DATE"
|
||||
Dim oDateEdit As New DateEdit With {
|
||||
.Name = Attribute.ID
|
||||
}
|
||||
Return oDateEdit
|
||||
|
||||
Case "BIG INTEGER"
|
||||
Dim oTextEdit As New TextEdit With {
|
||||
.Name = Attribute.ID
|
||||
}
|
||||
Return oTextEdit
|
||||
|
||||
Case "DECIMAL"
|
||||
Dim oTextEdit As New TextEdit With {
|
||||
.Name = Attribute.ID
|
||||
}
|
||||
Return oTextEdit
|
||||
|
||||
Case "FLOAT"
|
||||
Dim oTextEdit As New TextEdit With {
|
||||
.Name = Attribute.ID
|
||||
}
|
||||
Return oTextEdit
|
||||
|
||||
Case "VECTOR STRING"
|
||||
Dim oLookupEdit As New LookupControl2 With {
|
||||
.Name = Attribute.ID,
|
||||
.MultiSelect = True,
|
||||
.[ReadOnly] = True
|
||||
}
|
||||
Return oLookupEdit
|
||||
|
||||
Case Else
|
||||
Dim oTextEdit As New TextEdit With {
|
||||
.Name = Attribute.ID
|
||||
}
|
||||
Return oTextEdit
|
||||
|
||||
End Select
|
||||
End Function
|
||||
End Class
|
||||
@@ -23,7 +23,9 @@ Partial Class frmObjectPropertyDialog
|
||||
<System.Diagnostics.DebuggerStepThrough()> _
|
||||
Private Sub InitializeComponent()
|
||||
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmObjectPropertyDialog))
|
||||
Me.RepositoryItemComboBox1 = New DevExpress.XtraEditors.Repository.RepositoryItemComboBox()
|
||||
Me.TabFormControl1 = New DevExpress.XtraBars.TabFormControl()
|
||||
Me.cmbBusinessEntity = New DevExpress.XtraBars.BarEditItem()
|
||||
Me.TabPageProperties = New DevExpress.XtraBars.TabFormPage()
|
||||
Me.TabFormContentContainer1 = New DevExpress.XtraBars.TabFormContentContainer()
|
||||
Me.LayoutControlProperties = New DevExpress.XtraLayout.LayoutControl()
|
||||
@@ -32,36 +34,50 @@ Partial Class frmObjectPropertyDialog
|
||||
Me.TabFormContentContainer2 = New DevExpress.XtraBars.TabFormContentContainer()
|
||||
Me.TabPageLifecycle = New DevExpress.XtraBars.TabFormPage()
|
||||
Me.TabFormContentContainer3 = New DevExpress.XtraBars.TabFormContentContainer()
|
||||
Me.PanelControl1 = New DevExpress.XtraEditors.PanelControl()
|
||||
Me.Button3 = New System.Windows.Forms.Button()
|
||||
Me.Button2 = New System.Windows.Forms.Button()
|
||||
Me.Button1 = New System.Windows.Forms.Button()
|
||||
Me.BarStaticItem1 = New DevExpress.XtraBars.BarStaticItem()
|
||||
CType(Me.RepositoryItemComboBox1, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
CType(Me.TabFormControl1, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
Me.TabFormContentContainer1.SuspendLayout()
|
||||
CType(Me.LayoutControlProperties, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
CType(Me.Root, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
CType(Me.PanelControl1, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
Me.PanelControl1.SuspendLayout()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'RepositoryItemComboBox1
|
||||
'
|
||||
Me.RepositoryItemComboBox1.AutoHeight = False
|
||||
Me.RepositoryItemComboBox1.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)})
|
||||
Me.RepositoryItemComboBox1.Name = "RepositoryItemComboBox1"
|
||||
'
|
||||
'TabFormControl1
|
||||
'
|
||||
Me.TabFormControl1.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.cmbBusinessEntity, Me.BarStaticItem1})
|
||||
Me.TabFormControl1.Location = New System.Drawing.Point(0, 0)
|
||||
Me.TabFormControl1.Name = "TabFormControl1"
|
||||
Me.TabFormControl1.Pages.Add(Me.TabPageProperties)
|
||||
Me.TabFormControl1.Pages.Add(Me.TabPageMetadata)
|
||||
Me.TabFormControl1.Pages.Add(Me.TabPageLifecycle)
|
||||
Me.TabFormControl1.SelectedPage = Me.TabPageProperties
|
||||
Me.TabFormControl1.ShowAddPageButton = False
|
||||
Me.TabFormControl1.ShowTabCloseButtons = False
|
||||
Me.TabFormControl1.Size = New System.Drawing.Size(572, 71)
|
||||
Me.TabFormControl1.TabForm = Me
|
||||
Me.TabFormControl1.TabIndex = 0
|
||||
Me.TabFormControl1.TabRightItemLinks.Add(Me.BarStaticItem1)
|
||||
Me.TabFormControl1.TabRightItemLinks.Add(Me.cmbBusinessEntity)
|
||||
Me.TabFormControl1.TabStop = False
|
||||
'
|
||||
'cmbBusinessEntity
|
||||
'
|
||||
Me.cmbBusinessEntity.Caption = "cmbBusinessEntity"
|
||||
Me.cmbBusinessEntity.Edit = Me.RepositoryItemComboBox1
|
||||
Me.cmbBusinessEntity.EditWidth = 100
|
||||
Me.cmbBusinessEntity.Id = 6
|
||||
Me.cmbBusinessEntity.Name = "cmbBusinessEntity"
|
||||
'
|
||||
'TabPageProperties
|
||||
'
|
||||
Me.TabPageProperties.ContentContainer = Me.TabFormContentContainer1
|
||||
Me.TabPageProperties.Name = "TabPageProperties"
|
||||
Me.TabPageProperties.ShowCloseButton = DevExpress.Utils.DefaultBoolean.[False]
|
||||
Me.TabPageProperties.Text = "Eigenschaften"
|
||||
'
|
||||
'TabFormContentContainer1
|
||||
@@ -75,10 +91,11 @@ Partial Class frmObjectPropertyDialog
|
||||
'
|
||||
'LayoutControlProperties
|
||||
'
|
||||
Me.LayoutControlProperties.Location = New System.Drawing.Point(108, 80)
|
||||
Me.LayoutControlProperties.Dock = System.Windows.Forms.DockStyle.Fill
|
||||
Me.LayoutControlProperties.Location = New System.Drawing.Point(0, 0)
|
||||
Me.LayoutControlProperties.Name = "LayoutControlProperties"
|
||||
Me.LayoutControlProperties.Root = Me.Root
|
||||
Me.LayoutControlProperties.Size = New System.Drawing.Size(180, 120)
|
||||
Me.LayoutControlProperties.Size = New System.Drawing.Size(572, 534)
|
||||
Me.LayoutControlProperties.TabIndex = 0
|
||||
Me.LayoutControlProperties.Text = "LayoutControl1"
|
||||
'
|
||||
@@ -87,14 +104,13 @@ Partial Class frmObjectPropertyDialog
|
||||
Me.Root.EnableIndentsWithoutBorders = DevExpress.Utils.DefaultBoolean.[True]
|
||||
Me.Root.GroupBordersVisible = False
|
||||
Me.Root.Name = "Root"
|
||||
Me.Root.Size = New System.Drawing.Size(180, 120)
|
||||
Me.Root.Size = New System.Drawing.Size(572, 534)
|
||||
Me.Root.TextVisible = False
|
||||
'
|
||||
'TabPageMetadata
|
||||
'
|
||||
Me.TabPageMetadata.ContentContainer = Me.TabFormContentContainer2
|
||||
Me.TabPageMetadata.Name = "TabPageMetadata"
|
||||
Me.TabPageMetadata.ShowCloseButton = DevExpress.Utils.DefaultBoolean.[False]
|
||||
Me.TabPageMetadata.Text = "Metadaten"
|
||||
'
|
||||
'TabFormContentContainer2
|
||||
@@ -109,7 +125,6 @@ Partial Class frmObjectPropertyDialog
|
||||
'
|
||||
Me.TabPageLifecycle.ContentContainer = Me.TabFormContentContainer3
|
||||
Me.TabPageLifecycle.Name = "TabPageLifecycle"
|
||||
Me.TabPageLifecycle.ShowCloseButton = DevExpress.Utils.DefaultBoolean.[False]
|
||||
Me.TabPageLifecycle.Text = "Lebenszyklus"
|
||||
'
|
||||
'TabFormContentContainer3
|
||||
@@ -120,62 +135,28 @@ Partial Class frmObjectPropertyDialog
|
||||
Me.TabFormContentContainer3.Size = New System.Drawing.Size(572, 534)
|
||||
Me.TabFormContentContainer3.TabIndex = 3
|
||||
'
|
||||
'PanelControl1
|
||||
'BarStaticItem1
|
||||
'
|
||||
Me.PanelControl1.Controls.Add(Me.Button3)
|
||||
Me.PanelControl1.Controls.Add(Me.Button2)
|
||||
Me.PanelControl1.Controls.Add(Me.Button1)
|
||||
Me.PanelControl1.Dock = System.Windows.Forms.DockStyle.Bottom
|
||||
Me.PanelControl1.Location = New System.Drawing.Point(0, 554)
|
||||
Me.PanelControl1.Name = "PanelControl1"
|
||||
Me.PanelControl1.Size = New System.Drawing.Size(572, 51)
|
||||
Me.PanelControl1.TabIndex = 1
|
||||
'
|
||||
'Button3
|
||||
'
|
||||
Me.Button3.Location = New System.Drawing.Point(230, 6)
|
||||
Me.Button3.Name = "Button3"
|
||||
Me.Button3.Size = New System.Drawing.Size(106, 33)
|
||||
Me.Button3.TabIndex = 0
|
||||
Me.Button3.Text = "OK"
|
||||
Me.Button3.UseVisualStyleBackColor = True
|
||||
'
|
||||
'Button2
|
||||
'
|
||||
Me.Button2.Location = New System.Drawing.Point(342, 6)
|
||||
Me.Button2.Name = "Button2"
|
||||
Me.Button2.Size = New System.Drawing.Size(106, 33)
|
||||
Me.Button2.TabIndex = 0
|
||||
Me.Button2.Text = "Abbrechen"
|
||||
Me.Button2.UseVisualStyleBackColor = True
|
||||
'
|
||||
'Button1
|
||||
'
|
||||
Me.Button1.Location = New System.Drawing.Point(454, 6)
|
||||
Me.Button1.Name = "Button1"
|
||||
Me.Button1.Size = New System.Drawing.Size(106, 33)
|
||||
Me.Button1.TabIndex = 0
|
||||
Me.Button1.Text = "Übernehmen"
|
||||
Me.Button1.UseVisualStyleBackColor = True
|
||||
Me.BarStaticItem1.Caption = "Entity:"
|
||||
Me.BarStaticItem1.Id = 0
|
||||
Me.BarStaticItem1.Name = "BarStaticItem1"
|
||||
'
|
||||
'frmObjectPropertyDialog
|
||||
'
|
||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||
Me.ClientSize = New System.Drawing.Size(572, 605)
|
||||
Me.Controls.Add(Me.PanelControl1)
|
||||
Me.Controls.Add(Me.TabFormContentContainer1)
|
||||
Me.Controls.Add(Me.TabFormControl1)
|
||||
Me.IconOptions.SvgImage = CType(resources.GetObject("frmObjectPropertyDialog.IconOptions.SvgImage"), DevExpress.Utils.Svg.SvgImage)
|
||||
Me.Name = "frmObjectPropertyDialog"
|
||||
Me.TabFormControl = Me.TabFormControl1
|
||||
Me.Text = "Objekt-Eigenschaften"
|
||||
CType(Me.RepositoryItemComboBox1, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
CType(Me.TabFormControl1, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
Me.TabFormContentContainer1.ResumeLayout(False)
|
||||
CType(Me.LayoutControlProperties, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
CType(Me.Root, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
CType(Me.PanelControl1, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
Me.PanelControl1.ResumeLayout(False)
|
||||
Me.ResumeLayout(False)
|
||||
|
||||
End Sub
|
||||
@@ -189,8 +170,7 @@ Partial Class frmObjectPropertyDialog
|
||||
Friend WithEvents TabFormContentContainer3 As DevExpress.XtraBars.TabFormContentContainer
|
||||
Friend WithEvents LayoutControlProperties As DevExpress.XtraLayout.LayoutControl
|
||||
Friend WithEvents Root As DevExpress.XtraLayout.LayoutControlGroup
|
||||
Friend WithEvents PanelControl1 As DevExpress.XtraEditors.PanelControl
|
||||
Friend WithEvents Button2 As Windows.Forms.Button
|
||||
Friend WithEvents Button1 As Windows.Forms.Button
|
||||
Friend WithEvents Button3 As Windows.Forms.Button
|
||||
Friend WithEvents cmbBusinessEntity As DevExpress.XtraBars.BarEditItem
|
||||
Friend WithEvents RepositoryItemComboBox1 As DevExpress.XtraEditors.Repository.RepositoryItemComboBox
|
||||
Friend WithEvents BarStaticItem1 As DevExpress.XtraBars.BarStaticItem
|
||||
End Class
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports System.Windows.Forms
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DevExpress.XtraEditors.Repository
|
||||
Imports DevExpress.XtraLayout
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.ZooFlow
|
||||
|
||||
Public Class frmObjectPropertyDialog
|
||||
@@ -6,6 +11,8 @@ Public Class frmObjectPropertyDialog
|
||||
Private _Logger As Logger
|
||||
Private _Environment As Environment
|
||||
Private _ObjectId As Int64
|
||||
Private _Db As MSSQLServer
|
||||
Private _Controls As PropertyControls
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Environment As Environment, ObjectId As Long)
|
||||
' Dieser Aufruf ist für den Designer erforderlich.
|
||||
@@ -16,9 +23,96 @@ Public Class frmObjectPropertyDialog
|
||||
_Logger = LogConfig.GetLogger()
|
||||
_Environment = Environment
|
||||
_ObjectId = ObjectId
|
||||
_Db = _Environment.DatabaseIDB
|
||||
_Controls = New PropertyControls(_LogConfig, _Db)
|
||||
End Sub
|
||||
|
||||
Private Sub frmObjectPropertyDialog_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
Private Async Sub frmObjectPropertyDialog_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
Try
|
||||
Dim EntityIds = Await GetBusinessEntitiesForObjectId(_ObjectId)
|
||||
Dim oCombobox As RepositoryItemComboBox = DirectCast(cmbBusinessEntity.Edit, RepositoryItemComboBox)
|
||||
oCombobox.Items.AddRange(EntityIds)
|
||||
|
||||
If EntityIds.Count = 1 Then
|
||||
cmbBusinessEntity.EditValue = EntityIds.First()
|
||||
End If
|
||||
Catch ex As ApplicationException
|
||||
_Logger.Error(ex)
|
||||
MessageBox.Show(ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
MessageBox.Show("Unhandled exception occurred please check the log", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Async Function GetAttributesForBusinessEntity(EntityId As Long) As Task(Of List(Of Attribute))
|
||||
Dim oSQL = $"SELECT * FROM VWIDB_BE_ATTRIBUTE WHERE BE_ID = {EntityId}"
|
||||
Dim oDatatable = Await _Db.GetDatatableAsync(oSQL)
|
||||
|
||||
If oDatatable.Rows.Count = 0 Then
|
||||
Throw New ApplicationException($"BusinessEntity {EntityId} does not have any attributes!")
|
||||
Else
|
||||
Dim oAttributes As New List(Of Attribute)
|
||||
|
||||
For Each oRow As DataRow In oDatatable.Rows
|
||||
oAttributes.Add(New Attribute() With {
|
||||
.ID = oRow.Item("ATTR_ID"),
|
||||
.Title = oRow.Item("ATTR_TITLE"),
|
||||
.TypeID = oRow.Item("TYPE_ID"),
|
||||
.TypeName = oRow.Item("TYPE_NAME")
|
||||
})
|
||||
Next
|
||||
|
||||
Return oAttributes
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Async Function GetBusinessEntitiesForObjectId(ObjectId) As Task(Of List(Of Long))
|
||||
Dim oSQL = $"SELECT BE_ID FROM TBIDB_OBJECT_BE WHERE IDB_OBJ_ID = {ObjectId}"
|
||||
Dim oDatatable = Await _Db.GetDatatableAsync(oSQL)
|
||||
|
||||
If oDatatable.Rows.Count = 0 Then
|
||||
Throw New ApplicationException($"ObjectId {ObjectId} is not assigned to any business entity!")
|
||||
Else
|
||||
Dim oEntities As New List(Of Long)
|
||||
|
||||
For Each oRow In oDatatable.Rows
|
||||
oEntities.Add(oRow.item("BE_ID"))
|
||||
Next
|
||||
|
||||
Return oEntities
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Async Function GetAttributeValue(AttributeName As String, ObjectId As Long, Optional LanguageCode As String = "de-DE", Optional IsForeign As Boolean = False) As Task(Of Object)
|
||||
Dim oIsForeign = IIf(IsForeign, 1, 0)
|
||||
Dim oSQL = $"SELECT TERM_VALUE FROM [dbo].[FNIDB_PM_GET_VARIABLE_VALUE] ({ObjectId}, '{AttributeName}', '{LanguageCode}', {oIsForeign})"
|
||||
Dim oTermValue = Await _Db.GetScalarValueAsync(oSQL)
|
||||
|
||||
Return oTermValue
|
||||
End Function
|
||||
|
||||
Private Async Sub cmbBusinessEntity_EditValueChanged(sender As Object, e As EventArgs) Handles cmbBusinessEntity.EditValueChanged
|
||||
Dim oEntityId As Long
|
||||
|
||||
If Long.TryParse(cmbBusinessEntity.EditValue, oEntityId) = False Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oAttributes = Await GetAttributesForBusinessEntity(oEntityId)
|
||||
|
||||
For Each oAttribute As Attribute In oAttributes
|
||||
Dim oControl = _Controls.GetControlForAttribute(oAttribute)
|
||||
Dim oItem As LayoutControlItem = Root.AddItem()
|
||||
oItem.Text = oAttribute.Title
|
||||
oItem.Name = oAttribute.Title
|
||||
oItem.Control = oControl
|
||||
Next
|
||||
|
||||
For Each oItem As LayoutControlItem In Root.Items
|
||||
Dim oValue = Await GetAttributeValue(oItem.Name, _ObjectId)
|
||||
Dim oEdit = DirectCast(oItem.Control, BaseEdit)
|
||||
oEdit.EditValue = oValue
|
||||
Next
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user