private static void CacheTripTable(ref SQLiteDataReader reader, ref int processedRowCount, Stopwatch timeSoFar, ref string current_table_name, Action displayTableName, Action<int, Stopwatch> updateTimeUI, ref Dictionary<string, Trip> trips) { // Update the table name shown on the progress form if (displayTableName != null) displayTableName(); // Loop through the trips table and add the information to a dictionary keyed by trip_id try { while (reader.Read()) { ++processedRowCount; if (updateTimeUI != null) updateTimeUI(processedRowCount, timeSoFar); Trip trip = new Trip(); trip.route_id = reader["route_id"].ToString(); trip.service_id = reader["service_id"].ToString(); // Assign the correct wheelchair_accesssible enumerator value based on input string whchr = reader["wheelchair_accessible"].ToString(); if (whchr == null) { trip.wheelchair_accessible = TripRestrictionType.nodata; } else { Int16 wheelchair_accessible_int = Convert.ToInt16(whchr); if (wheelchair_accessible_int < 0 || wheelchair_accessible_int > 2) { trip.wheelchair_accessible = TripRestrictionType.nodata; } else { TripRestrictionType wheelchair_accessible = (TripRestrictionType)wheelchair_accessible_int; trip.wheelchair_accessible = wheelchair_accessible; } } // Assign the correct bikes_allowed enumerator value based on input string bike = reader["bikes_allowed"].ToString(); if (bike == null) { trip.bikes_allowed = TripRestrictionType.nodata; } else { Int16 bikes_allowed_int = Convert.ToInt16(bike); if (bikes_allowed_int < 0 || bikes_allowed_int > 2) { trip.bikes_allowed = TripRestrictionType.nodata; } else { TripRestrictionType bikes_allowed = (TripRestrictionType)bikes_allowed_int; trip.bikes_allowed = bikes_allowed; } } string trip_id = reader["trip_id"].ToString(); // Add the current trip to the dictionary of all trips trips.Add(trip_id, trip); } } catch (Exception e) { throw new Exception("Error caching trips table. Error: " + e.Message, e); } }
private bool IsTripRestricted(string trip_id, Trip tr) { if (m_RidingABicycle) { TripRestrictionType bikesValue = tr.bikes_allowed; if (bikesValue == TripRestrictionType.notallowed) { return true; } } if (m_UsingAWheelchair) { TripRestrictionType wheelchairValue = tr.wheelchair_accessible; if (wheelchairValue == TripRestrictionType.notallowed) { return true; } } if (m_ExcludeTrips != null) { bool junk; if (m_ExcludeTrips.TryGetValue(trip_id, out junk)) { return true;} } if (m_ExcludeRoutes != null) { bool junk; if (m_ExcludeRoutes.TryGetValue(tr.route_id, out junk)) { return true; } } return false; }
private static void CacheTripTable(ref SQLiteDataReader reader, ref int processedRowCount, Stopwatch timeSoFar, ref string current_table_name, Action displayTableName, Action <int, Stopwatch> updateTimeUI, ref Dictionary <string, Trip> trips) { // Update the table name shown on the progress form if (displayTableName != null) { displayTableName(); } // Loop through the trips table and add the information to a dictionary keyed by trip_id try { while (reader.Read()) { ++processedRowCount; if (updateTimeUI != null) { updateTimeUI(processedRowCount, timeSoFar); } Trip trip = new Trip(); trip.route_id = reader["route_id"].ToString(); trip.service_id = reader["service_id"].ToString(); // Assign the correct wheelchair_accesssible enumerator value based on input string whchr = reader["wheelchair_accessible"].ToString(); if (whchr == null) { trip.wheelchair_accessible = TripRestrictionType.nodata; } else { Int16 wheelchair_accessible_int = Convert.ToInt16(whchr); if (wheelchair_accessible_int < 0 || wheelchair_accessible_int > 2) { trip.wheelchair_accessible = TripRestrictionType.nodata; } else { TripRestrictionType wheelchair_accessible = (TripRestrictionType)wheelchair_accessible_int; trip.wheelchair_accessible = wheelchair_accessible; } } // Assign the correct bikes_allowed enumerator value based on input string bike = reader["bikes_allowed"].ToString(); if (bike == null) { trip.bikes_allowed = TripRestrictionType.nodata; } else { Int16 bikes_allowed_int = Convert.ToInt16(bike); if (bikes_allowed_int < 0 || bikes_allowed_int > 2) { trip.bikes_allowed = TripRestrictionType.nodata; } else { TripRestrictionType bikes_allowed = (TripRestrictionType)bikes_allowed_int; trip.bikes_allowed = bikes_allowed; } } string trip_id = reader["trip_id"].ToString(); // Add the current trip to the dictionary of all trips trips.Add(trip_id, trip); } } catch (Exception e) { throw new Exception("Error caching trips table. Error: " + e.Message, e); } }