/// <summary>
        /// Get User Info List
        /// </summary>
        /// <param name="queryModel"></param>
        /// <returns></returns>
        public ActionResult GetUserList(User_Profile_QueryModel queryModel)
        {
            try
            {
                var uiSvg = new UserInfoServices();

                var count = 0;
                var list  = uiSvg.GetUserList(queryModel, out count);
                return(Json(new NBCMSResultJson
                {
                    Status = StatusType.OK,
                    Data = new
                    {
                        total = count,
                        rows = list
                    }
                }));
            }
            catch (Exception ex)
            {
                NBCMSLoggerManager.Fatal(ex.Message);
                NBCMSLoggerManager.Fatal(ex.StackTrace);
                NBCMSLoggerManager.Error("");
                return(Json(new NBCMSResultJson
                {
                    Status = StatusType.Exception,
                    Data = ex.Message
                }));
            }
        }
示例#2
0
        /// <summary>
        /// Get User List
        /// </summary>
        /// <param name="page"></param>
        /// <param name="rows"></param>
        /// <param name="sort">SortColumn,eg:Display_Name</param>
        /// <param name="order">asc or desc</param>
        /// <returns></returns>
        public List <CMS_User_Profile_V_Model> GetUserList(User_Profile_QueryModel queryModel, out int count)
        {
            var list = new List <CMS_User_Profile_V_Model>();

            using (var db = new PermaisuriCMSEntities())
            {
                var query = db.CMS_User_Profile_V.Include(u => u.User_Channel_Relation).AsQueryable();
                if (!String.IsNullOrEmpty(queryModel.User_Account))
                {
                    query = query.Where(u => u.User_Account.Contains(queryModel.User_Account));
                }
                if (!String.IsNullOrEmpty(queryModel.Display_Name))
                {
                    query = query.Where(u => u.DisplayName.Contains(queryModel.Display_Name));
                }
                if (queryModel.UserStatusID > 0)
                {
                    switch (queryModel.UserStatusID)
                    {
                    case 1:     //CMS Enabled
                        query = query.Where(u => u.UserStatusID == 1);
                        break;

                    case 2:     //CMS Disabled
                        query = query.Where(u => u.UserStatusID == 2);
                        break;

                    case 3:     //WebPO Disabled
                        query = query.Where(u => u.IsDisabled == 1);
                        break;

                    case 4:     //WebPO Enaled
                        query = query.Where(u => u.IsDisabled == 0 || u.IsDisabled == null);
                        break;

                    default:
                        break;
                    }
                }
                if (!String.IsNullOrEmpty(queryModel.Primary_Email))
                {
                    query = query.Where(u => u.Primary_Email.Contains(queryModel.Primary_Email));
                }

                count = query.Count();
                query =
                    query.OrderBy(u => u.User_Account).Skip((queryModel.page - 1) * queryModel.rows).Take(queryModel.rows);
                list.AddRange(query.Select(ui => new CMS_User_Profile_V_Model
                {
                    User_Guid        = ui.User_Guid,
                    User_Account     = ui.User_Account,
                    Display_Name     = ui.DisplayName,
                    Last_Logon       = ui.Last_Logon.GetValueOrDefault().ToString("yyyy-MM-dd HH:mm:ss"),
                    UserStatusID     = ui.UserStatusID.GetValueOrDefault(),
                    UserStatusName   = ui.UserStatusName,
                    UserPWD          = ui.UserPWD,
                    Primary_Email    = ui.Primary_Email,
                    IsChannelControl = ui.IsChannelControl.HasValue ? ui.IsChannelControl.Value : false

                                       /*2013年11月1日15:23:41 经测试,在relation表为null的情况下,会一次性关联relation返回top 10条记录,如果有数据还未做测试*/
                                       //Channels = ui.User_Channel_Relation.Select(r => new Channel_Model
                                       //{
                                       //    ChannelID = r.Channel.ChannelID,
                                       //    ChannelName = r.Channel.ChannelName
                                       //}).ToList()

                                       /*在查询用户整个列表的时候还是不要关联去查询渠道,查询当个用户的信息的时候才关联查询该用户的渠道信息,符合业务特征也更简洁!
                                        * 2013年11月1日15:32:22
                                        */
                }));
                return(list);
            }
        }