Пример #1
0
        //获取用户视图权限
        //可写优先,只读次之,禁止最后
        public AccessType GetViewAccess(Guid UI_View_id)
        {
            //管理员有所有权限
            if (IsRole("管理员"))
            {
                return(AccessType.write);
            }
            //
            //默认拥有所有权限的用户
            if (AccessSetting == enumAccessSetting.All)
            {
                return(AccessType.write);
            }

            AccessType        accessType = AccessType.forbide;
            CViewAccessInUser vaiu       = ViewAccessInUserMgr.FindByView(UI_View_id);

            if (vaiu != null)
            {
                accessType = vaiu.Access;
                if (accessType == AccessType.write)
                {
                    return(AccessType.write);
                }
            }

            CCompany           Company = (CCompany)Ctx.CompanyMgr.Find(B_Company_id);
            List <CBaseObject> lstObj  = Company.RoleMgr.GetList();

            foreach (CBaseObject obj in lstObj)
            {
                CRole role = (CRole)obj;
                if (role.UserInRoleMgr.FindByUserid(Id) != null)
                {
                    CViewAccessInRole vair = role.ViewAccessInRoleMgr.FindByView(UI_View_id);
                    if (vair != null)
                    {
                        if (vair.Access == AccessType.write)
                        {
                            return(AccessType.write);
                        }
                        else if (vair.Access == AccessType.read)
                        {
                            accessType = AccessType.read;
                        }
                    }
                }
            }

            return(accessType);
        }
Пример #2
0
        public CViewAccessInUser FindByView(Guid UI_View_id)
        {
            List <CBaseObject> lstObj = GetList();

            foreach (CBaseObject obj in lstObj)
            {
                CViewAccessInUser vaiu = (CViewAccessInUser)obj;
                if (vaiu.UI_View_id == UI_View_id)
                {
                    return(vaiu);
                }
            }
            return(null);
        }