组织单元
更新时间: 2024-02-05 浏览次数: {{ hits }}

查找组织单元
获取组织机构中角色清单及员工所在部门、员工拥有哪些角色等。如:选择员工后,自动查询员工所在部门并赋值给其他字段。

示例:

//获取所有角色分组

H3.Organization.OrgRoleGroup[] groups = this.Request.Engine.Organization.GetAllRoleGroups();


//获取公司所有角色

H3.Organization.OrgRole[] allRoles =   this.Request.Engine.Organization.GetAllRoles(); 


// 获取用户所在部门

H3.Organization.Unit unit =   this.Request.Engine.Organization.GetParentUnit(this.Request.UserContext.UserId);   


//获取用户所有角色

H3.Organization.OrgRole[] roles =   this.Request.Engine.Organization.GetUserRoles(this.Request.UserContext.UserId,true);   


// 获取公司所有有效用户

string[] userIds =   this.Request.Engine.Organization.GetChildren(this.Request.Engine.Organization.Company.CompanyId,   H3.Organization.UnitType.User, true, H3.Organization.State.Active); 


//根据用户ID获取用户对象

H3.Organization.User user =   Engine.Organization.GetUnit(this.Request.UserContext.UserId) as H3.Organization.User; 


//根据人员Id查询其所有的部门Id

H3.Organization.User user = (H3.Organization.User) this.Engine.Organization.GetUnit("用户Id");

string[] pIds = user.ParentIds;


//根据人员id第N级父部门,0是第一级,1是第二级,以此类推

H3.Organization.Unit unit = this.Engine.Organization.GetParentUnitByLevel("用户Id", 1);


//根据部门Id获取其第N级父部门,0是第一级,1是第二级,以此类推

H3.Organization.Unit unit = this.Engine.Organization.GetParentUnitByLevel("部门Id", 1);


//判断一个部门是否是另一个部门的祖先部门,返回true表示是祖先部门

bool isAncestor = this.Engine.Organization.IsAncestor("子孙部门Id", "祖先部门Id");


//根据人员/部门ID获取人员/部门名称

string name=this.Engine.Organization.GetName(string id, H3.Organization.NameType type);
id:人员/部门的ID
type:名称的类型
H3.Organization.NameType.Name       名称
H3.Organization.NameType.Path       组织路径,/Company/OU1/OU2这种格式
H3.Organization.NameType.FullName   全名称,如果是用户则是:用户名[用户编码];如果是OU,则是:/Company/OU1/OU2这种格式



H3.Organization.OrgRoleGroup(角色分组)对象常用属性:

序号

注释

属性名

1

角色分组Id

ObjectId

2

角色分组名称

Name

3

公司Id

CompanyId


H3.Organization.OrgRole(角色分组)对象常用属性:

序号

注释

属性名

1

角色Id

ObjectId

2

角色名称

Name

3

公司Id

CompanyId

3

所属分组的分组Id

GroupId


H3.Organization.Unit(部门)对象常用属性:

序号

注释

属性名

1

部门Id

ObjectId

2

部门名称

Name

3

部门经理的人员Id

ManagerId

3

父部门Id

ParentId