Example #1
0
    private void OnNodeCreated(BPMConnection cn, OU ou, TreeNode node, SecurityToken token, ref TreeNode firstDeptNode)
    {
        if (token.ContainsSID(ou.SID))
        {
            OUCollection ous = OU.GetChildren(cn, node.Value);

            //用户是否在一个子部门内
            bool userInChildOU = false;
            foreach (OU cou in ous)
            {
                if (token.ContainsSID(cou.SID))
                {
                    userInChildOU = true;
                    break;
                }
            }

            //不在子级部门则返回
            if (!userInChildOU)
            {
                if (firstDeptNode == null)
                {
                    firstDeptNode = node;
                }

                return;
            }

            node.PopulateOnDemand = false;
            node.Expand();

            foreach (OU cou in ous)
            {
                TreeNode subNode = CreateNode(cou);
                node.ChildNodes.Add(subNode);

                OnNodeCreated(cn, cou, subNode, token, ref firstDeptNode);
            }
        }
    }
Example #2
0
        protected virtual void Expand(BPMConnection cn, JArray items, string path, SecurityToken token, ref JObject dirParentItem)
        {
            OUCollection ous;

            if (String.IsNullOrEmpty(path))
            {
                ous = cn.GetRootOUs();
            }
            else
            {
                ous = OU.GetChildren(cn, path);
            }

            bool parentOuExpanded = false;

            foreach (OU ou in ous)
            {
                JObject item = new JObject();
                item["leaf"]       = false;
                item["text"]       = ou.Name;
                item["iconCls"]    = "folder";
                item["id"]         = ou.FullName;
                item["expandable"] = true;
                items.Add(item);

                item["data"] = this.GetNodeData(ou);

                if (!parentOuExpanded && token.ContainsSID(ou.SID))
                {
                    dirParentItem    = item;
                    parentOuExpanded = true;

                    item["expanded"] = true;

                    JArray children = new JArray();
                    item[YZJsonProperty.children] = children;
                    Expand(cn, children, ou.FullName, token, ref dirParentItem);
                }
            }
        }