Common: ObjectPropertyDialog improvements, DocumentResultList Improvements
This commit is contained in:
@@ -6,6 +6,9 @@ Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports DigitalData.Modules.ZooFlow
|
||||
Imports DevExpress.XtraSplashScreen
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DigitalData.Modules.Base.IDB
|
||||
Imports DevExpress.XtraLayout
|
||||
|
||||
Public Class ctrlObjectPropertyDialog
|
||||
Implements IBaseForm
|
||||
@@ -14,15 +17,20 @@ Public Class ctrlObjectPropertyDialog
|
||||
Private Property Logger As Logger Implements IBaseForm.Logger
|
||||
Private Property ErrorHandler As BaseErrorHandler Implements IBaseForm.ErrorHandler
|
||||
Private Property ControlManager As AttributeControls
|
||||
Private Property GridBuilder As GridBuilder
|
||||
Private Property Client As Client
|
||||
Private Property Environment As Environment
|
||||
Private Property ObjectId As Long
|
||||
|
||||
Private ReadOnly Changes As New Dictionary(Of String, Object)
|
||||
|
||||
Public ReadOnly Property HasChanges As Boolean
|
||||
Get
|
||||
Return Changes.Count > 0
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private Loading As Boolean = False
|
||||
|
||||
Private IsLoading As Boolean = False
|
||||
Private LastEntityId As Integer = 0
|
||||
|
||||
Private Sub ctrlObjectPropertyDialog_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
@@ -34,10 +42,42 @@ Public Class ctrlObjectPropertyDialog
|
||||
Logger = pLogConfig.GetLogger()
|
||||
ErrorHandler = New BaseErrorHandler(pLogConfig, pHostForm)
|
||||
ControlManager = New AttributeControls(pLogConfig, pEnv, pClient)
|
||||
|
||||
GridBuilder = New GridBuilder(ViewObjectHistory, ViewValueHistory)
|
||||
GridBuilder.
|
||||
WithDefaults().
|
||||
WithReadOnlyOptions().
|
||||
WithClipboardHandler()
|
||||
|
||||
AddHandler ControlManager.EditValueChanged, AddressOf BaseEdit_EditValueChanged
|
||||
|
||||
Client = pClient
|
||||
Environment = pEnv
|
||||
End Sub
|
||||
|
||||
Public Async Function SaveChanges() As Task
|
||||
Try
|
||||
For Each oChange As KeyValuePair(Of String, Object) In Changes
|
||||
Logger.Info("Updating Attribute [{0}] with value [{1}]", oChange.Key, oChange.Value.ToString)
|
||||
Await Client.SetAttributeValueAsync(ObjectId, oChange.Key, oChange.Value, New Options.SetAttributeValueOptions With {
|
||||
.Language = Environment.User.Language,
|
||||
.Username = Environment.User.UserName
|
||||
})
|
||||
|
||||
Logger.Info("Updating Object State for Object [{0}]", ObjectId)
|
||||
Await Client.SetObjectStateAsync(ObjectId, FileStore.OBJECT_STATE_METADATA_CHANGED, New Options.SetObjectStateOptions With {
|
||||
.Language = Environment.User.Language,
|
||||
.Username = Environment.User.UserName
|
||||
})
|
||||
Next
|
||||
|
||||
ErrorHandler.ShowInfoMessage($"{Changes.Count} Änderungen gespeichert!")
|
||||
Changes.Clear()
|
||||
Catch ex As Exception
|
||||
ErrorHandler.ShowErrorMessage(ex, "SaveChanges")
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Async Function LoadObject(pObjectId As Long) As Task(Of Boolean)
|
||||
' Load Business Entities
|
||||
Dim oEntityIds = Await GetBusinessEntitiesForObjectId(pObjectId)
|
||||
@@ -52,7 +92,7 @@ Public Class ctrlObjectPropertyDialog
|
||||
End Function
|
||||
|
||||
Public Async Function LoadObject(pObjectId As Long, pEntityId As Long) As Task(Of Boolean)
|
||||
Loading = True
|
||||
IsLoading = True
|
||||
Dim oLoadingHandle = SplashScreenManager.ShowOverlayForm(Me)
|
||||
|
||||
Try
|
||||
@@ -85,13 +125,16 @@ Public Class ctrlObjectPropertyDialog
|
||||
' Save the current entity id
|
||||
LastEntityId = pEntityId
|
||||
|
||||
' Delete all existing changes from other objects
|
||||
Changes.Clear()
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
Finally
|
||||
SplashScreenManager.CloseOverlayForm(oLoadingHandle)
|
||||
Loading = False
|
||||
IsLoading = False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
@@ -123,8 +166,8 @@ Public Class ctrlObjectPropertyDialog
|
||||
txtObjectId.Text = oRow.Item("IDB_OBJ_ID")
|
||||
txtCreatedWhen.Text = oRow.Item("ADDED_WHEN")
|
||||
txtCreatedWho.Text = oRow.Item("ADDED_WHO")
|
||||
txtChangedWhen.Text = Utils.NotNull(oRow.Item("CHANGED_WHEN"), String.Empty)
|
||||
txtChangedWho.Text = Utils.NotNull(oRow.Item("CHANGED_WHO"), String.Empty)
|
||||
txtChangedWhen.Text = Utils.NotNull(oRow.Item("CHANGED_WHEN_SUBSTRUCTURE"), String.Empty)
|
||||
txtChangedWho.Text = Utils.NotNull(oRow.Item("CHANGED_WHO_SUBSTRUCTURE"), String.Empty)
|
||||
|
||||
lbLifecycleStart.Text = DirectCast(oRow.Item("ADDED_WHEN"), Date).ToShortDateString
|
||||
lbLifecycleEnd.Text = Date.MaxValue.ToShortDateString
|
||||
@@ -199,8 +242,6 @@ Public Class ctrlObjectPropertyDialog
|
||||
MsgBox($"Es konnten keine Attribute für das Objekt '{pObjectId}' geladen werden!", MsgBoxStyle.Critical, Text)
|
||||
End If
|
||||
|
||||
|
||||
|
||||
ControlManager.LoadControlsForAttributes(oAttributes, Root)
|
||||
Await ControlManager.LoadControlValuesForAttributes(pObjectId, Root)
|
||||
Catch ex As Exception
|
||||
@@ -211,8 +252,28 @@ Public Class ctrlObjectPropertyDialog
|
||||
Private Async Sub cmbEntityId_EditValueChanged(sender As Object, e As EventArgs) Handles cmbEntityId.EditValueChanged
|
||||
Dim oEntityId As Long
|
||||
|
||||
If Integer.TryParse(cmbEntityId.EditValue, oEntityId) AndAlso Loading = False Then
|
||||
If Integer.TryParse(cmbEntityId.EditValue, oEntityId) AndAlso IsLoading = False Then
|
||||
Await LoadObject(ObjectId, oEntityId)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub BaseEdit_EditValueChanged(sender As Object, e As EventArgs)
|
||||
If IsLoading = True Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oControlItem As LayoutControlItem = sender
|
||||
Dim oControl As BaseEdit = oControlItem.Control
|
||||
Dim oAttribute As Attribute = oControl.Tag
|
||||
Dim oValue = oControl.EditValue
|
||||
Dim oKey = oAttribute.Title
|
||||
|
||||
If Changes.ContainsKey(oKey) Then
|
||||
Changes.Item(oKey) = oValue
|
||||
Else
|
||||
Changes.Add(oAttribute.Title, oValue)
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user