Пример #1
0
        /// <summary>
        /// 添加操作记录
        /// </summary>
        /// <param name="content">操作数据内容</param>
        public void AddOpreateLog(string content, UserSessionModel model, string reqUrl)
        {
            try
            {
                IActionBLL actionBll = BLLFactory <IActionBLL> .GetBLL("ActionBLL");

                //获取到请求地址对应的权限
                var act = actionBll.GetEntity(a => a.Href.Equals(reqUrl));

                //如果当前为平台后台用户
                if (model.UserType == ConstantParam.USER_TYPE_PLATFORM)
                {
                    T_PlatformOpreateLog log = new T_PlatformOpreateLog()
                    {
                        Action      = act.ActionName,
                        Desc        = content,
                        OpreaterId  = model.UserID,
                        OpreateTime = DateTime.Now
                    };
                    IPlatformOpreateLogBLL bll = FactoryBLL.BLLFactory <IPlatformOpreateLogBLL> .GetBLL("PlatformOpreateLogBLL");

                    bll.Save(log);
                }
                else if (model.UserType == ConstantParam.USER_TYPE_PROPERTY)
                {
                    T_PropertyOpreateLog log = new T_PropertyOpreateLog()
                    {
                        Action      = act.ActionName,
                        Desc        = content,
                        OpreaterId  = model.UserID,
                        OpreateTime = DateTime.Now
                    };
                    IPropertyOpreateLogBLL bll = FactoryBLL.BLLFactory <IPropertyOpreateLogBLL> .GetBLL("PropertyOpreateLogBLL");

                    bll.Save(log);
                }
                else if (model.UserType == ConstantParam.USER_TYPE_COMPANY)
                {
                    T_CompanyOpreateLog log = new T_CompanyOpreateLog()
                    {
                        Action      = act.ActionName,
                        Desc        = content,
                        OpreaterId  = model.UserID,
                        OpreateTime = DateTime.Now
                    };
                    ICompanyOpreateLogBLL bll = FactoryBLL.BLLFactory <ICompanyOpreateLogBLL> .GetBLL("CompanyOpreateLogBLL");

                    bll.Save(log);
                }
            }
            catch
            {
            }
        }
Пример #2
0
        public ActionResult PropertyLogList(OperateLogSearchModel model)
        {
            //1.初始化默认查询模型
            DateTime today = DateTime.Today;

            if (model.StartDate == null)
            {
                model.StartDate = today.AddDays(-today.Day + 1);
            }
            if (model.EndDate == null)
            {
                model.EndDate = today;
            }

            var user = this.GetSessionModel();

            Expression <Func <T_PropertyOpreateLog, bool> > where = PredicateBuilder.True <T_PropertyOpreateLog>();

            //2.如果是普通用户,只能查看自己的操作
            if (user.IsMgr == ConstantParam.USER_ROLE_DEFAULT)
            {
                where = where.And(l => l.OpreaterId == user.UserID);
            }
            //4.用户姓名查询
            if (!string.IsNullOrEmpty(model.Kword))
            {
                where = where.And(l => (l.Opreater.TrueName != null && l.Opreater.TrueName.Contains(model.Kword) || l.Opreater.UserName.Contains(model.Kword)));
            }

            DateTime endDate = model.EndDate.Value.AddDays(1);

            //4.时间范围查询
            where = where.And(l => l.OpreateTime > model.StartDate && l.OpreateTime < endDate);
            var placeId = GetSessionModel().PropertyPlaceId.Value;

            where = where.And(l => l.Opreater.PropertyPlaceId == placeId);
            //5.排序
            var sortModel = this.SettingSorting("OpreateTime", false);

            //6.调用BLL层获取日志分页数据
            IPropertyOpreateLogBLL OpreateLogBLL = BLLFactory <IPropertyOpreateLogBLL> .GetBLL("PropertyOpreateLogBLL");

            model.PropertyLogList = OpreateLogBLL.GetPageList(where, sortModel.SortName, sortModel.IsAsc, model.PageIndex) as PagedList <T_PropertyOpreateLog>;

            return(View(model));
        }