コード例 #1
0
        /// <summary>
        /// 保存授权信息
        /// </summary>
        /// <param name="authorizationStore">授权信息</param>
        public void SaveAuthorization(AuthorizationStore authorizationStore)
        {
            DeleteAuthorization(authorizationStore.Role);
            db.Store(authorizationStore);

            // 触发事件处理程序
            if (AuthorizationChanged != null)
            {
                AuthorizationChanged(this, new EventArgs <string>(authorizationStore.Role));
            }
        }
コード例 #2
0
        /// <summary>
        /// 获取指定角色的权限信息
        /// </summary>
        /// <param name="role">角色名称</param>
        private AuthorizationStore GetAuthorizationForRole(string role)
        {
            authStore = Presenter.AuthorizationStoreService.GetAuthorizationsByRole(role);
            if (authStore == null)
            {
                authStore = new AuthorizationStore(role);

                IList<AuthorizationNode> lns = Presenter.AuthorizationNodeService.GetAll();
                foreach (AuthorizationNode an in lns)
                    authStore.Store(an);
                Presenter.AuthorizationStoreService.SaveAuthorization(authStore); // 保存角色的权限信息
            }
            return authStore;
        }
コード例 #3
0
        /// <summary>
        /// 加载所有的权限节点信息
        /// </summary>
        private void LoadAuthorizationNodes(AuthorizationStore store)
        {
            using (WaitCursor cursor = new WaitCursor(true))
            {
                tlAuth.BeginUpdate();
                tlAuth.Nodes.Clear();
                try
                {
                    AuthorizationNode authNode = new AuthorizationNode() {
                        Id = "Shell",
                        Name = "系统权限"
                    };
                    authNode.AuthorizationUri = GlobalConstants.Uri_Separator + "Shell";
                    TreeListNode tlNode = tlAuth.AppendNode(new object[] { authNode.Name, authNode.Id }, -1, authNode);
                    tlNode.Tag = authNode;
                    ((AuthorizationNode)tlNode.Tag).AuthorizationUri = GetAuthrizationNodePath(tlNode);
                    tlNode.ImageIndex = 0;
                    tlNode.SelectImageIndex = 1;

                    // 加载角色的相关权限节点
                    foreach (AuthorizationNode child in store.Nodes) {
                        LoadAuthorizationNode(child, tlAuth.Nodes[0]);
                    }
                    tlAuth.Nodes[0].ExpandAll(); // 展开所有子节点
                }
                finally
                {
                    tlAuth.EndUpdate();
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// 保存授权信息
        /// </summary>
        /// <param name="authorizationStore">授权信息</param>
        public void SaveAuthorization(AuthorizationStore authorizationStore)
        {
            DeleteAuthorization(authorizationStore.Role);
            db.Store(authorizationStore);

            // 触发事件处理程序
            if (AuthorizationChanged != null)
                AuthorizationChanged(this, new EventArgs<string>(authorizationStore.Role));
        }