/// <summary>
        /// 获取部门详情
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="idStr">部门ID</param>
        /// <returns></returns>
        public static DepartmentInfo GetDepartmentInfo(string accessToken, string departmentId)
        {
            try
            {
                IDingTalkClient          client  = new DefaultDingTalkClient("https://oapi.dingtalk.com/department/get");
                OapiDepartmentGetRequest request = new OapiDepartmentGetRequest();
                request.Id = departmentId;
                request.SetHttpMethod("GET");

                OapiDepartmentGetResponse response = client.Execute(request, accessToken);
                if (response != null)
                {
                    if (response.Errcode == 0)
                    {
                        DepartmentInfo depart = new DepartmentInfo();
                        depart.Id              = response.Id.ToString();
                        depart.Name            = response.Name;
                        depart.Parentid        = response.Parentid.ToString();
                        depart.CreateDeptGroup = response.CreateDeptGroup;
                        depart.AutoAddUser     = response.AutoAddUser;
                        return(depart);
                    }
                    else
                    {
                        throw new Exception(response.ErrMsg);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(null);
        }
Beispiel #2
0
        public static OapiDepartmentGetResponse CallbackDepInfo(string DepCode, string Token)
        {
            IDingTalkClient          client  = new DefaultDingTalkClient("https://oapi.dingtalk.com/department/get");
            OapiDepartmentGetRequest request = new OapiDepartmentGetRequest();

            request.Id = "2";
            request.SetHttpMethod("GET");
            OapiDepartmentGetResponse response = client.Execute(request, Token);

            return(response);
        }
        /// <summary>
        /// 获取部门详情
        /// </summary>
        /// <param name="token"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public virtual string DepartmentGetResponse(string token, string id)
        {
            DefaultDingTalkClient    client  = new DefaultDingTalkClient("https://oapi.dingtalk.com/department/get");
            OapiDepartmentGetRequest request = new OapiDepartmentGetRequest();

            request.Id = id;
            request.SetHttpMethod("GET");
            OapiDepartmentGetResponse response = client.Execute(request, token);

            return(response.DeptManagerUseridList.Replace("|", ","));
        }
Beispiel #4
0
        /// <summary>
        /// 获取部门详情
        /// </summary>
        /// <param name="departId">部门id</param>
        /// <returns></returns>
        public string GetDepart(string departId)
        {
            IDingTalkClient          client  = new DefaultDingTalkClient("https://oapi.dingtalk.com/department/get");
            OapiDepartmentGetRequest request = new OapiDepartmentGetRequest();

            request.Id = departId;
            request.SetHttpMethod("Get");
            OapiDepartmentGetResponse response = client.Execute(request, base.AccessToken);

            return(response.Body);
        }
Beispiel #5
0
        /// <summary>
        /// 获取部门详情
        /// </summary>
        /// <param name="accessToken">accessToken</param>
        /// <param name="id">部门id</param>
        /// <param name="lang">通讯录语言(默认zh_CN,未来会支持en_US)</param>
        /// <returns></returns>
        public OapiDepartmentGetResponse Get(string accessToken, string id, string lang = "zh_CN")
        {
            if (string.IsNullOrEmpty(accessToken))
            {
                accessToken = AccessToken.GetAccessToken();
            }
            IDingTalkClient          client  = new DefaultDingTalkClient("https://oapi.dingtalk.com/department/get");
            OapiDepartmentGetRequest request = new OapiDepartmentGetRequest();

            request.Id = id;
            request.SetHttpMethod("GET");
            OapiDepartmentGetResponse response = client.Execute(request, accessToken);

            return(response);
        }