//获取用户视图权限 //可写优先,只读次之,禁止最后 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); }
//¶¥¼¶µ¥Î» public CCompany FindTopCompany() { List <CBaseObject> lstObj = GetList(); foreach (CBaseObject obj in lstObj) { CCompany company = (CCompany)obj; if (company.Parent_id == Guid.Empty) { return(company); } } return(null); }
public CCompany FindByName(string sName) { List <CBaseObject> lstObj = GetList(); foreach (CBaseObject obj in lstObj) { CCompany company = (CCompany)obj; if (company.Name.Equals(sName, StringComparison.OrdinalIgnoreCase)) { return(company); } } return(null); }
//获取用户桌面组权限 //可写优先,只读次之,禁止最后 public AccessType GetDesktopGroupAccess(Guid UI_DesktopGroup_id) { //管理员有所有权限 if (IsRole("管理员")) { return(AccessType.write); } // AccessType accessType = AccessType.forbide; CDesktopGroupAccessInUser dgaiu = DesktopGroupAccessInUserMgr.FindByDesktopGroup(UI_DesktopGroup_id); if (dgaiu != null) { accessType = dgaiu.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) { CDesktopGroupAccessInRole dgair = role.DesktopGroupAccessInRoleMgr.FindByDesktopGroup(UI_DesktopGroup_id); if (dgair != null) { if (dgair.Access == AccessType.write) { return(AccessType.write); } else if (dgair.Access == AccessType.read) { accessType = AccessType.read; } } } } return(accessType); }
//是否某种角色 public bool IsRole(string sRoleName) { CCompany Company = (CCompany)Ctx.CompanyMgr.Find(B_Company_id); CRole role = Company.RoleMgr.FindByName(sRoleName); if (role == null) { return(false); } if (role.UserInRoleMgr.FindByUserid(this.Id) != null) { return(true); } else { return(false); } }
//获取用户字段权限 //可写优先,只读次之,禁止最后 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); }