コード例 #1
0
        /// <summary>
        /// 获取员工花名册字段信息 根据员工userid,批量访问员工花名册字段信息。
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="userIdList">员工userid列表,最大列表长度:20</param>
        /// <param name="fieldFilterList">需要获取的花名册字段列表,最大列表长度:20。具体业务字段的code参见附录(大小写敏感)。不传入该参数时,企业可获取所有字段信息。</param>
        public OapiSmartworkHrmEmployeeListResponse ListStaff(string accessToken, string userIdList, string fieldFilterList = "")
        {
            IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/list");
            OapiSmartworkHrmEmployeeListRequest req = new OapiSmartworkHrmEmployeeListRequest();

            req.UseridList      = userIdList;
            req.FieldFilterList = fieldFilterList;
            OapiSmartworkHrmEmployeeListResponse rsp = client.Execute(req, accessToken);

            return(rsp);
        }
コード例 #2
0
        /// <summary>
        /// 获取公司所有人员 包含试用期和正式员工
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="nextCursor">-1</param>
        /// <param name="reportRes"></param>
        /// <param name="pvd"></param>
        /// <param name="modelList"></param>
        /// <returns></returns>
        public OapiSmartworkHrmEmployeeListResponse ListEmployee(string accessToken, long nextCursor, OapiSmartworkHrmEmployeeQueryonjobResponse reportRes, OapiSmartworkHrmEmployeeQueryonjobResponse.PageResultDomain pvd, OapiSmartworkHrmEmployeeListResponse modelList)
        {
            if (nextCursor != 0)
            {
                if (string.IsNullOrEmpty(accessToken))
                {
                    accessToken = AccessToken.GetAccessToken();
                }
                if (nextCursor == -1)
                {
                    nextCursor = 0;
                }
                reportRes = ListStaffID(AccessToken.GetAccessToken(), "2,3", nextCursor, 20);
                if (reportRes.Errcode != 0)
                {
                    return(null);
                }
                else
                {
                    if (modelList.Result == null)
                    {
                        modelList.Result = ListStaff(accessToken, string.Join(",", reportRes.Result.DataList.ToArray())).Result;
                    }
                    else
                    {
                        modelList.Result.AddRange(ListStaff(accessToken, string.Join(",", reportRes.Result.DataList.ToArray())).Result);
                    }

                    reportRes.Result.NextCursor = reportRes.Result.NextCursor;
                    reportRes.Result.DataList   = pvd.DataList;
                    ListEmployee(accessToken, reportRes.Result.NextCursor, reportRes, pvd, modelList);
                }
            }
            return(modelList);
        }