/// <summary>
        /// 查询用户
        /// </summary>
        /// <param name="userQuery">查询用户条件</param>
        /// <param name="pageSize">页面显示条数</param>
        /// <param name="pageIndex">页码</param>
        /// <returns>用户分页集合</returns>
        public PagingDataSet <User> GetUsers(UserQuery userQuery, int pageSize, int pageIndex)
        {
            var sql_select = PetaPoco.Sql.Builder;

            sql_select.Select("*").From("tn_Users");

            buildSqlWhere(userQuery, ref sql_select);

            switch (userQuery.UserSortBy)
            {
            case UserSortBy.UserId:
                sql_select.OrderBy("UserId");
                break;

            case UserSortBy.UserId_Desc:
                sql_select.OrderBy("UserId DESC");
                break;

            case UserSortBy.LastActivityTime:
                sql_select.OrderBy("LastActivityTime");
                break;

            case UserSortBy.LastActivityTime_Desc:
                sql_select.OrderBy("LastActivityTime DESC");
                break;

            case UserSortBy.IsActivated:
                sql_select.OrderBy("IsActivated");
                break;

            case UserSortBy.IsActivated_Desc:
                sql_select.OrderBy("IsActivated DESC");
                break;

            case UserSortBy.IsModerated:
                sql_select.OrderBy("IsModerated");
                break;

            case UserSortBy.IsModerated_Desc:
                sql_select.OrderBy("IsModerated DESC");
                break;

            default:
                sql_select.OrderBy("UserId DESC");
                break;
            }

            //if (!string.IsNullOrEmpty(userQuery.Keyword) || !string.IsNullOrEmpty(userQuery.AccountEmailFilter) || userQuery.RegisterTimeLowerLimit.HasValue || userQuery.RegisterTimeUpperLimit.HasValue)
            return(GetPagingEntities(pageSize, pageIndex, sql_select));
            //else
            //    return base.GetPagingEntities(pageSize, pageIndex, CachingExpirationType.ObjectCollection,
            //         () =>
            //         {
            //             StringBuilder sb = new StringBuilder(RealTimeCacheHelper.GetListCacheKeyPrefix(CacheVersionType.GlobalVersion));
            //             if (!string.IsNullOrEmpty(userQuery.RoleName))
            //                 sb.AppendFormat("UserRoleName-{0}", userQuery.RoleName);
            //             if (userQuery.IsActivated.HasValue)
            //                 sb.AppendFormat("IsActivated-{0}", userQuery.IsActivated);
            //             if (userQuery.IsBanned.HasValue)
            //                 sb.AppendFormat("IsBanned-{0}", userQuery.IsBanned);
            //             if (userQuery.IsModerated.HasValue)
            //                 sb.AppendFormat("IsModerated-{0}", userQuery.IsModerated);
            //             if (userQuery.UserRankLowerLimit.HasValue)
            //                 sb.AppendFormat("UserRankLowerLimit-{0}", userQuery.UserRankLowerLimit);
            //             if (userQuery.UserRankUpperLimit.HasValue)
            //                 sb.AppendFormat("UserRankUpperLimit-{0}", userQuery.UserRankUpperLimit);
            //             sb.AppendFormat("UserSortBy-{0}", ((int?)userQuery.UserSortBy ?? 2));
            //             return sb.ToString();
            //         },
            //         () =>
            //         {
            //             return sql_select;
            //         });
        }
Exemple #2
0
 /// <summary>
 /// 查询用户
 /// </summary>
 /// <param name="userService"></param>
 /// <param name="userQuery">查询用户条件</param>
 /// <param name="pageSize">页面显示条数</param>
 /// <param name="pageIndex">页码</param>
 /// <returns></returns>
 public static PagingDataSet<User> GetUsers(this IUserService userService, UserQuery userQuery, int pageSize, int pageIndex)
 {
     IUserRepository userRepository = userService.GetUserRepository();
     return userRepository.GetUsers(userQuery, pageSize, pageIndex);
 }
