Beispiel #1
0
 protected void GetSource()
 {
     if (DataGuid.Length > 0 && DataGuid.Length < 32)
     {
         flightround = GetFeiying580();
         Session[string.Format("TicketsSessionKey_limit_{0}", DataGuid)] = flightround;
     }
     else
     {
         flightround = GetApi();
         Session[string.Format("TicketsSessionKey_limit_{0}", DataGuid)] = flightround;
     }
 }
Beispiel #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         try
         {
             long a = 0;
             ToCityName   = ReadXmlHelper.GetToCityNameByCode(ToCityCode, out a);
             FromCityName = ReadXmlHelper.GetFromCityNameByCode(FromCityCode, out a);
             //LogHelper.WriteLog(string.Format("TripType:{0},FromCityCode:{1},ToCityCode:{2},TripDate:{3},BackDate:{4}", this.TripType, this.FromCityCode, this.ToCityCode, this.TripDate, this.BackDate));
             FlightTotal ftinfo = (FlightTotal)Session[string.Format("TicketsSessionKey2_{0}_{1}_{2}_{3}_{4}", this.TripType, this.FromCityCode, this.ToCityCode, Convert.ToDateTime(this.TripDate).ToString("yyyyMMdd"), Convert.ToDateTime(this.BackDate).ToString("yyyyMMdd"))];
             if (ftinfo != null)
             {
                 foreach (FlightRoundTrip item in ftinfo.result)
                 {
                     bool isContains = false;
                     foreach (FlightInfo fInfo in item.ListInterFlightInfo)
                     {
                         if (DataGuid == fInfo.dataId)
                         {
                             isContains  = true;
                             flightround = item;
                             break;
                         }
                     }
                     if (isContains)
                     {
                         break;
                     }
                 }
             }
             else
             {
                 if (Session[string.Format("TicketsSessionKey_limit_{0}", DataGuid)] != null)
                 {
                     flightround = (FlightRoundTrip)Session[string.Format("TicketsSessionKey_limit_{0}", DataGuid)];
                 }
                 else
                 {
                     this.GetSource();
                 }
             }
         }
         catch (Exception ex)
         {
             //LogHelper.WriteLog(ex.StackTrace+ex.ToString()+ ex.Message);
         }
     }
 }
