/// <summary> /// /// </summary> /// <param name="application"></param> /// <param name="user"></param> /// <returns></returns> public RoleCollection GetUserRoles(IApplication application, IUser user) { application.NullCheck("application"); user.NullCheck("user"); //原来是按照ID进行权限判断,现在改成根据配置文件决定(沈峥) string userID = user.ID; UserValueType valueType = UserValueType.Guid; if (OguPermissionSettings.GetConfig().RoleRelatedUserParentDept&& user.FullPath.IsNotEmpty()) { userID = user.FullPath; valueType = UserValueType.AllPath; } bool includeMatrixUsers = ServiceBrokerContext.Current.Context.GetValue("includeMatrixUsers", true); DataTable table = AppAdminServiceBroker.Instance.GetUserRoles2( userID, application.CodeName, valueType, RightMaskType.App, DelegationMaskType.All, includeMatrixUsers).Tables[0]; RoleCollection roles = new RoleCollection(BuildObjectsFromTable <IRole>(table)); if (application != null) { roles.ForEach(r => ((RoleImpl)r).Application = application); } return(roles); }
/// <summary> /// 得到指定角色下,某些部门内的所有授权人员 /// </summary> /// <param name="roles">角色集合。</param> /// <param name="depts">组织机构集合。</param> /// <param name="recursively">是否递归。</param> /// <returns></returns> public OP.OguObjectCollection<OP.IOguObject> GetRolesObjects(OP.RoleCollection roles, OP.OguObjectCollection<OP.IOrganization> depts, bool recursively) { var items = PC.Adapters.SCSnapshotAdapter.Instance.QueryRolesContainsUsers(new string[] { "Roles" },(from r in roles select r.ID).ToArray(), Util.GetContextIncludeDeleted(), DateTime.MinValue); return new BridgedOrganizationMechanism().GetObjects<IOguObject>(SearchOUIDType.Guid, items.ToIDArray()); //忽略depts参数 }
public RoleCollection GetRoles(IApplication application) { application.NullCheck("application"); DataTable table = AppAdminServiceBroker.Instance.GetRoles(application.CodeName, RightMaskType.App).Tables[0]; RoleCollection roles = new RoleCollection(BuildObjectsFromTable <IRole>(table)); foreach (RoleImpl role in roles) { role.Application = application; } return(roles); }
private RoleCollection GetUserAppRoles(IApplication app) { RoleCollection roles = null; lock (this.userAppRoles) { if (this.userAppRoles.TryGetValue(app, out roles) == false) { roles = OguPermissionSettings.GetConfig().PermissionObjectImpls.GetUserRoles(app, User); this.userAppRoles.Add(app, roles); } } return(roles); }
/// <summary> /// 得到所有的应用角色 /// </summary> /// <returns></returns> public Dictionary <IApplication, RoleCollection> GetAllAppRoles() { ApplicationCollection allApps = OguPermissionSettings.GetConfig().PermissionFactory.GetAllApplications(); lock (this.userAppRoles) { foreach (IApplication app in allApps) { if (this.userAppRoles.ContainsKey(app) == false) { RoleCollection roles = OguPermissionSettings.GetConfig().PermissionObjectImpls.GetUserRoles(app, this.User); this.userAppRoles.Add(app, roles); } } } return(this.userAppRoles); }
public OguObjectCollection <IOguObject> GetRolesObjects(RoleCollection roles, OguObjectCollection <IOrganization> depts, bool recursively) { OguObjectCollection <IOguObject> result = null; if (roles.Count > 0) { string roleIDs = BuildRoleObjectIDs(roles); string deptFullPath = BuildOguObjectFullPath(depts); bool includeMatrixUsers = ServiceBrokerContext.Current.Context.GetValue("includeMatrixUsers", true); DataTable table = null; if (recursively) { table = AppAdminServiceBroker.Instance.GetRolesUsers2( deptFullPath, roles[0].Application.CodeName, roleIDs, DelegationMaskType.All, SidelineMaskType.All, Common.DefaultAttrs, includeMatrixUsers).Tables[0]; } else { table = AppAdminServiceBroker.Instance.GetChildrenInRoles2( deptFullPath, roles[0].Application.CodeName, roleIDs, false, true, true, includeMatrixUsers).Tables[0]; } result = new OguObjectCollection <IOguObject>(Common.BuildObjectsFromTable <IOguObject>(table)); } else { result = new OguObjectCollection <IOguObject>(new List <IOguObject>()); } return(result); }