예제 #1
0
        /// <summary>
        /// 根据Dept ID 获取所有用户部门对照数据
        /// </summary>
        /// <param name="parent_id"></param>
        /// <returns></returns>
        public async Task <ICollection <Tuple <string, int> > > GetAllUsersDeptRelation()
        {
            AbpExternalAuthenticateConfig auth_config = await this.GetCurrentAuth();

            string acc_token = await this.GetToken(auth_config.AppId, auth_config.Secret);

            var relations = await GetUserRelationByDeptId(acc_token, 1);

            if (relations != null)
            {
                var result = new List <Tuple <string, int> >();
                relations.ToList().ForEach(x =>
                {
                    foreach (var item in x.department)
                    {
                        result.Add(new Tuple <string, int>(x.userid, item));
                    }
                });
                return(result);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        public void RemoveQYEmail(QYMailUserInfocsForUpdate model, int tenant_id)
        {
            AbpExternalAuthenticateConfig auth_config = this.GetCurrentAuthWithoutTenant(tenant_id);

            model.access_token = this.GetToken(auth_config.AppId, auth_config.Secret);

            string url = @"https://api.exmail.qq.com/cgi-bin/user/update";

            url = url + string.Format(@"?access_token={0}", model.access_token);

            Dictionary <string, object> param = new Dictionary <string, object>();

            //param.Add("access_token", model.access_token);
            //param.Add("department", model.department);

            //param.Add("extid", model.extid);
            //param.Add("gender", model.gender);
            //param.Add("mobile", model.mobile);
            //param.Add("position", model.position);
            //param.Add("name", model.name);
            param.Add("userid", model.userid);

            //param.Add("password", model.extid + "Cailian");
            param.Add("enable", 0);

            var p       = JsonConvert.SerializeObject(param);
            var content = HttpMethods.RestJsonPost(url, param);
        }
예제 #3
0
        /// <summary>
        /// 根据Tag ID 获取所有标签名
        /// </summary>
        /// <param name="wechat_tag_id"></param>
        /// <returns></returns>
        public string GetTagNameById(int wechat_tag_id, int tenant_id)
        {
            AbpExternalAuthenticateConfig auth_config = this.GetCurrentAuthWithoutTenant(tenant_id);
            string acc_token = this.GetTokenSync(auth_config.AppId, auth_config.Secret);

            return(GetTagName(acc_token, wechat_tag_id));
        }
예제 #4
0
        /// <summary>
        /// 根据父节点ID获取Department
        /// </summary>
        public async Task <ICollection <AbpWeChatDepartment> > GetDepartmentsById(int?parent_id = null, bool is_only_one_layer = false)
        {
            AbpExternalAuthenticateConfig auth_config = await this.GetCurrentAuth();

            string acc_token = await this.GetToken(auth_config.AppId, auth_config.Secret);

            return(await this.GetDepartmentsById(acc_token, parent_id, is_only_one_layer));
        }
예제 #5
0
        /// <summary>
        /// 根据ID获取用户
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public async Task <AbpUserSingleResult> GetUserById(string user_id)
        {
            AbpExternalAuthenticateConfig auth_config = await this.GetCurrentAuth();

            string acc_token = await this.GetToken(auth_config.AppId, auth_config.Secret);

            return(await GetUserById(acc_token, user_id));
        }
예제 #6
0
        /// <summary>
        /// 根据tag ID 获取所有Users
        /// </summary>
        /// <param name="wechat_tag_id"></param>
        /// <returns></returns>
        public async Task <ICollection <AbpWeChatUser> > GetUserListByTag(int?wechat_tag_id)
        {
            AbpExternalAuthenticateConfig auth_config = await this.GetCurrentAuth();

            string acc_token = await this.GetToken(auth_config.AppId, auth_config.Secret);

            return(await GetTagUserList(acc_token, wechat_tag_id));
        }
예제 #7
0
        /// <summary>
        /// 获取企业微信所有标签
        /// </summary>
        /// <returns></returns>
        public async Task <ICollection <AbpWeChatTag> > GetAllTag()
        {
            AbpExternalAuthenticateConfig auth_config = await this.GetCurrentAuth();

            string acc_token = await this.GetToken(auth_config.AppId, auth_config.Secret);

            return(await this.GetAllTag(acc_token));
        }
예제 #8
0
        /// <summary>
        /// 根据Dept ID 获取所有Users
        /// </summary>
        /// <param name="parent_id"></param>
        /// <returns></returns>
        public async Task <ICollection <AbpWeChatUser> > GetAllUsersByDepartment(int?parent_id)
        {
            AbpExternalAuthenticateConfig auth_config = await this.GetCurrentAuth();

            string acc_token = await this.GetToken(auth_config.AppId, auth_config.Secret);

            return(await this.GetUserByDeptId(acc_token, parent_id));
        }
예제 #9
0
        /// <summary>
        /// 获取当前appid与密钥
        /// </summary>
        /// <returns></returns>
        private AbpExternalAuthenticateConfig GetCurrentAuthWithoutTenant(int tenant_id)
        {
            AbpExternalAuthenticateConfig auth_config = _authenticateConfigManager.GetCurrentAuth(DefaultProviderName, tenant_id);

            if (auth_config == null)
            {
                throw new UserFriendlyException("外部链接配置缺失");
            }
            return(auth_config);
        }
예제 #10
0
        /// <summary>
        /// 获取当前appid与密钥
        /// </summary>
        /// <returns></returns>
        private async Task <AbpExternalAuthenticateConfig> GetCurrentAuth()
        {
            AbpExternalAuthenticateConfig auth_config = await _authenticateConfigManager.GetCurrentAuth(DefaultProviderName);

            if (auth_config == null)
            {
                throw new UserFriendlyException("外部链接配置缺失");
            }
            return(auth_config);
        }
예제 #11
0
        public QYMailUserInfocsForSeach GetUserInfo(int tenant_id, string email)
        {
            AbpExternalAuthenticateConfig auth_config = this.GetCurrentAuthWithoutTenant(tenant_id);
            string acc_token = this.GetToken(auth_config.AppId, auth_config.Secret);
            string url       = string.Format(@"https://api.exmail.qq.com/cgi-bin/user/get?access_token={0}&userid={1}", acc_token, email);

            var content = HttpMethods.RestGet(url);
            var result  = JsonConvert.DeserializeObject <QYMailUserInfocsForSeach>(content);

            if (result.errmsg == "ok")
            {
                return(result);
            }
            else
            {
                return(null);
            }
        }
예제 #12
0
        public List <QYMailDepartment> GetEmailAllDepartment(int tenant_id)
        {
            AbpExternalAuthenticateConfig auth_config = this.GetCurrentAuthWithoutTenant(tenant_id);
            string acc_token = this.GetToken(auth_config.AppId, auth_config.Secret);
            string url       = string.Format(@"https://api.exmail.qq.com/cgi-bin/department/list?access_token={0}", acc_token);

            var content = HttpMethods.RestGet(url);
            var result  = JsonConvert.DeserializeObject <QYMailDepartmentResult>(content);

            if (result.errmsg == "ok")
            {
                return(result.department);
            }
            else
            {
                return(null);
            }
        }
예제 #13
0
        public List <QYMailCheckUserDtl> CheckMailUser(List <string> userList)
        {
            AbpExternalAuthenticateConfig auth_config = this.GetCurrentAuthWithoutTenant(2);
            string acc_token = this.GetToken(auth_config.AppId, auth_config.Secret);
            string url       = string.Format(@"https://api.exmail.qq.com/cgi-bin/user/batchcheck?access_token={0}", acc_token);
            var    result    = new List <QYMailCheckUserDtl>();
            //var param = new QYMailCheckUserSearch();
            Dictionary <string, object> param = new Dictionary <string, object>();
            var param_list = new List <string>();
            var i          = 0;

            foreach (var item in userList)
            {
                param_list.Add(item);
                if (param_list.Count == 20)
                {
                    param.Add("userlist", param_list);
                    var content1 = HttpMethods.RestJsonPost(url, param);
                    var m1       = JsonConvert.DeserializeObject <QYMailCheckUser>(content1);
                    if (m1.errmsg == "ok")
                    {
                        result = result.Concat(m1.list).ToList();
                    }
                    param_list.Clear();
                    param.Clear();
                }
            }
            param.Add("userlist", param_list);
            var content = HttpMethods.RestJsonPost(url, param);
            var m       = JsonConvert.DeserializeObject <QYMailCheckUser>(content);

            if (m.errmsg == "ok")
            {
                result = result.Concat(m.list).ToList();
            }

            return(result);
        }