/// <summary> /// 从订订服务器取考勤数据,跨度不超7天,人员不超50 /// </summary> /// <param name="emplist"></param> /// <param name="DateFrom"></param> /// <param name="DateTo"></param> /// <returns></returns> private List <AttRecord> GetCheckInOutRecordOnDingDingLimt(List <string> emplist, DateTime DateFrom, DateTime DateTo) { List <AttRecord> attRecords = new List <AttRecord>(); IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/attendance/list"); OapiAttendanceListRequest request = new OapiAttendanceListRequest { WorkDateFrom = DateTimeHelper.DatetimeToString(DateFrom), WorkDateTo = DateTimeHelper.DatetimeToString(DateTo), UserIdList = emplist, Offset = 0, Limit = 50 }; bool haveMore = false; do { OapiAttendanceListResponse response = client.Execute(request, ddOper.AccessToken); if (response.Errcode == 0) { if (response.Recordresult != null) { response.Recordresult.ForEach(p => { AttRecord ar = new AttRecord { DdId = p.UserId, BaseCheckTime = DateTimeHelper.StampToDateTime(p.BaseCheckTime), WorkDate = DateTimeHelper.StampToDateTime(p.WorkDate), CheckType = p.CheckType, TimeResult = p.TimeResult, }; if (p.TimeResult != "NotSigned") { ar.CheckTime = DateTimeHelper.StampToDateTime(p.UserCheckTime); } attRecords.Add(ar); }); } } if (response.HasMore) { haveMore = true; request.Offset += request.Limit; } else { haveMore = false; } } while (haveMore); return(attRecords); }
/// <summary> /// 获取打卡结果 该接口用于返回企业内员工的实际打卡结果。比如,企业给一个员工设定的排班是上午9点和下午6点各打一次卡,即使员工在这期间打了多次,该接口也只会返回两条记录,包括上午的打卡结果和下午的打卡结果。如果要获取打卡详细数据,比如打卡位置,可使用获取打卡详情接口。 /// </summary> /// <param name="accessToken"></param> /// <param name="userIdList">员工在企业内的UserID列表,企业用来唯一标识用户的字段。最多不能超过50个</param> /// <param name="workDateFrom">查询考勤打卡记录的起始工作日。格式为“yyyy-MM-dd HH:mm:ss”,HH:mm:ss可以使用00:00:00,具体查询的时候不会起作用,最后将返回此日期从0点到24点的结果</param> /// <param name="workDateTo">查询考勤打卡记录的结束工作日。格式为“yyyy-MM-dd HH:mm:ss”,HH:mm:ss可以使用00:00:00,具体查询的时候不会起作用,最后将返回此日期从0点到24点的结果。注意,起始与结束工作日最多相隔7天</param> /// <param name="offset">表示获取考勤数据的起始点,第一次传0,如果还有多余数据,下次获取传的offset值为之前的offset+limit,0、1、2...依次递增</param> /// <param name="limit">表示获取考勤数据的条数,最大不能超过50条</param> /// <param name="isI18n">取值为true和false,表示是否为海外企业使用,默认为false。其中,true:海外平台使用,false:国内平台使用</param> /// <returns></returns> public OapiAttendanceListResponse List(string accessToken, List <string> userIdList, string workDateFrom, string workDateTo, long offset = 0, long limit = 10, bool isI18n = false) { IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/attendance/list"); OapiAttendanceListRequest request = new OapiAttendanceListRequest(); request.WorkDateFrom = workDateFrom; request.WorkDateTo = workDateTo; request.UserIdList = userIdList; request.Offset = offset; request.Limit = limit; request.IsI18n = isI18n; OapiAttendanceListResponse response = client.Execute(request, accessToken); return(response); }
public AttendanceListResponse GetList(string workDateFrom, string workDateTo, List <string> userIdList, long offset, long limit) { var apiurl = string.Format(Urls.AttendanceList, RequestHelper.GetAccessToken()); var request = new OapiAttendanceListRequest { WorkDateFrom = workDateFrom, WorkDateTo = workDateTo, UserIdList = userIdList, Offset = offset, Limit = limit }; //var rtn = RequestHelper.Post<OapiAttendanceListResponse>(apiurl, request); //if (!String.Equals(rtn.ErrCode, ErrCodeEnum.OK.ToString(), StringComparison.CurrentCultureIgnoreCase)) var rtn = RequestHelper.Post <AttendanceListResponse>(apiurl, request); if (rtn.ErrCode != ErrCodeEnum.OK) { throw new ApiException(ApiCodeEnum.Error, rtn.ErrMsg); } return(rtn); }