Beispiel #1
0
        public ActionResult GetRoleTreeJson(string Ids, string roleIDs, int checkMode = 0, int mode = 0)
        {
            Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current();
            //不传Ids那么显示所有通用角色,选择Ids显示当前公司下面的加上所有通用角色
            string parentId = "0";
            var    treeList = new List <TreeEntity>();
            IEnumerable <RoleEntity> data = new List <RoleEntity>();

            //如果没有传递参数parentId,则给出默认值
            if (string.IsNullOrEmpty(Ids))
            {
                data = roleCache.GetList().Where(a => a.OrganizeId == "" || a.OrganizeId == null);
            }
            else
            {
                parentId = Ids.Contains(",") ? "0" : Ids;

                data = roleCache.GetList().Where(a => parentId.Contains(string.IsNullOrEmpty(a.OrganizeId) ? "" : a.OrganizeId) || string.IsNullOrWhiteSpace(a.OrganizeId)).ToList();
            }
            if (!user.IsSystem)
            {
                string roleName = "省级领导,省级专责工,省级主管用户,省级安管员用户,省级管理员,省级用户,集团用户,超级管理员";
                data = data.Where(t => !roleName.Contains(t.FullName));
            }
            foreach (RoleEntity item in data)
            {
                TreeEntity tree        = new TreeEntity();
                bool       hasChildren = false;
                tree.id       = item.RoleId;
                tree.text     = item.FullName;
                tree.value    = item.RoleId;
                tree.isexpand = true;
                tree.complete = true;
                if (!string.IsNullOrEmpty(roleIDs))
                {
                    if (roleIDs.Contains(item.RoleId))
                    {
                        tree.checkstate = 1;
                    }
                }
                tree.showcheck   = checkMode == 0 ? false : true;
                tree.hasChildren = hasChildren;
                tree.parentId    = parentId.Contains(",") ? "0" : parentId;
                treeList.Add(tree);
            }
            return(Content(treeList.TreeToJson(parentId)));
        }
Beispiel #2
0
        /// <summary>
        /// 获取角色数据
        /// </summary>
        /// <returns></returns>
        private object GetRoleData()
        {
            var data = roleCache.GetList();
            var dict = new Dictionary <string, object>();

            foreach (var entity in data)
            {
                var fieldItem = new { entity.EnCode, entity.FullName };
                dict.Add(entity.RoleId, fieldItem);
            }
            return(dict);
        }
        /// <summary>
        /// 获取角色数据
        /// </summary>
        /// <returns></returns>
        private object GetRoleData()
        {
            var data = roleCache.GetList();
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            foreach (RoleEntity item in data)
            {
                var fieldItem = new
                {
                    EnCode   = item.EnCode,
                    FullName = item.FullName
                };
                dictionary.Add(item.RoleId, fieldItem);
            }
            return(dictionary);
        }
Beispiel #4
0
        public ActionResult GetListJson(string organizeId)
        {
            var data = roleCache.GetList(organizeId);

            return(Content(data.ToJson()));
        }