zoukankan      html  css  js  c++  java
  • XAF 14.1 DC 实现自定审计日志信息

    由于一个系统的需要,需要在日志中加入自定义的信息,并且需要根据需要过滤显示其中的部分操作记录入修改,删除等,其他的不显示,具体的实现方法如下:

    一、需要继承 AuditDataItemPersistent,具体代码如下:

            public MyAuditDataItemPersistent(DevExpress.Xpo.Session session)
                : base(session)
            {
    
            }
            [XafDisplayName("修改标题")]
            public string PropertyCaption
            {
                get
                {
                    if (AuditedObject != null)
                    {
                        try
                        {
                            var caption = CaptionHelper.GetMemberCaption(AuditedObject.Target.GetType(), PropertyName);
                            return caption;
                        }
                        catch { }
                    }
    
                    return string.Empty;
                }
    
    
            }
        }
    

     二、在WinApplication.cs中设置Audit的存储对象为MyAuditDataItemPersistent

    三、

        [XafDisplayName("修改日志")]
        IList<MyAuditDataItemPersistent>Xt_Order_Review_Detail_Audit { get; }
    
        [DomainLogic(typeof(Xt_Order_Review_Detail_Dc))]
        public class ContactLogic
        {
            private static XPCollection<MyAuditDataItemPersistent> _changeHistory;
            public static IList<MyAuditDataItemPersistent> Get_Xt_Order_Review_Detail_Audit(Xt_Order_Review_Detail_Dc obj, IObjectSpace os)
            {
                
                var source = AuditedObjectWeakReference.GetAuditTrail(((XPObjectSpace)os).Session, obj);
                if (source != null)
                {
                    try
                    {
                        _changeHistory = new XPCollection<MyAuditDataItemPersistent>(((XPObjectSpace)os).Session, source);
                        _changeHistory.Filter = CriteriaOperator.Parse("OperationType='ObjectChanged'");
                    }
                    catch { }
    
                }
                return _changeHistory;
                 //return (MyAuditDataItemPersistent)DevExpress.Persistent.BaseImpl.AuditedObjectWeakReference.GetAuditTrail(((XPObjectSpace)os).Session, obj);
            }
    
  • 相关阅读:
    [置顶] 算法设计基础
    .net 多线程学习
    如何获得Repeater中的列
    npoi导出excel
    字符串的格式化问题
    用线程修改页面中的值(一)
    正则表达式的验证数值验证
    .net 线程更新页面中的值(方法二)
    .net 线程更新页面中的值(方法一)
    字符串的分割
  • 原文地址:https://www.cnblogs.com/ddlzq/p/4169691.html
Copyright © 2011-2022 走看看