public override RunTaskResult RunTask() { RunTaskResult taskResult = new RunTaskResult() { Success = true, Result = "执行完毕" }; FlightAirRuleDAL ruleDal = new FlightAirRuleDAL(); try { ruleDal.deleteAllData();//清空所有数据 bool flag = true; int index = 0; while (flag) { getModifyAndRefundStipulatesRequest req = new getModifyAndRefundStipulatesRequest(); req.rowPerPage = 1500; req.rowPerPageSpecified = true; string lastTimeAndId = GetLastUpTimeAndId("AirKGLog"); req.lastSeatId = Convert.ToInt32(lastTimeAndId.Split('|')[1]); req.lastSeatIdSpecified = true; req.lastModifiedAt = lastTimeAndId.Split('|')[0]; getModifyAndRefundStipulatesReply rep = _51bookHelper.getModifyAndRefundStipulates(req) as getModifyAndRefundStipulatesReply; if (rep.returnCode.ToLower() != "s") { ShowRunningLog(rep.returnMessage + "," + rep.returnStackTrace); flag = false; continue; } ShowRunningLog("收到退改签规定包数量:" + rep.modifyAndRefundStipulateList.Length + ",剩余页数:" + rep.leftPages); if (index > 0) { if (rep.leftPages == 0) { ShowRunningLog("剩余页数为0,已经全部取完!"); flag = false; } else { addDb(rep); } } else { addDb(rep); } index++; } SaveLastUpTimeAndId("2000-01-01 00:00:00|0", "AirKGLog"); ruleDal.deleteAllDataForever();//清空所有数据 } catch (Exception ex) { ShowRunningLog("添加航空公司客规失败:" + ex.Message); ruleDal.recoveryAllData(); } return(taskResult); }
public override RunTaskResult RunTask() { DbHelperSQL sql = new DbHelperSQL(this.AppConfig["ConnStr"].ToString()); _51bookHelper helper = new _51bookHelper(this.AppConfig["agencyCode"].ToString(), this.AppConfig["safetyCode"].ToString()); ShowProcessIngLog("读取该任务的配置参数:" + JsonConvert.SerializeObject(this.AppConfig)); RunTaskResult taskResult = new RunTaskResult() { RunStatus = (int)RunStatus.Normal, Message = "执行完毕" }; FlightAirRuleDAL ruleDal = new FlightAirRuleDAL(); try { ShowProcessIngLog("开始清除现有数据"); ruleDal.deleteAllData();//清空所有数据 ShowProcessIngLog("清除现有数据完成"); bool flag = true; int index = 0; while (flag) { getModifyAndRefundStipulatesRequest req = new getModifyAndRefundStipulatesRequest(); req.rowPerPage = 1500; req.rowPerPageSpecified = true; string lastTimeAndId = GetLastUpTimeAndId("AirKGLog"); req.lastSeatId = Convert.ToInt32(lastTimeAndId.Split('|')[1]); req.lastSeatIdSpecified = true; req.lastModifiedAt = lastTimeAndId.Split('|')[0]; ShowProcessIngLog("读取本次要抓取的配置:" + lastTimeAndId); getModifyAndRefundStipulatesReply rep = _51bookHelper.getModifyAndRefundStipulates(req) as getModifyAndRefundStipulatesReply; if (rep.returnCode.ToLower() != "s") { ShowProcessIngLog(rep.returnMessage + "," + rep.returnStackTrace); flag = false; continue; } ShowProcessIngLog("收到退改签规定包数量:" + rep.modifyAndRefundStipulateList.Length + ",剩余页数:" + rep.leftPages); if (index > 0) { if (rep.leftPages == 0) { ShowProcessIngLog("剩余页数为0,已经全部取完!"); flag = false; } else { addDb(rep); } } else { addDb(rep); } index++; } SaveLastUpTimeAndId("2000-01-01 00:00:00|0", "AirKGLog"); ruleDal.deleteAllDataForever();//清空所有数据 } catch (Exception ex) { ShowProcessIngLog("添加航空公司客规失败:" + ex.Message + ",异常:" + JsonConvert.SerializeObject(ex)); ruleDal.recoveryAllData(); taskResult = new RunTaskResult() { RunStatus = (int)RunStatus.Exception, Ex = ex, Message = ex.Message }; } return(taskResult); }