在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) { ...
随机推荐
- Java判断Class变量是什么类型
public static void main(String[] args) { java.util.Date date_u = new java.util.Date(1); java.sql.Dat ...
- adb shell出错“error: unknown host service”
已经测试,可用: 在命令行输入adb shell后输出如下错误: adb server is out of date. killing... ADB server didn't ACK * fail ...
- JAVA Socket 编程学习笔记(二)
在上一篇中,使用了 java Socket+Tcp/IP 协议来实现应用程序或客户端--服务器间的实时双向通信,本篇中,将使用 UDP 协议来实现 Socket 的通信. 1. 关于UDP UDP协 ...
- mysql连接查询,封装mysql函数
连接查询 交叉连接语法: select * | 字段列表 from 表1 cross join 表2 内连接: select *|字段列表 from 左表 inner join 右表 on 左表. ...
- CentOS7.2部署OpenStack(一)—环境准备
1.系统环境 # uname -r 3.10.0-327.el7.x86_64 # cat /etc/redhat-release CentOS Linux release 7.2.1511 (Cor ...
- LR12.53—第2课:准备脚本重播
第2课:准备脚本重播 创建Vuser脚本后,可以通过从VuGen中运行它验证它.有时重播将失败,即使同样的动作在录制过程中取得了成功. 许多应用程序使用,每次使用应用程序时更改动态值.例如,某些服 ...
- map和list遍历基础
本文属原创,转载请注明出处:http://www.cnblogs.com/robinjava77/p/5456085.html (Robin) Map import java.util.HashMap ...
- jquery 上传回显图片预览
/******************************************************************************* * 异步上传文件,兼容IE8,火狐和谷 ...
- treeview_dropdown_control
http://www.brad-smith.info/blog/archives/193 http://www.brad-smith.info/blog/projects/dropdown-contr ...
- TCP、UDP、IP 协议分析
http://rabbit.xttc.edu.cn/rabbit/htm/artical/201091145609.shtml http://bhsc881114.github.io/2015/06 ...