Exemple #3
0
        /// <summary>
        /// 查询用户
        /// </summary>
        /// <param name="userService"></param>
        /// <param name="userQuery">查询用户条件</param>
        /// <param name="pageSize">页面显示条数</param>
        /// <param name="pageIndex">页码</param>
        /// <returns></returns>
        public static PagingDataSet <User> GetUsers(this IUserService userService, UserQuery userQuery, int pageSize, int pageIndex)
        {
            IUserRepository userRepository = userService.GetUserRepository();

            return(userRepository.GetUsers(userQuery, pageSize, pageIndex));
        }
Exemple #4
0
        /// <summary>
        /// 重建索引
        /// </summary>  
        public void RebuildIndex()
        {
            //pageSize参数决定了每次批量取多少条数据进行索引。要注意的是,如果是分布式搜索,客户端会将这部分数据通过WCF传递给服务器端,而WCF默认的最大传输数据量是65535B,pageSize较大时这个设置显然是不够用的,WCF会报400错误;系统现在将最大传输量放宽了,但仍要注意一次不要传输过多,如遇异常,可适当调小pageSize的值
            int pageSize = 1000;
            int pageIndex = 1;
            long totalRecords = 0;
            bool isBeginning = true;
            bool isEndding = false;
            UserQuery query = new UserQuery();

            do
            {
                Dictionary<long, dynamic> userDictionary = new Dictionary<long, dynamic>();

                //分页获取用户列表
                PagingDataSet<User> users = userService.GetUsers(query, pageSize, pageIndex);
                totalRecords = users.TotalRecords;

                isEndding = (pageSize * pageIndex < totalRecords) ? false : true;
                List<long> userIds = new List<long>();

                //以用户id为key,存入字典类
                foreach (User user in users.ToList<User>())
                {
                    //构建动态对象,用于存放用户搜索相关字段
                    dynamic dUser = new ExpandoObject();
                    dUser.UserId = user.UserId;
                    dUser.UserName = user.UserName;
                    dUser.TrueName = user.TrueName;
                    dUser.NickName = user.NickName;
                    dUser.DateCreated = user.DateCreated;
                    dUser.LastActivityTime = user.LastActivityTime;

                    //初始化动态对象
                    dUser.Gender = null;
                    dUser.Birthday = null;
                    dUser.LunarBirthday = null;
                    dUser.BirthdayType = null;
                    dUser.NowAreaCode = null;
                    dUser.HomeAreaCode = null;
                    dUser.AvatarImage = null;
                    dUser.Introduction = null;
                    dUser.Schools = new List<string>();
                    dUser.CompanyNames = new List<string>();
                    dUser.TagNames = new List<string>();

                    dUser.AvatarImage = user.Avatar;
                    userDictionary.Add(user.UserId, dUser);
                    userIds.Add(user.UserId);
                }

                //根据用户id列表查询基本资料
                IEnumerable<UserProfile> userProfiles = userProfileService.GetUserProfiles(userIds);
                foreach (UserProfile userProfile in userProfiles)
                {
                    dynamic dUser = userDictionary[userProfile.UserId];
                    dUser.Gender = userProfile.Gender;
                    dUser.Birthday = userProfile.Birthday;
                    dUser.LunarBirthday = userProfile.LunarBirthday;
                    dUser.BirthdayType = userProfile.BirthdayType;
                    dUser.NowAreaCode = userProfile.NowAreaCode;
                    dUser.HomeAreaCode = userProfile.HomeAreaCode;
                    dUser.Introduction = userProfile.Introduction;
                }

                //根据用户id列表查询教育经历
                IEnumerable<long> educationExperienceIds = userProfileService.GetEducationExperienceIdsByUserIds(userIds);
                IEnumerable<EducationExperience> educationExperiences = userProfileService.GetEducationExperiences(educationExperienceIds);
                foreach (EducationExperience educationExperience in educationExperiences)
                {
                    dynamic dUser = userDictionary[educationExperience.UserId];
                    dUser.Schools.Add(educationExperience.School);
                }

                //根据用户id列表查询工作经历
                IEnumerable<long> workExperienceIds = userProfileService.GetWorkExperienceIdsByUserIds(userIds);
                IEnumerable<WorkExperience> workExperiences = userProfileService.GetWorkExperiences(workExperienceIds);
                foreach (WorkExperience workExperience in workExperiences)
                {
                    dynamic dUser = userDictionary[workExperience.UserId];
                    dUser.CompanyNames.Add(workExperience.CompanyName);
                }

                //根据用户id列表查询tags

                //fixed by jiangshl,修改了方法名,此处是为了性能考虑,以用户ID列表为参数,批量查询出对应的ItemInTag的ID,再批量查询出ItemInTag实体
                IEnumerable<long> itemInTagIds = tagService.GetItemInTagIdsByItemIds(userIds);
                IEnumerable<ItemInTag> itemInTags = tagService.GetItemInTags(itemInTagIds);
                foreach (ItemInTag itemInTag in itemInTags)
                {
                    dynamic dUser = userDictionary[itemInTag.ItemId];
                    dUser.TagNames.Add(itemInTag.TagName);
                }

                //重建索引
                List<dynamic> userList = new List<dynamic>();
                userList.AddRange(userDictionary.Values);

                IEnumerable<Document> docs = UserIndexDocument.Convert(userList);

                searchEngine.RebuildIndex(docs, isBeginning, isEndding);

                isBeginning = false;
                pageIndex++;
            }
            while (!isEndding);
        }
