Exemplo n.º 1
0
        public virtual object GetOrgTree(HttpContext context)
        {
            YZRequest      request        = new YZRequest(context);
            string         path           = request.GetString("node", null);
            string         srcoupath      = request.GetString("srcoupath", null);
            GetRootOUsType getRootOUsType = request.GetEnum <GetRootOUsType>("getRootOUsType", GetRootOUsType.All);

            if (YZStringHelper.EquName(path, "root"))
            {
                path = null;
            }

            JObject rv = new JObject();

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                JArray children = new JArray();
                rv[YZJsonProperty.children] = children;

                if (String.IsNullOrEmpty(path))
                {
                    SecurityToken token         = cn.Token;
                    JObject       dirParentItem = null;

                    this.Expand(cn, children, path, token, ref dirParentItem, getRootOUsType, srcoupath);

                    if (dirParentItem != null)
                    {
                        dirParentItem["dirou"] = true;

                        //没必要列出所在部门的子部门
                        //dirParentItem["expanded"] = false;
                        //dirParentItem.ChildItems.Clear();
                    }
                }
                else
                {
                    OUCollection ous = OU.GetChildren(cn, path);

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

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

            //输出数据
            return(rv);
        }
Exemplo n.º 2
0
    protected void LoadChildNode(BPMConnection cn, TreeNode node)
    {
        OUCollection ous = OU.GetChildren(cn, node.Value);

        foreach (OU cou in ous)
        {
            TreeNode subNode = CreateNode(cou);
            node.ChildNodes.Add(subNode);
        }
    }
Exemplo n.º 3
0
        public virtual object GetMemberDefine(HttpContext context)
        {
            YZRequest request  = new YZRequest(context);
            string    fullname = request.GetString("fullname");
            string    parentou = request.GetString("parentou");

            Member                  member;
            User                    user;
            UserCommonInfo          userCommonInfo;
            DataColumnCollection    userExtAttrsSchema;
            OUCollection            childOUs;
            OUCollection            fgOUs;
            BPMObjectNameCollection fgYWs;
            SupervisorCollection    supervisors;
            DirectXSCollection      directXSs;
            TaskRuleCollection      taskRules;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                member             = Member.FromFullName(cn, fullname);
                user               = member.GetUser(cn);
                userExtAttrsSchema = User.GetExtColumns(cn, user.NameSpace);
                userCommonInfo     = UserCommonInfo.FromAccount(cn, user.Account);
                childOUs           = OU.GetChildren(cn, parentou);

                fgOUs       = member.GetFGOUs(cn);
                fgYWs       = member.GetFGYWs(cn);
                supervisors = member.GetSupervisors(cn);
                directXSs   = member.GetDirectXSs(cn);

                taskRules = User.GetTaskRules(cn, user.Account);
            }

            return(new {
                User = user,
                UserExtAttrsSchema = YZJsonHelper.SerializeExtAttrSchema(userExtAttrsSchema),
                Member = member,
                UserCommonInfo = userCommonInfo,
                ChildOUs = YZJsonHelper.SerializeSimpleOU(childOUs),
                FGOUs = YZJsonHelper.Serialize2Array(fgOUs),
                FGYWs = fgYWs,
                Supervisors = supervisors,
                DirectXSs = directXSs,
                TaskRules = taskRules,
                temporaryUid = "temporary/" + Guid.NewGuid().ToString()
            });
        }
