C# Devexpress XAF新安全系统-标准见;SecuritySystemObjectPermissionsObject“;班

C# Devexpress XAF新安全系统-标准见;SecuritySystemObjectPermissionsObject“;班,c#,devexpress,xaf,C#,Devexpress,Xaf,我正在我的XAF项目中使用新的安全系统。我已经创建了自定义安全类“ExtendedSystemSecurityRole”和“SecuritySystemUser”。在Updater类中,我创建了一个名为“G1”的角色及其权限,如下所示。但在运行时,用户“John”看不到“Buyer”表单 ExtendedSecuritySystemRole basicUserRole=ObjectSpace.FindObject(新的二进制运算符(“Name”、“G1”); if(basicUserRole==

我正在我的XAF项目中使用新的安全系统。我已经创建了自定义安全类“ExtendedSystemSecurityRole”和“SecuritySystemUser”。在Updater类中,我创建了一个名为“G1”的角色及其权限,如下所示。但在运行时,用户“John”看不到“Buyer”表单

ExtendedSecuritySystemRole basicUserRole=ObjectSpace.FindObject(新的二进制运算符(“Name”、“G1”);
if(basicUserRole==null)
{
basicUserRole=ObjectSpace.CreateObject();
basicUserRole.Name=“G1”;
SecuritySystemTypePermissionObject用户类型权限=
ObjectSpace.CreateObject();
userTypePermission.TargetType=typeof(买方);
SecuritySystemObjectPermissionsObject currentUserObjectPermission=
ObjectSpace.CreateObject();
currentUserObjectPermission.Criteria=“[Active]=True”;
currentUserObjectPermission.AllowNavigate=true;
currentUserObjectPermission.Allowerad=true;
userTypePermission.ObjectPermissions.Add(currentUserObjectPermission);
basicUserRole.TypePermissions.Add(userTypePermission);
}
ExtendedSecuritySystemUser用户John=
ObjectSpace.FindObject(
新的二进制运算符(“用户名”、“约翰”);
if(userJohn==null)
{
userJohn=ObjectSpace.CreateObject();
userJohn.UserName=“John”;
userJohn.SetPassword(“”);
userJohn.Roles.Add(basicUserRole);
}

您的标准是
Buyer.Active=True
not
ExtendedSecuritySystemUser.Active=True

您可以
IsCurrentUserActive()

使用
ViewController
会更简单。比如:

public class InactiveUsersController : ViewController
{
    public InactiveUsersController()
    {
        this.TargetViewNesting = Nesting.Any;
        this.TargetViewType = ViewType.ListView;
        this.TargetObjectType = typeof(Buyer);
    }

    protected override void OnActivated()
    {
        base.OnActivated();
        ListView listView = View as ListView;
        listView.CollectionSource.Criteria.Remove("InactiveUserFilter"); // clear the filter

        var currentUser = SecuritySystem.CurrentUser as ExtendedSecuritySystemUser;
        if (!currentUser.Active)
        {
            // return empty list if user is inactive
            listView.CollectionSource.Criteria.Add("InactiveUserFilter", CollectionSource.EmptyCollectionCriteria); 
        }
    }
}

你忘记激活userJohn了吗?如果删除这些条件,是否有效?DevXPress支持的最佳位置是“John”处于活动状态。是的,它没有标准。DevXPress支持中心仅对注册用户(具有有效许可证)进行解答。感谢您的解答。但我需要做的与ExtendedSecuritySystemUser无关。我只想让安全系统了解标准,不管我写什么。如果我想过滤买方类型,我会使用其属性,如[Active]或其他属性。但问题是安全系统不会抛出任何异常,也不会显示任何合理的输出。哪个对象具有“Active”属性?买家还是用户?目前,您的条件似乎返回零行。您可以对
XPCollection
使用相同的条件语法来检查结果集。买家有一个“活动”属性。在这种情况下,您需要两个单独的权限对象。John应该能够导航到列表视图,而不考虑任何条件。因此,您需要一个具有
AllowNavigate
但没有条件的权限对象。但他不应该能够读取不活动的行。因此,为
allocread
添加另一个单独的权限对象,并使用条件。非常感谢,是的,您的解决方案成功了。但很抱歉,Devexpress支持中心对此一无所知。再次感谢:)
public class InactiveUsersController : ViewController
{
    public InactiveUsersController()
    {
        this.TargetViewNesting = Nesting.Any;
        this.TargetViewType = ViewType.ListView;
        this.TargetObjectType = typeof(Buyer);
    }

    protected override void OnActivated()
    {
        base.OnActivated();
        ListView listView = View as ListView;
        listView.CollectionSource.Criteria.Remove("InactiveUserFilter"); // clear the filter

        var currentUser = SecuritySystem.CurrentUser as ExtendedSecuritySystemUser;
        if (!currentUser.Active)
        {
            // return empty list if user is inactive
            listView.CollectionSource.Criteria.Add("InactiveUserFilter", CollectionSource.EmptyCollectionCriteria); 
        }
    }
}