XAF:如何让用户在运行时个性化界面并将个性化信息保存到数据库中 win/web/entityframework/xpo
public sealed partial class MySolutionWindowsFormsModule : ModuleBase {
private void Application_CreateCustomModelDifferenceStore(Object sender, CreateCustomModelDifferenceStoreEventArgs e) {
e.Store = new ModelDifferenceDbStore((XafApplication)sender, typeof(ModelDifference), true, "Win");
e.Handled = true;
}
private void Application_CreateCustomUserModelDifferenceStore(Object sender, CreateCustomModelDifferenceStoreEventArgs e) {
e.Store = new ModelDifferenceDbStore((XafApplication)sender, typeof(ModelDifference), false, "Win");
e.Handled = true;
}
//...
public override void Setup(XafApplication application) {
base.Setup(application);
application.CreateCustomModelDifferenceStore += Application_CreateCustomModelDifferenceStore;
application.CreateCustomUserModelDifferenceStore += Application_CreateCustomUserModelDifferenceStore;
}
}
注意红色的代码:
1.MySolutionWindowsFormsModule 是指 你的项目.Module.Win这个project.
2.在setup中的2行代码增加事件,CreateCustomModelDifferenceStore 是指全局的模型设置信息。
3.CreateCustomUserModelDifferenceStore ,是指当前用户的模型信息。
4.e.Store = new ModelDifferenceDbStore((XafApplication)sender, typeof(ModelDifference), true, "Win"); 其中,true代表是否为全局设置,“win"代表平台,当然在web中,需要写"web"。web项目是:你的项目.Module.Web
public sealed partial class MySolutionAspNetModule : ModuleBase {
private void Application_CreateCustomModelDifferenceStore(Object sender, CreateCustomModelDifferenceStoreEventArgs e) {
e.Store = new ModelDifferenceDbStore((XafApplication)sender, typeof(ModelDifference), true, "Web");
e.Handled = true;
}
private void Application_CreateCustomUserModelDifferenceStore(Object sender, CreateCustomModelDifferenceStoreEventArgs e) {
e.Store = new ModelDifferenceDbStore((XafApplication)sender, typeof(ModelDifference), false, "Web");
e.Handled = true;
}
// ...
public override void Setup(XafApplication application) {
base.Setup(application);
application.CreateCustomModelDifferenceStore += Application_CreateCustomModelDifferenceStore;
application.CreateCustomUserModelDifferenceStore += Application_CreateCustomUserModelDifferenceStore;
}
}
下面有介绍如何启用管理UI。
如果你使用Entity Framework, 需要在DbContext中做如下声明:
using DevExpress.Persistent.BaseImpl.EF;
// ...
public class MyDbContext : DbContext {
// ...
public DbSet<ModelDifference> ModelDifferences { get; set; }
public DbSet<ModelDifferenceAspect> ModelDifferenceAspects { get; set; }
}
另外,一定要确保所有用户都具有读/写访问 ModelDifference 和 ModelDifferenceAspect 类型的权限,否则有的权限模块会阻止这个行为成功执行。
下面是在代码中给权限的代码:
C#
public class Updater : ModuleUpdater {
public override void UpdateDatabaseAfterUpdateSchema() {
base.UpdateDatabaseAfterUpdateSchema(); SecuritySystemRole defaultRole = ObjectSpace.FindObject<SecuritySystemRole>(
new BinaryOperator("Name", "Default"));
if(defaultRole == null) {
defaultRole = ObjectSpace.CreateObject<SecuritySystemRole>();
// ...
defaultRole.SetTypePermissionsRecursively<ModelDifference>(
SecurityOperations.ReadWriteAccess, SecuritySystemModifier.Allow);
defaultRole.SetTypePermissionsRecursively<ModelDifferenceAspect>(
SecurityOperations.ReadWriteAccess, SecuritySystemModifier.Allow);
// The 'Create' permission is additionally required if you use the Middle Tier Application Server
defaultRole.SetTypePermissionsRecursively<ModelDifference>(
SecurityOperations.Create, SecuritySystemModifier.Allow);
defaultRole.SetTypePermissionsRecursively<ModelDifferenceAspect>(
SecurityOperations.Create, SecuritySystemModifier.Allow);
}
sampleUser.Roles.Add(defaultRole);
// ...
ObjectSpace.CommitChanges();
}
// ...
}

在运行时,通过菜单打开模型差异管理的列表,可以看到相关的按钮。

