public CTableAccessInRole FindByTable(Guid FW_Table_id) { List <CBaseObject> lstObj = GetList(); foreach (CBaseObject obj in lstObj) { CTableAccessInRole tair = (CTableAccessInRole)obj; if (tair.FW_Table_id == FW_Table_id) { return(tair); } } return(null); }
//获取用户表权限 //可写优先,只读次之,禁止最后 public AccessType GetTableAccess(Guid FW_Table_id) { //管理员有所有权限 if (IsRole("管理员")) { return(AccessType.write); } //默认拥有所有权限的用户 if (AccessSetting == enumAccessSetting.All) { return(AccessType.write); } AccessType accessType = AccessType.forbide; CTableAccessInUser taiu = TableAccessInUserMgr.FindByTable(FW_Table_id); if (taiu != null) { accessType = taiu.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) { CTableAccessInRole tair = role.TableAccessInRoleMgr.FindByTable(FW_Table_id); if (tair != null) { if (tair.Access == AccessType.write) { return(AccessType.write); } else if (tair.Access == AccessType.read) { accessType = AccessType.read; } } } } return(accessType); }