Ornament 类型资源权限

     类型资源,就是系统中所有者类型的资源只当做一个资源对待,例如Ornament的User,admin对所有的User的操作都是一致,而不是像普通资源那样,可以对某种资源的实例进行管理。

 

无论普通资源还是类型资源,我们都必须一开始就确定操作,Ornament的操作如下:

    [Flags]
    public enum UserOperator
    {
        None = 0,
        Read = 1,
        Modify = 2 | 1,
        Lock = 4 | 1 | 2,
        Approve = 8 | 2 | 1,
        SetPassword = 16 | 1 | 2 | 4 | 8
    }

定义资源

由于没有设定UI,因此在 Ornament.MVCWebFrame\Models\BaseDataInit.cs 文件中加入。

GenericResourceInfo<string> userResource = new GenericResourceInfo<string>("User", typeof(UserOperator))
            {
                Name = "UserResource"
            };

 var resDao = OrnamentContext.Current.MemberShipFactory.CreateResourceDao();
 resDao.SaveOrUpdate(userResource);
创建许可证的资源选择器

因为创建许可证是可以由管理员创建的,因此需要制定一个UI给他们对相同类型的资源进行选择。

在Ornament中,已经有关于TypeResource的选择器,了参考Ornament.MVCWebFrame/Areas/MemberShips/Views/Permissions/TypeResourcesSelector.ascx。因此我们要告诉Ornament,这个选择器的位置,所以要在Ornament.MVCWebFrame/Config/WebCfg.config中设定。

创建一个ResourceDescription对象,xml的意思,请参考Castle的IOC容器,非常简单,不懂看也没有关系得。

<component id="resType" type="Ornament.Web.ResourceDescription,Ornament.Web.Core">
      <parameters>
        <ValueType>System.String,mscorlib</ValueType>
        <Path>~/Areas/MemberShips/Views/Permissions/TypeResourcesSelector.ascx</Path>
        <Name>类型资源</Name>
      </parameters>
</component>
然后加入到容器中,请留意${resType} 和 上面xml中的 id,他们是相同的。
<component id="Configuration"
               type="Ornament.Web.Configuration,Ornament.Web.Core">
      <parameters>
        <resources>
          <list>
            <item>${resType}</item>
            <item>${resInfo}</item>
          </list>
        </resources>
      </parameters>
 </component>
创建Permission

输入URL /MemberShips/Permissions,或者在菜单“权限”->权限设定->许可设定,就会出现下面URL,然后点击添加,安装wizard一步步做就可以了

image

为Role分配Permission

输入URL,MemberShips/Role, 或者菜单中选择,”权限”-“角色”,然后就可以看到下面列表,点击编辑之后,就可以为角色分配有那几个Permission了。

image

转载于:https://www.cnblogs.com/fantasylu/archive/2011/05/23/2054335.html

<!DOCTYPE html> <html> <head> <title>圣诞树</title> <style> body{ background-color: #2C3E50; } .tree{ position: relative; margin: 0 auto; width: 0; height: 0; border-left: 100px solid transparent; border-right: 100px solid transparent; border-bottom: 200px solid green; animation: grow 2s ease-in-out; } .tree:before{ content: ""; position: absolute; top: -50px; left: -50px; width: 0; height: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-bottom: 100px solid green; } .tree:after{ content: ""; position: absolute; top: -75px; left: -75px; width: 0; height: 0; border-left: 75px solid transparent; border-right: 75px solid transparent; border-bottom: 150px solid green; } .tree .star{ position: absolute; top: -200px; left: -50px; width: 0; height: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-bottom: 50px solid yellow; transform: rotate(45deg); } .tree .ornament{ position: absolute; background-color: red; border-radius: 50%; animation: blink 2s infinite; } .tree .ornament1{ top: 50px; left: -10px; width: 20px; height: 20px; } .tree .ornament2{ top: 80px; left: -30px; width: 20px; height: 20px; } .tree .ornament3{ top: 120px; left: -40px; width: 20px; height: 20px; } .tree .ornament4{ top: 150px; left: -20px; width: 20px; height: 20px; } .tree .ornament5{ top: 100px; left: 30px; width: 20px; height: 20px; } .tree .ornament6{ top: 140px; left: 40px; width: 20px; height: 20px; } .tree .ornament7{ top: 180px; left: 0; width: 20px; height: 20px; } .tree .ornament8{ top: 200px; left: -20px; width: 20px; height: 20px; } .tree .ornament9{ top: 230px; left: 0; width: 20px; height: 20px; } @keyframes grow{ 0%{ transform: scale(0); } 100%{ transform: scale(1); } } @keyframes blink{ 0%{ opacity: 0.5; } 50%{ opacity: 1; } 100%{ opacity: 0.5; } } </style> </head> <body> <div class="tree"> <div class="star"></div> <div class="ornament ornament1"></div> <div class="ornament ornament2"></div> <div class="ornament ornament3"></div> <div class="ornament ornament4"></div> <div class="ornament ornament5"></div> <div class="ornament ornament6"></div> <div class="ornament ornament7"></div> <div class="ornament ornament8"></div> <div class="ornament ornament9"></div> </div> </body> </html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值