public OTA_AirAvailAndFaresRQType CreateAvailabilityRequestForRoundtrip(AvailabilityFightListRequest request, string origin, string destination)
 {
     return new OTA_AirAvailAndFaresRQType
     {
         SequenceNmbr = 1,
         SequenceNmbrSpecified = true,
         PrimaryLangID = "1",
         DirectFlightsOnly = request.directFlightsOnly,
         DirectFlightsOnlySpecified = true,
         POS = Common.GetPOSType(),
         TravelerInfoSummary = new TravelerInfoSummaryType
         {
             AirTravelerAvail = new AirTravelerAvailType
             {
                 PassengerTypeQuantity = this.GetPassengerQuantities(request),
                 temp = "temp"
             }
         },
         OriginDestinationInformation = new OriginDestinationInformationType
         {
             OriginLocation = new LocationType
             {
                 LocationCode = origin
             },
             DestinationLocation = new LocationType
             {
                 LocationCode = destination
             },
             DepartureDateTime = request.date.ToString("yyyy-MM-dd")
         },
         ReturnOriginDestinationInformation = new ReturnOriginDestinationInformation
         {
             ReturnDateTime = request.date.ToString("yyyy-MM-dd")
         }
     };
 }
        public List<OTA_AirAvailAndFaresRQType> CreateAvailabilityRequests(AvailabilityFightListRequest request)
        {
            //airport listesi elimizde olsaydı metadata gibi linq ile sorgu atabilirdik. veya db den soracağız. hava alanı listesini istek oluştururken static bir şekildede oluşturabiliriz.
            //query.IntendedSegments.First<AirQuery_Segment>().Destination;
            //buarada biz metadatadan arama yaparken sadece Airport Code üzerinden sorgu atıp diğer bilgileri oradan bulacağız ben şimdilik elle salladım.

            Airport departure = new Airport(request.origin, request.origin, "TR");
            Airport arrival = new Airport(request.destination, request.destination, "TR");

            string[] origins = new string[]
            {
                departure.Code
            };

            //IsCity deki amaç istanbuldan ankaraya uçacak ve istanbulda 2 ankarada 3 hava alanı var. kullanıcı ayrım yapmadan sorgulama yapmak istiyor. yani SAW (sabiha) veya burada amaç
            if (departure.IsCity && Common.CityAirports.ContainsKey(departure.Code))
            {
                origins = Common.CityAirports[departure.Code];
            }
            string[] destinations = new string[]
            {
                arrival.Code
            };
            if (arrival.IsCity && Common.CityAirports.ContainsKey(arrival.Code))
            {
                destinations = Common.CityAirports[arrival.Code];
            }

            return new List<OTA_AirAvailAndFaresRQType>
            {
                new OTA_AirAvailAndFaresRQType
                {
                    SequenceNmbr = 1,
                    SequenceNmbrSpecified = true,
                    PrimaryLangID = "1",
                    DirectFlightsOnly = request.directFlightsOnly,
                    DirectFlightsOnlySpecified = true,

                    POS = Common.GetPOSType(),
                    TravelerInfoSummary = new TravelerInfoSummaryType
                    {
                        AirTravelerAvail = new AirTravelerAvailType
                        {
                            PassengerTypeQuantity = this.GetPassengerQuantities(request),
                            temp = "temp"
                        }
                    },

                    OriginDestinationInformation = new OriginDestinationInformationType
                    {
                        OriginLocation = new LocationType
                        {
                            LocationCode = origins.First<string>()
                        },
                        DestinationLocation = new LocationType
                        {
                            LocationCode = destinations.First<string>()
                        },
                        DepartureDateTime =  request.date.ToString("yyyy-MM-dd")
                    }
                }
            };
        }
        //    var google_tag_params = {
        //    flight_originid : 'IST',
        //    flight_destid : 'JFK',
        //    flight_startdate : '2016-07-12',
        //    flight_enddate : '2016-07-19',
        //    flight_pagetype : 'availabilityInt'
        //};
        public AvailabilityFightListResponse ParseAvailabilityResults(AvailabilityFightListRequest request, OTA_AirAvailAndFaresRSType response)
        {
            //TODO : : OK::NOT:: bu iki bilgi requestin içine eklenebilir requet içinde code değilde airport eklenebilir bu sayede. bir ön mekenazima yapılıp onun istekleri yapmadan önce ilgili düzenlemeleri yapması istenebiir :)
            Airport departure = new Airport(request.origin, request.origin, "TR");
            Airport arrival = new Airport(request.destination, request.destination, "TR");

            AvailabilityFightListResponse formedResponse = new AvailabilityFightListResponse();

            if (response.Success && response.OriginDestinationOptionsExt.OriginDestinationOptionExt.Length > 0)
            {
                bool isDomestic = FlightHelper.FlightHelpers.IsFlightInTurkeyOrECN(departure, arrival);

                //string[] promoClasses = new string[0];
                if (isDomestic)
                {
                    //promoClasses = this.ProviderModel.GetDelimitedValues("DomesticPromoClasses", null, ';');
                }
                else
                {
                    //promoClasses = this.ProviderModel.GetDelimitedValues("InternationalPromoClasses", null, ';');
                }
                int nonInfants = request.adult + request.child + request.tsk + request.ogr; //FlightHelpers.GetNonInfantPassengerCounts(query);
                List<BookingClassAvailExtType> cheapestBookingClasses = new List<BookingClassAvailExtType>();
                OriginDestinationOptionExtType[] originDestinationOptionExt = response.OriginDestinationOptionsExt.OriginDestinationOptionExt;
                for (int i = 0; i < originDestinationOptionExt.Length; i++)
                {
                    OriginDestinationOptionExtType option = originDestinationOptionExt[i];
                    if (!request.directFlightsOnly || option.FlightSegmentExt.Length <= 1)
                    {
                        if (!option.FlightSegmentExt.Any((FlightSegmentExtType x) => x.BookingClassAvailExt == null))
                        {
                            FlightOption pgsOption = new FlightOption();
                            pgsOption.BookingProviderId = this.ProviderModel.ProviderNo;
                            pgsOption.BookingProviderCode = this.ProviderModel.ProviderCode;
                            pgsOption.RelatedQueryObject = query;
                            pgsOption.OptionFlag = "OW";
                            pgsOption.OriginDestinationFlag = string.Format("{0}-{1}", option.FlightSegmentExt.First<FlightSegmentExtType>().DepartureAirport.LocationCode, option.FlightSegmentExt.Last<FlightSegmentExtType>().ArrivalAirport.LocationCode);
                            pgsOption.TripType = E_TripTypes.OneWay;
                            pgsOption.FreeBaggageAllowance = new FreeBaggageAllowance[]
                            {
                                Common.GetBaggageAllowance(query, isDomestic)
                            };
                            pgsOption.Segments = new List<Segment>();
                            pgsOption.SegmentAvailabilities = new List<SegmentAvailability>();
                            int segmentIndex = 1;
                            FlightSegmentExtType[] flightSegmentExt = option.FlightSegmentExt;
                            for (int j = 0; j < flightSegmentExt.Length; j++)
                            {
                                FlightSegmentExtType segment = flightSegmentExt[j];
                                IEnumerable<BookingClassAvailExtType> availableBookingClasses =
                                    from x in segment.BookingClassAvailExt
                                    where x.ResBookDesigQuantity >= nonInfants
                                    select x;
                                SegmentAvailability pgsSegmentAvailability = new SegmentAvailability
                                {
                                    SegmentIndex = segmentIndex,
                                    BookingClasses = new List<BookingClassAvailability>()
                                };
                                foreach (BookingClassAvailExtType bookingClass in availableBookingClasses)
                                {
                                    pgsSegmentAvailability.BookingClasses.Add(new BookingClassAvailability
                                    {
                                        Code = bookingClass.ResBookDesigCode,
                                        AvailableSeats = bookingClass.ResBookDesigQuantity,
                                        IsPromo = promoClasses.Contains(bookingClass.ResBookDesigCode)
                                    });
                                }
                                pgsOption.SegmentAvailabilities.Add(pgsSegmentAvailability);
                                Segment pgsSegment = new Segment();
                                pgsSegment.Index = segmentIndex;
                                pgsSegment.OriginAirport = segment.DepartureAirport.LocationCode;
                                pgsSegment.DestinationAirport = segment.ArrivalAirport.LocationCode;
                                pgsSegment.OD_OriginAirport = option.FlightSegmentExt.First<FlightSegmentExtType>().DepartureAirport.LocationCode;
                                pgsSegment.OD_DestinationAirport = option.FlightSegmentExt.Last<FlightSegmentExtType>().ArrivalAirport.LocationCode;
                                pgsSegment.DepartureDateTime = DateTime.Parse(segment.DepartureDateTime);
                                pgsSegment.ArrivalDateTime = DateTime.Parse(segment.ArrivalDateTime);
                                pgsSegment.FlightNumber = segment.MarkettingAirline.CompanyShortName + segment.FlightNumber;
                                pgsSegment.MarketingAirline = segment.MarkettingAirline.CompanyShortName;
                                pgsSegment.OperatingAirline = pgsSegment.MarketingAirline;
                                pgsSegment.Equipment = segment.Equipment.AirEquipType;
                                BookingClassAvailExtType cheapestBookingClass = availableBookingClasses.FirstOrDefault((BookingClassAvailExtType x) => x.ResBookDesigCode == pgsSegmentAvailability.BookingClasses.Last<BookingClassAvailability>().Code);
                                cheapestBookingClasses.Add(cheapestBookingClass);
                                pgsSegment.BookingClassCode = cheapestBookingClass.ResBookDesigCode;
                                pgsSegment.FareBasisCode = pgsSegment.BookingClassCode;
                                pgsSegment.FareReference = cheapestBookingClass.FareDisplayInfos.FareDisplayInfo.Last<FareDisplayInfoType>().FareReference;
                                pgsSegment.FareReferenceId = cheapestBookingClass.FareDisplayInfos.FareDisplayInfo.Last<FareDisplayInfoType>().FareReferenceID;
                                pgsOption.Segments.Add(pgsSegment);
                                segmentIndex++;
                            }
                            result.FlightOptions.Add(pgsOption);
                        }
                    }
                }
                foreach (FlightOption pgsoption in result.FlightOptions)
                {
                    this.GetFareTypesInParallelThread(pgsoption);
                }
                this.CalculateFares(query, result, isDomestic, cheapestBookingClasses);
            }
            else
            {
                result.FlightOptions = null;
                result.HasError = true;
            }
            return result;
        }
        //public ProviderModel ProviderModel
        //{
        //    get;
        //    set;
        //}
        //public AvailabilityHelper(ProviderModel providerModel)
        //{
        //    this.ProviderModel = providerModel;
        //}
        public PassengerTypeQuantityType[] GetPassengerQuantities(AvailabilityFightListRequest request)
        {
            List<PassengerTypeQuantityType> passengers = new List<PassengerTypeQuantityType>();

            //pegasus ta adult child ve Infant var , military senior young falan hepsi Adult'a eklenmeli

            if (request.PTCsAdult > 0 || request.PTCsYoung > 0 || request.PTCsStudent > 0 || request.PTCsSenior > 0 || request.PTCsMilitary > 0)
            {
                passengers.Add(new PassengerTypeQuantityType
                {
                    Code = PassengerType.Adult.Code,
                    Quantity = request.PTCsAdult + request.PTCsYoung + request.PTCsStudent + request.PTCsSenior + request.PTCsMilitary,
                    QuantitySpecified = true
                });
            }

            if (request.PTCsChildren > 0)
            {
                passengers.Add(new PassengerTypeQuantityType
                {
                    Code = PassengerType.Child.Code,
                    Quantity = request.PTCsChildren,
                    QuantitySpecified = true
                });
            }

            if (request.PTCsInfant > 0)
            {
                passengers.Add(new PassengerTypeQuantityType
                {
                    Code = PassengerType.Infant.Code,
                    Quantity = request.PTCsInfant,
                    QuantitySpecified = true
                });
            }

            return passengers.ToArray();
        }
