private void Crawl(Dictionary <string, string> dictionary) { PastWeatherInput pastWeatherInput = new PastWeatherInput(); pastWeatherInput.query = CITY; pastWeatherInput.format = FORMAT; foreach (var item in dictionary) { pastWeatherInput.date = item.Key; pastWeatherInput.enddate = item.Value; WWOWeatherData weatherData = worker.GetPastWeather(pastWeatherInput); weatherDatas.Add(weatherData); lock (lockObject) { Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("Az alábbi év, hónap időjárási adata le lett töltve: " + item.Key); } //ImportantWeatherData important = new ImportantWeatherData(weatherData); foreach (var i in weatherData.data.weather) { SimpleWeather simple = new SimpleWeather(i); importantWeatherDatas.Add(simple); } } //ImportantWeatherData important; //foreach (var item in weatherDatas) //{ // important = new ImportantWeatherData(item); // importantWeatherDatas.Add(important); //} }
public string PremiumAPIKey = ""; //Az api kulcs helye public WWOWeatherData GetPastWeather(PastWeatherInput input) { // create URL based on input paramters string apiURL = ApiBaseURL + "past-weather.ashx?q=" + input.query + "&format=" + input.format + "&extra=" + input.extra + "&enddate=" + input.enddate + "&date=" + input.date + "&includelocation=" + input.includelocation + "&callback=" + input.callback + "&key=" + PremiumAPIKey; string result = RequestHandler.Process(apiURL); //itt a json sorokból tesszük át a normál formátumba WWOWeatherData pastweather = (WWOWeatherData) new JavaScriptSerializer().Deserialize(result, typeof(WWOWeatherData)); return(pastweather); }
public void Download() { Console.WriteLine("Letöltésre kész: " + Ev); semaphoreSlim.Wait(); Console.WriteLine("Letöltés megkezdve: " + Ev); APIEngine api = new APIEngine(); for (int i = 0; i < dataStart.Length; i++) { WWOWeatherData pastWeather = api.GetPastWeather(inputWeather); WeatherDatas.Add(pastWeather); } Thread.Sleep(1000); Console.WriteLine("Befejezte: " + Ev); semaphoreSlim.Release(); }
public Stopwatch GetDatas() { stopwatch = new Stopwatch(); stopwatch.Start(); APIEngine api = new APIEngine(); InputGenerator inputGenerator = new InputGenerator(); YearsInDictionary yearsInDictionary = new YearsInDictionary(); /*szekvenciálishoz*/ for (int i = 0; i < inputGenerator.startdates.Length; i++) { input.date = inputGenerator.startdates[i]; input.enddate = inputGenerator.enddates[i]; WWOWeatherData pastweather = api.GetPastWeather(input); WeatherDatas.Add(pastweather); } /*párhuzamos*/ //foreach (var item in yearsInDictionary.dictionaryList) //{ // foreach (var years in item) // { // input.date = years.Key; // input.enddate = years.Value; // WWOWeatherData pastweather = api.GetPastWeather(input); // WeatherDatas.Add(pastweather); // } //} stopwatch.Stop(); return(stopwatch); //string watch = stopwatch.ToString(); //return watch; }
public ImportantWeatherData(WWOWeatherData weatherData) { this.weatherData = weatherData; CallSimple(); }