Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • Hi, i need to show audit info about a master object and his childs in a unique popup.
                                    Actually i've implemented this code to show audit info:

                                    Public Class viewAudit
                                        Inherits DevExpress.ExpressApp.ViewController
                                        Private showAuditInfoActionCore As SimpleAction

                                        Public Sub New()
                                            showAuditInfoActionCore = New SimpleAction(Me, "ShowAuditInfo", DevExpress.Persistent.Base.PredefinedCategory.View)
                                            showAuditInfoActionCore.Caption = "Cronologia modifiche"
                                            showAuditInfoActionCore.ImageName = "Audit"
                                            AddHandler showAuditInfoActionCore.Execute, AddressOf showAuditInfoActionCore_Execute
                                            showAuditInfoActionCore.PaintStyle = ActionItemPaintStyle.Image
                                            showAuditInfoActionCore.TargetViewType = ViewType.Any
                                        End Sub
                                        
                                    Public Function GetAuditInfo(ByVal session As Session, ByVal targetType As Type) As XPCollection(Of AuditDataItemPersistent)
                                            Dim bo1 As New BinaryOperator("TargetType", session.GetObjectType(session.GetClassInfo(targetType)))
                                            Dim bo2 As New BinaryOperator("TargetKey", XPWeakReference.KeyToString(ObjectSpace.GetKeyValue(Me.View.CurrentObject)))
                                            Dim auditObjectWeakReference As AuditedObjectWeakReference = session.FindObject(Of AuditedObjectWeakReference)(New GroupOperator(GroupOperatorType.And, bo1, bo2))
                                            If auditObjectWeakReference IsNot Nothing Then
                                                auditObjectWeakReference.AuditDataItems.BindingBehavior = CollectionBindingBehavior.AllowNone
                                                Return auditObjectWeakReference.AuditDataItems
                                            End If
                                            Return Nothing
                                    End Function

                                        Protected Overridable Sub ShowAuditInfo(ByVal e As SimpleActionExecuteEventArgs)
                                            Dim auditInfo As XPCollection(Of AuditDataItemPersistent)
                                            Dim objSpace As XPObjectSpace = CType(View.ObjectSpace, XPObjectSpace)
                                            auditInfo = GetAuditInfo(CType(View.ObjectSpace, XPObjectSpace).Session, View.ObjectTypeInfo.Type)
                                            If auditInfo IsNot Nothing Then
                                                Dim cs As CollectionSourceBase = New CollectionSource(objSpace, GetType(AuditDataItemPersistent))
                                                e.ShowViewParameters.CreatedView = Application.CreateListView(Application.FindListViewId(GetType(AuditDataItemPersistent)), cs, False)
                                                e.ShowViewParameters.CreatedView.Caption = String.Format("{0} History", e.ShowViewParameters.CreatedView.ObjectTypeInfo.Name)
                                                cs.Criteria("AllAuditInfo") = New InOperator(objSpace.GetKeyPropertyName(GetType(AuditDataItemPersistent)), auditInfo)
                                                e.ShowViewParameters.Context = TemplateContext.View
                                                e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow
                                            Else
                                                XtraMessageBox.Show("Non ci sono dati nella cronologia.", Application.Title, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information)
                                            End If
                                        End Sub

                                        Private Sub showAuditInfoActionCore_Execute(ByVal sender As Object, ByVal e As SimpleActionExecuteEventArgs)
                                            ShowAuditInfo(e)
                                        End Sub

                                        Public ReadOnly Property ShowAuditInfoAction() As SimpleAction
                                            Get
                                                Return showAuditInfoActionCore
                                            End Get
                                        End Property

                                    End Class

                                    In the GetAuditInfo sub i'd like to return a complete collection of AuditDataItemPersistent referred to master object and childs too.
                                    How can i get all types and all id's of object referred from the master object so i can create the criteria and return the complete collection?
                                    Thanks,
                                    Paolo

                                • Please accept our apologies for the delay in responding. We couldn't find an immediate answer or resolution. Please bear with us. We will inform you as soon as an answer is found.

                                1 Solution

                                Creation Date Rating Importance Sort by
                                0

                                The AuditTrail module is not designed to show audit information about a current object and each object from its collection property.
                                However, you can implement this behavior manually. I have demonstrated how to do this in the following example: Audit - How to show audit entries for a current object and for each object from its collection property in one list.
                                Generic implementation that shows audit entries for a current object and its related objects from all collection properties is a complicated task, so we cannot provide an immediate complete solution. In the meantime, check the How to: Access Business Class Metadata topic and the corresponding example How to: Access Business Class Metadata, where we described how to get information about properties of any persistent type.

                                • Paolo Parente 03.12.2013

                                  Why this code doesn't works??

                                      Public Function GetAuditInfo(ByVal session As Session, ByVal targetType As Type) As XPCollection(Of AuditDataItemPersistent)

                                          Dim g1 As New GroupOperator
                                          Dim retcoll As New XPCollection(Of AuditDataItemPersistent)(session)

                                          For Each mi As XPMemberInfo In session.GetClassInfo(targetType).CollectionProperties
                                              If mi.IsAggregated AndAlso mi.IsCollection AndAlso mi.IsAssociation Then

                                                  Dim objs As ICollection = mi.GetValue(Me.View.CurrentObject)

                                                  For Each obj As IXPObject In objs
                                                      Dim b1 As New BinaryOperator("TargetType", session.GetObjectType(session.GetClassInfo(obj)))
                                                      Dim b2 As New BinaryOperator("TargetKey", XPWeakReference.KeyToString(ObjectSpace.GetKeyValue(obj)))
                                                      g1 = GroupOperator.Combine(GroupOperatorType.And, b1, b2)

                                                      Dim auditObjectWeakReference As AuditedObjectWeakReference = session.FindObject(Of AuditedObjectWeakReference)(g1)
                                                      If auditObjectWeakReference IsNot Nothing Then
                                                          auditObjectWeakReference.AuditDataItems.BindingBehavior = CollectionBindingBehavior.AllowNone
                                                          retcoll.AddRange(auditObjectWeakReference.AuditDataItems)
                                                      End If
                                                  Next obj

                                              End If
                                          Next mi

                                          Return retcoll

                                      End Function

                                  Thanks,
                                  Paolo

                                • Dan (DevExpress) 03.13.2013

                                  I have integrated your code into the Audit - How to show audit entries for a current object and for each object from its collection property in one list example with only one change:

                                  [VB.NET]
                                  'Dim retcoll As New XPCollection(Of AuditDataItemPersistent)(session) Dim retcoll As New List(Of AuditDataItemPersistent)()
                                  because the XPCollection class automatically loads its content from the database when its items are queried the first time and removes your manually added items.
                                  With this change, your code works as expected: all audit entries for each object in the aggregated 'Addresses' collection are loaded and shown. For more details, see the attached solution.
                                  Don't hesitate to write to me if I misunderstand your needs. In this case, please describe the current behavior of your code and the necessary behavior in greater detail.

                                • Paolo Parente 03.13.2013

                                  Thanks, it works!!
                                  Paolo

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2017 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners