Example #1
0
        public override Gateway.GetTripStatusResponse GetTripStatus(Gateway.GetTripStatusRequest request)
        {
            Logger.BeginRequest("GetTripStatus received from " + tripthru.name, request, request.tripID);
            Gateway.GetTripStatusResponse response = null;
            if (activeTrips.ContainsKey(request.tripID))
            {
                string bookingPK = activeTrips[request.tripID].pk;

                TDispatchAPI.GetBookingStatusResponse getBookingStatusResponse = api.GetBookingStatus(bookingPK);

                TDispatchAPI.GetBookingResponse getBookingResponse = api.GetBooking(bookingPK);

                TDispatchAPI.Booking booking = getBookingStatusResponse.booking;
                booking.Merge(getBookingResponse.booking);

                TDispatchAPI.GetFareResponse fare = api.GetFare(new TDispatchAPI.GetFareRequest
                {
                    way_points  = booking.way_points,
                    pickup_time =
                        booking.pickup_time != null
                            ? ((DateTime)booking.pickup_time).ToString("yyyy-MM-dd'T'HH:mm:ssK",
                                                                       DateTimeFormatInfo.InvariantInfo)
                            : null,
                    pickup_location  = booking.pickup_Location.location,
                    dropoff_location = booking.dropoff_Location.location,
                    dropoff_time     =
                        booking.dropoff_time != null
                            ? ((DateTime)booking.dropoff_time).ToString("yyyy-MM-dd'T'HH:mm:ssK",
                                                                        DateTimeFormatInfo.InvariantInfo)
                            : null,
                    payment_method = booking.payment_method
                });

                response = new Gateway.GetTripStatusResponse(
                    partnerID: ID, partnerName: name, passengerName: booking.customerName,
                    pickupLocation: new Location((double)booking.pickup_Location.location.lat, (double)booking.pickup_Location.location.lng),
                    dropoffLocation: new Location((double)booking.dropoff_Location.location.lat, (double)booking.dropoff_Location.location.lng),
                    fleetID: booking.office.slug, fleetName: booking.office.name,
                    driverID: booking.driver != null ? booking.driver.pk : null,
                    driverName: booking.driver != null ? booking.driver.name : null,
                    driverLocation: booking.driver != null
                        ? new Location((double)booking.driver.location.lat,
                                       (double)booking.driver.location.lng)
                        : null, price: booking.cost.value, distance: fare.fare.distance.km,
                    result: Result.OK, status: this.ConvertTDispatchStatusToTripThruStatus(booking.status, booking.sub_status)
                    );
                if (booking.pk == null)
                {
                    booking.pk = bookingPK;
                }
                //activeTrips[request.tripID] = booking;
            }
            else
            {
                Logger.Log("Trip " + request.tripID + " not found");
                response = new GetTripStatusResponse(result: Result.NotFound);
            }
            Logger.EndRequest(response);
            return(response);
        }
Example #2
0
        public override Gateway.GetTripStatusResponse GetTripStatus(Gateway.GetTripStatusRequest request)
        {
            Uri uri;

            if (!Uri.TryCreate(RootUrl, UriKind.Absolute, out uri))
            {
                return new Gateway.GetTripStatusResponse
                       {
                           result = Result.InvalidParameters
                       }
            }
            ;
            Logger.BeginRequest("GetTripStatus sent to " + name, request);
            //Logger.Log("RootURL: " + RootUrl);
            JsonServiceClient client = new JsonServiceClient(RootUrl);

            client.Timeout = timeout;
            GatewayService.TripStatusResponse resp = client.Get <GatewayService.TripStatusResponse>(new GatewayService.TripStatus
            {
                access_token = AccessToken,
                TripId       = request.tripID
            });
            GetTripStatusResponse response;

            if (resp.ResultCode == Result.OK)
            {
                response = new Gateway.GetTripStatusResponse
                {
                    result                = Gateway.Result.OK,
                    ETA                   = resp.ETA,
                    passengerName         = resp.PassengerName,
                    driverID              = resp.DriverId,
                    driverLocation        = resp.DriverLocation,
                    driverInitialLocation = resp.DriverInitialLocation,
                    driverName            = resp.DriverName,
                    dropoffTime           = resp.DropoffTime,
                    dropoffLocation       = resp.DropoffLocation,
                    fleetName             = resp.FleetName,
                    fleetID               = resp.FleetId,
                    vehicleType           = resp.VehicleType,
                    status                = resp.Status,
                    partnerName           = resp.PartnerName,
                    partnerID             = resp.PartnerId,
                    pickupTime            = resp.PickupTime,
                    pickupLocation        = resp.PickupLocation,
                    distance              = resp.Distance,
                    driverRouteDuration   = resp.DriverRouteDuration,
                    price                 = resp.Price
                };
            }
            else
            {
                response = new Gateway.GetTripStatusResponse
                {
                    result = resp.ResultCode
                };
            }
            Logger.EndRequest(response);
            return(response);
        }