Beispiel #3
0
 /// <summary>
 /// 获取API接口数据
 /// </summary>
 /// <returns></returns>
 private FlightRoundTrip GetApi()
 {
     try
     {
         FlightRoundTrip rtInfo = null;
         FlightParamInfo param  = new FlightParamInfo();
         param.Startairport = FromCityCode;
         param.Endairport   = ToCityCode;
         param.Startdate    = TripDate;
         //为往返的,加上返回时间
         if (Convert.ToInt32(TripType) == 1)
         {
             param.Backdate = BackDate;
         }
         string      jsonTxt = FlightAPI.GetFlight(param);
         FlightTotal ft      = FlightAPI.DeserializeJsonToObject <FlightTotal>(jsonTxt);
         if (ft.result != null)
         {
             for (int i = 0; i < ft.result.Count; i++)
             {
                 bool isContains = false;
                 for (int j = 0; j < ft.result[i].ListInterFlightInfo.Count; j++)
                 {
                     if (DataGuid == ft.result[i].ListInterFlightInfo[j].dataId)
                     {
                         rtInfo     = ft.result[i];
                         isContains = true;
                         break;
                     }
                 }
                 if (isContains)
                 {
                     break;
                 }
             }
         }
         return(rtInfo);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Beispiel #4
0
    /// <summary>
    /// 获取feiying网手工数据
    /// </summary>
    /// <returns></returns>
    private FlightRoundTrip GetFeiying580()
    {
        DataRow         dr    = null;
        DataSet         ds    = null;
        FlightRoundTrip rTrip = null;
        string          str   = "select FY_Ticket.*,FY_FromCity.chName as fromCityname,FY_Airline.airlineCode as airlineCode,FY_FromCity.cityCode as fromCityCode, FY_ToCity.chName as toCityname,FY_ToCity.cityCode as toCityCode, FY_Airline.chName as airname,FY_Airline.planNum as planNum,FY_Airline.age as age,FY_Airline.aId as airId ,FY_Airline.logoPic as logoPic,FY_Airline.smallPic as smallPic, fAirport.chName as fAirportName,fAirport.airPortCode as fAirportCode, tAirport.chName as tAirportName,tAirport.airPortCode as tAirportCode,tAirport.description as tairportdescription from FY_Ticket left join FY_FromCity on FY_FromCity.fId=FY_Ticket.fromCity left join FY_ToCity on FY_ToCity.tId=FY_Ticket.toCity left join FY_Airline on FY_Airline.aId=FY_Ticket.airLine  left join FY_Airport as  fAirport on fAirport.apId=FY_Ticket.fromPort left join FY_Airport as tAirport on tAirport.apId=FY_Ticket.toPort  where FY_Ticket.tId=" + DataGuid;

        try
        {
            ds = SqlHelper.ExecuteDataset(SqlHelper.ConnString_select, CommandType.Text, str);
            if (ds != null && ds.Tables[0].Rows.Count != 0)
            {
                dr = ds.Tables[0].Rows[0];

                rTrip = new FlightRoundTrip();
                List <FlightInfo>  listF  = new List <FlightInfo>();
                List <FlightInfo2> listF2 = new List <FlightInfo2>();
                if (Convert.ToInt32(TripType) == 0)
                {
                    #region 单程
                    List <FlightDetail> listDeteil = new List <FlightDetail>();
                    FlightInfo          finfo      = new FlightInfo();
                    finfo.Data        = Guid.NewGuid().ToString("N").ToUpper();
                    finfo.Source      = "feiying";
                    finfo.TicketPrice = decimal.Parse(dr["untaxPrice"].ToString());
                    finfo.XmlInfo     = dr["tid"].ToString();
                    finfo.Tid         = dr["tid"].ToString();

                    FlightDetail fdInfo = new FlightDetail();
                    fdInfo.AirCompanyCode = dr["airlineCode"].ToString();
                    fdInfo.StartCityCode  = dr["fromCityCode"].ToString();
                    fdInfo.StartCityName  = ReadXmlHelper.GetAirPortNameByCode(dr["fromCityCode"].ToString());
                    fdInfo.BeginCityName  = dr["fromCityname"].ToString();

                    //如果有中转,则到达城市、机场等替换为中转地
                    if (string.IsNullOrEmpty(dr["relayPort"].ToString()))
                    {
                        fdInfo.EndCityCode = dr["toCityCode"].ToString();
                        fdInfo.EndCityName = ReadXmlHelper.GetAirPortNameByCode(dr["toCityCode"].ToString());
                        fdInfo.ToCityName  = dr["toCityname"].ToString();
                    }
                    else
                    {
                        string[] array = dr["relayPort"].ToString().Split('-');
                        fdInfo.EndCityCode = array[0];
                        fdInfo.EndCityName = ReadXmlHelper.GetAirPortNameByCode(array[0]);
                        long a = 0;//纯粹接收参数
                        fdInfo.ToCityName = ReadXmlHelper.GetToCityNameByCode(array[0], out a);
                    }

                    fdInfo.FromTime   = DateTime.Parse(ReadTime(this.TripDate, 0));
                    fdInfo.ArriveTime = ReadTime(fdInfo.FromTime);
                    listDeteil.Add(fdInfo);
                    //如果有中转
                    if (!string.IsNullOrEmpty(dr["relayPort"].ToString()))
                    {
                        FlightDetail fdInfo2 = new FlightDetail();
                        fdInfo2.AirCompanyCode = string.Empty;       //dr["airlineCode"].ToString();
                        fdInfo2.StartCityCode  = fdInfo.EndCityCode; //dr["fromCityCode"].ToString();
                        fdInfo2.EndCityCode    = dr["toCityCode"].ToString();
                        fdInfo2.StartCityName  = ReadXmlHelper.GetAirPortNameByCode(fdInfo.EndCityCode);
                        fdInfo2.EndCityName    = ReadXmlHelper.GetAirPortNameByCode(dr["toCityCode"].ToString());
                        fdInfo2.BeginCityName  = fdInfo.ToCityName;//dr["fromCityname"].ToString();
                        fdInfo2.ToCityName     = dr["toCityname"].ToString();
                        fdInfo2.FromTime       = ReadTime(fdInfo.ArriveTime);
                        fdInfo2.ArriveTime     = ReadTime(fdInfo2.FromTime);
                        listDeteil.Add(fdInfo2);
                    }
                    finfo.ListInterFlightDetails = listDeteil;
                    listF.Add(finfo);
                    #endregion
                }
                else
                {
                    #region 去程
                    List <FlightDetail> listDeteil = new List <FlightDetail>();
                    FlightInfo          finfo      = new FlightInfo();
                    finfo.Data        = Guid.NewGuid().ToString("N").ToUpper();
                    finfo.Source      = "feiying";
                    finfo.TicketPrice = decimal.Parse(dr["untaxPrice"].ToString());
                    finfo.XmlInfo     = dr["tid"].ToString();
                    finfo.Tid         = dr["tid"].ToString();

                    FlightDetail fdInfo = new FlightDetail();
                    fdInfo.AirCompanyCode = dr["airlineCode"].ToString();
                    fdInfo.StartCityCode  = dr["fromCityCode"].ToString();
                    fdInfo.StartCityName  = ReadXmlHelper.GetAirPortNameByCode(dr["fromCityCode"].ToString());
                    fdInfo.BeginCityName  = dr["fromCityname"].ToString();

                    //如果有中转,则到达城市、机场等替换为中转地
                    if (string.IsNullOrEmpty(dr["relayPort"].ToString()))
                    {
                        fdInfo.EndCityCode = dr["toCityCode"].ToString();
                        fdInfo.EndCityName = ReadXmlHelper.GetAirPortNameByCode(dr["toCityCode"].ToString());
                        fdInfo.ToCityName  = dr["toCityname"].ToString();
                    }
                    else
                    {
                        string[] array = dr["relayPort"].ToString().Split('-');
                        fdInfo.EndCityCode = array[0];
                        fdInfo.EndCityName = ReadXmlHelper.GetAirPortNameByCode(array[0]);
                        long a = 0;//纯粹接收参数
                        fdInfo.ToCityName = ReadXmlHelper.GetToCityNameByCode(array[0], out a);
                    }

                    fdInfo.FromTime   = DateTime.Parse(ReadTime(this.TripDate, 0));
                    fdInfo.ArriveTime = ReadTime(fdInfo.FromTime);
                    listDeteil.Add(fdInfo);
                    //如果有中转
                    if (!string.IsNullOrEmpty(dr["relayPort"].ToString()))
                    {
                        FlightDetail fdInfo2 = new FlightDetail();
                        fdInfo2.AirCompanyCode = string.Empty;       //dr["airlineCode"].ToString();
                        fdInfo2.StartCityCode  = fdInfo.EndCityCode; //dr["fromCityCode"].ToString();
                        fdInfo2.EndCityCode    = dr["toCityCode"].ToString();
                        fdInfo2.StartCityName  = ReadXmlHelper.GetAirPortNameByCode(fdInfo.EndCityCode);
                        fdInfo2.EndCityName    = ReadXmlHelper.GetAirPortNameByCode(dr["toCityCode"].ToString());
                        fdInfo2.BeginCityName  = fdInfo.ToCityName;//dr["fromCityname"].ToString();
                        fdInfo2.ToCityName     = dr["toCityname"].ToString();
                        fdInfo2.FromTime       = ReadTime(fdInfo.ArriveTime);
                        fdInfo2.ArriveTime     = ReadTime(fdInfo2.FromTime);
                        listDeteil.Add(fdInfo2);
                    }
                    finfo.ListInterFlightDetails = listDeteil;
                    listF.Add(finfo);
                    #endregion

                    #region 返程
                    List <FlightDetail> listDeteil2 = new List <FlightDetail>();
                    FlightInfo2         finfo2      = new FlightInfo2();
                    finfo2.Source      = "feiying";
                    finfo2.TicketPrice = decimal.Parse(dr["untaxPrice"].ToString());

                    FlightDetail fdbkInfo = new FlightDetail();
                    fdbkInfo.AirCompanyCode = dr["airlineCode"].ToString();
                    fdbkInfo.StartCityCode  = dr["toCityCode"].ToString();
                    fdbkInfo.StartCityName  = fdInfo.EndCityName;//使用去程的到达机场作为返回的出发机场 //ReadXmlHelper.GetAirPortNameByCode(dr["toCityCode"].ToString());
                    fdbkInfo.BeginCityName  = dr["toCityname"].ToString();

                    //如果有中转,则到达城市、机场等替换为中转地
                    if (string.IsNullOrEmpty(dr["relayPort"].ToString()))
                    {
                        fdbkInfo.EndCityCode = dr["fromCityCode"].ToString();
                        fdbkInfo.EndCityName = fdInfo.StartCityName;//使用去程的出发机场作为返回的到达机场 //ReadXmlHelper.GetAirPortNameByCode(dr["fromCityCode"].ToString());
                        fdbkInfo.ToCityName  = dr["fromCityname"].ToString();
                    }
                    else
                    {
                        string[] array = dr["relayPort"].ToString().Split('-');
                        fdbkInfo.EndCityCode = array[0];
                        fdbkInfo.EndCityName = fdInfo.EndCityName;
                        long a = 0;                              //纯粹接收参数
                        fdbkInfo.ToCityName = fdInfo.ToCityName; //ReadXmlHelper.GetToCityNameByCode(array[0], out a);
                    }

                    fdbkInfo.FromTime   = DateTime.Parse(ReadTime(this.BackDate, 0));
                    fdbkInfo.ArriveTime = ReadTime(fdbkInfo.FromTime);
                    listDeteil2.Add(fdbkInfo);
                    //如果有中转
                    if (!string.IsNullOrEmpty(dr["relayPort"].ToString()))
                    {
                        FlightDetail fdbkInfo2 = new FlightDetail();
                        fdbkInfo2.AirCompanyCode = string.Empty;         //dr["airlineCode"].ToString();
                        fdbkInfo2.StartCityCode  = fdbkInfo.EndCityCode; //dr["fromCityCode"].ToString();
                        fdbkInfo2.EndCityCode    = dr["fromCityCode"].ToString();
                        fdbkInfo2.StartCityName  = fdbkInfo.EndCityName; //使用第一次中转的到达机场作为第二次中转的出发机场 //ReadXmlHelper.GetAirPortNameByCode(fdbkInfo.EndCityCode);
                        fdbkInfo2.EndCityName    = fdInfo.StartCityName; //使用去程的出发机场作为返回的到达机场 //ReadXmlHelper.GetAirPortNameByCode(dr["fromCityCode"].ToString());
                        fdbkInfo2.BeginCityName  = fdInfo.ToCityName;    //使用去程的到达城市作为返回的出发城市 //dr["fromCityname"].ToString();
                        fdbkInfo2.ToCityName     = dr["fromCityname"].ToString();
                        fdbkInfo2.FromTime       = ReadTime(fdbkInfo.ArriveTime);
                        fdbkInfo2.ArriveTime     = ReadTime(fdbkInfo2.FromTime);
                        listDeteil2.Add(fdbkInfo2);
                    }
                    finfo2.ListInterFlightDetails = listDeteil2;
                    listF2.Add(finfo2);
                    #endregion
                }
                rTrip.ListInterFlightInfo  = listF;
                rTrip.ListInterFlightInfo2 = listF2;
            }
            return(rTrip);
        }
        catch (Exception)
        {
            return(null);
        }
    }
Beispiel #5
0
    /// <summary>
    /// 获取Fei580票价
    /// </summary>
    /// <returns></returns>
    protected List <FlightRoundTrip> getFei580Ticekt()
    {
        #region SQL语句
        StringBuilder str = new StringBuilder();
        str.Append("select top 100 percent");
        str.Append(" FY_Ticket.tid,FY_Ticket.untaxPrice,FY_Ticket.relayPort,FY_Ticket.tripType,");
        str.Append(" FY_FromCity.cityCode as fromCityCode,");
        str.Append(" FY_ToCity.cityCode as toCityCode,");
        str.Append(" FY_Tax.tax,");
        str.Append(" FY_FromCity.chName as fromCityname,FY_FromCity.fId,FY_Airline.aId,FY_ToCity.tId as toId,");
        str.Append(" FY_ToCity.chName as toCityname,FY_Airline.airlineCode as airlineCode,FY_Airline.chName as airname, FY_Airline.smallPic as smallPic from FY_Ticket ");
        str.Append(" left join FY_FromCity on FY_FromCity.fId=FY_Ticket.fromCity");
        str.Append(" left join FY_ToCity on FY_ToCity.tId=FY_Ticket.toCity");
        str.Append(" left join FY_Airline on FY_Airline.aId=FY_Ticket.airLine");
        str.Append(" 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.Append(" where 1=1 ");
        if (this.tripType != 2)
        {
            str.Append(" and (FY_Ticket.tripType=" + this.tripType + ")");
        }
        if (this.fromcity != 0)
        {
            str.Append(" and (FY_FromCity.fId=" + this.fromcity + ")");
        }
        if (!string.IsNullOrEmpty(this.tocityName1))
        {
            str.Append(" and (FY_ToCity.chName like '%" + tocityName1 + "%')");
        }
        if (!string.IsNullOrEmpty(this.tripDate))
        {
            str.Append(" and (FY_Ticket.fromtripDate<='" + tripDate + "' and FY_Ticket.totripDate>='" + tripDate + "' )");
        }
        if (!string.IsNullOrEmpty(this.tripDate) && !string.IsNullOrEmpty(this.backDate) && this.tripType != 0)
        {
            int day = (Convert.ToDateTime(backDate) - Convert.ToDateTime(tripDate)).Days;
            str.Append(" and DateDiff(d,FY_Ticket.fromtripDate,FY_Ticket.totripDate) >= " + day);
        }
        str.Append(" and (FY_Ticket.tosaleDate>='" + DateTime.Now.ToString("yyyy-MM-dd") + "')");
        if (!string.IsNullOrEmpty(this.airlineId))
        {
            str.Append(" and (FY_Airline.aId=" + airlineId + ")");
        }
        if (string.IsNullOrEmpty(this.orderStr))
        {
            str.Append(" order by FY_Ticket.untaxPrice asc ,FY_Ticket.tId desc");
        }
        else
        {
            str.Append(" order by FY_Ticket." + this.orderStr + " asc ,FY_Ticket.tId desc");
        }
        #endregion
        DataSet   ds = SqlHelper.ExecuteDataset(SqlHelper.ConnString_select, CommandType.Text, str.ToString());
        DataTable dt = ds.Tables[0];

        List <FlightRoundTrip> ListRTrip = new List <FlightRoundTrip>();

        foreach (DataRow dr in dt.Rows)
        {
            FlightRoundTrip    rTrip  = new FlightRoundTrip();
            List <FlightInfo>  listF  = new List <FlightInfo>();
            List <FlightInfo2> listF2 = new List <FlightInfo2>();
            if (Convert.ToInt32(dr["tripType"]) == 0)
            {
                #region 单程
                List <FlightDetail> listDeteil = new List <FlightDetail>();
                FlightInfo          finfo      = new FlightInfo();
                finfo.Data        = Guid.NewGuid().ToString("N").ToUpper();
                finfo.Source      = "feiying";
                finfo.TicketPrice = decimal.Parse(dr["untaxPrice"].ToString());
                finfo.XmlInfo     = dr["tid"].ToString();
                finfo.Tid         = dr["tid"].ToString();

                FlightDetail fdInfo = new FlightDetail();
                fdInfo.AirCompanyCode = dr["airlineCode"].ToString();
                fdInfo.StartCityCode  = dr["fromCityCode"].ToString();
                fdInfo.StartCityName  = ReadXmlHelper.GetAirPortNameByCode(dr["fromCityCode"].ToString());
                fdInfo.BeginCityName  = dr["fromCityname"].ToString();

                //如果有中转,则到达城市、机场等替换为中转地
                if (string.IsNullOrEmpty(dr["relayPort"].ToString()))
                {
                    fdInfo.EndCityCode = dr["toCityCode"].ToString();
                    fdInfo.EndCityName = ReadXmlHelper.GetAirPortNameByCode(dr["toCityCode"].ToString());
                    fdInfo.ToCityName  = dr["toCityname"].ToString();
                }
                else
                {
                    string[] array = dr["relayPort"].ToString().Split('-');
                    fdInfo.EndCityCode = array[0];
                    fdInfo.EndCityName = ReadXmlHelper.GetAirPortNameByCode(array[0]);
                    long a = 0;//纯粹接收参数
                    fdInfo.ToCityName = ReadXmlHelper.GetToCityNameByCode(array[0], out a);
                }

                fdInfo.FromTime   = DateTime.Parse(ReadTime(this.tripDate, 0));
                fdInfo.ArriveTime = ReadTime(fdInfo.FromTime);
                listDeteil.Add(fdInfo);
                //如果有中转
                if (!string.IsNullOrEmpty(dr["relayPort"].ToString()))
                {
                    FlightDetail fdInfo2 = new FlightDetail();
                    fdInfo2.AirCompanyCode = string.Empty;       //dr["airlineCode"].ToString();
                    fdInfo2.StartCityCode  = fdInfo.EndCityCode; //dr["fromCityCode"].ToString();
                    fdInfo2.EndCityCode    = dr["toCityCode"].ToString();
                    fdInfo2.StartCityName  = ReadXmlHelper.GetAirPortNameByCode(fdInfo.EndCityCode);
                    fdInfo2.EndCityName    = ReadXmlHelper.GetAirPortNameByCode(dr["toCityCode"].ToString());
                    fdInfo2.BeginCityName  = fdInfo.ToCityName;//dr["fromCityname"].ToString();
                    fdInfo2.ToCityName     = dr["toCityname"].ToString();
                    fdInfo2.FromTime       = ReadTime(fdInfo.ArriveTime);
                    fdInfo2.ArriveTime     = ReadTime(fdInfo2.FromTime);
                    listDeteil.Add(fdInfo2);
                }
                finfo.ListInterFlightDetails = listDeteil;
                listF.Add(finfo);
                #endregion
            }
            else
            {
                #region 去程
                List <FlightDetail> listDeteil = new List <FlightDetail>();
                FlightInfo          finfo      = new FlightInfo();
                finfo.Data        = Guid.NewGuid().ToString("N").ToUpper();
                finfo.Source      = "feiying";
                finfo.TicketPrice = decimal.Parse(dr["untaxPrice"].ToString());
                finfo.XmlInfo     = dr["tid"].ToString();
                finfo.Tid         = dr["tid"].ToString();

                FlightDetail fdInfo = new FlightDetail();
                fdInfo.AirCompanyCode = dr["airlineCode"].ToString();
                fdInfo.StartCityCode  = dr["fromCityCode"].ToString();
                fdInfo.StartCityName  = ReadXmlHelper.GetAirPortNameByCode(dr["fromCityCode"].ToString());
                fdInfo.BeginCityName  = dr["fromCityname"].ToString();

                //如果有中转,则到达城市、机场等替换为中转地
                if (string.IsNullOrEmpty(dr["relayPort"].ToString()))
                {
                    fdInfo.EndCityCode = dr["toCityCode"].ToString();
                    fdInfo.EndCityName = ReadXmlHelper.GetAirPortNameByCode(dr["toCityCode"].ToString());
                    fdInfo.ToCityName  = dr["toCityname"].ToString();
                }
                else
                {
                    string[] array = dr["relayPort"].ToString().Split('-');
                    fdInfo.EndCityCode = array[0];
                    fdInfo.EndCityName = ReadXmlHelper.GetAirPortNameByCode(array[0]);
                    long a = 0;//纯粹接收参数
                    fdInfo.ToCityName = ReadXmlHelper.GetToCityNameByCode(array[0], out a);
                }

                fdInfo.FromTime   = DateTime.Parse(ReadTime(this.tripDate, 0));
                fdInfo.ArriveTime = ReadTime(fdInfo.FromTime);
                listDeteil.Add(fdInfo);
                //如果有中转
                if (!string.IsNullOrEmpty(dr["relayPort"].ToString()))
                {
                    FlightDetail fdInfo2 = new FlightDetail();
                    fdInfo2.AirCompanyCode = string.Empty;       //dr["airlineCode"].ToString();
                    fdInfo2.StartCityCode  = fdInfo.EndCityCode; //dr["fromCityCode"].ToString();
                    fdInfo2.EndCityCode    = dr["toCityCode"].ToString();
                    fdInfo2.StartCityName  = ReadXmlHelper.GetAirPortNameByCode(fdInfo.EndCityCode);
                    fdInfo2.EndCityName    = ReadXmlHelper.GetAirPortNameByCode(dr["toCityCode"].ToString());
                    fdInfo2.BeginCityName  = fdInfo.ToCityName;//dr["fromCityname"].ToString();
                    fdInfo2.ToCityName     = dr["toCityname"].ToString();
                    fdInfo2.FromTime       = ReadTime(fdInfo.ArriveTime);
                    fdInfo2.ArriveTime     = ReadTime(fdInfo2.FromTime);
                    listDeteil.Add(fdInfo2);
                }
                finfo.ListInterFlightDetails = listDeteil;
                listF.Add(finfo);
                #endregion

                #region 返程
                List <FlightDetail> listDeteil2 = new List <FlightDetail>();
                FlightInfo2         finfo2      = new FlightInfo2();
                finfo2.Source      = "feiying";
                finfo2.TicketPrice = decimal.Parse(dr["untaxPrice"].ToString());

                FlightDetail fdbkInfo = new FlightDetail();
                fdbkInfo.AirCompanyCode = dr["airlineCode"].ToString();
                fdbkInfo.StartCityCode  = dr["toCityCode"].ToString();
                fdbkInfo.StartCityName  = fdInfo.EndCityName;//使用去程的到达机场作为返回的出发机场 //ReadXmlHelper.GetAirPortNameByCode(dr["toCityCode"].ToString());
                fdbkInfo.BeginCityName  = dr["toCityname"].ToString();

                //如果有中转,则到达城市、机场等替换为中转地
                if (string.IsNullOrEmpty(dr["relayPort"].ToString()))
                {
                    fdbkInfo.EndCityCode = dr["fromCityCode"].ToString();
                    fdbkInfo.EndCityName = fdInfo.StartCityName;//使用去程的出发机场作为返回的到达机场 //ReadXmlHelper.GetAirPortNameByCode(dr["fromCityCode"].ToString());
                    fdbkInfo.ToCityName  = dr["fromCityname"].ToString();
                }
                else
                {
                    string[] array = dr["relayPort"].ToString().Split('-');
                    fdbkInfo.EndCityCode = array[0];
                    fdbkInfo.EndCityName = fdInfo.EndCityName;
                    long a = 0;                              //纯粹接收参数
                    fdbkInfo.ToCityName = fdInfo.ToCityName; //ReadXmlHelper.GetToCityNameByCode(array[0], out a);
                }

                fdbkInfo.FromTime   = DateTime.Parse(ReadTime(this.backDate, 0));
                fdbkInfo.ArriveTime = ReadTime(fdbkInfo.FromTime);
                listDeteil2.Add(fdbkInfo);
                //如果有中转
                if (!string.IsNullOrEmpty(dr["relayPort"].ToString()))
                {
                    FlightDetail fdbkInfo2 = new FlightDetail();
                    fdbkInfo2.AirCompanyCode = string.Empty;         //dr["airlineCode"].ToString();
                    fdbkInfo2.StartCityCode  = fdbkInfo.EndCityCode; //dr["fromCityCode"].ToString();
                    fdbkInfo2.EndCityCode    = dr["fromCityCode"].ToString();
                    fdbkInfo2.StartCityName  = fdbkInfo.EndCityName; //使用第一次中转的到达机场作为第二次中转的出发机场 //ReadXmlHelper.GetAirPortNameByCode(fdbkInfo.EndCityCode);
                    fdbkInfo2.EndCityName    = fdInfo.StartCityName; //使用去程的出发机场作为返回的到达机场 //ReadXmlHelper.GetAirPortNameByCode(dr["fromCityCode"].ToString());
                    fdbkInfo2.BeginCityName  = fdInfo.ToCityName;    //使用去程的到达城市作为返回的出发城市 //dr["fromCityname"].ToString();
                    fdbkInfo2.ToCityName     = dr["fromCityname"].ToString();
                    fdbkInfo2.FromTime       = ReadTime(fdbkInfo.ArriveTime);
                    fdbkInfo2.ArriveTime     = ReadTime(fdbkInfo2.FromTime);
                    listDeteil2.Add(fdbkInfo2);
                }
                finfo2.ListInterFlightDetails = listDeteil2;
                listF2.Add(finfo2);
                #endregion
            }
            rTrip.ListInterFlightInfo  = listF;
            rTrip.ListInterFlightInfo2 = listF2;
            ListRTrip.Add(rTrip);
        }
        return(ListRTrip);
    }
Beispiel #6
0
    /// <summary>
    /// 异步获取数据
    /// </summary>
    public void AsyncData()
    {
        FlightTotal tickets1 = null;

        if (Session[string.Format("TicketsSessionKey2_{0}_{1}_{2}_{3}_{4}", this.tripType, fromcityCode, this.tocityCode, Convert.ToDateTime(this.tripDate).ToString("yyyyMMdd"), Convert.ToDateTime(this.backDate).ToString("yyyyMMdd"))] == null)
        {
            //通知等待
            //System.Threading.AutoResetEvent resetEvent = new System.Threading.AutoResetEvent(false);

            System.Threading.AutoResetEvent[] autoEvents = new System.Threading.AutoResetEvent[]
            {
                new System.Threading.AutoResetEvent(false),
                new System.Threading.AutoResetEvent(false)
            };
            GjrinterFlightHandler  d1       = new GjrinterFlightHandler(GetFlights);
            GFei_580Handler        d2       = new GFei_580Handler(getFei580Ticekt);
            IAsyncResult           iar1     = null;
            IAsyncResult           iar2     = null;
            List <FlightRoundTrip> tickets2 = null;
            AsyncCallback back1 = delegate(IAsyncResult iar)
            {
                try
                {
                    tickets1 = d1.EndInvoke(iar1);
                    if (iar1 != null && iar1.IsCompleted)
                    {
                        autoEvents[0].Set();
                    }
                }
                catch (Exception)
                {
                    autoEvents[0].Set();
                }
            };
            AsyncCallback back2 = delegate(IAsyncResult iar)
            {
                try
                {
                    tickets2 = d2.EndInvoke(iar2);
                    if (iar2 != null && iar2.IsCompleted)
                    {
                        autoEvents[1].Set();
                    }
                }
                catch (Exception)
                {
                    autoEvents[1].Set();
                }
            };
            iar1 = d1.BeginInvoke(back1, null);
            iar2 = d2.BeginInvoke(back2, null);
            //等待通知
            //if (resetEvent.WaitOne(12000, true))
            if (System.Threading.AutoResetEvent.WaitAll(autoEvents, 10000))
            {
                autoEvents[0].Close();
                autoEvents[1].Close();
            }
            //resetEvent.Close();

            #region 无数据显示
            //没数据 显示提示
            if ((tickets1 == null || tickets1.result == null) && (tickets2 == null || tickets2.Count == 0))
            //if ((tickets1 == null || (tickets1.result == null ? 0 : tickets1.result.Count) == 0))
            {
                this.panHaveValue2.Visible = false;
                this.panNoValue.Visible    = true;
                return;
            }
            else
            {
                this.panHaveValue2.Visible = true;
                this.panNoValue.Visible    = false;
            }
            #endregion

            #region 整合数据
            if (tickets1 != null)
            {
                if (tickets1.result != null)
                {
                    foreach (FlightRoundTrip item in tickets2)
                    {
                        tickets1.result.Add(item);
                    }
                }
                else
                {
                    tickets1.result = tickets2;
                }
            }
            else
            {
                tickets1        = new FlightTotal();
                tickets1.result = tickets2;
            }
            #endregion

            #region 排序
            if (true)
            {
                if (tickets1.result != null)
                {
                    airlineList.Clear();
                    //冒泡排序
                    for (int i = 0; i < tickets1.result.Count - 1; i++)
                    {
                        for (int j = tickets1.result.Count - 1; j > i; j--)
                        {
                            if (tickets1.result[j].ListInterFlightInfo[0].TicketPrice < tickets1.result[j - 1].ListInterFlightInfo[0].TicketPrice)
                            {
                                FlightRoundTrip finfo = tickets1.result[j];
                                tickets1.result[j]     = tickets1.result[j - 1];
                                tickets1.result[j - 1] = finfo;
                            }
                        }
                        #region 获取航空公司
                        if (tickets1.result[i].ListInterFlightInfo.Count > 0)
                        {
                            foreach (FlightInfo item in tickets1.result[i].ListInterFlightInfo)
                            {
                                if (!isInAirlineList(item.ListInterFlightDetails[0].AirCompanyCode))
                                {
                                    airlineList.Add(item.ListInterFlightDetails[0].AirCompanyCode);
                                }
                            }
                        }
                        #endregion
                    }
                    #region 保存查询结果中出现的航空公司
                    ArrayList arr    = this.getAirLines();
                    ArrayList newArr = new ArrayList();
                    foreach (string item in airlineList)
                    {
                        foreach (kabe_Airline airlineInfo in arr)
                        {
                            if (item == airlineInfo.airlineCode)
                            {
                                newArr.Add(airlineInfo);
                            }
                        }
                    }
                    Session["TicketsSessionKey_Airlines"] = newArr;
                    #endregion
                }
            }
            #endregion
        }
        else
        {
            tickets1 = (FlightTotal)Session[string.Format("TicketsSessionKey2_{0}_{1}_{2}_{3}_{4}", this.tripType, fromcityCode, this.tocityCode, Convert.ToDateTime(this.tripDate).ToString("yyyyMMdd"), Convert.ToDateTime(this.backDate).ToString("yyyyMMdd"))];
        }

        this.BindData(tickets1);
        dvPageCount.InnerHtml = tickets1.result.Count.ToString();
    }