在这里,会列出存在的用户的模型差异(用户打开一次程序后,就会保存该用户的模型差异),如果想为没有使用过程序的用户创建模型差异,可以单击创建模型差异。
如果想要加载共享的模式差异(就是在 Visual Studio (Model.xafml) 文件中创建的那个),可以点击导入共享模型差异。
另外三个按钮是:复制模型差异、 导出模型差异和重置模型差异 ,将应用于所选记录。
在模型的差异列表视图中,有一条共享模型差异的记录。它不是指某个用户的设置,而是指应用程序全局的设置。
XAF:如何让用户在运行时个性化界面并将个性化信息保存到数据库中 win/web/entityframework/xpo的更多相关文章
- XAF实现运行时填加验证规则并保存到数据库中
有几种方法可以用来声明一个验证规则.最常用的方法是使用对应的Attribute来定义.详见这里.验证模块还允许您通过在业务类实现 IRuleSource 接口定义自定义的验证规则的来源. IRuleS ...
- iOS crash log 解析 symbol address = stack address - slide 运行时获取slide的api 利用dwarfdump从dsym文件中得到symbol
概述: 为什么 crash log 内 Exception Backtrace 部分的地址(stack address)不能从 dsym 文件中查出对应的代码? 因为 ASLR(Address spa ...
- 【Python】【demo实验1】【Python运行时强制刷新缓冲区,输出信息】(Python3 应不存在类似情况)
[原文] 需求:打印一颗 ”*” 休息1s 代码如下: #!/usr/bin/python #coding=utf-8 ''' 暂停1s输出 ''' import time def printStar ...
- Java虚拟机及运行时数据区
1.Java虚拟机的定义 Java虚拟机(Java Virtual Machine),简称JVM.当我们说起Java虚拟机时,可能指的是如下三种不同的东西: 抽象的虚拟机规范 规范的具体实现 一个运行 ...
- Objective-C Runtime 运行时之四:Method Swizzling
理解Method Swizzling是学习runtime机制的一个很好的机会.在此不多做整理,仅翻译由Mattt Thompson发表于nshipster的Method Swizzling一文. Me ...
- Mysql常用show命令,show variables like xxx 详解,mysql运行时参数
MySQL中有很多的基本命令,show命令也是其中之一,在很多使用者中对show命令的使用还容易产生混淆,本文汇集了show命令的众多用法. 详细: http://dev.mysql.com/doc/ ...
- Objective-C Runtime 运行时之四:Method Swizzling(转载)
理解Method Swizzling是学习runtime机制的一个很好的机会.在此不多做整理,仅翻译由Mattt Thompson发表于nshipster的Method Swizzling一文. Me ...
- Java 9 揭秘(7. 创建自定义运行时映像)
Tips 做一个终身学习的人. 在第一章节中,主要介绍以下内容: 什么是自定义运行时映像和JIMAGE格式 如何使用jlink工具创建自定义的运行时映像 如何指定命令名称来运行存储在自定义映像中的应用 ...
- 解读JavaScript 之引擎、运行时和堆栈调用
转载自开源中国 译者:Tocy, 凉凉_, 亚林瓜子, 离诌 原文链接 英文原文:How JavaScript works: an overview of the engine, the runtim ...
随机推荐
- APP开发:一个APP开发需要哪些技术人员?
亿合科技小编了解到:国民老公王思聪曾经在一个访谈中谈到过,如果他是一个普通人,他会选择移动互联网去创业,因为做个网站或者App开发门槛较低,做大做强的机会也比较多.小编觉得创业就是投资,重 ...
- ssh免密码认证
举例:有机器PC_A(172.0.246),PC_B(172.0.1.140).现想A通过ssh免密码登录到B. 1.在PC_A主机下生成公钥/私钥对 [comodo@PC_A ~]$ ssh-key ...
- 使用geoserver发布arcgis切片
arcgis map 版本:10.1,10.2,10.3均可 jre:7或者8 geoserver:2.8.2以上 切片:松散型,256*256 ,png 1:安装geoserver并独立部署geo ...
- 使用Apache Ambari管理Hadoop
随着Hadoop越来越普及,对合适的管理平台的需求成为当前亟待解决的问题.已经有几个商业性的Hadoop管理平台,如Cloudera Enterprise Manager,但Apache Ambari ...
- css3基础必回选择器全解
1. *:通用元素选择器 * { margin: 0; padding: 0; } *选择器是选择页面上的全部元素,上面的代码作用是把全部元素的margin和padding设为0,最基本的清除 ...
- VMware下centos6.3minimal搭建网络环境
VMware提供3钟连接网络的方式,参看http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/03/15/1985084.html 先确定VMw ...
- js学习心得之思维逻辑与对象上下文环境(一)
html5 canvas矩形绘制实例(绘图有js 实现) html: <canvas id="myCanvas" width="200" height=& ...
- 敏捷开发之Scrum扫盲篇
现在敏捷开发是越来越火了,人人都在谈敏捷,人人都在学习Scrum和XP... 为了不落后他人,于是我也开始学习Scrum,今天主要是对我最近阅读的相关资料,根据自己的理解,用自己的话来讲述Scrum中 ...
- QT常见数据类型操作
平常使用QStringList,都是通过at()访问其中的元素,然后试图也通过它修改元素,编译器报错,原来要使用下标访问修改: //accessRecList.at(3)=strSimilarity; ...
- NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
今天调试SSM框架项目后台JSOn接口,报出来一个让人迷惑的错误:NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config 上网查了一下别人的博 ...