Beispiel #1
0
        private int CheckLogs()
        {
            //根据当前时间 遍历打卡记录
            var logs = AttendanceManager.GetLogs(new Parameters.CheckInOutParameter
            {
                BeginTime  = DateTime.Today,
                EndTime    = DateTime.Now,
                HasChecked = false,
            });

            foreach (var log in logs)
            {
                if (log.ApiResult.HasValue)
                {
                    continue;
                }
                var json = InvokeApi(log);
                var data = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, string> >(json);
                log.ApiResult  = data["msg"].Contains("成功") || data["msg"].Contains("您已") || data["msg"].Contains("该用户不存在");
                log.ApiContent = data.ToJson();
                AttendanceManager.SaveApiResult(log);
                LogWriter.Instance.WriteLog($"[{DateTime.Now}]\t打卡{(log.ApiResult.Value ? "成功" : "失败")}:{log.ToJson()}\r\n");
            }
            return(logs.Count());
        }