ObjectPropertyDialog: Add Loading indicator, show basic object properties, show attribute history
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DevExpress.XtraEditors.Repository
|
||||
Imports DevExpress.XtraLayout
|
||||
Imports DevExpress.XtraSplashScreen
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.ZooFlow
|
||||
@@ -28,13 +29,23 @@ Public Class frmObjectPropertyDialog
|
||||
End Sub
|
||||
|
||||
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)
|
||||
Dim oHandle As IOverlaySplashScreenHandle = Nothing
|
||||
|
||||
If EntityIds.Count = 1 Then
|
||||
cmbBusinessEntity.EditValue = EntityIds.First()
|
||||
Try
|
||||
oHandle = SplashScreenManager.ShowOverlayForm(Me)
|
||||
|
||||
Dim oEntityIds = Await GetBusinessEntitiesForObjectId(_ObjectId)
|
||||
Dim oHistoryDataTable = Await GetValueHistoryForObjectId(_ObjectId)
|
||||
Dim oObjectProperties = Await GetPropertiesForObjectId(_ObjectId)
|
||||
Dim oCombobox As RepositoryItemComboBox = DirectCast(cmbBusinessEntity.Edit, RepositoryItemComboBox)
|
||||
oCombobox.Items.AddRange(oEntityIds)
|
||||
|
||||
|
||||
ShowAttributeHistory(oHistoryDataTable)
|
||||
ShowObjectProperties(oObjectProperties)
|
||||
|
||||
If oEntityIds.Count = 1 Then
|
||||
cmbBusinessEntity.EditValue = oEntityIds.First()
|
||||
End If
|
||||
Catch ex As ApplicationException
|
||||
_Logger.Error(ex)
|
||||
@@ -42,6 +53,10 @@ Public Class frmObjectPropertyDialog
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
MessageBox.Show("Unhandled exception occurred please check the log", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
||||
Finally
|
||||
If oHandle IsNot Nothing
|
||||
SplashScreenManager.CloseOverlayForm(oHandle)
|
||||
End If
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -67,7 +82,7 @@ Public Class frmObjectPropertyDialog
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Async Function GetBusinessEntitiesForObjectId(ObjectId) As Task(Of List(Of Long))
|
||||
Private Async Function GetBusinessEntitiesForObjectId(ObjectId As Long) 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)
|
||||
|
||||
@@ -84,6 +99,20 @@ Public Class frmObjectPropertyDialog
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Async Function GetValueHistoryForObjectId(ObjectId As Long) As Task(Of DataTable)
|
||||
Dim oSQL As String = $"SELECT * FROM VWIDB_CHANGE_LOG WHERE IDB_OBJ_ID = {ObjectId} ORDER BY ChangeID DESC"
|
||||
Dim oDatatable = Await _Db.GetDatatableAsync(oSQL)
|
||||
|
||||
Return oDatatable
|
||||
End Function
|
||||
|
||||
Private Async Function GetPropertiesForObjectId(ObjectId As Long) As Task(Of DataTable)
|
||||
Dim oSQL As String = $"SELECT * FROM TBIDB_OBJECT WHERE IDB_OBJ_ID = {ObjectId}"
|
||||
Dim oDatatable = Await _Db.GetDatatableAsync(oSQL)
|
||||
|
||||
Return oDatatable
|
||||
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})"
|
||||
@@ -103,16 +132,47 @@ Public Class frmObjectPropertyDialog
|
||||
|
||||
For Each oAttribute As Attribute In oAttributes
|
||||
Dim oControl = _Controls.GetControlForAttribute(oAttribute)
|
||||
Dim oItem As LayoutControlItem = Root.AddItem()
|
||||
Dim oItem As LayoutControlItem = AttributeLayout.AddItem()
|
||||
oItem.Text = oAttribute.Title
|
||||
oItem.Name = oAttribute.Title
|
||||
oItem.Control = oControl
|
||||
Next
|
||||
|
||||
For Each oItem As LayoutControlItem In Root.Items
|
||||
For Each oItem As LayoutControlItem In AttributeLayout.Items
|
||||
Dim oValue = Await GetAttributeValue(oItem.Name, _ObjectId)
|
||||
Dim oEdit = DirectCast(oItem.Control, BaseEdit)
|
||||
oEdit.EditValue = oValue
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Function ShowAttributeHistory(pDatatable As DataTable) As Boolean
|
||||
Try
|
||||
If pDatatable.Rows.Count > 0
|
||||
GridValueHistory.DataSource = pDatatable
|
||||
Else
|
||||
TabPageHistory.Visible = False
|
||||
End If
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function ShowObjectProperties(pDatatable As DataTable) As Boolean
|
||||
Try
|
||||
Dim oRow As DataRow = pDatatable.Rows.Item(0)
|
||||
txtObjectId.Text = oRow.Item("IDB_OBJ_ID")
|
||||
txtCreatedWhen.Text = oRow.Item("ADDED_WHEN")
|
||||
txtCreatedWho.Text = oRow.Item("ADDED_WHO")
|
||||
txtChangedWhen.Text = oRow.Item("CHANGED_WHEN")
|
||||
txtChangedWho.Text = oRow.Item("CHANGED_WHO")
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user