コード例 #1
0
ファイル: Station.cs プロジェクト: Costo/BikeShare
 public static Station FromXml(XElement xml)
 {
     var station = new Station((int)xml.Element("id"))
     {
         Name = (string)xml.Element("name"),
         Latitude = (double)xml.Element("lat"),
         Longitude = (double)xml.Element("long"),
         BikesAvailable = (int)xml.Element("nbBikes"),
         DocksAvailable = (int)xml.Element("nbEmptyDocks"),
     };
     return station;
 }
コード例 #2
0
ファイル: VelovCrawler.cs プロジェクト: Costo/BikeShare
 public void StationLoop(Station[] stations)
 {
     while(true)
     {
         try
         {
             var forEach = Parallel.ForEach(stations, x => new VelovStationCrawler(x, svc).Run());
         }
         catch (AggregateException e)
         {
             e.Handle(x =>
             {
                 System.Console.WriteLine(x.Message);
                 return true;
             });
         }
         Thread.Sleep(TimeSpan.FromMinutes(4));
     }
 }
コード例 #3
0
ファイル: BicingCrawler.cs プロジェクト: Costo/BikeShare
 public StationCrawler(Station station, NameValueCollection values, BikeShareWriteService svc)
 {
     this.station = station;
     this.values = values;
     this.svc = svc;
 }
コード例 #4
0
 public void Store(string system, Station station)
 {
     Cache.Client.Store(StoreMode.Set, "system_" + system + "_station_" + station.Id, station);
 }
コード例 #5
0
 public void Store(string system, Station[] stations)
 {
     Cache.Client.Store(StoreMode.Set, "system_" + system, stations);
 }
コード例 #6
0
 public VelovStationCrawler(Station station, BikeShareWriteService svc)
 {
     this.svc = svc;
     this.station = station;
     this.uri = new Uri(string.Format(StationDataUrlFormat, station.Id), UriKind.Absolute);
 }
コード例 #7
0
ファイル: VelovCrawler.cs プロジェクト: Costo/BikeShare
        private Station[] Parse(Task<string>[] tasks)
        {
            var stations = new List<Station>();
            foreach (var t in tasks)
            {
                if (t.Status == TaskStatus.RanToCompletion)
                {
                    dynamic json = Newtonsoft.Json.JsonConvert.DeserializeObject(t.Result);
                    foreach (var m in json.markers)
                    {
                        var station = new Station((int)m.numStation)
                        {
                            Latitude = m.x,
                            Longitude = m.y,
                            Name = m.nomStation
                        };
                        stations.Add(station);
                    }

                }
            }
            return stations.ToArray();
        }