Exemple #1
0
        public void GetData()
        {
            bikeStationsDic = new Dictionary <Network, List <BikeStation> >();
            BikeAPIManager bikeApiManager = new BikeAPIManager();

            networks = bikeApiManager.GetAllCities().Result;
            int totalNetworks = networks.Count();
            int i             = 1;

            foreach (Network network in networks)
            {
                List <BikeStation> bikeStations = bikeApiManager.GetCityBikeStations(network).Result;
                bikeStationsDic.Add(network, bikeStations);
                log.Info($"GetData() Processing {i++}/{totalNetworks}: {network.Name}");
            }
        }
Exemple #2
0
        private void UpdateValues()
        {
            try
            {
                BikeAPIManager bikeApiManager = new BikeAPIManager();
                Networks       networks       = bikeApiManager.GetAllCities().Result;
                int            i = 0;
                foreach (Network network in networks)
                {
                    List <BikeStation> bikeStations = bikeApiManager.GetCityBikeStations(network).Result;
                    AFElement          cityElement  = piSystemManager.GetCity(network);

                    foreach (BikeStation bikeStation in bikeStations)
                    {
                        if (cont == false)
                        {
                            break;
                        }
                        AFElement stationElement = cityElement.Elements[bikeStation.FixedName];
                        if (stationElement == null)
                        {
                            bool result = piSystemManager.CreateBikeStation(bikeStation, cityElement);
                            stationElement = cityElement.Elements[bikeStation.FixedName];
                        }

                        if (stationElement != null)
                        {
                            AFValues values = piSystemManager.GetBikeStationValues(bikeStation, stationElement);
                            if ((values != null) && (values.Count > 0))
                            {
                                piSystemManager.UpdateValues(values);
                            }
                        }
                    }
                    if (cont == false)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("Error updating values...", ex);
                SetupProxies();
            }
        }