Ejemplo n.º 1
0
        /// <summary>
        /// 获取用户日志数据
        /// </summary>
        /// <param name="accessToken">accessToken</param>
        /// <param name="userId">员工的userid</param>
        ///<param name="timplateName">要查询的模板名称</param>
        /// <param name="startTime">起始时间。时间的毫秒数</param>
        /// <param name="endTime">截止时间。时间的毫秒数,如:1520956800000</param>
        /// <param name="cursor">查询游标,初始传入0,后续从上一次的返回值中获取</param>
        /// <param name="size">每页数据量, 最大值是20</param>
        /// <returns></returns>
        public OapiReportListResponse ListReport(string accessToken, string timplateName, long startTime, long endTime, long cursor, long size, string userId = null)
        {
            IDingTalkClient       client  = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/report/list");
            OapiReportListRequest request = new OapiReportListRequest
            {
                Userid       = userId,
                StartTime    = startTime,
                EndTime      = endTime,
                Cursor       = cursor,
                Size         = size,
                TemplateName = timplateName
            };
            OapiReportListResponse response = client.Execute(request, accessToken);

            return(response);
        }
Ejemplo n.º 2
0
        public List <Daily> GetOneEmplayeeDaily(RequestParams requestParams)
        {
            IDingTalkClient       client  = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/report/list");
            OapiReportListRequest request = new OapiReportListRequest();

            request.StartTime = requestParams.StartTime;
            request.EndTime   = requestParams.EndTime;
            request.Cursor    = requestParams.Cursor;
            request.Size      = requestParams.Size;
            OapiReportListResponse response = client.Execute(request, TooUtil.GetAccessToken());
            JObject jobjext = (JObject)JsonConvert.DeserializeObject(response.Body);

            if (jobjext["errcode"].ToString() == "0" && jobjext["result"]["data_list"].ToString().Length > 0 && jobjext["result"]["data_list"].ToString() != "")
            {
                JArray jr = (JArray)jobjext["result"]["data_list"];
                if (jr.Count > 0)
                {
                    foreach (var item in jr)
                    {
                        if (!userReportId.Contains(item["report_id"].ToString()))
                        {
                            userReportId.Add(item["report_id"].ToString());
                            Daily daily = new Daily();
                            daily.DaiContents = item["contents"].ToString();
                            if (item["contents"] != null)
                            {
                                JArray jrcont = (JArray)item["contents"];
                                if (jrcont.Count > 0)
                                {
                                    foreach (var ite in jrcont)
                                    {
                                        if (ite["key"] != null && ite["key"].ToString() == "日志日期")
                                        {
                                            daily.DaiDate = ite["value"].ToString();
                                        }
                                    }
                                }
                            }
                            daily.Remark          = item["remark"].ToString();
                            daily.DaiTemplateName = item["template_name"].ToString();
                            daily.DaiDeptName     = item["template_name"].ToString();
                            daily.DaiCreatorName  = item["creator_name"].ToString();
                            daily.DaiCreatorId    = item["creator_id"].ToString();
                            daily.DaiCreateTime   = Convert.ToInt64(item["create_time"].ToString());
                            daily.DaiReportId     = item["report_id"].ToString();
                            if (!userlistIdandname.ContainsKey(item["creator_id"].ToString()))
                            {
                                userlistIdandname.Add(item["creator_id"].ToString(), item["creator_name"].ToString());
                            }
                            dailyList.Add(daily);
                        }
                    }
                }
            }
            if (response.Result.HasMore)
            {
                RequestParams requestParametersDd = new RequestParams();
                requestParametersDd        = requestParams;
                requestParametersDd.Cursor = response.Result.NextCursor;
                GetOneEmplayeeDaily(requestParametersDd);
            }
            return(dailyList);
        }