Esempio n. 1
0
        public override Gateway.DispatchTripResponse DispatchTrip(Gateway.DispatchTripRequest request)
        {
            Logger.BeginRequest("DispatchTrip sent to " + name, request);
            GatewayService.Dispatch dispatch = new GatewayService.Dispatch
            {
                access_token  = AccessToken,
                PassengerId   = request.passengerID,
                PassengerName = request.passengerName,
                Luggage       = request.luggage,
                Persons       = request.persons,
                PickupLat     = request.pickupLocation.Lat,
                PickupLng     = request.pickupLocation.Lng,
                PickupTime    = request.pickupTime,
                DropoffLat    = request.dropoffLocation == null ? (double?)null : request.dropoffLocation.Lat,
                DropoffLng    = request.dropoffLocation == null ? (double?)null : request.dropoffLocation.Lng,
                PaymentMethod = request.paymentMethod,
                VehicleType   = request.vehicleType,
                MaxPrice      = request.maxPrice,
                MinRating     = request.minRating,
                PartnerId     = request.partnerID,
                FleetId       = request.fleetID,
                DriverId      = request.driverID,
                TripId        = request.tripID
            };
            JsonServiceClient client = new JsonServiceClient(RootUrl);

            GatewayService.DispatchResponse resp     = client.Get <GatewayService.DispatchResponse>(dispatch);
            Gateway.DispatchTripResponse    response = new Gateway.DispatchTripResponse
            {
                result = resp.ResultCode,
            };
            Logger.EndRequest(response);
            return(response);
        }
Esempio n. 2
0
 public override Gateway.DispatchTripResponse DispatchTrip(Gateway.DispatchTripRequest request)
 {
     requests++;
     requests++; //Assuming Tripthru will quote itself in AutoDispatch
     Gateway.DispatchTripResponse resp = server.DispatchTrip(request);
     if (resp.result == Gateway.Result.Rejected)
     {
         rejects++;
     }
     if (resp.result == Result.OK)
     {
         var resp1 = GetTripStatus(new GetTripStatusRequest(request.clientID, request.tripID));
         if (resp1.distance != null)
         {
             distance = distance + resp1.distance.Value;
         }
         if (resp1.price != null)
         {
             fare = fare + resp1.price.Value;
         }
     }
     Gateway.DispatchTripResponse response = new Gateway.DispatchTripResponse
     {
         result = resp.result,
     };
     return(response);
 }
 public override Gateway.DispatchTripResponse DispatchTrip(Gateway.DispatchTripRequest request)
 {
     requests++;
     requests++; //Assuming Tripthru will quote itself in AutoDispatch
     Gateway.DispatchTripResponse resp = server.DispatchTrip(request);
     if (resp.result == Gateway.Result.Rejected)
     {
         rejects++;
     }
     Gateway.DispatchTripResponse response = new Gateway.DispatchTripResponse
     {
         result = resp.result,
     };
     return(response);
 }
Esempio n. 4
0
        public override Gateway.DispatchTripResponse DispatchTrip(Gateway.DispatchTripRequest request)
        {
            Logger.BeginRequest("DispatchTrip recieved from " + tripthru.name, request, request.tripID);
            Gateway.DispatchTripResponse response = null;
            {
                // TDispatch requires that we supply the string address and postal code in addition to the Lng/Lat coordinates
                Pair <string, string> pickup_address  = MapTools.GetReverseGeoLocAddress(request.pickupLocation);
                Pair <string, string> dropoff_address = MapTools.GetReverseGeoLocAddress(request.dropoffLocation);

                TDispatchAPI.CreateBookingRequest createRequest = new TDispatchAPI.CreateBookingRequest
                {
                    passenger       = api.passengerProxyPK,
                    customer_name   = request.passengerName,
                    luggage         = 1,
                    passengers      = 1,
                    payment_method  = "cash",
                    pickup_location = new TDispatchAPI.Address
                    {
                        address  = pickup_address.First,
                        location = new TDispatchAPI.Location {
                            lat = request.pickupLocation.Lat, lng = request.pickupLocation.Lng
                        },
                        postcode = pickup_address.Second
                    },
                    pickup_time      = request.pickupTime.ToString("yyyy-MM-dd'T'HH:mm:ssK", DateTimeFormatInfo.InvariantInfo),
                    dropoff_location = new TDispatchAPI.Address
                    {
                        address  = dropoff_address.First,
                        location = new TDispatchAPI.Location {
                            lat = request.dropoffLocation.Lat, lng = request.dropoffLocation.Lng
                        },
                        postcode = dropoff_address.Second
                    },
                    status   = "incoming",
                    pre_paid = false
                };
                TDispatchAPI.CreateBookingResponse createResponse = api.CreateBooking(createRequest);
                if (createResponse.booking.pk == null)
                {
                    throw new Exception("Fatal Error: null booking pk");
                }
                activeTrips.Add(request.tripID, createResponse.booking); // TODO: need to clean these up later
                response = new Gateway.DispatchTripResponse(createResponse.status_code == 200 ? Result.OK : Result.UnknownError);
            }
            Logger.EndRequest(response);
            return(response);
        }
Esempio n. 5
0
        public override Gateway.DispatchTripResponse DispatchTrip(Gateway.DispatchTripRequest request)
        {
            Uri uri;

            if (!Uri.TryCreate(RootUrl, UriKind.Absolute, out uri))
            {
                return new Gateway.DispatchTripResponse
                       {
                           result = Result.InvalidParameters
                       }
            }
            ;
            Logger.BeginRequest("DispatchTrip sent to " + name, request);
            //Logger.Log("RootURL: " + RootUrl);
            GatewayService.Trip dispatch = new GatewayService.Trip
            {
                access_token  = AccessToken,
                PassengerId   = request.passengerID,
                PassengerName = request.passengerName,
                Luggage       = request.luggage,
                Persons       = request.persons,
                PickupLat     = request.pickupLocation.Lat,
                PickupLng     = request.pickupLocation.Lng,
                PickupTime    = request.pickupTime,
                DropoffLat    = request.dropoffLocation == null ? (double?)null : request.dropoffLocation.Lat,
                DropoffLng    = request.dropoffLocation == null ? (double?)null : request.dropoffLocation.Lng,
                PaymentMethod = request.paymentMethod,
                VehicleType   = request.vehicleType,
                MaxPrice      = request.maxPrice,
                MinRating     = request.minRating,
                PartnerId     = request.partnerID,
                FleetId       = request.fleetID,
                DriverId      = request.driverID,
                TripId        = request.tripID
            };
            JsonServiceClient client = new JsonServiceClient(RootUrl);

            client.Timeout = timeout;
            GatewayService.TripResponse  resp     = client.Post <GatewayService.TripResponse>(dispatch);
            Gateway.DispatchTripResponse response = new Gateway.DispatchTripResponse
            {
                result = resp.ResultCode,
            };
            Logger.EndRequest(response);
            return(response);
        }