Esempio n. 1
0
 public TDispatchIntegration(Gateway tripthru, string apiKey,
                             string fleetAuth, string fleetAccessToken, string fleetRefreshToken,
                             string passengerAuth, string passengerAccessToken, string passengerRefreshToken, string passengerProxyPK,
                             List <Fleet> fleets, List <VehicleType> vehicleTypes)
     : base("TDispatch", "TDispatch")
 {
     this.tripthru     = tripthru;
     this.fleets       = fleets;
     this.vehicleTypes = vehicleTypes;
     api = new TDispatchAPI(apiKey: apiKey,
                            fleetAuth: fleetAuth, fleetAccessToken: fleetAccessToken, fleetRefreshToken: fleetRefreshToken,
                            passengerAuth: passengerAuth, passengerAccessToken: passengerAccessToken, passengerRefreshToken: passengerRefreshToken, passengerProxyPK: passengerProxyPK);
     TDispatchAPI.GetFleetResponse getFleetResponse = api.GetFleet();
     name = getFleetResponse.fleet.name;
     ID   = getFleetResponse.fleet.pk;
 }
Esempio n. 2
0
        Status ConvertTDispatchStatusToTripThruStatus(string status, TDispatchAPI.Booking.SubStatus sub_status)
        {
            switch (status)
            {
                case "missed": return Status.Cancelled;
                case "dispatched": return Status.Dispatched;
                case "incoming": return Status.Queued;
                case "completed": return Status.Complete;
                case "rejected": return Status.Rejected;
                case "cancelled": return Status.Cancelled;
                case "confirmed": return Status.Confirmed;
                case "active":
                    {
                        if (sub_status.is_on_way_to_job)
                            return Status.Enroute;
                        if (sub_status.is_arrived_waiting)
                            return Status.ArrivedAndWaiting;
                        return Status.PickedUp;
                    }

                default: throw new Exception("fatal error");
            }
        }
Esempio n. 3
0
 public TDispatchIntegration(Gateway tripthru, string apiKey,
     string fleetAuth, string fleetAccessToken, string fleetRefreshToken,
     string passengerAuth, string passengerAccessToken, string passengerRefreshToken, string passengerProxyPK,
     List<Fleet> fleets, List<VehicleType> vehicleTypes)
     : base("TDispatch", "TDispatch")
 {
     this.tripthru = tripthru;
     this.fleets = fleets;
     this.vehicleTypes = vehicleTypes;
     api = new TDispatchAPI(apiKey: apiKey,
         fleetAuth: fleetAuth, fleetAccessToken: fleetAccessToken, fleetRefreshToken: fleetRefreshToken,
         passengerAuth: passengerAuth, passengerAccessToken: passengerAccessToken, passengerRefreshToken: passengerRefreshToken, passengerProxyPK: passengerProxyPK);
     TDispatchAPI.GetFleetResponse getFleetResponse = api.GetFleet();
     name = getFleetResponse.fleet.name;
     ID = getFleetResponse.fleet.pk;
 }
Esempio n. 4
0
        public void UpdateBooking(string tripID, TDispatchAPI.Booking value)
        {
            Status activeTrip = ConvertTDispatchStatusToTripThruStatus(activeTrips[tripID].status,
                activeTrips[tripID].sub_status);
            Status valueTrip = ConvertTDispatchStatusToTripThruStatus(value.status,
                value.sub_status);

            if (activeTrip == valueTrip)
                return;

            Logger.BeginRequest("TDispatch trip " + tripID + " update", null, tripID);
            string bookingPK = activeTrips[tripID].pk;
            if (value.pk == null)
                value.pk = bookingPK;

            activeTrips[tripID] = value;

            Logger.Log("BookingStatus changed ", value);
            Logger.Log("Notify originating partner through TripThru");
            Logger.Tab();
            Location newLocation = null;

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

            if (getBookingStatusResponse.booking.driver != null)
                if (getBookingStatusResponse.booking.driver.location != null)
                    if (getBookingStatusResponse.booking.driver.location.lat != null)
                        if (getBookingStatusResponse.booking.driver.location.lng != null)
                            newLocation = new Location((double)getBookingStatusResponse.booking.driver.location.lat, (double)getBookingStatusResponse.booking.driver.location.lng);

            Gateway.UpdateTripStatusRequest request = new Gateway.UpdateTripStatusRequest(
                clientID: ID,
                tripID: tripID,
                status: ConvertTDispatchStatusToTripThruStatus(value.status, value.sub_status),
                driverLocation: newLocation);
            tripthru.UpdateTripStatus(request);
            Logger.Untab();
            if (activeTrips[tripID].status == "completed" || activeTrips[tripID].status == "cancelled" ||
                        activeTrips[tripID].status == "rejected" || activeTrips[tripID].status == "missed")
                activeTrips.Remove(tripID);
            Logger.EndRequest(null);
        }
Esempio n. 5
0
        public void UpdateBooking(string tripID, TDispatchAPI.Booking value)
        {
            if (activeTrips[tripID].status == value.status)
                return;

            Logger.BeginRequest("TDispatch trip " + tripID + " update", null, tripID);
            string bookingPK = activeTrips[tripID].pk;
            if (value.pk == null)
                value.pk = bookingPK;

            activeTrips[tripID] = value;

            Logger.Log("BookingStatus changed ", value);
            Logger.Log("Notify originating partner through TripThru");
            Logger.Tab();
            Gateway.UpdateTripStatusRequest request = new Gateway.UpdateTripStatusRequest(
                clientID: ID,
                tripID: tripID,
                status: ConvertTDispatchStatusToTripThruStatus(value.status, value.sub_status));
            tripthru.UpdateTripStatus(request);
            Logger.Untab();
            if (activeTrips[tripID].status == "completed" || activeTrips[tripID].status == "cancelled" ||
                        activeTrips[tripID].status == "rejected" || activeTrips[tripID].status == "missed")
                activeTrips.Remove(tripID);
            Logger.EndRequest(null);
        }