Common: Fix Property Dialog, Fix context Menu in DocumentResultList

This commit is contained in:
Jonathan Jenne
2021-01-05 16:06:43 +01:00
parent 9cfdacb6f8
commit 59e925d6b2
10 changed files with 274 additions and 133 deletions

View File

@@ -8,16 +8,18 @@ Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.ZooFlow
Imports DigitalData.Modules.Language
Imports DevExpress.XtraGrid
Imports DigitalData.Modules.EDMI.API
Public Class frmObjectPropertyDialog
Private _LogConfig As LogConfig
Private _Logger As Logger
Private _Environment As Environment
Private ReadOnly _Client As Client
Private _ObjectId As Int64
Private _Db As MSSQLServer
Private _Controls As PropertyControls
Public Sub New(LogConfig As LogConfig, Environment As Environment, ObjectId As Long)
Public Sub New(LogConfig As LogConfig, Environment As Environment, Client As Client, ObjectId As Long)
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
@@ -25,6 +27,7 @@ Public Class frmObjectPropertyDialog
_LogConfig = LogConfig
_Logger = LogConfig.GetLogger()
_Environment = Environment
_Client = Client
_ObjectId = ObjectId
_Db = _Environment.DatabaseIDB
_Controls = New PropertyControls(_LogConfig, _Db)
@@ -36,6 +39,10 @@ Public Class frmObjectPropertyDialog
Try
oHandle = SplashScreenManager.ShowOverlayForm(Me)
If IsNothing(_ObjectId) Then
Throw New ApplicationException("No valid Object Id supplied!")
End If
Dim oEntityIds = Await GetBusinessEntitiesForObjectId(_ObjectId)
Dim oHistoryDataTable = Await GetValueHistoryForObjectId(_ObjectId)
Dim oObjectProperties = Await GetPropertiesForObjectId(_ObjectId)
@@ -45,15 +52,16 @@ Public Class frmObjectPropertyDialog
ShowAttributeHistory(oHistoryDataTable)
ShowObjectProperties(oObjectProperties)
If oEntityIds.Count = 1 Then
cmbBusinessEntity.EditValue = oEntityIds.First()
End If
'If oEntityIds.Count = 1 Then
' cmbBusinessEntity.EditValue = oEntityIds.First()
'End If
cmbBusinessEntity.EditValue = oEntityIds.First()
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)
MessageBox.Show("Unhandled exception occurred. Please check the log." & vbNewLine & ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Finally
If oHandle IsNot Nothing
SplashScreenManager.CloseOverlayForm(oHandle)
@@ -62,72 +70,90 @@ Public Class frmObjectPropertyDialog
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)
Try
Dim oSQL = $"SELECT * FROM VWIDB_BE_ATTRIBUTE WHERE BE_ID = {EntityId}"
Dim oResult = Await _Client.GetDatatableFromIDBAsync(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)
If oResult.OK = False Then
Throw New ApplicationException($"Attributes for Business Entity {EntityId} could not be retrieved!")
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
ElseIf oResult.Table.Rows.Count = 0 Then
Throw New ApplicationException($"BusinessEntity {EntityId} does not have any attributes!")
Return oAttributes
End If
Else
Dim oAttributes As New List(Of Attribute)
For Each oRow As DataRow In oResult.Table.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
Catch ex As Exception
_Logger.Error(ex)
Return New List(Of Attribute)
End Try
End Function
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)
Try
Dim oSQL = $"SELECT BE_ID FROM TBIDB_OBJECT_BE WHERE IDB_OBJ_ID = {ObjectId}"
Dim oResult = Await _Client.GetDatatableFromIDBAsync(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)
If oResult.OK = False Then
Throw New ApplicationException($"Business Entities could not be retrieved!")
For Each oRow In oDatatable.Rows
oEntities.Add(oRow.item("BE_ID"))
Next
ElseIf oResult.Table.Rows.Count = 0 Then
Throw New ApplicationException($"ObjectId {ObjectId} is not assigned to any business entity!")
Return oEntities
End If
Else
Dim oEntities As New List(Of Long)
For Each oRow In oResult.Table.Rows
oEntities.Add(oRow.item("BE_ID"))
Next
Return oEntities
End If
Catch ex As Exception
_Logger.Error(ex)
Return New List(Of Long)
End Try
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)
Dim oResult = Await _Client.GetDatatableFromIDBAsync(oSQL)
Return oDatatable
Return oResult.Table
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)
Dim oResult = Await _Client.GetDatatableFromIDBAsync(oSQL)
Return oDatatable
Return oResult.Table
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)
Dim oResult = Await _Client.GetScalarValueFromIDBAsync(oSQL)
Return oTermValue
Return oResult.Scalar
End Function
Private Async Function GetAttributeValueAsTable(AttributeName As String, ObjectId As Long, Optional LanguageCode As String = "de-DE", Optional IsForeign As Boolean = False) As Task(Of DataTable)
Dim oIsForeign = IIf(IsForeign, 1, 0)
Dim oSQL = $"SELECT TERM_VALUE FROM [dbo].[FNIDB_PM_GET_VARIABLE_VALUE] ({ObjectId}, '{AttributeName}', '{LanguageCode}', {oIsForeign})"
Dim oDatatable = Await _Db.GetDatatableAsync(oSQL)
Dim oResult = Await _Client.GetDatatableFromIDBAsync(oSQL)
Return oDatatable
Return oResult.Table
End Function
Private Async Sub cmbBusinessEntity_EditValueChanged(sender As Object, e As EventArgs) Handles cmbBusinessEntity.EditValueChanged