private async Task getHistoricalTimeLine() { try { string response = string.Empty; DeserializeJSON deserializeJson = new DeserializeJSON(); if (Properties.Settings.Default.isInternet) { GETHandler apiHandler = new GETHandler(); apiHandler.endPoint = string.Format("https://covid19.mathdro.id/api/daily"); response = apiHandler.GETRequest(); } else { response = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\APIJson\daily.json"; } //Getting data from json. await CreateStatsGraph(deserializeJson.getHistoricalTimeline(response)); await Task.CompletedTask; } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private async Task getAllCountryName() { string response = string.Empty; DeserializeJSON deserializeJson = new DeserializeJSON(); if (Properties.Settings.Default.isInternet) { GETHandler apiHandler = new GETHandler(); apiHandler.endPoint = string.Format("https://disease.sh/v2/countries"); response = apiHandler.GETRequest(); } else { response = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\APIJson\countries.json"; } //Getting data from json. var countrynamedata = deserializeJson.getAllCountryName(response); foreach (var item in countrynamedata) { comboBox1.Items.Add(string.Format("{0}", item.ToString())); } await Task.CompletedTask; }
private async Task getCountryData(string _countryname) { try { string response = string.Empty; DeserializeJSON deserializeJson = new DeserializeJSON(); if (Properties.Settings.Default.isInternet) { GETHandler apiHandler = new GETHandler(); apiHandler.endPoint = string.Format( string.Format("https://disease.sh/v2/countries/{0}", _countryname)); response = apiHandler.GETRequest(); } else { response = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + string.Format(@"\APIJson\{0}.json", _countryname); } //Getting data from json. var countrydata = deserializeJson.getSpecificCountryData(response, _countryname); //cases, todayCases, deaths, todayDeaths, recovered, active, critical, flag, iso2, iso3 lblcases.Text = string.Format("{0:n0}", countrydata.Item1); lbltodaycases.Text = string.Format("{0:n0}", countrydata.Item2); lbldeath.Text = string.Format("{0:n0}", countrydata.Item3); lbltodaydeath.Text = string.Format("{0:n0}", countrydata.Item4); lblrecovered.Text = string.Format("{0:n0}", countrydata.Item5); lblactive.Text = string.Format("{0:n0}", countrydata.Item6); lblcritical.Text = string.Format("{0:n0}", countrydata.Item7); _cases = countrydata.Item1; _recovered = countrydata.Item5; _death = countrydata.Item3; if (Properties.Settings.Default.isInternet) { pictureBox1.LoadAsync(countrydata.Item8); } else { } lbliso2.Text = countrydata.Item9; lbliso3.Text = countrydata.Item10; await Task.CompletedTask; } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private async Task downloadJson() { try { string response = string.Empty; GETHandler apiHandler = new GETHandler(); DeserializeJSON deserializeJson = new DeserializeJSON(); apiHandler.endPoint = string.Format("https://disease.sh/v2/countries"); response = apiHandler.GETRequest(); //Getting data from json. var countrynamedata = deserializeJson.getAllCountryName(response); if (countrynamedata.Count() >= 1) { bunifuProgressBar1.MaximumValue = countrynamedata.Count() + 3; foreach (var item in countrynamedata) { SetStatus(Classes.OpenURL.DownloadJson( string.Format("https://disease.sh/v2/countries/{0}", item.ToString()), item.ToString())); } SetStatus(Classes.OpenURL.DownloadJson("https://disease.sh/v2/all", "all")); SetStatus(Classes.OpenURL.DownloadJson("https://disease.sh/v2/countries/", "countries")); SetStatus(Classes.OpenURL.DownloadJson("https://covid19.mathdro.id/api/daily", "daily")); lblDescription.Text = "Download Complete."; } else { bunifuProgressBar1.MaximumValue = 1; SetStatus("Can't Connect to API"); bunifuButton1.Visible = true; } await Task.CompletedTask; } catch (Exception ex) { lblDescription.Text = ex.Message; } }
private async Task getCountriesDataAsync() { try { string response = string.Empty; DeserializeJSON deserializeJson = new DeserializeJSON(); if (Properties.Settings.Default.isInternet) { GETHandler apiHandler = new GETHandler(); apiHandler.endPoint = string.Format("https://disease.sh/v2/countries"); response = apiHandler.GETRequest(); } else { response = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\APIJson\countries.json"; } DisposeUserControl(flowLayoutPanel1); DisposeUserControl(flowLayoutPanel2); //Getting data from json. var countriesdata = deserializeJson.getCountriesData(response); ////putting the data to the label and long var newcountriesdata = countriesdata.OrderByDescending(item => item.Item2).ToList().GetRange(0, 3); foreach (var item in countriesdata) { AddCountryCard(item.Item1, item.Item2, item.Item4); } foreach (var item in newcountriesdata) { AddTopCountryCard(item.Item1, _totalcases, item.Item2, item.Item3); } countriesdata.Clear(); newcountriesdata.Clear(); await Task.CompletedTask; } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private async Task GetDataAsync(string _url) { try { string response = string.Empty; DeserializeJSON deserializeJson = new DeserializeJSON(); if (Properties.Settings.Default.isInternet) { GETHandler apiHandler = new GETHandler(); apiHandler.endPoint = string.Format(_url); response = apiHandler.GETRequest(); } else { response = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\APIJson\countries.json"; } var covidtogrid = deserializeJson.getDataToGrid(response); foreach (var item in covidtogrid) { bunifuDataGridView1.Rows.Add(new object[] { item.Item1, item.Item2, item.Item3, item.Item4, item.Item5, item.Item6, item.Item7, item.Rest.Item1 }); } await Task.CompletedTask; } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private async Task downloadJson1(string ccountry) { try { string response = string.Empty; GETHandler apiHandler = new GETHandler(); DeserializeJSON deserializeJson = new DeserializeJSON(); apiHandler.endPoint = string.Format("https://disease.sh/v2/countries"); response = apiHandler.GETRequest(); var countrynamedata = deserializeJson.getAllCountryName(response); Console.WriteLine(countrynamedata.Count().ToString()); if (countrynamedata.Count() > 0) { //Getting data from json. bunifuProgressBar1.MaximumValue = 1; SetStatus(Classes.OpenURL.DownloadJson( string.Format("https://disease.sh/v2/countries/{0}", ccountry), ccountry)); lblDescription.Text = "Download Complete."; } else { bunifuProgressBar1.MaximumValue = 1; SetStatus("Download Failed"); bunifuButton1.Visible = true; } await Task.CompletedTask; } catch (Exception ex) { lblDescription.Text = ex.Message; } }
private async Task getCovidDataAsync() { try { string response = string.Empty; DeserializeJSON deserializeJson = new DeserializeJSON(); if (Properties.Settings.Default.isInternet) { GETHandler apiHandler = new GETHandler(); apiHandler.endPoint = string.Format("https://disease.sh/v2/all"); response = apiHandler.GETRequest(); } else { response = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\APIJson\all.json"; } //Getting data from json. (totalcases, todaycases, deaths, todaydeahts, recovered, active, Updated) var coviddata = deserializeJson.getDailyData(response); //putting the data to the label and long lbltotalcases.Text = string.Format("{0:n0}", coviddata.Item1); lbltodaycases.Text = string.Format("+{0:n0}", coviddata.Item2); lbldeath.Text = string.Format("{0:n0}", coviddata.Item3); lbltodaydeaths.Text = string.Format("+{0:n0}", coviddata.Item4); lblrecovered.Text = string.Format("{0:n0}", coviddata.Item5); lblactive.Text = string.Format("Active: {0:n0}", coviddata.Item6); lblupdated.Text = coviddata.Item7; _totalcases = coviddata.Item1; _death = coviddata.Item2; _recovered = coviddata.Item3; await Task.CompletedTask; } catch (Exception ex) { Console.WriteLine(ex.Message); } }