Exemple #5
0
        /// <summary>
        /// 重建索引
        /// </summary>
        public void RebuildIndex()
        {
            //pageSize参数决定了每次批量取多少条数据进行索引。要注意的是,如果是分布式搜索,客户端会将这部分数据通过WCF传递给服务器端,而WCF默认的最大传输数据量是65535B,pageSize较大时这个设置显然是不够用的,WCF会报400错误;系统现在将最大传输量放宽了,但仍要注意一次不要传输过多,如遇异常,可适当调小pageSize的值
            int       pageSize     = 1000;
            int       pageIndex    = 1;
            long      totalRecords = 0;
            bool      isBeginning  = true;
            bool      isEndding    = false;
            UserQuery query        = new UserQuery();

            do
            {
                Dictionary <long, dynamic> userDictionary = new Dictionary <long, dynamic>();

                //分页获取用户列表
                PagingDataSet <User> users = userService.GetUsers(query, pageSize, pageIndex);
                totalRecords = users.TotalRecords;

                isEndding = (pageSize * pageIndex < totalRecords) ? false : true;
                List <long> userIds = new List <long>();

                //以用户id为key,存入字典类
                foreach (User user in users.ToList <User>())
                {
                    //构建动态对象,用于存放用户搜索相关字段
                    dynamic dUser = new ExpandoObject();
                    dUser.UserId           = user.UserId;
                    dUser.UserName         = user.UserName;
                    dUser.TrueName         = user.TrueName;
                    dUser.NickName         = user.NickName;
                    dUser.DateCreated      = user.DateCreated;
                    dUser.LastActivityTime = user.LastActivityTime;

                    //初始化动态对象
                    dUser.Gender        = null;
                    dUser.Birthday      = null;
                    dUser.LunarBirthday = null;
                    dUser.BirthdayType  = null;
                    dUser.NowAreaCode   = null;
                    dUser.HomeAreaCode  = null;
                    dUser.AvatarImage   = null;
                    dUser.Introduction  = null;
                    dUser.Schools       = new List <string>();
                    dUser.CompanyNames  = new List <string>();
                    dUser.TagNames      = new List <string>();

                    dUser.AvatarImage = user.Avatar;
                    userDictionary.Add(user.UserId, dUser);
                    userIds.Add(user.UserId);
                }

                //根据用户id列表查询基本资料
                IEnumerable <UserProfile> userProfiles = userProfileService.GetUserProfiles(userIds);
                foreach (UserProfile userProfile in userProfiles)
                {
                    dynamic dUser = userDictionary[userProfile.UserId];
                    dUser.Gender        = userProfile.Gender;
                    dUser.Birthday      = userProfile.Birthday;
                    dUser.LunarBirthday = userProfile.LunarBirthday;
                    dUser.BirthdayType  = userProfile.BirthdayType;
                    dUser.NowAreaCode   = userProfile.NowAreaCode;
                    dUser.HomeAreaCode  = userProfile.HomeAreaCode;
                    dUser.Introduction  = userProfile.Introduction;
                }

                //根据用户id列表查询教育经历
                IEnumerable <long> educationExperienceIds = userProfileService.GetEducationExperienceIdsByUserIds(userIds);
                IEnumerable <EducationExperience> educationExperiences = userProfileService.GetEducationExperiences(educationExperienceIds);
                foreach (EducationExperience educationExperience in educationExperiences)
                {
                    dynamic dUser = userDictionary[educationExperience.UserId];
                    dUser.Schools.Add(educationExperience.School);
                }

                //根据用户id列表查询工作经历
                IEnumerable <long>           workExperienceIds = userProfileService.GetWorkExperienceIdsByUserIds(userIds);
                IEnumerable <WorkExperience> workExperiences   = userProfileService.GetWorkExperiences(workExperienceIds);
                foreach (WorkExperience workExperience in workExperiences)
                {
                    dynamic dUser = userDictionary[workExperience.UserId];
                    dUser.CompanyNames.Add(workExperience.CompanyName);
                }

                //根据用户id列表查询tags

                //fixed by jiangshl,修改了方法名,此处是为了性能考虑,以用户ID列表为参数,批量查询出对应的ItemInTag的ID,再批量查询出ItemInTag实体
                IEnumerable <long>      itemInTagIds = tagService.GetItemInTagIdsByItemIds(userIds);
                IEnumerable <ItemInTag> itemInTags   = tagService.GetItemInTags(itemInTagIds);
                foreach (ItemInTag itemInTag in itemInTags)
                {
                    dynamic dUser = userDictionary[itemInTag.ItemId];
                    dUser.TagNames.Add(itemInTag.TagName);
                }

                //重建索引
                List <dynamic> userList = new List <dynamic>();
                userList.AddRange(userDictionary.Values);

                IEnumerable <Document> docs = UserIndexDocument.Convert(userList);

                searchEngine.RebuildIndex(docs, isBeginning, isEndding);

                isBeginning = false;
                pageIndex++;
            }while (!isEndding);
        }