Exemplo n.º 5
0
        public AvailabilityFightListResponse AvailabilityFightList(AvailabilityFightListRequest request)
        {
            List<AvailabilityFight> flights = new List<AvailabilityFight>();

            AvailabilityFightListResponse response = new AvailabilityFightListResponse();

            //try
            //{

            //    var basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
            //    basicHttpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
            //    basicHttpBinding.SendTimeout = new System.TimeSpan(0, 5, 0);

            //    SunExpressCraneOTAServiceExtendedServiceReference.CraneOTAServiceExtendedPortTypeClient client = new SunExpressCraneOTAServiceExtendedServiceReference.CraneOTAServiceExtendedPortTypeClient(basicHttpBinding, new EndpointAddress("https://ota.sunexpress.com/axis2/services/CraneOTAServiceExtended?wsdl"));

            //    client.ClientCredentials.UserName.UserName = "******";
            //    client.ClientCredentials.UserName.Password = "******";

            //    if (client.InnerChannel.State != System.ServiceModel.CommunicationState.Faulted)
            //    {
            //        var res = client.Ping(new SunExpressCraneOTAServiceExtendedServiceReference.OTA_PingRQType() { SequenceNmbr = 1, TimeStamp = "1", EchoData = "this is a ping." });
            //    }
            //    else
            //    {
            //        client = new SunExpressCraneOTAServiceExtendedServiceReference.CraneOTAServiceExtendedPortTypeClient(basicHttpBinding, new EndpointAddress("https://ota.sunexpress.com/axis2/services/CraneOTAServiceExtended?wsdl"));
            //        client.ClientCredentials.UserName.UserName = "******";
            //        client.ClientCredentials.UserName.Password = "******";

            //        var res = client.Ping(new SunExpressCraneOTAServiceExtendedServiceReference.OTA_PingRQType() { SequenceNmbr = 1, TimeStamp = "1", EchoData = "this is a ping." });

            //    }
            //}catch  ()
            //{
            //}

            try
            {
                //SunExpressXMLServiceReference.CraneOTAService cc = new SunExpressXMLServiceReference.CraneOTAService();

                //var res = cc.Ping(new SunExpressXMLServiceReference.OTA_PingRQType() {  });
                //cc.Availability(new SunExpressXMLServiceReference.OTA_AirAvailRQType()
                //    {
                //        PrimaryLangID= "TR",
                //        POS= new SunExpressXMLServiceReference.POSType(),

                //        DirectFlightsOnly = true,
                //        OriginDestinationInformation = new SunExpressXMLServiceReference.OriginDestinationInformationType()
                //        {
                //            DepartureDateTime = "20160808",
                //            DestinationLocation = new SunExpressXMLServiceReference.LocationType() { LocationCode = "AYT" },
                //            OriginLocation = new SunExpressXMLServiceReference.LocationType() { LocationCode = "IST" }
                //        }
                //    });
                //header = new SunExpressSoapHeader(username, password);
                header = new SunExpressSoapHeader();
                header.Username = "******";
                header.Password = "******";

                try
                {

                    //SunExpressServiceReference.CraneOTAServicePortTypeClient xc = new SunExpressServiceReference.CraneOTAServicePortTypeClient("CraneOTAServiceSOAP12port_http2");

                    //var basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
                    //basicHttpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;

                    //xc.ClientCredentials.UserName.UserName = "******";
                    //xc.ClientCredentials.UserName.Password = "******";

                    //xc.Ping(new SunExpressServiceReference.OTA_PingRQType() { SequenceNmbr = 1, TimeStamp = "1", EchoData = "this is a ping." });

                }
                catch (System.Exception)
                {

                }

                //SunExpressXMLServiceReference.CraneOTAService cc = new SunExpressXMLServiceReference.CraneOTAService();
                //var resp = cc.Ping(new SunExpressXMLServiceReference.OTA_PingRQType() { SequenceNmbr = 1, TimeStamp = "1", EchoData = "this is a ping." });
                var basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
                basicHttpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
                basicHttpBinding.SendTimeout = new System.TimeSpan(0, 5, 0);

                //https://ota.sunexpress.com/axis2/services/CraneOTAServiceExtended?wsdl
                using (SunExpressServiceReference.CraneOTAServicePortTypeClient client = new SunExpressServiceReference.CraneOTAServicePortTypeClient(basicHttpBinding, new EndpointAddress("https://ota.sunexpress.com:80/axis2/services/CraneOTAService?wsdl")))
                {

                    client.ClientCredentials.UserName.UserName = "******";
                    client.ClientCredentials.UserName.Password = "******";

                    ////header = new SunExpressSoapHeader(username, password);
                    //using (new OperationContextScope(client.InnerChannel))
                    //{
                    //    //// Add a HTTP Header to an outgoing request
                    //    //HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty();
                    //    //requestMessage.Headers["MyHttpHeader"] = header.ToString();
                    //    //OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage;

                    //    var res = client.Ping(new SunExpressServiceReference.OTA_PingRQType() { });
                    //}

                    ////header = new SunExpressSoapHeader(username, password);
                    //using (new OperationContextScope(client.InnerChannel))
                    //{
                    //    //// Add a HTTP Header to an outgoing request
                    //    //HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty();
                    //    //requestMessage.Headers["MyHttpHeader"] = header.ToString();
                    //    //OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage;

                    //    var res = client.Ping(new SunExpressServiceReference.OTA_PingRQType() { SequenceNmbr = 1, TimeStamp = "1", EchoData = "this is a ping." });
                    //}

                    using (new OperationContextScope(client.InnerChannel))
                    {

                        //// Add a HTTP Header to an outgoing request
                        HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty();
                        requestMessage.Headers["Header"] = "Content-Type: text/xml; charset=utf-8"; // "Content-Type: application/soap+xml; charset = utf-8";

                        OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage;

                        MessageHeader aMessageHeader = MessageHeader.CreateHeader("wsse:Security", "", header);
                        OperationContext.Current.OutgoingMessageHeaders.Add(aMessageHeader);

                        var res = client.Ping(new SunExpressServiceReference.OTA_PingRQType() { SequenceNmbr = 1, TimeStamp = "1", EchoData = "this is a ping." });

                        //var res = client.Ping(new SunExpressServiceReference.OTA_PingRQType() { SequenceNmbr = 1, TimeStamp = "1", EchoData = "this is a ping." });
                    }

                    client.Close();
                }

                //using (SunExpressServiceReference.CraneOTAServicePortTypeClient client = new SunExpressServiceReference.CraneOTAServicePortTypeClient("CraneOTAServiceSOAP11port_http2"))
                //{

                //    header = new SunExpressSoapHeader(username, password);

                //    var res = client.Availability(new SunExpressServiceReference.OTA_AirAvailRQType()
                //    {
                //        DirectFlightsOnly = true,
                //        OriginDestinationInformation = new SunExpressServiceReference.OriginDestinationInformationType()
                //        {
                //            DepartureDateTime = "20160808",
                //            DestinationLocation = new LocationType() { LocationCode = "AYT" },
                //            OriginLocation = new LocationType() { LocationCode = "ESB" }
                //        }
                //    });
                //    //SunExpressServiceReference.AvailabilityData availabilityResponse = client.availabilityV3(request.username, request.password, request.lang, request.direction.ToString(), request.origin, request.destination, request.date, request.adult, request.child, request.inf, request.ogr, request.tsk, request.yp, request.sc, request.tripType.ToString());

                //    //if (availabilityResponse != null && availabilityResponse.flightData != null)
                //    //{

                //    //    if (availabilityResponse.flightData.Length > 1)
                //    //    {
                //    //        foreach (var flight in availabilityResponse.flightData)
                //    //        {
                //    //            flights.Add(new AvailabilityFight() { Message = flight.message, Voyagecode = flight.voyagecode });
                //    //        }
                //    //    }
                //    //    else
                //    //    {
                //    //        ///log yazıp geçeceğiz...
                //    //    }
                //    //    response.Entities = flights;
                //    //    response.TotalCount = flights.Count;
                //    //}

                //    client.Close();
                //}
            }
            catch (System.Exception)
            {

            }

            return response;
        }
