public void GetNextTripsForStop_Test() { var result = TranspoService.GetNextTripsForStop("3037", "97").Result; Assert.IsNotNull(result); //foreach (var routeDirection in result.GetNextTripsForStopResult.Route.RouteDirection) //{ // foreach (var trip in routeDirection.Trips.Trip) // { // Debug.WriteLine($"{trip.AdjustmentAge} | {trip.GetArrivalTime(result.TimeOfRequest)}"); // } //} }
public async void GetRouteInfo() { // If the Stop Number or Route Number hasn't been supplied, Stop the Timer and exit if (string.IsNullOrWhiteSpace(StopNumber) || string.IsNullOrWhiteSpace(RouteNumber)) { StopApiCall(); return; } // Rate Limit the API Call with the GPS Update Time //if (DateTime.Now <= APICallLastMade.AddSeconds(OCTranspoService.GPS_UPDATE_EVERY_SECONDS)) //{ // UpdateArrivalMinutes(); // return; //} // Make the API Call var result = await _ocTranspo.GetNextTripsForStop(StopNumber, RouteNumber); if (result == null) { APICallLastMade = DateTime.Now; return; } // Check if there was an error in the API if (!string.IsNullOrWhiteSpace(result.GetNextTripsForStopResult.Error)) { Debug.WriteLine(result.GetNextTripsForStopResult.Error); StopApiCall(); return; } // Cache the API Call ApiResult = result; APICallLastMade = result.TimeOfResponse; // Update the Route & Trip Information var route = result.GetNextTripsForStopResult.Route; if (route.RouteDirection.Count > 0) { FirstRoute = route.RouteDirection[0]; } if (FirstRoute.Trips.Trip.Count > 0) { FirstTrip = FirstRoute.Trips.Trip[0]; switch (FirstTrip.TripSource) { case OCTranspo_Net.Models.States.TripDataSource.GPS: IsGPSData = true; break; case OCTranspo_Net.Models.States.TripDataSource.None: case OCTranspo_Net.Models.States.TripDataSource.Schedule: default: IsGPSData = false; break; } UpdateArrivalMinutes(); } }