Exemple #6
0
        public ActionResult ManageUsers(int?pageIndex, int pageSize = 30)
        {
            pageResourceManager.InsertTitlePart("用户管理");

            #region 组装搜索条件


            UserQuery query = new UserQuery();
            query.Keyword            = Request.QueryString.GetString("uname", string.Empty);
            query.AccountEmailFilter = Request.QueryString.GetString("uemail", string.Empty);
            query.RoleName           = Request.QueryString.GetString("RoleName", string.Empty);

            if (!string.IsNullOrEmpty(Request.QueryString["IsActivated"]))
            {
                query.IsActivated = Request.QueryString.GetBool("IsActivated", false);
            }

            if (!string.IsNullOrEmpty(Request.QueryString["IsModerated"]))
            {
                query.IsModerated = Request.QueryString.GetBool("IsModerated", false);
            }

            if (!string.IsNullOrEmpty(Request.QueryString["IsBanned"]))
            {
                query.IsBanned = Request.QueryString.GetBool("IsBanned", false);
            }


            int result = 0;
            if (int.TryParse(Request.QueryString["rankstart"], out result))
            {
                query.UserRankLowerLimit = Request.QueryString.GetInt("rankstart", 0);
            }

            if (int.TryParse(Request.QueryString["rankend"], out result))
            {
                query.UserRankUpperLimit = Request.QueryString.GetInt("rankend", 0);
            }

            if (Request.QueryString.Get <DateTime>("startdate") != DateTime.MinValue)
            {
                query.RegisterTimeLowerLimit = Request.QueryString.Get <DateTime>("startdate");
            }

            if (Request.QueryString.Get <DateTime>("enddate") != DateTime.MinValue)
            {
                query.RegisterTimeUpperLimit = Request.QueryString.Get <DateTime>("enddate");
            }

            #endregion

            #region 组装搜索下拉列表

            IEnumerable <Role> roles = roleService.GetRoles();
            if (roles != null)
            {
                ViewData["RoleName"] = new SelectList(roles, "RoleName", "FriendlyRoleName", query.RoleName);
            }

            Dictionary <bool, string> activatedValues = new Dictionary <bool, string> {
                { true, "已激活" }, { false, "未激活" }
            };
            ViewData["IsActivated"] = new SelectList(activatedValues.Select(n => new { text = n.Value, value = n.Key.ToString().ToLower() }), "value", "text", query.IsActivated);

            Dictionary <bool, string> moderatedValues = new Dictionary <bool, string> {
                { true, "管制" }, { false, "未管制" }
            };
            ViewData["IsModerated"] = new SelectList(moderatedValues.Select(n => new { text = n.Value, value = n.Key.ToString().ToLower() }), "value", "text", query.IsModerated);

            Dictionary <bool, string> bannedValues = new Dictionary <bool, string> {
                { true, "封禁" }, { false, "未封禁" }
            };
            ViewData["IsBanned"] = new SelectList(bannedValues.Select(n => new { text = n.Value, value = n.Key.ToString().ToLower() }), "value", "text", query.IsBanned);

            #endregion
            pageIndex = pageIndex ?? 1;
            PagingDataSet <User> users = userService.GetUsers(query, pageSize, pageIndex.Value);
            if (pageIndex > 1 && (users == null || users.Count() == 0))
            {
                users = userService.GetUsers(query, pageSize, pageIndex.Value - 1);
                var dd = Request.Url.Query;
            }

            return(View(users));
        }
