Пример #1
0
        /// <summary>
        ///     获取用户登录日记列表
        /// </summary>
        /// <param name="parentId">父Id</param>
        /// <returns>用户登录日记列表</returns>
        public ResultModel GetUserLoginLog(SearchUserLoginLogModel model)
        {
            var tb = _database.Db.UserLoginLog;

            var where = new SimpleExpression(1, 1, SimpleExpressionType.Equal);

            if (!string.IsNullOrEmpty(model.UserName))
            {
                where = new SimpleExpression(where, tb.UserName.Like("%" + model.UserName.Trim() + "%"),
                                             SimpleExpressionType.And); //会员名称
            }

            if (model.BeginLoginTime != null)
            {
                //查询开始登陆时间
                where = new SimpleExpression(where, tb.LoginTime >= model.BeginLoginTime, SimpleExpressionType.And);
            }

            if (model.EndLoginTime != null)
            {
                //结束 时间加一天是为了查询结束当天的数据
                where = new SimpleExpression(where, tb.LoginTime < model.EndLoginTime, SimpleExpressionType.And);
            }

            var result = new ResultModel
            {
                Data =
                    new SimpleDataPagedList <UserLoginLogModel>(_database.Db.UserLoginLog.FindAll(where).OrderByLoginTimeDescending(),
                                                                model.PagedIndex, model.PagedSize)
            };

            return(result);
        }
Пример #2
0
        public JsonResult List(SearchUserLoginLogModel logmodel)
        {
            //SearchAC_OperateLogModel logmodel = new SearchAC_OperateLogModel();
            logmodel.PagedIndex = logmodel.PagedIndex == 0? 0:logmodel.PagedIndex;
            logmodel.PagedSize  = logmodel.PagedSize == 0 ? 10 : logmodel.PagedSize;
            //加一天是为查询最后一天的数据
            logmodel.EndLoginTime = logmodel.EndLoginTime == null?DateTime.Now.AddDays(1) : logmodel.EndLoginTime.Value.AddDays(1);

            //查询后台用户登录日志表
            var result = this._userLoginLogService.GetUserLoginLog(logmodel);
            List <UserLoginLogModel> ds = result.Data;
            var data = new
            {
                rows  = ds,
                total = result.Data.TotalCount,
            };

            return(Json(data, JsonRequestBehavior.AllowGet));
        }