コード例 #1
0
 /// <summary>
 /// 获取组织机构子节点
 /// </summary>
 /// <param name="unitID"></param>
 /// <param name="UnitType"></param>
 /// <param name="Recursive"></param>
 /// <returns></returns>
 public JsonResult LoadTreeData(string unitID, OThinker.Organization.UnitType UnitType = OThinker.Organization.UnitType.Unspecified, bool Recursive = false)
 {
     return(ExecuteFunctionRun(() =>
     {
         object treeObj = LoadOrgChildNode(unitID, UnitType, Recursive);
         return Json(treeObj, JsonRequestBehavior.AllowGet);
     }));
 }
コード例 #2
0
        /// <summary>
        /// 创建组织结构孩子节点
        /// </summary>
        /// <param name="unitID"></param>
        /// <returns></returns>
        private List <FormulaTreeNode> LoadOrgChildNode(
            string unitID,
            OThinker.Organization.UnitType UnitType = OThinker.Organization.UnitType.Unspecified,
            bool Recursive = false)
        {
            List <OThinker.Organization.Unit> stateFilteredChildren = this.Engine.Organization.GetChildUnits(
                unitID,
                UnitType,
                Recursive,
                OThinker.Organization.State.Active);

            // 按照可见类型进行过滤
            // 按照OrganizationUnit, Group, User的顺序进行排列
            ArrayList unitList = SortOrgList(stateFilteredChildren.ToArray());

            List <FormulaTreeNode> treeNode = new List <FormulaTreeNode>();

            foreach (OThinker.Organization.Unit child in unitList)
            {
                if (treeNode.Any(p => p.ObjectID == child.ObjectID))
                {
                    continue;
                }

                switch (child.UnitType)
                {
                case OThinker.Organization.UnitType.OrganizationUnit:
                    treeNode.Add(BuildOrgChildNode(unitID, child, "fa icon-zuzhitubiao"));
                    break;

                case OThinker.Organization.UnitType.Group:
                    treeNode.Add(BuildOrgChildNode(unitID, child, "fa fa-users"));
                    break;

                case OThinker.Organization.UnitType.User:
                    string iconName = "fa fa-user";
                    treeNode.Add(BuildOrgChildNode(unitID, child, iconName));
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
            return(treeNode);
        }