Example #1
0
        void AddStop(StopData sd)
        {
            //Do we know about this in ther DB?
            var  stop = GetStop(sd);
            Stop si;

            if (stop != null)
            {
                si = new Stop(stop);
            }
            else
            {
                si = new Stop(sd);
            }


            if (stop != null)
            {
                stopdatabase.DeleteItem(si);
            }
            //Cache and Add
            stopdatabase.SaveItem(si);

            if (!Stops.Contains(sd))
            {
                Stops.Add(sd);
            }
            else
            {
                Stops.Remove(sd);
                Stops.Add(sd);
            }
        }
Example #2
0
        private void LoadStops(List <string[]> stopsData)
        {
            Console.WriteLine(this + "Loading Stops...");
            var watch = Stopwatch.StartNew();

            foreach (var stopData in stopsData)
            {
                var stop = new Stop(int.Parse(stopData[0]), stopData[1], stopData[2], double.Parse(stopData[4]),
                                    double.Parse(stopData[5]));
                if (!Stops.Contains(stop))
                {
                    Stops.Add(stop);
                }
            }
            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;
            var seconds   = elapsedMs * 0.001;

            Console.WriteLine(this.ToString() + Stops.Count + " stops were successfully loaded in " + seconds +
                              " seconds.");
        }