コード例 #1
0
        public static int GetAverageValue(this FlightOption option)
        {
            switch (option)
            {
            case (FlightOption.LessThan5):
                return(3);

            case (FlightOption.From5To10):
                return(8);

            case (FlightOption.From10To50):
                return(34);

            case (FlightOption.From50To100):
                return(81);

            case (FlightOption.From100To500):
                return(340);

            case (FlightOption.MoreThan500):
                return(811);

            default:
                return(0);
            }
        }
コード例 #2
0
        public static string GetDescription(this FlightOption option)
        {
            switch (option)
            {
            case (FlightOption.LessThan5):
                return("Less than 5");

            case (FlightOption.From5To10):
                return("5-10");

            case (FlightOption.From10To50):
                return("10-50");

            case (FlightOption.From50To100):
                return("50-100");

            case (FlightOption.From100To500):
                return("100-500");

            case (FlightOption.MoreThan500):
                return("More than 500");

            default:
                return("Not flying anymore");
            }
        }
コード例 #3
0
ファイル: EmissionService.cs プロジェクト: angry-guru/jcf-api
        private async Task <CarbonFootprintResult> CalculateFlightEmission(FlightOption flightOption, TimeOption timeOption)
        {
            var yearlyNumberOfFlights = ((double)flightOption.GetAverageValue() / timeOption.GetDays()) * TimeOption.year.GetDays();

            var response = await emissionClient.GetHotelEmission(yearlyNumberOfFlights);

            return(mapper.Map <CarbonFootprintResult>(response));
        }
コード例 #4
0
    protected override void nextBlockObject()
    {
        _selectFlight = _bullectOp.flightType(_currentCount++);
        if (_selectFlight == null)
        {
            _nextObjectChack = false;
            return;
        }

        Vector3 endPosition = Vector3.zero;

        if (_RandomAngle)
        {
            endPosition         = _selfTF.eulerAngles;
            endPosition.z       = Random.Range(0, 360);
            _selfTF.eulerAngles = endPosition;
        }

        _selectFlight.resetValue(_nonresetValue);

        _drowPoint     = Vector3.zero;
        _chackDrowTime = _selectFlight.drowTIme;
        _smoothOption  = _selectFlight.smoothOption;
        _currentTime   = 0;

        if (_currentCount < _bullectOp.maxFlightTypeCount && _chackDrowTime > 0)
        {
            _nextObjectChack = true;
        }
        else
        {
            _nextObjectChack = false;
        }

        this.enabled = true;
        controlMoveOption();
    }
コード例 #5
0
 private void GetFareTypesInParallelThread(FlightOption option)
 {
     Task<FareType> oServiceFeetask = Task<FareType>.New((object o) => FareHelper.GetItineraryServiceFee(option, this.ProviderModel), option);
     option.FreeVolatileData.Add("ServicesFeesTask", oServiceFeetask);
     oServiceFeetask.Start();
 }
コード例 #6
0
        //    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;
        }