Exemple #7
0
        public ActionResult Home()
        {
            pageResourceManager.InsertTitlePart("后台首页");

            ApplicationService applicationService = new ApplicationService();
            //获得所有应用的应用名
            IEnumerable <ApplicationBase> applications = applicationService.GetAll();
            //初始化待处理应用数组
            List <ApplicationStatisticData> allManageableDatas = new List <ApplicationStatisticData>();
            //初始化数据统计项实体数组
            List <ApplicationStatisticItem> statisticItems = new List <ApplicationStatisticItem>();

            var authorizer         = new Authorizer();
            var isApplicationAdmin = !UserContext.CurrentUser.IsInRoles(RoleNames.Instance().SuperAdministrator(), RoleNames.Instance().ContentAdministrator());

            //遍历应用名
            foreach (var application in applications)
            {
                if (isApplicationAdmin)
                {
                    if (!authorizer.IsAdministrator(application.ApplicationId))
                    {
                        continue;
                    }
                }
                //获取所有待处理数据实体
                IEnumerable <ApplicationStatisticData> manageableDatas = DIContainer.ResolveNamed <IApplicationStatisticDataGetter>(application.ApplicationKey).GetManageableDatas();
                //获取所有数据统计应用数据实体
                IEnumerable <ApplicationStatisticData> applicationStatisticDatas = DIContainer.ResolveNamed <IApplicationStatisticDataGetter>(application.ApplicationKey).GetStatisticDatas();
                //将所有待处理数据实体添加到未处理应用数组
                allManageableDatas.AddRange(manageableDatas);
                //遍历所有应用简称
                foreach (string shortName in applicationStatisticDatas.Select(n => n.ShortName))
                {
                    //如果数组中已存在该应用则继续
                    var item = statisticItems.Where(n => n.ShortName == shortName).FirstOrDefault();
                    if (statisticItems.Contains(item))
                    {
                        continue;
                    }
                    //获取该简称下的应用数组
                    IEnumerable <ApplicationStatisticData> datas = applicationStatisticDatas.Where(n => n.ShortName == shortName);
                    //获取该简称下的总数应用
                    ApplicationStatisticData applicationStatisticDataTotal = datas.Where(n => n.DataKey == ApplicationStatisticDataKeys.Instance().TotalCount()).FirstOrDefault();
                    //初始化总数
                    long totalCount = 0;
                    //初始化URL
                    string itemUrl = null;
                    //如果存在总数应用
                    if (applicationStatisticDataTotal != null)
                    {
                        //为数据统计项实体总数和url赋值
                        totalCount = applicationStatisticDataTotal.Value;
                        itemUrl    = applicationStatisticDataTotal.Url;
                    }
                    //获取该简称下的24小时新增数应用
                    var applicationStatisticDataLast24H = datas.Where(n => n.DataKey == ApplicationStatisticDataKeys.Instance().Last24HCount()).FirstOrDefault();
                    //初始化24小时新增数
                    long Last24H = 0;
                    //如果存在24小时新增数应用
                    if (applicationStatisticDataLast24H != null)
                    {
                        //为总数项实体24小时新增数赋值
                        Last24H = applicationStatisticDataLast24H.Value;
                    }
                    //实例化数据统计项实体
                    ApplicationStatisticItem appItem = new ApplicationStatisticItem(shortName, totalCount, Last24H);
                    appItem.Url = itemUrl;
                    //添加到数组
                    statisticItems.Add(appItem);
                }
            }
            //获取待处理事项实体数组
            ViewData["allManageableDatas"] = allManageableDatas;

            //增加有多少个待审核评论
            PagingDataSet <Comment> comments = new CommentService().GetComments(PubliclyAuditStatus.Pending, null, null, null, null, 20, 1);

            ViewData["commentsCount"] = comments.TotalRecords;

            //多少未读客服消息
            ViewData["customMessageCount"] = new MessageService().GetUnreadCount((long)BuildinMessageUserId.CustomerService);

            //待处理用户举报
            ViewData["impeachCount"] = new ImpeachReportService().GetsForAdmin(false, null).TotalRecords;

            //待激活的用户
            UserQuery userQuery = new UserQuery();

            userQuery.IsActivated          = false;
            ViewData["activatedUserCount"] = userService.GetUsers(userQuery, 20, 1).TotalRecords;

            //24小时新增用户数
            ViewData["userCount24H"] = userService.GetUser24H();

            //总用户数
            UserQuery usersQuery = new UserQuery();

            ViewData["userCount"] = userService.GetUsers(usersQuery, 20, 1).TotalRecords;

            //获取系统信息

            SystemInfo systemInfo = new SystemInfo();

            ViewData["systemInfo"] = systemInfo;
            return(View(statisticItems));
        }
