Exemplo n.º 1
0
 private async void btnValues_Click(object sender, EventArgs e)
 {
     var mr = new MakeRequest();
     //await getCountries();
     using (var _db = new GLOBALEDGE_MVCEntities())
     {
         var countryList = _db.Countries.Select(a=>new CountriesWithID{countryid=a.CountryID, iso2code=a.iso2code, name=a.NameCIA});
         var indicatorList = _db.DIBS_Fields.Where(a => a.SourceID == 38 && a.DateDataUpdated < dateTimePicker.Value).Select(a => a.FieldID).ToList();
         foreach (var indicator in indicatorList)
         {
             textBox1.Invoke(new UpdateTextBox(UpdateText), indicator + " is being updated");
             List<IndicatorData> indicatorData = await mr.getIndicatorValues(indicator);
             foreach (var i in indicatorData)
             {
                 if (!i.value.HasValue)
                 {
                     continue;
                 }
                 // Checks to see if it's in our country list.
                 var country = countryList.FirstOrDefault(a => a.iso2code == i.country.id);
                 if (country == null)
                 {
                     continue;
                 }
                 _db.DIBS_Insert_Data(indicator, i.value, i.date, country.countryid);
             }
             updateField(indicator);
         }
     }
 }
Exemplo n.º 2
0
 private async void button1_Click(object sender, EventArgs e)
 {
     var mr = new MakeRequest();
     var indicators = mr.getAllIndicators();
     List<Indicators> ind = await indicators;
     using (var _db = new GLOBALEDGE_MVCEntities())
     {
         foreach (var i in ind)
         {
             Match m = Regex.Match(i.name.Trim(), @"(.*)\((.*)\)+$");
             string name = "", unit = "";
             if (m.Groups.Count > 1)
             {
                 name = m.Groups[1].Value;
                 unit = m.Groups[2].Value;
             }
             else
             {
                 name = i.name;
             }
             var unitID = _db.DIBS_Insert_Unit(unit).First().UnitID;
             _db.SaveChanges();
             _db.DIBS_Field_Insert(i.id, i.name.Trim(), i.sourceNote.Trim(), unitID, 117, 38, true, false);
             _db.SaveChanges();
             textBox1.Invoke(new UpdateTextBox(UpdateText), i.name.Trim());
         }
     }
     mr.Dispose();
 }
Exemplo n.º 3
0
 private async Task getCountries()
 {
     var mr = new MakeRequest();
     var countries = mr.getAllCountries();
     List<Countries> country = await countries;
     using (var _db = new GLOBALEDGE_MVCEntities())
     {
         foreach (var i in country)
         {
             textBox1.Invoke(new UpdateTextBox(UpdateText), i.name + " ...");
             var c = _db.Countries.FirstOrDefault(a => a.Abbr == i.iso2code || a.NameCIA == i.name);
             if (c == null)
             {
                 continue;
             }
             c.iso2code = i.iso2code;
             _db.SaveChanges();
             textBox1.Invoke(new UpdateTextBox(UpdateText), i.name + " Updated");
         }
     }
 }
Exemplo n.º 4
0
 void updateField(string indicator)
 {
     using (var _db = new GLOBALEDGE_MVCEntities())
     {
         var i = _db.DIBS_Fields.FirstOrDefault(a => a.FieldID == indicator);
         i.DateDataUpdated = DateTime.Now;
         _db.SaveChanges();
     }
 }