Exemplo n.º 6
0
        public AvailabilityFightListResponse AvailabilityFightList(AvailabilityFightListRequest request)
        {
            List<AvailabilityFight> flights = new List<AvailabilityFight>();
            AvailabilityFightListResponse response = new AvailabilityFightListResponse();

            try
            {

                var cRequest = new List<OTA_AirAvailAndFaresRQType>
            {
            new OTA_AirAvailAndFaresRQType
            {
            SequenceNmbr = 1,
            SequenceNmbrSpecified = true,
            PrimaryLangID = "1",
            DirectFlightsOnly = true,
            DirectFlightsOnlySpecified = true,
            POS = Common.GetPOSType(),
            TravelerInfoSummary = new TravelerInfoSummaryType
            {
                AirTravelerAvail = new AirTravelerAvailType
                {
                    PassengerTypeQuantity = Common.GetPassengerQuantities(),
                    temp = "temp"
                }
            },
            OriginDestinationInformation = new OriginDestinationInformationType
            {
                OriginLocation = new LocationType
                {
                    LocationCode = "ADA"
                },
                DestinationLocation = new LocationType
                {
                    LocationCode = "SAW"
                },
                DepartureDateTime = "2016-08-10"
            }
            }
            };

                using (CraneOTAServiceV21PortTypeClient client = Common.GetClient())
                {
                    using (List<OTA_AirAvailAndFaresRQType>.Enumerator enumerator = cRequest.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            try
                            {

                                Common.ConfigureBinding.SetTimeOut(client.Endpoint.Binding, 20000);

                                var cResponse = client.AvailabilityAndFares(enumerator.Current);
                                if (cResponse.Success)
                                {
                                    var ccc = cResponse;
                                }
                                else
                                {

                                }
                            }
                            catch (System.Exception)
                            {

                            }

                            return response;
                        }
                    }
                }
            }
            catch
            {

            }

            return response;
        }