예제 #1
0
        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;
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
            }
        }