public CColumnAccessInUser FindByColumn(Guid FW_Column_id)
        {
            List <CBaseObject> lstObj = GetList();

            foreach (CBaseObject obj in lstObj)
            {
                CColumnAccessInUser caiu = (CColumnAccessInUser)obj;
                if (caiu.FW_Column_id == FW_Column_id)
                {
                    return(caiu);
                }
            }
            return(null);
        }
Пример #2
0
        //获取用户字段权限
        //可写优先,只读次之,禁止最后
        public AccessType GetColumnAccess(CColumn col)
        {
            //管理员有所有权限
            if (IsRole("管理员"))
            {
                return(AccessType.write);
            }
            //
            //如果是系统字段,则权限都为只读,避免其他功能读取不到字段值
            if (col.IsSystem)
            {
                return(AccessType.read);
            }
            //

            bool                bHasSetAccess = false; //是否手动设置字段权限
            AccessType          accessType    = AccessType.forbide;
            CColumnAccessInUser caiu          = ColumnAccessInUserMgr.FindByColumn(col.Id);

            if (caiu != null)
            {
                bHasSetAccess = true;
                accessType    = caiu.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)
                {
                    CColumnAccessInRole cair = role.ColumnAccessInRoleMgr.FindByColumn(col.Id);
                    if (cair != null)
                    {
                        bHasSetAccess = true;
                        if (cair.Access == AccessType.write)
                        {
                            return(AccessType.write);
                        }
                        else if (cair.Access == AccessType.read)
                        {
                            accessType = AccessType.read;
                        }
                    }
                }
            }

            //如果没有手动设置字段权限,默认字段权限为可写,即如果有表权限,则默认拥有所有字段写权限
            if (!bHasSetAccess)
            {
                accessType = AccessType.write;
            }

            return(accessType);
        }