Exemplo n.º 4
0
        protected virtual void Expand(BPMConnection cn, JArray items, string path, SecurityToken token, ref JObject dirParentItem, GetRootOUsType getRootOUsType, string srcoupath)
        {
            OUCollection ous;

            if (String.IsNullOrEmpty(path))
            {
                if (getRootOUsType != GetRootOUsType.All && !String.IsNullOrEmpty(srcoupath))
                {
                    ous = cn.GetRootOUs(srcoupath, getRootOUsType);
                }
                else
                {
                    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 ((ous.Count == 1 && String.IsNullOrEmpty(path)) || (!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, getRootOUsType, srcoupath);
                }
            }
        }
Exemplo n.º 5
0
        private object GetChildOUs(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    path    = request.GetString("path", null);

            OUCollection parents  = new OUCollection();
            OUCollection ous      = new OUCollection();
            JArray       children = new JArray();

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                if (String.IsNullOrEmpty(path))
                {
                    ous     = cn.GetRootOUs();
                    parents = new OUCollection();
                }
                else
                {
                    OU ou = OU.FromFullName(cn, path);
                    parents = this.GetAllParentOU(cn, ou);
                    ous     = OU.GetChildren(cn, path);

                    foreach (OU cou in ous)
                    {
                    }
                }

                foreach (OU ou in ous)
                {
                    JObject      jou  = this.Serialize(ou);
                    OUCollection cous = OU.GetChildren(cn, ou.FullName);
                    jou["isLeaf"] = cous.Count >= 1 ? false : true;

                    children.Add(jou);
                }
            }

            return(new
            {
                parents = parents,
                children = children
            });
        }
Exemplo n.º 6
0
        public virtual JArray GetChildOUs(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    path    = request.GetString("node", null);

            if (path == "root")
            {
                path = null;
            }

            OUCollection ous;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                if (String.IsNullOrEmpty(path))
                {
                    ous = cn.GetRootOUs(false);
                }
                else
                {
                    ous = OU.GetChildren(cn, path);
                }
            }

            JArray rv = new JArray();

            foreach (OU ou in ous)
            {
                JObject item = new JObject();
                rv.Add(item);
                item["leaf"]       = false;
                item["text"]       = ou.Name;
                item["iconCls"]    = "folder";
                item["rsid"]       = ou.RSID;
                item["path"]       = ou.FullName;
                item["editable"]   = ou.HasPermision(BPMObjectPermision.Edit);
                item["enpandable"] = true;
            }
            return(rv);
        }
Exemplo n.º 7
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);
            }
        }
    }
Exemplo n.º 8
0
        public virtual object GetNewMemberDefaults(HttpContext context)
        {
            YZRequest request  = new YZRequest(context);
            string    parentou = request.GetString("parentou");

            DataColumnCollection userExtAttrsSchema;
            OUCollection         childOUs;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                userExtAttrsSchema = User.GetExtColumns(cn, parentou);
                childOUs           = OU.GetChildren(cn, parentou);
            }

            return(new
            {
                UserExtAttrsSchema = YZJsonHelper.SerializeExtAttrSchema(userExtAttrsSchema),
                ChildOUs = YZJsonHelper.SerializeSimpleOU(childOUs),
                temporaryUid = "temporary/" + Guid.NewGuid().ToString()
            });
        }
Exemplo n.º 9
0
        private object GetOUObjects(BPMConnection cn, string path, bool includeRole, bool includeMember)
        {
            OUCollection   parents = new OUCollection();
            OUCollection   ous     = new OUCollection();
            RoleCollection roles   = new RoleCollection();

            BPMClient.MemberCollection members = new BPMClient.MemberCollection();

            if (String.IsNullOrEmpty(path))
            {
                ous     = cn.GetRootOUs();
                parents = new OUCollection();
            }
            else
            {
                OU ou = OU.FromFullName(cn, path);
                parents = this.GetAllParentOU(cn, ou);

                ous = OU.GetChildren(cn, path);

                if (includeRole)
                {
                    roles = OU.GetRoles(cn, path);
                }

                if (includeMember)
                {
                    members = OU.GetMembers(cn, path);
                }
            }

            List <object> children = new List <object>();

            foreach (OU ou in ous)
            {
                children.Add(new {
                    Type = "OU",
                    data = ou
                });
            }

            foreach (Role role in roles)
            {
                children.Add(new
                {
                    Type = "Role",
                    data = role
                });
            }

            foreach (BPMClient.Member member in members)
            {
                User user = User.TryGetUser(cn, member.UserAccount);
                if (user != null && !user.Disabled)
                {
                    children.Add(new
                    {
                        Type = "Member",
                        data = new
                        {
                            member = member,
                            user   = member.GetUser(cn)
                        }
                    });
                }
            }

            return(new {
                parents = parents,
                children = children
            });
        }