62,050
社区成员
发帖
与我相关
我的任务
分享
若想求角色的或权限,即code1|code2|code3=(1111)|(0011)|(1010)=1111,即四种权限都有,所
以以相或规则求的是不同角色的并集的权限
假设有3种角色都涉及rightID=1的权限,如下:
UInsert UDelete UUpdate UOutPut
RoleID=1,rightID=1 1 1 1 1
RoleID=2,rightID=1 0 0 1 1
RoleID=3,rightID=1 1 0 1 0
即RoleID分别为1,2,3的rightID为1的权限码分别为(二进制):code1=1111,code2=0011,code3=1010
若你想求角色的与权限,即code1&code2&code3=(1111)&(0011)&(1010)=0010,仅剩Update权限,
所以以相与规则是求的不同角色的交集的权限
若想求角色的或权限,即code1|code2|code3=(1111)&(0011)&(1010)=1111,即四种权限都有,所
以以相或规则求的是不同角色的并集的权限
roleRight = new RoleRights();
roleRight.UInsert = Convert.ToBoolean(ds.Tables[0].Rows[0]["UInsert"].ToString());
roleRight.UDelete = Convert.ToBoolean(ds.Tables[0].Rows[0]["UDelete"].ToString());
roleRight.UUpdate = Convert.ToBoolean(ds.Tables[0].Rows[0]["UUpdate"].ToString());
roleRight.UOutPut = Convert.ToBoolean(ds.Tables[0].Rows[0]["UOutPut"].ToString());
roleRight.UExamine = Convert.ToBoolean(ds.Tables[0].Rows[0]["UExamine"].ToString());