public void OnSelectCommand(object sender, EventArgs e) { frmSelectCommand form = WorkItem.Items.Get <frmSelectCommand>(SelectCommandForm); if (form == null) { form = WorkItem.Items.AddNew <frmSelectCommand>(SelectCommandForm); } AuthorizationNode authNode = CurrentAuthNode.Tag as AuthorizationNode; form.AuthNode = authNode; form.RefreshList(); // 为授权节点添加操作 if (form.ShowDialog() == DialogResult.OK) { List <AuthorizationCommand> lcs = form.GetSelection(); foreach (AuthorizationCommand ac in lcs) { authNode.AddCommand(ac); View.ListAuthorizationCommands(authNode); // 刷新操作列表 AuthorizationNodeService.Save(authNode); UpdateRoleAuthorization(authNode); CurrentAuthNode.Tag = authNode; } } }
/// <summary> /// 删除权限节点 /// </summary> /// <param name="node">权限节点</param> private void DeleteAuthNode(TreeListNode node) { foreach (TreeListNode child in node.Nodes) { DeleteAuthNode(child); } AuthorizationNode authNode = node.Tag as AuthorizationNode; if (authNode != null) { try { AuthorizationNodeService.Delete(authNode); // 更新角色的授权信息 IList <AuthorizationStore> stores = AuthorizationStoreService.GetAll(); if (stores != null) { foreach (AuthorizationStore store in stores) { store.Remove(authNode); AuthorizationStoreService.SaveAuthorization(store); } } } catch { } } }
public void OnNewAuthNode(object sender, EventArgs e) { frmAuthNode form = GetAuthNodeForm(); form.EditMode(false); form.AuthId = ""; form.AuthName = ""; if (form.ShowDialog() == DialogResult.OK) { TreeListNode node = View.TLAuth.AppendNode(new object[] { form.AuthName, form.AuthId }, CurrentAuthNode); node.Tag = new AuthorizationNode() { Id = form.AuthId, Name = form.AuthName }; AuthorizationNode authNode = node.Tag as AuthorizationNode; if (authNode != null) { authNode.AuthorizationUri = View.GetAuthrizationNodePath(node); AuthorizationNodeService.Save(authNode); UpdateRoleAuthorization(authNode); } node.ImageIndex = 0; node.SelectImageIndex = 1; CurrentAuthNode.ExpandAll(); } }
public void OnEditAuthNode(object sender, EventArgs e) { frmAuthNode form = GetAuthNodeForm(); AuthorizationNode authNode = CurrentAuthNode.Tag as AuthorizationNode; form.EditMode(true); form.AuthId = authNode.Id; form.AuthName = authNode.Name; if (form.ShowDialog() == DialogResult.OK) { authNode.Id = form.AuthId; authNode.Name = form.AuthName; AuthorizationNodeService.Save(authNode); UpdateRoleAuthorization(authNode); } }
/// <summary> /// 删除选定数据资料 /// </summary> public override void Delete() { if (XtraMessageBox.Show("你真的要删除选定的操作项吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { base.Delete(); AuthorizationCommand command = View.TLCommands.Selection[0].Tag as AuthorizationCommand; // 获取准备删除的操作项 if (CurrentAuthNode != null) { AuthorizationNode authNode = CurrentAuthNode.Tag as AuthorizationNode; authNode.RemoveCommand(command); View.TLCommands.DeleteNode(View.TLCommands.Selection[0]); CurrentAuthNode.Tag = authNode; AuthorizationNodeService.Save(authNode); // 将变化保存回后端数据库 UpdateRoleAuthorization(authNode); } } }