예제 #1
0
        private List <SysUser> GetUserList(int roleId)
        {
            LoginUserInfo currentLogin = this.WorkContext.CurrentUser;

            if (roleId < 1)
            {
                if (currentLogin.RoleId == 7 || currentLogin.RoleId == 8)
                {
                    roleId = currentLogin.RoleId;
                }
                else
                {
                    roleId = 7;
                }
            }

            //具有国内/国际开发主管角色的登入用户进入该页后,用户名下拉列表只列出自己的名字;
            //具有系统管理员角色或运维角色的登入用户进入该页后,用户名下拉列表列出符合角色下拉列表框中所选中角色的所有用户;
            //具有其他角色的登入用户进入该页后,用户名下拉列表框没有用户可选:
            List <SysUser> userList = new List <SysUser>();

            SysUserLogic sysUserLogic = new SysUserLogic();

            if ((currentLogin.RoleId == 7 || currentLogin.RoleId == 8) && currentLogin.RoleId == roleId)//7表示国内开发主管角色,8表示国际开发主管角色
            {
                userList = sysUserLogic.GetUserList(currentLogin.UserName, currentLogin.RoleId, 0).ToList <SysUser>();
            }
            else if (currentLogin.RoleId == 2 || currentLogin.RoleId == 4)//2表示系统管理员角色,4表示运维角色
            {
                userList = sysUserLogic.GetUserList("", -1, 0).ToList <SysUser>();
                userList = userList.Where(x => x.RoleId == roleId).ToList <SysUser>();
            }

            return(userList);
        }
예제 #2
0
        public ActionResult UserJson()
        {
            var logic    = new SysUserLogic();
            var userList = logic.GetUserList(null, -1, -1).ToList();
            var list     = new List <IdNameModel>
            {
                new IdNameModel()
                {
                    Text  = "全部",
                    Value = ""
                }
            };

            list.AddRange(userList.Select(i => new IdNameModel()
            {
                Text = i.UserName, Value = i.UserName
            }));
            return(Content(JsonConvert.SerializeObject(list)));
        }
예제 #3
0
        //
        // GET: /User/
        public ActionResult Index(string userName = "", int roleId = -1, int status = -1, int pageIndex = 1)
        {
            PageItem pageItem = new PageItem {
                PageIndex = pageIndex, PageSize = 15
            };
            List <SysUser> userList = logic.GetUserList(userName, roleId, status, pageItem).ToList <SysUser>();
            var            model    = new PagedList <SysUser>(userList, pageItem.PageIndex, pageItem.PageSize, pageItem.TotalCount);

            Dictionary <int, SysRole> dictionaryRole = new Dictionary <int, SysRole>();

            List <SysRole> roleList = roleLogic.GetRoleList(0).ToList <SysRole>();

            if (roleList != null)
            {
                for (int index = 0; index < roleList.Count; index++)
                {
                    dictionaryRole.Add(roleList[index].RoleId, roleList[index]);
                }
            }
            ViewBag.DictionaryRole = dictionaryRole;

            return(View(model));
        }