Пример #1
0
 /// <summary>
 /// Creates a new feed.
 /// </summary>
 public GTFSFeed()
 {
     _feedInfo = new FeedInfo();
     this.Agencies = new UniqueEntityListCollection<Agency>(new List<Agency>(),
         (e, id) => { return e.Id == id; });
     this.CalendarDates = new EntityListCollection<CalendarDate>(new List<CalendarDate>(),
         (e, id) => { return e.ServiceId == id; });
     this.Calendars = new EntityListCollection<Calendar>(new List<Calendar>(),
         (e, id) => { return e.ServiceId == id; });
     this.FareAttributes = new EntityListCollection<FareAttribute>(new List<FareAttribute>(),
         (e, id) => { return e.FareId == id; });
     this.FareRules = new UniqueEntityListCollection<FareRule>(new List<FareRule>(),
         (e, id) => { return e.FareId == id; });
     this.Frequencies = new EntityListCollection<Frequency>(new List<Frequency>(),
         (e, id) => { return e.TripId == id; });
     this.Routes = new UniqueEntityListCollection<Route>(new List<Route>(),
         (e, id) => { return e.Id == id; });
     this.Shapes = new EntityListCollection<Shape>(new List<Shape>(),
         (e, id) => { return e.Id == id; });
     this.Stops = new UniqueEntityListCollection<Stop>(new List<Stop>(),
         (e, id) => { return e.Id == id; });
     this.StopTimes = new StopTimeListCollection(new List<StopTime>());
     this.Transfers = new TransferListCollection(new List<Transfer>());
     this.Trips = new UniqueEntityListCollection<Trip>(new List<Trip>(),
         (e, id) => { return e.Id == id; });
 }
Пример #2
0
        /// <summary>
        /// Sets the feed info.
        /// </summary>
        /// <param name="feedInfo"></param>
        public void SetFeedInfo(FeedInfo feedInfo)
        {
            string sql = "UPDATE feed SET feed_publisher_name = :feed_publisher_name, feed_publisher_url = :feed_publisher_url, feed_lang = :feed_lang, feed_start_date = :feed_start_date, feed_end_date = :feed_end_date, feed_version = feed_version WHERE ID = :id;";
            using (var command = _connection.CreateCommand())
            {
                command.CommandText = sql;
                command.Parameters.Add(new SQLiteParameter(@"feed_publisher_name", DbType.String));
                command.Parameters.Add(new SQLiteParameter(@"feed_publisher_url", DbType.String));
                command.Parameters.Add(new SQLiteParameter(@"feed_lang", DbType.String));
                command.Parameters.Add(new SQLiteParameter(@"feed_start_date", DbType.String));
                command.Parameters.Add(new SQLiteParameter(@"feed_end_date", DbType.String));
                command.Parameters.Add(new SQLiteParameter(@"feed_version", DbType.String));
                command.Parameters.Add(new SQLiteParameter(@"id", DbType.Int64));

                command.Parameters[0].Value = feedInfo.PublisherName;
                command.Parameters[1].Value = feedInfo.PublisherUrl;
                command.Parameters[2].Value = feedInfo.Lang;
                command.Parameters[3].Value = feedInfo.StartDate;
                command.Parameters[4].Value = feedInfo.EndDate;
                command.Parameters[5].Value = feedInfo.Version;
                command.Parameters[6].Value = _id;

                command.ExecuteNonQuery();
            }
        }
Пример #3
0
        /// <summary>
        /// Returns the feed info.
        /// </summary>
        /// <returns></returns>
        public FeedInfo GetFeedInfo()
        {
            FeedInfo feedInfo = null;
            string sql = "SELECT ID, feed_publisher_name, feed_publisher_url, feed_lang, feed_start_date, feed_end_date, feed_version FROM feed WHERE ID = :id;";
            using (var command = _connection.CreateCommand())
            {
                command.CommandText = sql;
                command.Parameters.Add(new SQLiteParameter(@"id", DbType.Int64));
                command.Parameters[0].Value = _id;

                using(var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        feedInfo = new FeedInfo();
                        feedInfo.PublisherName = reader.IsDBNull(1) ? null : reader.GetString(1);
                        feedInfo.PublisherUrl = reader.IsDBNull(2) ? null : reader.GetString(2);
                        feedInfo.Lang = reader.IsDBNull(3) ? null : reader.GetString(3);
                        feedInfo.StartDate = reader.IsDBNull(4) ? null : reader.GetString(4);
                        feedInfo.EndDate = reader.IsDBNull(5) ? null : reader.GetString(5);
                        feedInfo.Version = reader.IsDBNull(6) ? null : reader.GetString(6);
                        break;
                    }
                }
            }
            return feedInfo;
        }
Пример #4
0
 /// <summary>
 /// Sets the feed info.
 /// </summary>
 /// <param name="feedInfo"></param>
 public void SetFeedInfo(FeedInfo feedInfo)
 {
     if (feedInfo != null)
     {
         _feedInfo.EndDate = feedInfo.EndDate;
         _feedInfo.Lang = feedInfo.Lang;
         _feedInfo.PublisherName = feedInfo.PublisherName;
         _feedInfo.PublisherUrl = feedInfo.PublisherUrl;
         _feedInfo.StartDate = feedInfo.StartDate;
         _feedInfo.Version = _feedInfo.Version;
     }
 }