/// <summary> /// 返回所有请求成功的数据 /// </summary> /// <param name="date">几天之内</param> /// <returns></returns> private Result GetAllPost(int date) { return(RunFun((logpath, dataPath) => { string allSend = "AllSend.log"; string notSend = "NotSend.json"; List <GeelyField> notSendList; List <string> isSendList; // 读取数据库 if (!File.Exists(dataPath + notSend)) { string sqlDeclares = GetSqlParam($"Declare @Date int = {date}"); notSendList = GeelyField.GetAllPost(sqlDeclares, DbContent); // 初始化,将数据库中已经发送过请求的数据 notSendList = GeelyField.GetSendList(notSendList, c => true); // 放入待重新请求文件 ToolFile.CreatFile(dataPath + notSend, ToolString.ConvertJson(notSendList), false); } // 读取文件 else { notSendList = ToolString.ConvertObject <List <GeelyField> >(File.ReadAllText(dataPath + notSend)); } // 过滤已发送的数据 if (File.Exists(dataPath + allSend)) { // 所有获取所有已发送列表 isSendList = File.ReadAllLines(dataPath + allSend).ToList(); foreach (var item in isSendList) { GeelyField geely = notSendList.FirstOrDefault(c => c.cand == item); if (geely != null) { notSendList.Remove(geely); } } } // 已处理过的数据日志,用于更新 Res.Msg = dataPath + allSend; // 待处理的数据集 Res.Object = notSendList; //foreach (var item in notSendList) //{ // string url = "http://local.askform.cn/Custom/CampusRecruitment.aspx"; // url += "?name=" + item.firstName + "&cand=" + item.cand + "&instr=" + item.instr + "&pid=" + item.pid + "&valid=" + item.valid + "&keyword=" + item.EntryID; // string log = item.cand; // try // { // log += "\t发起请求"; // string res = ToolHttp.RequestUrl(url); // log += "\t请求成功"; // ToolFile.CreatFile(dataPath + allSend, item.cand, true); // } // catch (Exception ex) // { // log += "\t请求失败:" + ex.Message; // } // WriteLog(logpath, log); //} return Res; })); }