コード例 #7
0
        static void Main(string[] args)
        {
            //
            // PING REQUEST
            //
            String payload     = "this my payload; there are many like it but this one is mine";
            String someTraceId = "doesntmatter-8176";
            String originApp   = "UAPI";

            //set up the request parameters into a PingReq object
            PingReq req = new PingReq();

            req.Payload = payload;
            req.TraceId = someTraceId;

            ConsoleApplication1.SystemService.BillingPointOfSaleInfo billSetInfo = new ConsoleApplication1.SystemService.BillingPointOfSaleInfo();
            billSetInfo.OriginApplication = originApp;

            req.BillingPointOfSaleInfo = billSetInfo;
            req.TargetBranch           = CommonUtility.GetConfigValue(ProjectConstants.G_TARGET_BRANCH);
            Console.WriteLine(req);



            try {
                //run the ping request
                //WSDLService.sysPing.showXML(true);
                SystemPingPortTypeClient client = new SystemPingPortTypeClient("SystemPingPort", WsdlService.SYSTEM_ENDPOINT);
                //Console.WriteLine(client.Endpoint);
                client.ClientCredentials.UserName.UserName = Helper.RetrunUsername();
                client.ClientCredentials.UserName.Password = Helper.ReturnPassword();

                /*var httpHeaders = new Dictionary<string, string>();
                 * httpHeaders.Add("Username", "travelportsuperadmin");
                 * httpHeaders.Add("Password", "abc123");
                 * client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders));*/

                /*HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
                 * httpRequestProperty.Headers[HttpRequestHeader.Authorization] = "Basic " +
                 *  Convert.ToBase64String(Encoding.ASCII.GetBytes(client.ClientCredentials.UserName.UserName +
                 *  ":" + client.ClientCredentials.UserName.Password));
                 *
                 * using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                 *  {
                 *      OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] =
                 *          httpRequestProperty;
                 *      return client.processRequest(castRequest) as TSRsp;
                 *  }
                 *
                 *
                 * OperationContext.Current.OutgoingMessageProperties*/



                var httpHeaders = Helper.ReturnHttpHeader();
                client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders));


                PingRsp rsp = client.service(req);
                //print results.. payload and trace ID are echoed back in response
                Console.WriteLine(rsp.Payload);
                //Console.WriteLine(rsp.TraceId);
                //Console.WriteLine(rsp.TransactionId);

                AirportDetails airports = new AirportDetails();
                //Here we are getting the list of airports, we can use it anyway we want
                IDictionary <String, String> airportsList = airports.AllAirportsList();


                //Here we are getting the list of airports in a particular city, we are harcoding the city as New York here
                IDictionary <String, String> airportInCityList = airports.GetAllAiportsFromParticualrCity("New York");


                AirSvcTest airTest = new AirSvcTest();
                airTest.Availability();

                AirLFSTest lfsTest        = new AirLFSTest();
                Boolean    solutionResult = false; //Change it to true if you want AirPricingSolution, by default it is false
                                                   //and will send AirPricePoint in the result
                LowFareSearchRsp lowFareRsp = lfsTest.LowFareShop(solutionResult);

                if (lowFareRsp != null)
                {
                    typeBaseAirSegment[]      airSegments     = lowFareRsp.AirSegmentList;
                    List <typeBaseAirSegment> pricingSegments = new List <typeBaseAirSegment>();

                    IEnumerator        items      = lowFareRsp.Items.GetEnumerator();
                    AirPricingSolution lowestFare = null;
                    AirPricePoint      lowest     = null;

                    while (items.MoveNext())
                    {
                        if (solutionResult)
                        {
                            AirPricingSolution airPricingSolution = (AirPricingSolution)items.Current;
                            if (lowestFare == null)
                            {
                                lowestFare = airPricingSolution;
                            }
                            else
                            {
                                if (Helper.ConvertToDecimal(lowestFare.TotalPrice) > Helper.ConvertToDecimal(airPricingSolution.TotalPrice))
                                {
                                    lowestFare = airPricingSolution;
                                }
                            }
                        }
                        else
                        {
                            AirPricePointList airPricePointList = (AirPricePointList)items.Current;

                            if (airPricePointList != null)
                            {
                                foreach (var airPricePoint in airPricePointList.AirPricePoint)
                                {
                                    if (lowest == null)
                                    {
                                        lowest = airPricePoint;
                                    }
                                    else
                                    {
                                        if (Helper.ConvertToDecimal(lowest.TotalPrice) > Helper.ConvertToDecimal(airPricePoint.TotalPrice))
                                        {
                                            lowest = airPricePoint;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (lowestFare != null)
                    {
                        IEnumerator journeys = lowestFare.Journey.GetEnumerator();
                        while (journeys.MoveNext())
                        {
                            Journey journeyDetails = (Journey)journeys.Current;
                            if (journeyDetails != null)
                            {
                                AirSegmentRef[] segmentRef     = journeyDetails.AirSegmentRef;
                                string          refKey         = segmentRef[0].Key;
                                IEnumerator     airSegmentList = airSegments.GetEnumerator();
                                while (airSegmentList.MoveNext())
                                {
                                    typeBaseAirSegment airSeg = (typeBaseAirSegment)airSegmentList.Current;
                                    if (airSeg.Key.CompareTo(refKey) == 0)
                                    {
                                        pricingSegments.Add(airSeg);
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    if (lowest != null)
                    {
                        IEnumerator pricingInfos = lowest.AirPricingInfo.GetEnumerator();

                        while (pricingInfos.MoveNext())
                        {
                            AirPricingInfo priceInfo = (AirPricingInfo)pricingInfos.Current;
                            if (priceInfo != null)
                            {
                                foreach (var flightOption in priceInfo.FlightOptionsList)
                                {
                                    FlightOption option  = flightOption;
                                    IEnumerator  options = option.Option.GetEnumerator();
                                    if (options.MoveNext())
                                    {
                                        Option opt = (Option)options.Current;
                                        if (opt != null)
                                        {
                                            IEnumerator bookingInfoList = opt.BookingInfo.GetEnumerator();
                                            if (bookingInfoList.MoveNext())
                                            {
                                                BookingInfo bookingInfo = (BookingInfo)bookingInfoList.Current;
                                                if (bookingInfo != null)
                                                {
                                                    String      key            = bookingInfo.SegmentRef;
                                                    IEnumerator airSegmentList = airSegments.GetEnumerator();
                                                    while (airSegmentList.MoveNext())
                                                    {
                                                        typeBaseAirSegment airSeg = (typeBaseAirSegment)airSegmentList.Current;
                                                        if (airSeg.Key.CompareTo(key) == 0)
                                                        {
                                                            pricingSegments.Add(airSeg);
                                                            break;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }

                                    break;
                                }
                            }
                        }
                    }

                    AirPriceRsp        priceRsp    = AirReq.AirPrice(pricingSegments);
                    AirPricingSolution lowestPrice = null;
                    if (priceRsp != null)
                    {
                        if (priceRsp.AirPriceResult != null)
                        {
                            IEnumerator priceResults = priceRsp.AirPriceResult.GetEnumerator();
                            if (priceResults.MoveNext())//We would take  the first Price Result and will Search for the lowest Price
                            {
                                AirPriceResult result = (AirPriceResult)priceResults.Current;
                                if (result.AirPricingSolution != null)
                                {
                                    IEnumerator priceingSolutions = result.AirPricingSolution.GetEnumerator();
                                    while (priceingSolutions.MoveNext())
                                    {
                                        AirPricingSolution priceSol = (AirPricingSolution)priceingSolutions.Current;
                                        if (lowestPrice == null)
                                        {
                                            lowestPrice = priceSol;
                                        }
                                        else
                                        {
                                            if (Helper.ConvertToDecimal(lowestPrice.TotalPrice) > Helper.ConvertToDecimal(priceSol.TotalPrice))
                                            {
                                                lowestPrice = priceSol;
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        if (lowestPrice != null && priceRsp.AirItinerary != null)
                        {
                            AirBookTest book = new AirBookTest();
                            ConsoleApplication1.UniversalService.AirCreateReservationRsp bookResponse = book.AirBook(lowestPrice, priceRsp.AirItinerary);

                            if (bookResponse != null)
                            {
                                var urLocatorCode = bookResponse.UniversalRecord.LocatorCode;
                                Console.WriteLine("Universal Record Locator Code :" + urLocatorCode);
                                UniversalRetrieveTest univ = new UniversalRetrieveTest();
                                univ.RetrieveRecord(urLocatorCode);
                            }
                        }
                    }
                }
            } catch (Exception e) {
                //usually only the error message is useful, not the full stack
                //trace, since the stack trace in is your address space...
                Console.WriteLine("Error : " + e.Message);
            }
        }