private static IOrganization GetOrganization(UserGraphTreeParams requestParams) { IOrganization org = null; if (requestParams.ID.IsNotEmpty()) { org = OguMechanismFactory.GetMechanism().GetObjects <IOrganization>(SearchOUIDType.Guid, requestParams.ID).SingleOrDefault(); (org != null).FalseThrow("不能找到ID为\"{0}\"的组织", requestParams.ID); } else { if (requestParams.FullPath.IsNotEmpty()) { org = OguMechanismFactory.GetMechanism().GetObjects <IOrganization>(SearchOUIDType.FullPath, requestParams.FullPath).SingleOrDefault(); (org != null).FalseThrow("不能找到路径为\"{0}\"的组织", requestParams.FullPath); } else { org = OguMechanismFactory.GetMechanism().GetRoot(); } } return(org); }
/// <summary> /// 得到某一级组织的子对象 /// </summary> /// <param name="requestParams"></param> /// <param name="addedAction">添加了树节点以后的回调</param> /// <returns></returns> public static List <UserGraphTreeNode> GetChildren(UserGraphTreeParams requestParams, Func <IOguObject, bool> filter = null, Action <IOguObject, UserGraphTreeNode> addedAction = null) { List <UserGraphTreeNode> childNodes = new List <UserGraphTreeNode>(); requestParams.DoServiceCall(rp => { IOrganization parent = GetOrganization(requestParams); parent.Children.FillChildNodes(childNodes, requestParams.ListMask, filter, addedAction); }); return(childNodes); }
/// <summary> /// 得到根组织,如果传入的根组织路径为空,则返回系统组织架构树的根 /// </summary> /// <param name="fullPath"></param> /// <param name="requestParams"></param> /// <param name="filter">子对象的过滤器</param> /// <param name="addedAction">添加了树节点以后的回调</param> /// <returns></returns> public static UserGraphTreeNode GetRoot(UserGraphTreeParams requestParams, Func <IOguObject, bool> filter = null, Action <IOguObject, UserGraphTreeNode> addedAction = null) { UserGraphTreeNode rootNode = null; requestParams.DoServiceCall((rp) => { IOrganization parent = GetOrganization(requestParams); rootNode = parent.ToTreeNode(); parent.Children.FillChildNodes(rootNode.Children, rp.ListMask, filter, addedAction); rootNode.Open = true; }); return(rootNode); }