Esempio n. 1
0
        public ActionResult AuthorizationRule()
        {
            var authGridModel = new AuthorizationGridModel();

            SetUpAuthGridModel(authGridModel);
            return(View(authGridModel));
        }
Esempio n. 2
0
        public JsonResult AuthorizationRuleOfAuth_RequestData(Guid parentRowID)
        {
            var authGridModel = new AuthorizationGridModel();

            SetUpAuthGridModel(authGridModel);
            //SetupRoelGridModel(authGridModel.RolesGrid);
            var context = db;
            //if (!string.IsNullOrEmpty(parentRowID))
            //{
            var auths = from s in context.aspnet_Sitemaps.Where(w => w.Code != "000" && w.IsAuthorize == true)
                        join a in context.aspnet_AuthorizationRules.Where(w => w.RoleId == parentRowID) on s.Code equals a.SiteMapKey into sa
                        from auth in sa.DefaultIfEmpty()
                        //where auth.RoleName == RoleName
                        select new
            {
                //EditActions=false,
                IsInRole = (auth == null ? false : true),
                Code     = s.Code,
                s.Title
                //RoleName = parentRowID
            };

            return(authGridModel.AuthorizationGrid.DataBind(auths));
            //}
            //else
            //{
            //    var auths = context.aspnet_Sitemaps.Select(s => new { IsInRole = false, Code = s.Code, Title = s.Title, RoleName = "" })
            //   .Where(w => w.Code != "000");
            //    return authGridModel.AuthorizationGrid.DataBind(auths);
            //}
        }
Esempio n. 3
0
        private void SetUpAuthGridModel(AuthorizationGridModel authorizationGridModel)
        {
            var authorizationGrid = authorizationGridModel.AuthorizationGrid;
            var roleGrid          = authorizationGridModel.RolesGrid;

            authorizationGrid.DataUrl = Url.Action("AuthorizationRuleOfAuth_RequestData");
            authorizationGrid.EditUrl = Url.Action("AuthorizationRuleOfAuth_EditData");
            authorizationGrid.SearchDialogSettings.MultipleSearch = true;
            authorizationGrid.ToolBarSettings.ShowEditButton      = true;
            authorizationGrid.SortSettings.InitialSortColumn      = "Sort";
            authorizationGrid.SortSettings.InitialSortDirection   = Trirand.Web.Mvc.SortDirection.Asc;

            this.SetBoolColumn(authorizationGrid, "IsInRole");
            this.SetBoolColumn(authorizationGrid, "IsClient");

            roleGrid.DataUrl = Url.Action("AuthorizationRuleOfRole_RequestData");
            roleGrid.ID      = "RolesGrid";
            roleGrid.HierarchySettings.HierarchyMode          = HierarchyMode.Parent;
            roleGrid.AppearanceSettings.Caption               = this.Title;
            roleGrid.ClientSideEvents.SubGridRowExpanded      = "showAuthsSubGrid";
            roleGrid.SearchDialogSettings.MultipleSearch      = true;
            authorizationGrid.HierarchySettings.HierarchyMode = HierarchyMode.Child;

            authorizationGrid.ID = "AuthorizationGrid";
        }
Esempio n. 4
0
        public JsonResult AuthorizationRuleOfRole_RequestData()
        {
            var authGridModel = new AuthorizationGridModel();

            SetUpAuthGridModel(authGridModel);
            var roles = Uow.aspnet_Roles.GetAll();

            return(authGridModel.RolesGrid.DataBind(roles));
        }
Esempio n. 5
0
        private void SetUpAuthGridModel(AuthorizationGridModel authorizationGridModel)
        {
            var authorizationGrid = authorizationGridModel.AuthorizationGrid;
            var roleGrid          = authorizationGridModel.RolesGrid;

            authorizationGrid.DataUrl = Url.Action("AuthorizationRuleOfAuth_RequestData");
            authorizationGrid.EditUrl = Url.Action("AuthorizationRuleOfAuth_EditData");
            authorizationGrid.SearchDialogSettings.MultipleSearch = true;
            //authorizationGrid.Columns.Insert(0, new JQGridColumn
            //{
            //    Sortable=false,
            //    Fixed = true,
            //    EditActionIconsColumn = true
            //});
            authorizationGrid.ToolBarSettings.ShowEditButton = true;
            JQGridColumn isInRoleColumn = authorizationGrid.Columns.Find(c => c.DataField == "IsInRole");

            isInRoleColumn.Formatter  = new CheckBoxFormatter();
            isInRoleColumn.SearchType = SearchType.DropDown;
            if (authorizationGrid.AjaxCallBackMode == AjaxCallBackMode.RequestData)
            {
                isInRoleColumn.SearchList = new List <SelectListItem>()
                {
                    new SelectListItem {
                        Text = "所有", Value = ""
                    },
                    new SelectListItem {
                        Text = "选择", Value = "true"
                    },
                    new SelectListItem {
                        Text = "未选择", Value = "false"
                    }
                };
            }
            isInRoleColumn.EditType = EditType.CheckBox;

            roleGrid.DataUrl = Url.Action("AuthorizationRuleOfRole_RequestData");
            roleGrid.ID      = "RolesGrid";
            roleGrid.HierarchySettings.HierarchyMode          = HierarchyMode.Parent;
            roleGrid.AppearanceSettings.Caption               = "权限";
            roleGrid.ClientSideEvents.SubGridRowExpanded      = "showAuthsSubGrid";
            roleGrid.SearchDialogSettings.MultipleSearch      = true;
            authorizationGrid.HierarchySettings.HierarchyMode = HierarchyMode.Child;

            authorizationGrid.ID = "AuthorizationGrid";
        }