Exemple #8
0
        /// <summary>
        /// 重建索引
        /// </summary>  
        public void RebuildIndex()
        {
            //pageSize参数决定了每次批量取多少条数据进行索引。要注意的是,如果是分布式搜索,客户端会将这部分数据通过WCF传递给服务器端,而WCF默认的最大传输数据量是65535B,pageSize较大时这个设置显然是不够用的,WCF会报400错误;系统现在将最大传输量放宽了,但仍要注意一次不要传输过多,如遇异常,可适当调小pageSize的值
            int pageSize = 1000;
            int pageIndex = 1;
            long totalRecords = 0;
            bool isBeginning = true;
            bool isEndding = false;
            UserQuery query = new UserQuery();

            long followedUserId = 0;
            Document doc = null;
            do
            {
                //分页获取粉丝列表
                PagingDataSet<User> users = userService.GetUsers(query, pageSize, pageIndex);

                totalRecords = users.TotalRecords;
                IEnumerable<long> followerUserIds = users.Select(n => n.UserId);

                isEndding = (pageSize * pageIndex < totalRecords) ? false : true;

                //根据粉丝列表批量查询关注用户列表
                IEnumerable<FollowEntity> followedUsers = followService.GetFollowedUsers(followerUserIds);

                //循环关注用户列表(已按照UserId排序),对每个UserId建立索引
                List<Document> docs = new List<Document>();
                foreach (FollowEntity followedUser in followedUsers)
                {
                    //判断当前记录的被关注用户的ID是否与上一条的被关注用户的ID相同。
                    //如果相同,说明属于同一个用户的关注对象
                    if (followedUser.UserId == followedUserId)
                    {
                        doc.Add(new Field(FollowedUserIds, followedUser.FollowedUserId.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
                    }
                    else
                    {

                        //fixed by jiangshl

                        //对于下一个用户,需要重新构建Document对象
                        doc = new Document();
                        doc.Add(new Field(UserId, followedUser.UserId.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
                        doc.Add(new Field(FollowedUserIds, followedUser.FollowedUserId.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
                        docs.Add(doc);

                        followedUserId = followedUser.UserId;
                    }
                }

                searchEngine.RebuildIndex(docs, isBeginning, isEndding);

                isBeginning = false;
                pageIndex++;
            }
            while (!isEndding);
        }
        public ActionResult ManageUsers(int? pageIndex, int pageSize = 30)
        {
            pageResourceManager.InsertTitlePart("用户管理");

            #region 组装搜索条件

            UserQuery query = new UserQuery();
            query.Keyword = Request.QueryString.GetString("uname", string.Empty);
            query.AccountEmailFilter = Request.QueryString.GetString("uemail", string.Empty);
            query.RoleName = Request.QueryString.GetString("RoleName", string.Empty);

            if (!string.IsNullOrEmpty(Request.QueryString["IsActivated"]))
                query.IsActivated = Request.QueryString.GetBool("IsActivated", false);

            if (!string.IsNullOrEmpty(Request.QueryString["IsModerated"]))
                query.IsModerated = Request.QueryString.GetBool("IsModerated", false);

            if (!string.IsNullOrEmpty(Request.QueryString["IsBanned"]))
                query.IsBanned = Request.QueryString.GetBool("IsBanned", false);

            int result = 0;
            if (int.TryParse(Request.QueryString["rankstart"], out result))
                query.UserRankLowerLimit = Request.QueryString.GetInt("rankstart", 0);

            if (int.TryParse(Request.QueryString["rankend"], out result))
                query.UserRankUpperLimit = Request.QueryString.GetInt("rankend", 0);

            if (Request.QueryString.Get<DateTime>("startdate") != DateTime.MinValue)
                query.RegisterTimeLowerLimit = Request.QueryString.Get<DateTime>("startdate");

            if (Request.QueryString.Get<DateTime>("enddate") != DateTime.MinValue)
                query.RegisterTimeUpperLimit = Request.QueryString.Get<DateTime>("enddate");

            #endregion

            #region 组装搜索下拉列表

            IEnumerable<Role> roles = roleService.GetRoles();
            if (roles != null)
            {
                ViewData["RoleName"] = new SelectList(roles, "RoleName", "FriendlyRoleName", query.RoleName);
            }

            Dictionary<bool, string> activatedValues = new Dictionary<bool, string> { { true, "已激活" }, { false, "未激活" } };
            ViewData["IsActivated"] = new SelectList(activatedValues.Select(n => new { text = n.Value, value = n.Key.ToString().ToLower() }), "value", "text", query.IsActivated);

            Dictionary<bool, string> moderatedValues = new Dictionary<bool, string> { { true, "管制" }, { false, "未管制" } };
            ViewData["IsModerated"] = new SelectList(moderatedValues.Select(n => new { text = n.Value, value = n.Key.ToString().ToLower() }), "value", "text", query.IsModerated);

            Dictionary<bool, string> bannedValues = new Dictionary<bool, string> { { true, "封禁" }, { false, "未封禁" } };
            ViewData["IsBanned"] = new SelectList(bannedValues.Select(n => new { text = n.Value, value = n.Key.ToString().ToLower() }), "value", "text", query.IsBanned);

            #endregion
            pageIndex = pageIndex ?? 1;
            PagingDataSet<User> users = userService.GetUsers(query, pageSize, pageIndex.Value);
            if (pageIndex > 1 && (users == null || users.Count() == 0))
            {
                users = userService.GetUsers(query, pageSize, pageIndex.Value - 1);
                var dd = Request.Url.Query;
            }

            return View(users);
        }