Esempio n. 1
0
 public static PrivilegeState Create(PrivilegeBase privilege)
 {
     if (privilege == null)
     {
         throw new ArgumentNullException("privilege");
     }
     return(new PrivilegeState(privilege.Id)
     {
         _createOn = privilege.CreateOn
     }.InternalModify(privilege));
 }
Esempio n. 2
0
        internal PrivilegeState InternalModify(PrivilegeBase privilege)
        {
            if (privilege == null)
            {
                throw new ArgumentNullException("privilege");
            }
            if (string.IsNullOrEmpty(privilege.SubjectType))
            {
                throw new AnycmdException("必须指定主授权授权类型");
            }
            if (string.IsNullOrEmpty(privilege.ObjectType))
            {
                throw new AnycmdException("必须指定授权授权类型");
            }
            AcElementType subjectType;
            AcElementType acObjectType;
            AcRecordType  acType;

            if (!privilege.SubjectType.TryParse(out subjectType))
            {
                throw new AnycmdException("非法的主授权类型" + privilege.SubjectType);
            }
            if (!privilege.ObjectType.TryParse(out acObjectType))
            {
                throw new AnycmdException("非法的从授权类型" + privilege.ObjectType);
            }
            if (!(privilege.SubjectType + privilege.ObjectType).TryParse(out acType))
            {
                throw new AnycmdException("非法的授权类型" + privilege.ObjectType);
            }

            _acType            = acType;
            _subjectType       = subjectType;
            _subjectInstanceId = privilege.SubjectInstanceId;
            _objectType        = acObjectType;
            _objectInstanceId  = privilege.ObjectInstanceId;
            _acContent         = privilege.AcContent;
            _createBy          = privilege.CreateBy;
            _createUserId      = privilege.CreateUserId;
            _acContentType     = privilege.AcContentType;

            return(this);
        }
Esempio n. 3
0
 public void DeleteRoles(params int[] roleIds)
 {
     PrivilegeBase.DeleteRoles(roleIds);
 }