Exemplo n.º 1
0
        /// <summary>
        /// 操作日志查询(分页)
        /// </summary>
        /// <returns></returns>
        public PagedResults <OperateLog> QueryOperateLogLogs(OperateLogParams modeLogParams)
        {
            Expression <Func <OperateLog, bool> > expression = p => true;

            if (modeLogParams.StartTime != default(DateTime))
            {
                expression = expression.And(p => p.CreateTime >= modeLogParams.StartTime);
            }

            if (modeLogParams.EndTime != default(DateTime))
            {
                if (modeLogParams.EndTime == modeLogParams.StartTime)
                {
                    modeLogParams.EndTime = modeLogParams.EndTime.AddDays(1).AddMilliseconds(-1);
                }
                expression = expression.And(p => p.CreateTime <= modeLogParams.EndTime);
            }

            if (!string.IsNullOrEmpty(modeLogParams.Function))
            {
                expression = expression.And(p => p.Function.Contains(modeLogParams.Function));
            }
            if (!string.IsNullOrEmpty(modeLogParams.IP))
            {
                expression = expression.And(p => p.ClientIp.Contains(modeLogParams.IP));
            }
            if (!string.IsNullOrEmpty(modeLogParams.Operate))
            {
                modeLogParams.Operate = modeLogParams.Operate.ToLower();
                expression            = expression.And(p => p.Operate.ToLower().Contains(modeLogParams.Operate));
            }
            if (!string.IsNullOrEmpty(modeLogParams.ManagerAccount))
            {
                expression = expression.And(p => p.ManagerAccount.Contains(modeLogParams.ManagerAccount));
            }

            return(QueryPagedResults(expression, modeLogParams));
        }
Exemplo n.º 2
0
 public ExcutedResult QueryOperateLog([FromBody] OperateLogParams model)
 {
     try
     {
         if (model == null)
         {
             return(ExcutedResult.FailedResult(BusinessResultCode.ArgumentError, "参数错误或无效"));
         }
         if (String.IsNullOrEmpty(model.SortName))
         {
             model.SortName = "CreateTime";
         }
         var dataInfo = _operateLogRepository.QueryOperateLogLogs(model);
         if (dataInfo != null)
         {
             return(ExcutedResult.SuccessResult(dataInfo));
         }
         return(ExcutedResult.FailedResult(BusinessResultCode.DataNotExist, " 数据不存在,请刷新!"));
     }
     catch (BusinessException businessException)
     {
         return(ExcutedResult.FailedResult(businessException.ErrorCode, businessException.Message));
     }
 }