Current filter:
                                You should refresh the page.
                                Support Center
                                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, and this example demonstrates how to do this:


                                1. Introduce a new collection property to return an extended list with necessary audit entries:

                                [C#]
                                public class MyPerson : XPObject { public MyPerson(Session session) : base(session) { } public string FullName { get { return GetPropertyValue<string>("FullName"); } set { SetPropertyValue<string>("FullName", value); } } [Association, Aggregated] public XPCollection<MyAddress> Addresses { get { return GetCollection<MyAddress>("Addresses"); } } private BindingList<CustomAuditDataItem> auditTrail; public BindingList<CustomAuditDataItem> AuditTrail { get { if(auditTrail == null) { auditTrail = new BindingList<CustomAuditDataItem>(); auditTrail.AllowEdit = false; auditTrail.AllowNew = false; auditTrail.AllowRemove = false; XPCollection<AuditDataItemPersistent> rootItems = AuditedObjectWeakReference.GetAuditTrail(Session, this); if(rootItems != null) { foreach(AuditDataItemPersistent entry in rootItems) { auditTrail.Add(new CustomAuditDataItem(entry, "Person")); } } foreach(MyAddress address in Addresses) { XPCollection<AuditDataItemPersistent> addressItems = AuditedObjectWeakReference.GetAuditTrail(Session, address); if(addressItems != null) { foreach(AuditDataItemPersistent entry in addressItems) { auditTrail.Add(new CustomAuditDataItem(entry, "Address - " + address.Oid.ToString() + ", " + address.AddressLine)); } } } } return auditTrail; } } }

                                2. The standard AuditDataItemPersistent class is not designed to show information about a related object, so introduce a new CustomAuditDataItem class with an additional property:

                                [C#]
                                public class CustomAuditDataItem { private AuditDataItemPersistent sourceAuditDataItem; private string targetObjectName; public CustomAuditDataItem(AuditDataItemPersistent sourceAuditDataItem, string targetObjectName) { this.sourceAuditDataItem = sourceAuditDataItem; this.targetObjectName = targetObjectName; } public string TargetObjectName { get { return targetObjectName; } } public string Description { get { return sourceAuditDataItem.Description; } } public DateTime ModifiedOn { get { return sourceAuditDataItem.ModifiedOn; } } [Size(1024)] public string NewValue { get { return sourceAuditDataItem.NewValue; } } [Size(1024)] public string OldValue { get { return sourceAuditDataItem.OldValue; } } public string OperationType { get { return sourceAuditDataItem.OperationType; } } public string PropertyName { get { return sourceAuditDataItem.PropertyName; } } public string UserName { get { return sourceAuditDataItem.UserName; } } }

                                As a result, the application will look as follows (in addition, I have customized the layout to demonstrate items from the 'Addresses' and 'Audit' properties at once):

                                Show Implementation Details
                                Select file
                                • CustomAuditDataItem.cs
                                • MyAddress.cs
                                • MyPerson.cs
                                Select language
                                • C#
                                • VB.NET
                                Select version
                                • v2013 vol 1.4 - v2017 vol 1.4
                                • v2012 vol 2.4 - v2012 vol 2.18

                                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