Ejemplo n.º 1
0
 /// <summary>
 /// 查询用户日志
 /// </summary>
 /// <param name="Parameter"></param>
 /// <returns></returns>
 public BaseResponse <UserLogResult> UserLogInfoView(QueryUserLogParameter Parameter)
 {
     if (ValidateData <QueryUserLogParameter>(Parameter))
     {
         return(logManager.QueryUserLog(Parameter));
     }
     else
     {
         BaseResponse <UserLogResult> result = new BaseResponse <UserLogResult>();
         result.IsSuccessful = false;
         result.Code         = "001311";
         LogHelper.WriteLog(string.Format("未通过安全验证:({0}:{1}", result.Code, result.Reason));
         return(result);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 查询用户日志
        /// </summary>
        /// <param name="Parameter"></param>
        /// <returns></returns>
        public BaseResponse <UserLogResult> QueryUserLog(QueryUserLogParameter Parameter)
        {
            BaseResponse <UserLogResult> result = new BaseResponse <UserLogResult>();

            var total         = 0;
            var sortDirection = Parameter.Order.ToLower().Equals("desc") ? ListSortDirection.Descending : ListSortDirection.Ascending;

            try
            {
                IQueryable <UserLog> userLogs = null;
                if (Parameter.Page == -1)
                {
                    if (Parameter.IsSuperAdmin)
                    {
                        userLogs = userLogRepository.GetDatas <UserLog>(p => true, false);
                    }
                    else
                    {
                        userLogs = userLogRepository.GetDatas <UserLog>(t => t.UserID != 1011, false);
                    }
                }
                else
                {
                    if (Parameter.IsSuperAdmin)
                    {
                        userLogs = userLogRepository.GetDatas <UserLog>(p => true, false);
                    }
                    else
                    {
                        userLogs = userLogRepository.GetDatas <UserLog>(t => t.UserID != 1011, false);
                    }
                }

                var users = new iCMSDbContext().Users.ToList();
                var linq  = from log in userLogs
                            join user in users
                            on log.UserID equals user.UserID into userlogGroup
                            from ul in userlogGroup.DefaultIfEmpty(new User())
                            select new UserLogInfo
                {
                    UserLogID = log.UserLogID,
                    UserID    = log.UserID,
                    Record    = log.Record,
                    UserName  = ul.UserName,
                    AddDate   = log.AddDate,
                    IsDeleted = ul.IsDeleted,
                };

                result.Result = new UserLogResult
                {
                    UserLogInfo = linq.AsQueryable()
                                  .Where(Parameter.Page, Parameter.PageSize, out total, new PropertySortCondition(Parameter.Sort, sortDirection))
                                  .ToList(),
                    Total = total,
                };
                result.IsSuccessful = true;
                return(result);
            }
            catch (Exception e)
            {
                LogHelper.WriteLog(e);
                result.Code         = "003881";
                result.IsSuccessful = false;
                result.Result       = new UserLogResult {
                    Total = 0, UserLogInfo = new List <UserLogInfo>()
                };
                return(result);
            }
        }