Esempio n. 1
0
        public List <Sys_ModuleButtonModel> GetButtonList1(string roleId)
        {
            Sys_ModuleButtonBLL mbbll = new Sys_ModuleButtonBLL();
            var data = new List <Sys_ModuleButtonModel>();
            Sys_RoleAuthorizeBLL rhbll = new Sys_RoleAuthorizeBLL();

            if (OperatorProvider.Provider.GetCurrent().IsSystem)
            {
                data = mbbll.GetModelList("");
            }
            else
            {
                var buttondata    = mbbll.GetModelList("");
                var authorizedata = rhbll.GetModelList("F_ObjectId = '" + roleId + "'  and F_ItemType = 2");
                foreach (var item in authorizedata)
                {
                    Sys_ModuleButtonModel moduleButtonEntity = mbbll.GetModel(item.F_ItemId);
                    if (moduleButtonEntity != null)
                    {
                        data.Add(moduleButtonEntity);
                    }
                }
            }
            return(data.OrderBy(t => t.F_SortCode).ToList());
        }
Esempio n. 2
0
        private bool ActionValidate(string roleId, string moduleId, string action)
        {
            Sys_ModuleBLL        modulebll        = new Sys_ModuleBLL();
            Sys_ModuleButtonBLL  moduleButtonbll  = new Sys_ModuleButtonBLL();
            Sys_RoleAuthorizeBLL roleAuthorizebll = new Sys_RoleAuthorizeBLL();
            var authorizeurldata = new List <AuthorizeActionModel>();
            var cachedata        = CacheFactory.Cache().GetCache <List <AuthorizeActionModel> >("authorizeurldata_" + roleId);

            if (cachedata == null)
            {
                var moduledata    = modulebll.GetModelList("");
                var buttondata    = moduleButtonbll.GetModelList("");
                var authorizedata = roleAuthorizebll.GetModelList("F_ObjectId ='" + roleId + "'");
                foreach (var item in authorizedata)
                {
                    if (item.F_ItemType == 1)
                    {
                        var moduleEntity = moduledata.Find(t => t.F_Id == item.F_ItemId);
                        authorizeurldata.Add(new AuthorizeActionModel {
                            F_Id = moduleEntity.F_Id, F_UrlAddress = moduleEntity.F_UrlAddress
                        });
                    }
                    else if (item.F_ItemType == 2)
                    {
                        var moduleButtonEntity = buttondata.Find(t => t.F_Id == item.F_ItemId);
                        authorizeurldata.Add(new AuthorizeActionModel {
                            F_Id = moduleButtonEntity.F_ModuleId, F_UrlAddress = moduleButtonEntity.F_UrlAddress
                        });
                    }
                }
                CacheFactory.Cache().WriteCache(authorizeurldata, "authorizeurldata_" + roleId, DateTime.Now.AddMinutes(5));
            }
            else
            {
                authorizeurldata = cachedata;
            }
            authorizeurldata = authorizeurldata.FindAll(t => t.F_Id.Equals(moduleId));
            foreach (var item in authorizeurldata)
            {
                if (!string.IsNullOrEmpty(item.F_UrlAddress))
                {
                    string[] url = item.F_UrlAddress.Split('?');
                    if (item.F_Id == moduleId && url[0] == action)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 3
0
        public ActionResult GetPermissionTree(string roleId)
        {
            var moduledata    = modulebll.GetModelList("");
            var buttondata    = moduleButtonbll.GetModelList("");
            var authorizedata = new List <Sys_RoleAuthorizeModel>();

            if (!string.IsNullOrEmpty(roleId))
            {
                authorizedata = roleAuthorizebll.GetModelList("F_ObjectId='" + roleId + "'");
            }
            var treeList = new List <TreeViewModel>();

            foreach (var item in moduledata)
            {
                TreeViewModel tree        = new TreeViewModel();
                bool          hasChildren = moduledata.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true;
                tree.id          = item.F_Id;
                tree.text        = item.F_FullName;
                tree.value       = item.F_EnCode;
                tree.parentId    = item.F_ParentId;
                tree.isexpand    = true;
                tree.complete    = true;
                tree.showcheck   = true;
                tree.checkstate  = authorizedata.Count(t => t.F_ItemId == item.F_Id);
                tree.hasChildren = true;
                tree.img         = item.F_Icon == "" ? "" : item.F_Icon;
                treeList.Add(tree);
            }
            foreach (var item in buttondata)
            {
                TreeViewModel tree        = new TreeViewModel();
                bool          hasChildren = buttondata.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true;
                tree.id          = item.F_Id;
                tree.text        = item.F_FullName;
                tree.value       = item.F_EnCode;
                tree.parentId    = item.F_ParentId == "0" ? item.F_ModuleId : item.F_ParentId;
                tree.isexpand    = true;
                tree.complete    = true;
                tree.showcheck   = true;
                tree.checkstate  = authorizedata.Count(t => t.F_ItemId == item.F_Id);
                tree.hasChildren = hasChildren;
                tree.img         = item.F_Icon == "" ? "" : item.F_Icon;
                treeList.Add(tree);
            }
            return(Content(treeList.TreeViewJson()));
        }