1. Home
  2. Docs
  3. Llamachant Framework Modules
  4. Extended Functionality
  5. ITrackedObject Interface

ITrackedObject Interface

While the Audit Trail Module from DevExpress is extremely useful, it’s often nice to have a quick view of when an object was created, last modified, and deleted. The ITrackedObject interface helps make that job easier for all of your XPO business objects. We typically create a CustomBaseObject class that all of our XPO objects inherit from. Within this CustomBaseObject, we use the TrackedObjectHelper class to do the work for us.

Below, you can see an example of a CustomBaseObject implementation we have used.

				
					[NonPersistent]
    public abstract class CustomBaseObject : BaseObject , ITrackedObject
    {
        public CustomBaseObject(Session session) : base(session) { }

        public override void AfterConstruction()
        {
            base.AfterConstruction();
            TrackedObjectHelper.AfterConstruction(this, nameof(CreatedBy));
        }

        protected override void OnSaving()
        {
            TrackedObjectHelper.OnSaving(this, nameof(LastModifiedBy));
            base.OnSaving();
        }

        protected override void OnDeleting()
        {
            TrackedObjectHelper.OnDeleting(this, nameof(DeletedBy));
            base.OnDeleting();
        }



        private DateTime _CreatedOn;
        [NonCloneable]
        [EditorAlias("ReadOnlyLabelPropertyEditor")]
        [ModelDefault("DisplayFormat", "{0:g}")]
        [ModelDefault("AllowEdit", "False")]
        [VisibleInDetailView(false)]
        [VisibleInListView(false)]
        [VisibleInLookupListView(false)]
        public DateTime CreatedOn
        {
            get { return _CreatedOn; }
            set { SetPropertyValue<DateTime>(nameof(CreatedOn), ref _CreatedOn, value); }
        }


        private DateTime _ModifiedOn;
        [NonCloneable]
        [EditorAlias("ReadOnlyLabelPropertyEditor")]
        [ModelDefault("DisplayFormat", "{0:g}")]
        [ModelDefault("AllowEdit", "False")]
        [VisibleInDetailView(false)]
        [VisibleInListView(false)]
        [VisibleInLookupListView(false)]
        public DateTime ModifiedOn
        {
            get { return _ModifiedOn; }
            set { SetPropertyValue<DateTime>(nameof(ModifiedOn), ref _ModifiedOn, value); }
        }


        private DateTime _DeletedOn;
        [NonCloneable]
        [EditorAlias("ReadOnlyLabelPropertyEditor")]
        [ModelDefault("DisplayFormat", "{0:g}")]
        [ModelDefault("AllowEdit", "False")]
        [VisibleInDetailView(false)]
        [VisibleInListView(false)]
        [VisibleInLookupListView(false)]
        public DateTime DeletedOn
        {
            get { return _DeletedOn; }
            set { SetPropertyValue<DateTime>(nameof(DeletedOn), ref _DeletedOn, value); }
        }


        private PermissionPolicyUser _CreatedBy;
        [NonCloneable]
        [EditorAlias("ReadOnlyLabelPropertyEditor")]
        [ModelDefault("AllowEdit", "False")]
        [VisibleInDetailView(false)]
        [VisibleInListView(false)]
        [VisibleInLookupListView(false)]
        [SearchMemberOptions(SearchMemberMode.Exclude)]
        public PermissionPolicyUser CreatedBy
        {
            get { return _CreatedBy; }
            set { SetPropertyValue<PermissionPolicyUser>(nameof(CreatedBy), ref _CreatedBy, value); }
        }


        private PermissionPolicyUser _LastModifiedBy;
        [NonCloneable]
        [EditorAlias("ReadOnlyLabelPropertyEditor")]
        [ModelDefault("AllowEdit", "False")]
        [VisibleInDetailView(false)]
        [VisibleInListView(false)]
        [VisibleInLookupListView(false)]
        [SearchMemberOptions(SearchMemberMode.Exclude)]
        public PermissionPolicyUser LastModifiedBy
        {
            get { return _LastModifiedBy; }
            set { SetPropertyValue<PermissionPolicyUser>(nameof(LastModifiedBy), ref _LastModifiedBy, value); }
        }


        private PermissionPolicyUser _DeletedBy;
        [NonCloneable]
        [EditorAlias("ReadOnlyLabelPropertyEditor")]
        [ModelDefault("AllowEdit", "False")]
        [VisibleInDetailView(false)]
        [VisibleInListView(false)]
        [VisibleInLookupListView(false)]
        [SearchMemberOptions(SearchMemberMode.Exclude)]
        public PermissionPolicyUser DeletedBy
        {
            get { return _DeletedBy; }
            set { SetPropertyValue<PermissionPolicyUser>(nameof(DeletedBy), ref _DeletedBy, value); }
        }
    }
				
			

Important Notes

Only the CreatedOn, ModifiedOn, and DeletedOn properties are required to use this interface. If you want to know who created, last modified, and deleted an object, you can link to your user class (whether it inherits from PermissionPolicyUser or not). When calling the TrackedObjectHelper methods, pass in the property name for those user properties – otherwise pass null.

Was this article helpful to you? Yes 6 No 1

How can we help?