Пример #1
0
        /// <summary>
        /// 获取指定部门下  指定手机号的人员
        /// </summary>
        /// <param name="FK_Dept">部门编号</param>
        /// <param name="Tel">手机号</param>
        /// <returns></returns>
        public UserInfoBelongDept GetUserListByDeptIDAndTel(string FK_Dept, string Tel = null)
        {
            string access_token = getAccessToken();
            string url          = "https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token= " + access_token + "&department_id=" + FK_Dept + "&status=0";

            try
            {
                string          str   = new HttpWebResponseUtility().HttpResponseGet(url);
                UsersBelongDept users = FormatToJson.ParseFromJson <UsersBelongDept>(str);

                //指定人员
                if (Tel != null)
                {
                    foreach (UserInfoBelongDept user in users.userlist)
                    {
                        if (user.mobile == Tel)
                        {
                            return(user);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                BP.DA.Log.DefaultLogWriteLineError(ex.Message);
            }
            return(null);
        }
Пример #2
0
        /// <summary>
        /// 下载人员头像
        /// </summary>
        public bool DownLoadUserIcon(string savePath)
        {
            if (Directory.Exists(savePath) == false)
            {
                Directory.CreateDirectory(savePath);
            }

            DeptMent_GetList deptMentList = GetDeptMentList();

            if (deptMentList != null && deptMentList.errcode == "0")
            {
                foreach (DeptMentInfo deptMent in deptMentList.department)
                {
                    UsersBelongDept users = GetUserListByDeptID(deptMent.id);
                    if (users != null && users.errcode == "0")
                    {
                        foreach (UserInfoBelongDept userInfo in users.userlist)
                        {
                            if (userInfo.avatar != null)
                            {
                                //大图标
                                string headimgurl = userInfo.avatar;
                                string UserIcon   = savePath + "\\" + userInfo.userid + "Biger.png";
                                BP.DA.DataType.HttpDownloadFile(headimgurl, UserIcon);

                                //小图标
                                string iconSize = userInfo.avatar.Substring(headimgurl.LastIndexOf('/'));
                                if (iconSize == "/")
                                {
                                    headimgurl = userInfo.avatar + "64";
                                }
                                else
                                {
                                    headimgurl = userInfo.avatar.Substring(0, headimgurl.LastIndexOf('/')) + "64";
                                }
                                UserIcon = savePath + "\\" + userInfo.userid + "Smaller.png";
                                BP.DA.DataType.HttpDownloadFile(headimgurl, UserIcon);
                            }
                        }
                    }
                }
                return(true);
            }
            return(false);
        }