Example #3
0
        public override Gateway.GetTripStatusResponse GetTripStatus(Gateway.GetTripStatusRequest request)
        {
            Logger.BeginRequest("GetTripStatus sent to " + name, request);
            JsonServiceClient client = new JsonServiceClient(RootUrl);

            GatewayService.TripStatusResponse resp = client.Get <GatewayService.TripStatusResponse>(new GatewayService.TripStatus
            {
                access_token = AccessToken,
                TripId       = request.tripID
            });
            GetTripStatusResponse response;

            if (resp.ResultCode == Result.OK)
            {
                response = new Gateway.GetTripStatusResponse
                {
                    result              = Gateway.Result.OK,
                    ETA                 = resp.ETA,
                    passengerName       = resp.PassengerName,
                    driverID            = resp.DriverId,
                    driverLocation      = resp.DriverLocation,
                    driverName          = resp.DriverName,
                    dropoffTime         = resp.DropoffTime,
                    dropoffLocation     = resp.DropoffLocation,
                    fleetName           = resp.FleetName,
                    fleetID             = resp.FleetId,
                    vehicleType         = resp.VehicleType,
                    status              = resp.Status,
                    partnerName         = resp.PartnerName,
                    partnerID           = resp.PartnerId,
                    pickupTime          = resp.PickupTime,
                    pickupLocation      = resp.PickupLocation,
                    distance            = resp.Distance,
                    driverRouteDuration = resp.DriverRouteDuration,
                    price               = resp.Price
                };
            }
            else
            {
                response = new Gateway.GetTripStatusResponse
                {
                    result = resp.ResultCode
                };
            }
            Logger.EndRequest(response);
            return(response);
        }
Example #4
0
 public void ValidateTripThruStatus(PartnerTrip trip)
 {
     if (trip.origination != PartnerTrip.Origination.Foreign && trip.service != PartnerTrip.Origination.Foreign)
     {
         return;
     }
     Gateway.GetTripStatusResponse response = tripthru.GetTripStatus(new Gateway.GetTripStatusRequest(partner.ID, trip.ID));
     Assert.AreEqual(trip.status, response.status, "The trip local status is different in compare how gateway says. Trip ID: " + trip.ID);
     if (trip.status == Status.Enroute)
     {
         Assert.IsNotNull(response.driverLocation, "The trip is route but the driverLocation is null. Trip ID: " + trip.ID);
     }
     if (trip.status == Status.PickedUp)
     {
         Assert.IsTrue(response.driverLocation.Equals(trip.pickupLocation, tolerance: locationVerificationTolerance), "The trip is PickedUp but the driverLocation is out to the tolerance area. Trip ID: " + trip.ID);
     }
     if (trip.status == Status.Complete)
     {
         Assert.IsTrue(response.driverLocation.Equals(trip.dropoffLocation, tolerance: locationVerificationTolerance), "The trip is Complete but the driverLocation is out to the tolerance area. Trip ID: " + trip.ID);
     }
 }
 public override Gateway.GetTripStatusResponse GetTripStatus(Gateway.GetTripStatusRequest request)
 {
     requests++;
     Gateway.GetTripStatusResponse resp = server.GetTripStatus(request);
     Gateway.GetTripStatusResponse response;
     if (resp.result == Gateway.Result.OK)
     {
         response = new Gateway.GetTripStatusResponse
         {
             result              = Gateway.Result.OK,
             ETA                 = resp.ETA,
             passengerName       = resp.passengerName,
             driverID            = resp.driverID,
             driverLocation      = resp.driverLocation,
             driverName          = resp.driverName,
             dropoffTime         = resp.dropoffTime,
             dropoffLocation     = resp.dropoffLocation,
             fleetName           = resp.fleetName,
             fleetID             = resp.fleetID,
             vehicleType         = resp.vehicleType,
             status              = resp.status,
             partnerName         = resp.partnerName,
             partnerID           = resp.partnerID,
             pickupTime          = resp.pickupTime,
             pickupLocation      = resp.pickupLocation,
             distance            = resp.distance,
             driverRouteDuration = resp.driverRouteDuration,
             price               = resp.price
         };
     }
     else
     {
         response = new Gateway.GetTripStatusResponse
         {
             result = resp.result
         };
     }
     return(response);
 }