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 void addDb(getModifyAndRefundStipulatesReply rep) { try { string seatId = "0"; string lastModifiedAt = "2000-01-01 00:00:00"; int i = 0; FlightAirRuleDAL airRuleBll = new FlightAirRuleDAL(); ShowProcessIngLog(DateTime.Now + ":开始添加退改签规定包:" + rep.modifyAndRefundStipulateList.Length); //获取记录并添加到数据库中 for (i = 0; i < rep.modifyAndRefundStipulateList.Length; i++) { FlightAirRule airRule = new FlightAirRule(); airRule.id = System.Guid.NewGuid().ToString(); airRule.returnn = HttpUtility.UrlDecode(rep.modifyAndRefundStipulateList[i].refundStipulate, System.Text.Encoding.UTF8); airRule.endorsement = HttpUtility.UrlDecode(rep.modifyAndRefundStipulateList[i].modifyStipulate, System.Text.Encoding.UTF8); lastModifiedAt = rep.modifyAndRefundStipulateList[i].modifiedAt; seatId = rep.modifyAndRefundStipulateList[i].seatId.ToString(); airRule.seatclass = rep.modifyAndRefundStipulateList[i].seatCode; airRule.change = HttpUtility.UrlDecode(rep.modifyAndRefundStipulateList[i].changeStipulate, System.Text.Encoding.UTF8); airRule.airline = rep.modifyAndRefundStipulateList[i].airlineCode; try { int r = airRuleBll.Add(airRule); if (r == 0) { ShowProcessIngLog("添加航空公司客规失败:" + rep.modifyAndRefundStipulateList[i].airlineCode + rep.modifyAndRefundStipulateList[i].seatCode + rep.modifyAndRefundStipulateList[i].seatId); } } catch (Exception ex) { } } if (i >= rep.modifyAndRefundStipulateList.Length) { ShowProcessIngLog(DateTime.Now + ":添加完成:" + rep.modifyAndRefundStipulateList.Length + ",保存最后一次信息:Info=" + lastModifiedAt + "|" + seatId); SaveLastUpTimeAndId(lastModifiedAt + "|" + seatId, "AirKGLog"); } } catch (Exception ex) { } }
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); }