Esempio n. 6
0
        public JsonResult AuthorizationRuleOfAuth_RequestData(Guid parentRowID)
        {
            var authGridModel = new AuthorizationGridModel();

            SetUpAuthGridModel(authGridModel);
            JQGridTreeExpandData expandData = authGridModel.AuthorizationGrid.GetTreeExpandData();

            Guid empty = Guid.Empty;
            var  auths = (from s in Uow.aspnet_Sitemaps.GetAll().Where(w => w.IsAuthorize == true && w.Code != "000")
                          join a in Uow.aspnet_AuthorizationRules.GetAll().Where(w => w.RoleId == parentRowID) on s.Code equals a.SiteMapKey into sa
                          from auth in sa.DefaultIfEmpty()
                          orderby s.Sort
                          select new
            {
                IsInRole = (auth == null ? false : true),
                Code = s.Code,
                s.Title,
                s.IsClient,
                s.ParentCode,
                tree_loaded = true,
                tree_level = 0,
                tree_parent = s.ParentCode,
                tree_leaf = false,
                tree_expanded = false
            }).ToList();

            var auths1 = auths.Select((map, idx) => new
            {
                map.IsInRole,
                map.Code,
                map.Title,
                map.IsClient,
                map.ParentCode,
                Sort = idx + 1,
                map.tree_loaded,
                map.tree_level,
                map.tree_parent,
                map.tree_leaf,
                map.tree_expanded
            });

            var auths2 = (from d in auths1
                          where d.ParentCode == "000"
                          select new
            {
                d.IsInRole,
                d.Code,
                d.Title,
                d.IsClient,
                Sort = d.Sort.ToString().PadLeft(5, '0'),
                d.tree_loaded,
                tree_level = 0,
                tree_parent = "",
                tree_leaf = false,
                d.tree_expanded
            }).ToList();

            var auths3 = (from d in auths1
                          join d2 in auths2 on d.ParentCode equals d2.Code
                          select new
            {
                d.IsInRole,
                d.Code,
                d.Title,
                d.IsClient,
                Sort = d2.Sort + d.Sort.ToString().PadLeft(5, '0'),
                d.tree_loaded,
                tree_level = 1,
                tree_parent = d2.Code,
                tree_leaf = false,
                d.tree_expanded
            }).ToList();

            var auths4 = (from d in auths1
                          join d2 in auths3 on d.ParentCode equals d2.Code
                          select new
            {
                d.IsInRole,
                d.Code,
                d.Title,
                d.IsClient,
                Sort = d2.Sort + d.Sort.ToString().PadLeft(5, '0'),
                d.tree_loaded,
                tree_level = 2,
                tree_parent = d2.Code,
                tree_leaf = true,
                d.tree_expanded
            }).ToList();

            var auths5 = (from d in auths3
                          join d2 in auths4 on d.Code equals d2.tree_parent into dd1
                          from dd1s in dd1.DefaultIfEmpty()
                          select new
            {
                d.IsInRole,
                d.Code,
                d.Title,
                d.IsClient,
                Sort = d.Sort,
                d.tree_loaded,
                tree_level = 1,
                tree_parent = d.tree_parent,
                tree_leaf = dd1s == null?true:false,
                d.tree_expanded
            }).ToList();
            var authss = auths2.Union(auths5).Union(auths4).ToList();

            if (expandData.ParentID != null)
            {
                string parentId = expandData.ParentID;
                authss = authss.Where(w => w.tree_parent == parentId).ToList();
            }
            authss = authss.OrderBy(o => o.Sort).ToList();
            return(authGridModel.AuthorizationGrid.DataBind(authss.AsQueryable()));
        }