XAF自定义登录页

本文参阅官网文档 How to: Use Custom Logon Parameters and Authentication 加以实践并做简单的总结归纳。

修改登录页面文本信息

如果需要修改登录页面文本信息或实现本地化,可以双击解决方案中module工程下的 .xafml 文件,进入模型编辑器,在项目树结构中展开 Views 节点 → 展开 DevExpress.ExpressApp.Security → 展开AuthenticationStandardLogonParameters_DetailView 。 然后可以在 Items 文件中选择对应的属性值进行修改, 或者在 Layout 节点中的设计面板中右键点击 costomize layout 按钮中进入设计模式进行编辑。
在这里插入图片描述

自定义登录页面

如果需要修改登录页面的登录参数,例如下文所述,是按照公司+工号+密码的方式登录。以下是具体步骤。

创建自定义登录页面

在创建自定义登录页面之前,需要创建登录信息所涉及的 EmployeeCompany 类。 其中 Employee 继承于 PermissionPolicyUser 类,主要的作用是作为 PermissionPolicyUser 类的拓展,提供了工号属性,并与 Company 类关联。

在解决方案中 module 工程下的 BusinessObjects 文件夹中新建 Employee.cs

using System.ComponentModel;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl.PermissionPolicy;
using DevExpress.Xpo;
// ...
[DefaultClassOptions, DefaultProperty(nameof(Gonghao))]
public class Employee : PermissionPolicyUser{
   
    public Employee(Session session) : base(session) {
   }
    
    private Company company;
	string gonghao;
    [Size(SizeAttribute.DefaultStringMappingFieldSize)]
    
    [RuleRequiredField("Employee_Gonghao_RuleRequiredField", DefaultContexts.Save)]
    [RuleUniqueValue("Employee_Gonghao_RuleUniqueValue", DefaultContexts.Save, "本系统中已经存在该工号!")]
    public string Gonghao
    {
   
        get => gonghao;
        set => SetPropertyValue(nameof(Gonghao), ref gonghao, value);
    }

    [Association("Company-Employees")]
    public Company Company {
   
        get {
    return company; }
        set {
    SetPropertyValue(nameof(Company), ref company, value);}
    }
}

在解决方案中 module 工程下的 BusinessObjects 文件夹中新建 Company.cs

using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Xpo;
// ...
[DefaultClassOptions]
public class Company : BaseObject {
   
    public Company(Session session) : base(session) {
   }
    private string name;
    public string Name {
   
        get {
    return name; }
        set {
    SetPropertyValue(nameof(Name), ref name, value); }
    }
    [Association("Company-Employees")]
    public XPCollection<Employee> Employees {
   
        get {
    return GetCollection<Employee>(nameof(Employees)); }
    }
}

需要注意的是,需要将公司和工号下拉框设置成不可新增。

在这里插入图片描述

在解决方案中 module 工程下创建 CustomLogonParameters 类,作为自定义登录界面。

using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using DevExpress.ExpressApp.DC;
using DevExpress.Persistent.Base;

namespace MySolution.Module.BusinessObjects
{
   
    [DomainComponent, Serializable]
    [
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值