在xaf 14 中实现 Tonyyang原文中的action权限
具体实现过程,主要修改了以下几个地方:
第一:角色和用户类中需要修改成SecurityStrategy的方式:
具体代码
MySecurityRole:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Text;
using DevExpress.ExpressApp.Security.Strategy;
using DevExpress.Xpo;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.Validation;
using System.Collections.ObjectModel;
using DevExpress.Persistent.Base.Security;
namespace SecurityDemoTest.Module.BusinessObjects
{
[DefaultClassOptions]
public class MySecurityRole : SecuritySystemRole
{
public const string DefaultAdministratorsGroupName = "Administrators";
//private List<IPermission> _Permissions = new List<IPermission>();
public MySecurityRole(Session session)
: base(session)
{ } [Association("ActionDatas-MySecurityRoles")]
public XPCollection<ActionData> ActionPermissions
{
get
{
return GetCollection<ActionData>("ActionPermissions");
}
}
}
}
MySecurityUser:
using System;
using System.Collections.Generic;
using System.Linq;
//using DevExpress.ExpressApp.Security;
using System.Drawing;
using System.Security;
using DevExpress.ExpressApp.Security.Strategy;
using DevExpress.Persistent.Validation;
using DevExpress.Xpo;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.Base.General;
using DevExpress.Persistent.Base.Security;
using DevExpress.ExpressApp.DC;
using System.ComponentModel;
//using WinWebSolution.Module; namespace SecurityDemoTest.Module.BusinessObjects
{
[XafDisplayName("User"), Persistent, ImageName("BO_User")]
public class MySecurityUser : SecuritySystemUser // SecurityUserWithRolesBase
{
public MySecurityUser(DevExpress.Xpo.Session session)
: base(session)
{
//_Permissions = new List<IPermission>();
} [Persistent("Color")]
private int _Color;
[NonPersistent]
public Color Color
{
get { return Color.FromArgb(_Color); }
set { SetPropertyValue("Color", ref _Color, value.ToArgb()); }
}
public override void AfterConstruction()
{
base.AfterConstruction();
_Color = Color.White.ToArgb();
}
private string _Description;
public string Description
{
get
{
return _Description;
}
set
{
SetPropertyValue("Description", ref _Description, value);
}
} }
}
第二:需要在ViewController中添加如下代码:
private static bool IsAllowAccessAction(string actionId)
{
MySecurityUser currentUser = SecuritySystem.CurrentUser as MySecurityUser;
Guard.ArgumentNotNull(currentUser, "CurrentUser");
Guard.ArgumentNotNullOrEmpty(actionId, "ActionId");
foreach (MySecurityRole role in currentUser.Roles)
{
foreach (ActionData ap in role.ActionPermissions)
{
if (ap.ActionId == actionId && ap.Kind == "Custom")
return true;
}
}
return false;
}
在xaf 14 中实现 Tonyyang原文中的action权限的更多相关文章
- XAF 框架中,自定义参数动作(Action),输入参数的控件可定义,用于选择组织及项目
XAF 框架中,如何生成一个自定义参数动作(Action),输入参数的控件可定义? 参考文档:https://documentation.devexpress.com/eXpressAppFramew ...
- N个整数(数的大小为0-255)的序列,把它们加密为K个整数(数的大小为0-255).再将K个整数顺序随机打乱,使得可以从这乱序的K个整数中解码出原序列。设计加密解密算法,且要求K<=15*N.
N个整数(数的大小为0-255)的序列,把它们加密为K个整数(数的大小为0-255).再将K个整数顺序随机打乱,使得可以从这乱序的K个整数中解码出原序列.设计加密解密算法,且要求K<=15*N. ...
- devexpress xaf 开发中遇到的问题.
devexpress xaf 开发中遇到的问题很多久了就忘记了.每天都把开发内容记录下来,方便大家,方便自己
- 15、解决14中csv用excel打开乱码的问题 open('zhihu.csv','w',newline='',encoding='utf-8-sig')
解决14中csv用excel打开乱码的问题 ,其实就是在写csv的时候把 utf-8 改成 utf-8-sig open('zhihu.csv','w',newline='',encoding='ut ...
- 在VMware 14中安装Centos7
在VMware 14中安装Centos7 一.安装前准备 安装VMware14.1 Centos7 64位镜像下载 在VMware中安装Centos7的步骤为: 1.创建虚拟机 创建虚拟机有两种方式: ...
- 并发编程学习笔记(4)----jdk5中提供的原子类及Lock使用及原理
(1)jdk中原子类的使用: jdk5中提供了很多原子类,它会使变量的操作变成原子性的. 原子性:原子性指的是一个操作是不可中断的,即使是在多个线程一起操作的情况下,一个操作一旦开始,就不会被其他线程 ...
- Ubuntu 14 中给 APACHE2安装 SSL 模块 Enable SSL site on Ubuntu 14 LTS, Apache 2.4.7:
Ubuntu 14 中给 APACHE2安装 SSL 模块 Enable SSL site on Ubuntu 14 LTS, Apache 2.4.7: 参考 http://blog.csdn.ne ...
- Go 1.14 中 Cleanup 方法简介
目录 一般的测试 使用 defer 清除依赖 使用 Cleanup 关于t.Parallel 总结 原文:What's New In Go 1.14: Test Cleanup 单元测试通常遵循某些步 ...
- Java 14中对switch的增强,终于可以不写break了
面对这样的if语句,你是不是很难受呢? if (flag == 1) { log.info("didispace.com: 1"); } else if (flag == 2) { ...
随机推荐
- 2015.05.14:codesmith
安装: 安装好codesmith会有两个软件:一个编译器(CodeSmith Generator Explorer),一个生成工具(CodeSmith Generator Studio) 破解: 一般 ...
- 配置web项目时页面报错java.lang.NoClassDefFoundError: Tag
把tomcat:common\lib 下的servlet-api.jar 和jsp-api.jar cp到项目的web-inf 的lib包里 ,重启项目即可
- RequireJS 加载 easyui
requireJS 可以让js加载起来比较优雅,像java里import一样.有了这个,我们可以创建自己的 js控件库,在需要时,页面中只引入 requireJS,然后通过代码方式引入需要用到的控件, ...
- oracle DBlink 【转】
. 实现结果:在一个数据库中某个用户下编写一个存储过程,在存储过程中使用DBLINK连接另一个数据库,从此数据库中的一个用户下取数,然后插入当前的数据库中的一个表中. 二. 实现方法步骤: 1. 创建 ...
- svn记录删除
Delete SVN Folders.reg 批量删除文件夹里的SVN 文件 ------------------------------------------------------------- ...
- Leetcode2:Add Two Numbers@Python
You are given two linked lists representing two non-negative numbers. The digits are stored in rever ...
- MySQL之账户管理
MySQL之账户管理 账户管理是MySQL用户管理最基本的内容.包括登录,退出MySQL服务器.创建用户.删除用户.密码管理和权限管理等内容. 其中登录方式非常简单,在这个地址有:http://www ...
- ARCGIS多种影像裁剪
在互联网上下载的遥感影像都进行过分幅处理,下载下来的影像多是规则的四方形,而在进行遥感影像研究时,多是针对特定区域来进行,比如研究北京市的遥感影像,不在北京市范围内的影像对于研究者就没有利用意义,如果 ...
- jq实现全选、全不选、反选
基本思路: 1全选:点击全选按钮的时候,将input的属性checked设置为true; 2全不选:点击全不选按钮的时候,将input的属性checked设置为false; 3反选:点击反选按钮的时候 ...
- JAVAC 命令详解(转)
本文来自:http://www.cnblogs.com/JeffChen/archive/2008/01/16/1041783.html 结构 javac [ options ] [ sourcefi ...