Example #1
0
        private DeptTree deptTree;      //部门列表,调用微信接口获得
        private void setDeptTree()
        {
            //获取access_token
            String access_token = getServiceToken();
            //调用微信接口,获取部门列表,json字符串
            String   url         = "https://qyapi.weixin.qq.com/cgi-bin/department/list";
            String   data        = "access_token=" + access_token;
            String   method      = "GET";
            int      timeout     = 6000;
            String   contentType = "text/xml";
            String   resp        = NetHelper.HttpRequest(url, data, method, timeout, Encoding.UTF8, contentType);
            JObject  jsonData    = JObject.Parse(resp);
            JArray   deptJArray  = (JArray)jsonData["department"];
            DeptNode rootNode    = null;

            foreach (JObject jNode in deptJArray)
            {
                if ("1" == jNode["id"].ToString())
                {
                    rootNode = new DeptNode(jNode);
                    break;
                }
            }
            deptTree = new DeptTree(deptJArray, rootNode);
        }
Example #2
0
        public ActionResult GetMyCompanyTreeJson(string userID)
        {
            List <EasyTreeData> treeList = new List <EasyTreeData>();

            User userInfo = BLLFactory <UserBLL> .Instance.FindByID(userID);

            if (userInfo != null)
            {
                List <DeptNode> list = new List <DeptNode>();
                if (BLLFactory <UserBLL> .Instance.UserInRole(userInfo.Name, Role.SuperAdminName))
                {
                    list = BLLFactory <DeptBLL> .Instance.GetGroupCompanyTree();
                }
                else
                {
                    Dept myCompanyInfo = BLLFactory <DeptBLL> .Instance.FindByID(userInfo.CompanyID);

                    if (myCompanyInfo != null)
                    {
                        list.Add(new DeptNode(myCompanyInfo));
                    }
                }
                if (list.Count > 0)
                {
                    DeptNode     info = list[0];
                    EasyTreeData node = new EasyTreeData(info.ID, info.Name, GetIconcls(info.Category));
                    GetTreeDataWithDeptNode(info.Children, node);
                    treeList.Add(node);
                }
            }
            string json = ToJson(treeList);

            return(Content(json));
        }
Example #3
0
        public DeptNode GetNode(string id, DataTable dt)
        {
            Dept     deptInfo     = this.FindByID(id);
            DeptNode deptNodeInfo = new DeptNode(deptInfo);

            string sort = string.Format("{0} {1}", GetSafeFileName(sortField), IsDescending ? "DESC" : "ASC");

            DataRow[] dChildRows = dt.Select(string.Format(" PID='{0}' ", id), sort);
            for (int i = 0; i < dChildRows.Length; i++)
            {
                string   childId   = (string)dChildRows[i]["ID"];
                DeptNode childNode = GetNode(childId, dt);
                deptNodeInfo.Children.Add(childNode);
            }
            return(deptNodeInfo);
        }
Example #4
0
        public List <DeptNode> GetTreeByID(string mainDeptID)
        {
            List <DeptNode> arrReturn = new List <DeptNode>();
            string          sql       = string.Format("Select * From {0} Order By PID,Name", tableName);
            DataTable       dt        = SqlTable(sql);
            string          sort      = string.Format("{0} {1}", GetSafeFileName(sortField), IsDescending ? "DESC" : "ASC");

            DataRow[] dataRows = dt.Select(string.Format(" PID='{0}' ", mainDeptID), sort);
            for (int i = 0; i < dataRows.Length; i++)
            {
                string   id       = (string)dataRows[i]["ID"];
                DeptNode menuNode = GetNode(id, dt);
                arrReturn.Add(menuNode);
            }
            return(arrReturn);
        }
Example #5
0
        private void setDeptTree()
        {
            if (deptJArray == null)
            {
                setDeptJArray();
            }
            DeptNode rootNode = null;

            //查找部门树的根节点
            foreach (JObject jNode in deptJArray)
            {
                if ("1" == jNode["id"].ToString())
                {
                    rootNode = new DeptNode(jNode);
                    break;
                }
            }
            deptTree = new DeptTree(deptJArray, rootNode);
        }
Example #6
0
        public List <DeptNode> GetGroupCompanyTree()
        {
            List <DeptNode> list = new List <DeptNode>();

            Dept groupDept = GetTopGroup();

            if (groupDept != null)
            {
                DeptNode groupNodeInfo = new DeptNode(groupDept);

                List <Dept> complayList = GetAllCompany();
                foreach (Dept info in complayList)
                {
                    groupNodeInfo.Children.Add(new DeptNode(info));
                }
                list.Add(groupNodeInfo);
            }
            return(list);
        }
Example #7
0
 private void IniDeptNode(DeptNode parDeptNode, Node parTreeNode)
 {
     parTreeNode.NodeID = parDeptNode.DeptInfo.ObjId.ToString() + (i++).ToString();
     parTreeNode.Text   = parDeptNode.DeptInfo.DeptName;
     if (parDeptNode.Checked)
     {
         parTreeNode.Checked = true;
     }
     if (parDeptNode.Child.Count == 0)
     {
         parTreeNode.Leaf = true;
         return;
     }
     foreach (DeptNode deptNode in parDeptNode.Child)
     {
         Node n = new Node();
         IniDeptNode(deptNode, n);
         parTreeNode.Children.Add(n);
     }
 }
Example #8
0
 private void IniDeptNodeParent(DeptNode node)
 {
     try
     {
         DeptNode pnode = new DeptNode();
         SsbDept  dept  = basDeptManager.GetEntityList(new SsbDept()
         {
             ObjId = node.DeptInfo.ParentId
         })[0];
         if (deptInfo.TryGetValue(dept.ObjId.ToString(), out pnode))
         {
             node.ParDeptNode = pnode;
             if (!deptInfo.ContainsKey(node.DeptInfo.ObjId.ToString()))
             {
                 deptInfo.Add(node.DeptInfo.ObjId.ToString(), node);
                 pnode.Child.Add(node);
             }
             return;
         }
         else
         {
             pnode            = new DeptNode();
             pnode.DeptInfo   = dept;
             node.ParDeptNode = pnode;
             if (!deptInfo.ContainsKey(node.DeptInfo.ObjId.ToString()))
             {
                 deptInfo.Add(node.DeptInfo.ObjId.ToString(), node);
                 pnode.Child.Add(node);
             }
             if (checkedDeptInfo.ContainsKey(pnode.DeptInfo.ObjId.ToString()))
             {
                 pnode.Checked = true;
             }
             IniDeptNodeParent(pnode);
             deptInfo.Add(dept.ObjId.ToString(), pnode);
         }
     }
     catch
     {
     }
 }
Example #9
0
    private void IniDeptNode(string role)
    {
        IList <SspDeptRole> lst = sysDeptRoleManager.GetEntityList(new SspDeptRole()
        {
            RoleId = Convert.ToInt32(role)
        });

        foreach (SspDeptRole m in lst)
        {
            DeptNode node = new DeptNode();
            SsbDept  dept = basDeptManager.GetEntityList(new SsbDept()
            {
                ObjId = m.DeptId
            })[0];
            node.DeptInfo = dept;
            node.Checked  = true;
            checkedDeptInfo.Add(dept.ObjId.ToString(), node);
        }
        foreach (DeptNode node in checkedDeptInfo.Values)
        {
            IniDeptNodeParent(node);
        }
    }