protected void Page_Load(object sender, EventArgs e) { from = Request.QueryString["from"]; to = Request.QueryString["to"]; airline = Request.QueryString["airline"]; AiFeiService afs = new AiFeiService(); FeiYingFlight flight = afs.getFlightMsg2(from, to, airline, string.Empty); //没有数据 if (flight == null) { Response.Write("false"); Response.End(); return; } Response.Write(flight.airplan); Response.End(); }
protected void GetAiFeiTickets() { //获得页面参数 string dpt = ""; string arr = ""; string toTime = ""; string reTime = ""; string cate = ""; //出发城市 if (fromCity.SelectedValue != "" && fromCity.SelectedValue != "0") { //获得出发城市三字码 string cityCodeSql = "select cityCode from FY_FromCity where fId='" + fromCity.SelectedValue + "'"; DataSet dsCityCode = SqlHelper.ExecuteDataset(SqlHelper.ConnString_select, CommandType.Text, cityCodeSql); if (dsCityCode != null) { dpt = dsCityCode.Tables[0].Rows[0]["cityCode"].ToString(); } } else { return; } //目的城市 if (txtSearch_tocity.Value.Trim() != "") { //获得目的城市三字码 arr = txtSearch_tocity.Value.Trim().Substring(0, 3); } else { return; } //获得出发时间 if (fromtripDate_more.Value.Trim() != "") { toTime = fromtripDate_more.Value.Trim().Replace("-", ""); } else { return; } //获得到达时间 if (totripDate_more.Value.Trim() != "") { reTime = totripDate_more.Value.Trim().Replace("-", ""); } else { return; } //获得客票类型 if (cateSelect.Value.Trim() != "") { cate = cateSelect.Value.Trim(); } else { return; } //请求客票 AiFeiService aifeiService = new AiFeiService(); ArrayList data = aifeiService.GlobalTicket(dpt, arr, toTime, reTime, cate); ArrayList tickets = new ArrayList(); //排序爱飞机票 foreach (AiFeiTicketEntity orderTicket in data) { //过滤日期 DateTime dt = Convert.ToDateTime(orderTicket.totripDate.Substring(0, 4) + "-" + orderTicket.totripDate.Substring(4, 2) + "-" + orderTicket.totripDate.Substring(6, 2)); if ((dt - DateTime.Now).Days < 0) { continue; } //获取中转 FeiYingFlight toFlight = aifeiService.getFlightMsg2(orderTicket.fromCity, orderTicket.toCity, orderTicket.airlineCode, ""); if (toFlight != null) { if (string.IsNullOrEmpty(toFlight.relayPort)) { orderTicket.relayPort = "直飞"; } else { orderTicket.relayPort = ReadXmlHelper.GetAirPortNameByCode(toFlight.relayPort); } } if (tickets.Count == 0) { tickets.Add(orderTicket); } else { for (int i = 0; i < tickets.Count; i++) { AiFeiTicketEntity aft = (AiFeiTicketEntity)tickets[i]; if (tickets.Count <= i + 1) { tickets.Add(orderTicket); break; } else { AiFeiTicketEntity next = (AiFeiTicketEntity)tickets[i + 1]; if (Convert.ToDecimal(orderTicket.ticketPrice) > Convert.ToDecimal(aft.ticketPrice) && Convert.ToDecimal(orderTicket.ticketPrice) <= Convert.ToDecimal(next.ticketPrice)) { tickets.Insert(i + 1, orderTicket); break; } } } } } this.GetData = tickets; rptshopnews.DataSource = tickets; rptshopnews.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { from = Request.QueryString["from"]; to = Request.QueryString["to"]; string airline = Request.QueryString["airline"]; totime = Request.QueryString["totime"]; fromtime = Request.QueryString["fromtime"]; string ticketType = Request.QueryString["ticketType"];//机票类型 单程、往返 AiFeiService afs = new AiFeiService(); //清除过期记录 afs.clearTimeOutLogs(from, to, airline); if (ticketType != null && ticketType.Equals("1")) { //往返 FeiYingFlight toFlight = afs.getFlightMsg2(from, to, airline, totime); FeiYingFlight backFlight = afs.getFlightMsg2(to, from, airline, fromtime); //System.Threading.AutoResetEvent resetEvent = new System.Threading.AutoResetEvent(false); //AiFeiService.GlobalFlight2Handler d1 = new AiFeiService.GlobalFlight2Handler(afs.GlobalFlight2); //AiFeiService.GlobalFlight2Handler d2 = new AiFeiService.GlobalFlight2Handler(afs.GlobalFlight2); //IAsyncResult iar1 = null, iar2 = null; //bool searchto = false, searchback = false; //AsyncCallback back1 = delegate(IAsyncResult iar) //{ // toFlight = d1.EndInvoke(iar1); // if (!searchback || (iar2 != null && iar2.IsCompleted)) // resetEvent.Set(); //}; //AsyncCallback back2 = delegate(IAsyncResult iar) //{ // backFlight = d2.EndInvoke(iar2); // if (!searchto || (iar1 != null && iar1.IsCompleted)) // resetEvent.Set(); //}; //if (toFlight == null) //{ // searchto = true; // iar1 = d1.BeginInvoke(from, to, airline, "Y", 1, totime, back1, null); //} //if (backFlight == null) //{ // searchback = true; // iar2 = d2.BeginInvoke(to, from, airline, "Y", 1, fromtime, back2, null); //} //if (toFlight == null || backFlight == null) //{ // if (resetEvent.WaitOne(30000, true)) // resetEvent.Close(); //} ////远程 //if (toFlight == null) //{ // //请求远程 // System.Threading.Thread thread = new System.Threading.Thread((System.Threading.ThreadStart)delegate // { // toFlight = afs.GlobalFlight2(from, to, airline, "Y", 1, totime); // }); // thread.IsBackground = true; // thread.Start(); //} //if (backFlight == null) //{ // //请求远程 // System.Threading.Thread thread = new System.Threading.Thread((System.Threading.ThreadStart)delegate // { // backFlight = afs.GlobalFlight2(to, from, airline, "Y", 1, fromtime); // }); // thread.IsBackground = true; // thread.Start(); //} if (toFlight == null) { this.InsertAiFeiLogs(from, to, airline, totime); } if (backFlight == null) { this.InsertAiFeiLogs(to, from, airline, fromtime); } //没有数据 if (toFlight == null || backFlight == null) { Response.Write("false"); Response.End(); return; } StringBuilder str = new StringBuilder(); str.Append("<div>"); str.Append("<span class=\"aifeifrom\">" + printf_flights(toFlight, backFlight, "from", ticketType) + "</span>"); str.Append("<span class=\"aifeito\">" + printf_flights(toFlight, backFlight, "to", ticketType) + "</span>"); str.Append("<span class=\"aifeiline\">" + printf_flights(toFlight, backFlight, "line", ticketType) + "</span>"); str.Append("<span class=\"relay\">" + printf_relay(toFlight, backFlight) + "</span>"); if (string.IsNullOrEmpty(toFlight.airplan) && string.IsNullOrEmpty(backFlight.airplan)) { str.Append("<span class=\"airplan\"></span>"); } else if (!string.IsNullOrEmpty(toFlight.airplan) && !string.IsNullOrEmpty(backFlight.airplan)) { str.Append("<span class=\"airplan\">" + (toFlight.airplan + "").Trim() + " / " + (backFlight.airplan + "").Trim() + "</span>"); } else { str.Append("<span class=\"airplan\">" + (toFlight.airplan + "").Trim() + (backFlight.airplan + "").Trim() + "</span>"); } str.Append("</div>"); Response.Write(str.ToString()); Response.End(); } else if (ticketType != null && ticketType.Equals("0")) { FeiYingFlight toFlight = afs.getFlightMsg2(from, to, airline, totime); ////远程 //if (toFlight == null) //{ // //请求远程 // System.Threading.Thread thread = new System.Threading.Thread((System.Threading.ThreadStart)delegate // { // toFlight = afs.GlobalFlight2(from, to, airline, "Y", 1, totime); // }); // thread.IsBackground = true; // thread.Start(); //} //没有数据 if (toFlight == null) { this.InsertAiFeiLogs(from, to, airline, totime); Response.Write("false"); Response.End(); return; } StringBuilder str = new StringBuilder(); str.Append("<div>"); str.Append("<span class=\"aifeifrom\">" + printf_flights(toFlight, null, "from", ticketType) + "</span>"); str.Append("<span class=\"aifeito\">" + printf_flights(toFlight, null, "to", ticketType) + "</span>"); str.Append("<span class=\"aifeiline\">" + printf_flights(toFlight, null, "line", ticketType) + "</span>"); str.Append("<span class=\"relay\">" + printf_relay(toFlight, null) + "</span>"); str.Append("<span class=\"airplan\">" + (toFlight.airplan + "").Trim() + "</span>"); str.Append("</div>"); Response.Write(str.ToString()); Response.End(); } }