protected string printf_flights(AiFeiTicket aft, string type) { if (type.Equals("from")) { string str = ""; if (aft.tripType.Equals("1")) { str += "<li class='lititle1'>" + ReadXmlHelper.GetAirPortNameByCode(aft.fromCityCode) + "</li><li class='lititle2'>起飞:" + convertDate(ajaxToTime, readTimeFromCookie(aft.fromCityCode, aft.toCityCode, aft.airlineCode, "toDt", ajaxToTime)) + "</li>"; str += "<li class='lititle1'>" + ReadXmlHelper.GetAirPortNameByCode(aft.toCityCode) + "</li><li class='lititle2'>起飞:" + convertDate(ajaxFromTime, readTimeFromCookie(aft.toCityCode, aft.fromCityCode, aft.airlineCode, "toDt", ajaxFromTime)) + "</li>"; } if (aft.tripType.Equals("0")) { str += "<li class='lititle1'>" + ReadXmlHelper.GetAirPortNameByCode(aft.fromCityCode) + "</li><li class='lititle2'>起飞:" + convertDate(ajaxToTime, readTimeFromCookie(aft.fromCityCode, aft.toCityCode, aft.airlineCode, "toDt", ajaxToTime)) + "</li>"; } return(str); } else if (type.Equals("to")) { string str = ""; if (aft.tripType.Equals("1")) { str += "<li class='lititle1'>" + ReadXmlHelper.GetAirPortNameByCode(aft.toCityCode) + "</li><li class='lititle2'>到达:" + convertDate(ajaxToTime, readTimeFromCookie(aft.fromCityCode, aft.toCityCode, aft.airlineCode, "arriveDt", ajaxToTime)) + "</li>"; str += "<li class='lititle1'>" + ReadXmlHelper.GetAirPortNameByCode(aft.fromCityCode) + "</li><li class='lititle2'>到达:" + convertDate(ajaxFromTime, readTimeFromCookie(aft.toCityCode, aft.fromCityCode, aft.airlineCode, "arriveDt", ajaxFromTime)) + "</li>"; } if (aft.tripType.Equals("0")) { str += "<li class='lititle1'>" + ReadXmlHelper.GetAirPortNameByCode(aft.toCityCode) + "</li><li class='lititle2'>到达:" + convertDate(ajaxToTime, readTimeFromCookie(aft.fromCityCode, aft.toCityCode, aft.airlineCode, "arriveDt", ajaxToTime)) + "</li>"; } return(str); } else if (type.Equals("line")) { string str = ""; if (aft.tripType.Equals("1")) { str += "<li class='lititle1'><img src='/images/sgo.gif'/>→</li><li class='lititle2'> </li>"; str += "<li class='lititle1'><img src='/images/sback.gif'/>→</li><li class='lititle2'> </li>"; } if (aft.tripType.Equals("0")) { str += "<li class='lititle1'><img src='/images/sgo.gif'/>→</li><li class='lititle2'> </li>"; } return(str); } return(""); }
protected string printfXXLink(AiFeiTicket aft) { //加上起降时间 if (aft.sourceType.Equals("feiying")) { return("/ticket_" + aft.ticketId + "_" + readTimeFromCookie(aft.fromCityCode, aft.toCityCode, aft.airlineCode, "toDt", ajaxToTime) + "_" + readTimeFromCookie(aft.fromCityCode, aft.toCityCode, aft.airlineCode, "arriveDt", ajaxToTime) + ".htm"); } else if (aft.sourceType.Equals("aifei")) { return("/ticket_" + aft.ticketCode + "aifei_" + readTimeFromCookie(aft.fromCityCode, aft.toCityCode, aft.airlineCode, "toDt", ajaxToTime) + "_" + readTimeFromCookie(aft.fromCityCode, aft.toCityCode, aft.airlineCode, "arriveDt", ajaxToTime) + ".htm"); } return("#"); }
protected string printJpjz(AiFeiTicket aft) { string cookieKey = aft.tripType + "-" + fromCityId + "-" + getToCityCodeByName(toCityNameStr.Trim()) + "-" + tripDateStr; string key = aft.airlineCode + aft.fromCityCode + aft.toCityCode + aft.price + "-" + aft.ticketId + "-" + aft.ticketCode; if (Request.Cookies[cookieKey] != null) { string name = Request.Cookies[cookieKey][key]; if (name != null && name.Equals("jpjz")) { return("<img src='images/jwyouxian.gif' />"); } } return(" "); }
private void makeJpjz(ArrayList pageTickets, string tripTypeIntP, int start, int end) { string cookieKey = tripTypeIntP + "-" + fromCityId + "-" + getToCityCodeByName(toCityNameStr.Trim()) + "-" + tripDateStr; if (Request.Cookies[cookieKey] == null) { HttpCookie cookie = new HttpCookie(cookieKey); //默认价格排序 Random ra = new Random(); int jpjzNum = ra.Next(start, end); int jpjzContent = 5; if (pageTickets.Count < 6) { jpjzContent = pageTickets.Count; } for (int i = 0, j = 0; i < jpjzNum; i++) { //生成随机数 int jpjzTicket = ra.Next(0, jpjzContent); AiFeiTicket cacheAFT = (AiFeiTicket)pageTickets[jpjzTicket]; string ticketKey = cacheAFT.airlineCode + cacheAFT.fromCityCode + cacheAFT.toCityCode + cacheAFT.price + "-" + cacheAFT.ticketId + "-" + cacheAFT.ticketCode; if (cacheAFT.tripType.Equals(tripTypeIntP)) { cookie.Values[ticketKey] = "jpjz"; j++; } if ((jpjzContent + 2) < pageTickets.Count && i == jpjzNum - 1 && j == 0) { jpjzContent = jpjzContent + 2; i = 0; } } cookie.Expires = System.DateTime.Now.AddDays(1);//设置过期时间 1天 Response.Cookies.Add(cookie); } }
protected void GetSearchTicket() { //从本地数据库查询 DataSet ds = new DataSet(); //查找航空公司名称 构造航空公司排序数组 string str = @"select top 100 percent"; str += " FY_Ticket.tid,FY_Ticket.untaxPrice,FY_Ticket.relayPort,FY_Ticket.tripType,"; str += " FY_FromCity.cityCode as fromCityCode,"; str += " FY_ToCity.cityCode as toCityCode,"; str += " FY_Tax.tax,"; str += " FY_FromCity.chName as fromCityname,FY_FromCity.fId,FY_Airline.aId,FY_ToCity.tId as toId,"; str += " FY_ToCity.chName as toCityname,FY_Airline.airlineCode as airlineCode,FY_Airline.chName as airname, FY_Airline.smallPic as smallPic from FY_Ticket "; str += " left join FY_FromCity on FY_FromCity.fId=FY_Ticket.fromCity"; str += " left join FY_ToCity on FY_ToCity.tId=FY_Ticket.toCity"; str += " left join FY_Airline on FY_Airline.aId=FY_Ticket.airLine"; str += " left join FY_Tax on (FY_Ticket.tripType =FY_Tax.taxType and FY_Ticket.airLine = FY_Tax.airline and FY_Ticket.toCity = FY_Tax.toCity and FY_Ticket.fromCity = FY_Tax.fromCity)"; str += " where 1=1 "; //查找航空公司 string strAirline = @"select FY_Ticket.airLine,min(FY_Ticket.untaxPrice) as untaxPrice "; strAirline += " from FY_Ticket"; strAirline += " left join FY_FromCity on FY_FromCity.fId=FY_Ticket.fromCity"; strAirline += " left join FY_ToCity on FY_ToCity.tId=FY_Ticket.toCity"; strAirline += " left join FY_Tax on (FY_Ticket.airLine = FY_Tax.airline and FY_Ticket.toCity = FY_Tax.toCity and FY_Ticket.fromCity = FY_Tax.fromCity)"; strAirline += " where 1=1 "; if (tripTypeInt != 2) { str += " and (FY_Ticket.tripType=" + tripTypeInt + ")"; strAirline += " and (FY_Ticket.tripType=" + tripTypeInt + ")"; } if (fromCityId != 0) { str += " and (FY_FromCity.fId=" + fromCityId + ")"; strAirline += " and (FY_FromCity.fId=" + fromCityId + ")"; } if (toCityNameStr != "") { str += " and (FY_ToCity.chName like '%" + toCityNameStr + "%')"; strAirline += " and (FY_ToCity.chName like '%" + toCityNameStr + "%')"; } if (tripDateStr != "") { str += " and (FY_Ticket.fromtripDate<='" + tripDateStr + "' and FY_Ticket.totripDate>='" + tripDateStr + "' )"; strAirline += " and (FY_Ticket.fromtripDate<='" + tripDateStr + "' and FY_Ticket.totripDate>='" + tripDateStr + "' )"; } if (tripDateStr != "" && backDateStr != "" && tripTypeInt != 0) { int day = (Convert.ToDateTime(backDateStr) - Convert.ToDateTime(tripDateStr)).Days; str += " and DateDiff(d,FY_Ticket.fromtripDate,FY_Ticket.totripDate) >= " + day; strAirline += " and DateDiff(d,FY_Ticket.fromtripDate,FY_Ticket.totripDate) >= " + day; } str += " and (FY_Ticket.tosaleDate>='" + DateTime.Now.ToString("yyyy-MM-dd") + "')"; strAirline += " and (FY_Ticket.tosaleDate>='" + DateTime.Now.ToString("yyyy-MM-dd") + "')"; if (airlineId != 0) { str += " and (FY_Airline.aId=" + airlineId + ")"; } if (getorderStr != "") { str += " order by FY_Ticket." + getorderStr + " asc ,FY_Ticket.tId desc"; } else { str += " order by FY_Ticket.untaxPrice asc ,FY_Ticket.tId desc"; } ArrayList allAirlines = new ArrayList(); strAirline += " group by FY_Ticket.airLine order by min(FY_Ticket.untaxPrice) asc"; //查询航空公司 DataSet dsStrAirLine = SqlHelper.ExecuteDataset(SqlHelper.ConnString_select, CommandType.Text, strAirline); if (dsStrAirLine != null) { foreach (DataRow drAifeiAirline in dsStrAirLine.Tables[0].Rows) { AiFeiAirline afa = new AiFeiAirline(); afa.minPrice = drAifeiAirline["untaxPrice"].ToString(); afa.airlineId = drAifeiAirline["airLine"].ToString(); string code = string.Empty; string pic = string.Empty; afa.airlineName = ReadXmlHelper.GetAirLineNameByID(Convert.ToInt64(afa.airlineId), out code, out pic); afa.airlinePic = pic; afa.airlineCode = code; //if(allAirlines.Count<11) allAirlines.Add(afa); } } //从爱飞网获得数据并排序 AiFeiService aifeiService = new AiFeiService(); //ArrayList = aifeiService.GlobalTicket(dpt, arr, toTime, reTime, cate); ///dpt 出发三字码 arr 到达三字码 /// string arr = getToCityCodeByName(toCityNameStr); string dpt = getFromCityCodeByName(fromCityName); //string cate = "ALL"; string cate = "SF"; ArrayList aifeiTickets = new ArrayList(); if (tripTypeInt == 0) { cate = "DC"; aifeiTickets = aifeiService.AiFeiTickets(dpt, arr, ajaxToTime, ajaxFromTime, cate, airlineId, ref allAirlines);//过滤航空公司 } else if (tripTypeInt == 1) { cate = "SF"; aifeiTickets = aifeiService.AiFeiTickets(dpt, arr, ajaxToTime, ajaxFromTime, cate, airlineId, ref allAirlines);//过滤航空公司 } else if (tripTypeInt == 2) { System.Threading.AutoResetEvent resetEvent = new System.Threading.AutoResetEvent(false); AiFeiService.AiFeiTicketsHandler d1 = new AiFeiService.AiFeiTicketsHandler(aifeiService.AiFeiTickets); AiFeiService.AiFeiTicketsHandler d2 = new AiFeiService.AiFeiTicketsHandler(aifeiService.AiFeiTickets); IAsyncResult iar1 = null, iar2 = null; ArrayList aifeiTickets2 = null; AsyncCallback back1 = delegate(IAsyncResult iar) { aifeiTickets = d1.EndInvoke(ref allAirlines, iar1); if (iar2 != null && iar2.IsCompleted) { resetEvent.Set(); } }; AsyncCallback back2 = delegate(IAsyncResult iar) { aifeiTickets2 = d2.EndInvoke(ref allAirlines, iar2); if (iar1 != null && iar1.IsCompleted) { resetEvent.Set(); } }; iar1 = d1.BeginInvoke(dpt, arr, ajaxToTime, ajaxFromTime, "SF", airlineId, ref allAirlines, back1, null); iar2 = d2.BeginInvoke(dpt, arr, ajaxToTime, ajaxFromTime, "DC", airlineId, ref allAirlines, back2, null); if (resetEvent.WaitOne(2000, true)) { resetEvent.Close(); } if (aifeiTickets2 != null) { for (int i = 0; i < aifeiTickets2.Count; i++) { aifeiTickets.Add(aifeiTickets2[i]); } } } //获得爱飞机票列表 ArrayList tickets = new ArrayList(); ArrayList feiYingTickets = new ArrayList(); int aifeinum = Convert.ToInt32(this.hidd_aifeinum.Value); ds = SqlHelper.ExecuteDataset(SqlHelper.ConnString_select, CommandType.Text, str); //没数据 显示提示 if ((ds.Tables[0] == null || ds.Tables[0].Rows.Count == 0) && aifeiTickets.Count == 0) { this.panHaveValue2.Visible = false; this.panNoValue.Visible = true; return; } else { this.panHaveValue2.Visible = true; this.panNoValue.Visible = false; DataTable dt = ds.Tables[0]; //遍历行 foreach (DataRow dr in dt.Rows) { //遍历列 AiFeiTicket aifeiTicket = new AiFeiTicket(); aifeiTicket.ticketId = dr["tid"].ToString().Trim(); aifeiTicket.price = Convert.ToInt32(dr["untaxPrice"].ToString()); aifeiTicket.fromCity = dr["fromCityName"].ToString(); aifeiTicket.fromCityCode = dr["fromCityCode"].ToString(); aifeiTicket.fromCityId = dr["fId"].ToString(); aifeiTicket.toCity = dr["toCityName"].ToString(); aifeiTicket.toCityCode = dr["toCityCode"].ToString(); aifeiTicket.toCityId = dr["toId"].ToString(); aifeiTicket.airlineCode = dr["airlineCode"].ToString(); aifeiTicket.airline = dr["airname"].ToString(); aifeiTicket.airlineId = dr["aId"].ToString(); aifeiTicket.airlineSmallPic = dr["smallPic"].ToString(); aifeiTicket.relayPort = dr["relayPort"].ToString(); aifeiTicket.sourceType = "feiying"; aifeiTicket.tripType = dr["tripType"].ToString();//单程or往返 //查询税费信息 //aifeiTicket.tax = getTaxMessage(aifeiTicket.fromCityId, aifeiTicket.toCityId, aifeiTicket.airlineId, Convert.ToInt32(aifeiTicket.tripType)); feiYingTickets.Add(aifeiTicket); } } if (getorderStr.Equals("")) { //排序飞瀛机票 foreach (AiFeiTicket orderTicket in feiYingTickets) { if (tickets.Count == 0) { tickets.Add(orderTicket); } else { bool isEnd = false; for (int i = 0; i < tickets.Count && !isEnd; i++) { AiFeiTicket aft = (AiFeiTicket)tickets[i]; if ((i + 1) == tickets.Count && orderTicket.price > aft.price) { tickets.Add(orderTicket); isEnd = true; break; } else if (orderTicket.price <= aft.price) { tickets.Insert(i, orderTicket); isEnd = true; break; } } } } //排序爱飞机票 foreach (AiFeiTicket orderTicket in aifeiTickets) { if (tickets.Count == 0) { tickets.Add(orderTicket); } else { bool isEnd = false; for (int i = 0; i < tickets.Count && !isEnd; i++) { AiFeiTicket aft = (AiFeiTicket)tickets[i]; if ((i + 1) == tickets.Count && orderTicket.price > aft.price) { tickets.Add(orderTicket); isEnd = true; break; } else if (orderTicket.price < aft.price) { tickets.Insert(i, orderTicket); isEnd = true; break; } else if (orderTicket.price == aft.price && orderTicket.airlineCode.Equals(aft.airlineCode)) { isEnd = true; break; } } } } } else if (getorderStr.Equals("airLine")) { //航空公司排序 tickets = feiYingTickets; //排序爱飞机票 foreach (AiFeiTicket orderTicket in aifeiTickets) { if (tickets.Count == 0) { tickets.Add(orderTicket); } else { bool isEnd = false; for (int i = 0; i < tickets.Count && !isEnd; i++) { AiFeiTicket aft = (AiFeiTicket)tickets[i]; if ((i + 1) == tickets.Count && orderTicket.price > aft.price && orderTicket.airlineCode.Equals(aft.airlineCode)) { tickets.Add(orderTicket); isEnd = true; break; } else if (orderTicket.price < aft.price && orderTicket.airlineCode.Equals(aft.airlineCode)) { tickets.Insert(i, orderTicket); isEnd = true; break; } else if (orderTicket.price == aft.price && orderTicket.airlineCode.Equals(aft.airlineCode)) { isEnd = true; break; } } } } } //绑定航空公司 Session["TicketsSessionKey_Airlines"] = allAirlines; //写入Session 分页使用 Session["TicketsSessionKey_" + tripTypeInt + "_" + fromCityId + "_" + Server.HtmlEncode(toCityNameStr) + "_" + ajaxToTime + "_" + ajaxFromTime] = tickets; this.BindData(tickets); }
public ArrayList AiFeiTickets(string Dpt, string Arr, string ToTime, string ReTime, string Cate, int airlineId, ref ArrayList allAirlines) { ArrayList ticketsList = this.GlobalTicket(Dpt, Arr, ToTime, ReTime, Cate); ArrayList tickets = new ArrayList(); //查找airlineId信息 string airlineCode = null; if (airlineId > 0) { airlineCode = ReadXmlHelper.GetAirLineCodeByID(airlineId); } foreach (object obj in ticketsList) { AiFeiTicket aifeiTicket = new AiFeiTicket(); AiFeiTicketEntity ticketObj = (AiFeiTicketEntity)obj; aifeiTicket.price = Convert.ToInt32(ticketObj.ticketPrice); aifeiTicket.ticketCode = ticketObj.ticketCode; bool hasairline = false; foreach (AiFeiAirline v in allAirlines) { if (v.airlineCode.Trim() == (ticketObj.airlineCode + "").Trim() && !string.IsNullOrEmpty(ticketObj.airlineCode)) { hasairline = true; } } if (!hasairline) { //查找airline信息 long airlineId11 = 0; string airlineSmallPic1 = string.Empty; string airline1 = ReadXmlHelper.GetAirLineNameByCode(ticketObj.airlineCode, out airlineId11, out airlineSmallPic1); AiFeiAirline afa = new AiFeiAirline(); afa.airlineId = airlineId11.ToString(); afa.airlineCode = ticketObj.airlineCode; afa.airlineName = airline1; afa.airlinePic = airlineSmallPic1; allAirlines.Add(afa); } if (airlineCode != null) { if (!airlineCode.Equals(ticketObj.airlineCode)) { continue; } } aifeiTicket.fromCityCode = ticketObj.fromCity; long fromCityId = 0; aifeiTicket.fromCity = ReadXmlHelper.GetFromCityNameByCode(ticketObj.fromCity, out fromCityId); aifeiTicket.fromCityId = fromCityId.ToString(); //查找city信息 //string str = "select * from FY_FromCity where cityCode='" + ticketObj.fromCity.Trim() + "'"; //DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.ConnString_select, CommandType.Text, str); //if (ds != null) //{ // aifeiTicket.fromCity = ds.Tables[0].Rows[0]["chName"].ToString(); // aifeiTicket.fromCityId = ds.Tables[0].Rows[0]["fId"].ToString(); //} //else //{ // aifeiTicket.fromCity = ""; // aifeiTicket.fromCityId = "0"; //} aifeiTicket.toCityCode = ticketObj.toCity; long toCityId = 0; aifeiTicket.toCity = ReadXmlHelper.GetToCityNameByCode(ticketObj.toCity, out toCityId); aifeiTicket.toCityId = toCityId.ToString(); //查找city信息 //str = "select * from FY_ToCity where cityCode='" + ticketObj.toCity.Trim() + "'"; //ds = SqlHelper.ExecuteDataset(SqlHelper.ConnString_select, CommandType.Text, str); //if (ds != null) //{ // aifeiTicket.toCity = ds.Tables[0].Rows[0]["chName"].ToString(); // aifeiTicket.toCityId = ds.Tables[0].Rows[0]["tId"].ToString(); //} //else //{ // aifeiTicket.toCity = ""; // aifeiTicket.toCityId = "0"; //} aifeiTicket.airlineCode = ticketObj.airlineCode; //查找airline信息 long airlineId1 = 0; string airlineSmallPic = string.Empty; string airline = ReadXmlHelper.GetAirLineNameByCode(ticketObj.airlineCode, out airlineId1, out airlineSmallPic); aifeiTicket.airline = airline; aifeiTicket.airlineId = airlineId1.ToString(); aifeiTicket.airlineSmallPic = airlineSmallPic; //str = "select * from FY_Airline where airlineCode='" + ticketObj.airlineCode.Trim() +"'"; //ds = SqlHelper.ExecuteDataset(SqlHelper.ConnString_select, CommandType.Text, str); //if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) //{ // aifeiTicket.airline = ; // aifeiTicket.airlineId = ds.Tables[0].Rows[0]["aId"].ToString(); // aifeiTicket.airlineSmallPic = ds.Tables[0].Rows[0]["smallPic"].ToString(); //} //else //{ // aifeiTicket.airline = ""; // aifeiTicket.airlineId = "0"; //} aifeiTicket.sourceType = "aifei"; if (ticketObj.type == "SF") { aifeiTicket.tripType = "1"; } else if (ticketObj.type == "DC") { aifeiTicket.tripType = "0"; } //aifeiTicket.isRelay = ticketObj.type; //查找税费信息 //string str = "select * from FY_Tax where airline='" + aifeiTicket.airlineId + "' and fromCity='" + fromCityId + "' and toCity='" + toCityId + "'"; //DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.ConnString_select, CommandType.Text, str); //if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) //{ // aifeiTicket.tax = ds.Tables[0].Rows[0]["tax"].ToString(); //} //else //{ // aifeiTicket.tax = "---"; //} //本地查询航班信息 from to airline fromtime /* * ArrayList flightList = getFlightMsg(aifeiTicket.fromCityCode, aifeiTicket.toCityCode, aifeiTicket.airlineCode, ToTime); * if(flightList == null){ * //增加航班信息缓存 * //请求航班信息 * flightList = this.GlobalFlight(aifeiTicket.fromCityCode, aifeiTicket.toCityCode, aifeiTicket.airlineCode, "Y", 1, ToTime); * //flightList = new ArrayList(); * } * aifeiTicket.flights = flightList; */ tickets.Add(aifeiTicket); } //this.GlobalFlight(string fromCode,string toCode,string airLineCode,string cls,int num,string goTime); return(tickets); }