Ejemplo n.º 1
0
        private void LoadRatesFromWeb(DateTime date)
        {
            try
            {
                ExRatesSoapClient ws   = new ExRatesSoapClient();
                DataSet           ds   = ws.ExRatesDaily(date);
                DataTable         dt   = ds.Tables["DailyExRatesOnDate"];
                DataRowCollection rows = dt.Rows;
                int rowIndexUsd        = 2;
                int rowIndexEuro       = 3;
                int rowIndexRur        = 21;

                edtEURO.Text = rows[rowIndexEuro]["Cur_OfficialRate"].ToString();
                edtUSD.Text  = rows[rowIndexUsd]["Cur_OfficialRate"].ToString();
                edtRUR.Text  = rows[rowIndexRur]["Cur_OfficialRate"].ToString();
            }
            catch (Exception)
            {
                edtEURO.Text = "1";
                edtUSD.Text  = "1";
                edtRUR.Text  = "1";
                MessageBox.Show("Не удалось загрузить курсы из интернета! Проверьте подключение.");
            }
            AddRates();
        }
Ejemplo n.º 2
0
 private DataSet getExRatesDaily()
 {
     if ((DateTime.Today != _lastUpdated_exRatesDaily) || (!_exRatesDaily.IsInitialized))
     {
         _exRatesDaily = rates.ExRatesDaily(DateTime.Today);
         if (_exRatesDaily.IsInitialized)
         {
             _lastUpdated_exRatesDaily = DateTime.Today;
         }
     }
     return(_exRatesDaily);
 }
Ejemplo n.º 3
0
        private void LoadRatesFromWeb(DateTime date)
        {
            try
             {
                ExRatesSoapClient ws = new ExRatesSoapClient();
                DataSet ds = ws.ExRatesDaily(date);
                DataTable dt = ds.Tables["DailyExRatesOnDate"];
                DataRowCollection rows = dt.Rows;
                int rowIndexUsd = 2;
                int rowIndexEuro = 3;
                int rowIndexRur = 21;

                edtEURO.Text = rows[rowIndexEuro]["Cur_OfficialRate"].ToString();
                edtUSD.Text = rows[rowIndexUsd]["Cur_OfficialRate"].ToString();
                edtRUR.Text = rows[rowIndexRur]["Cur_OfficialRate"].ToString();
            }
            catch (Exception)
            {
                edtEURO.Text = "1";
                edtUSD.Text = "1";
                edtRUR.Text = "1";
                MessageBox.Show("Не удалось загрузить курсы из интернета! Проверьте подключение.");
            }
            AddRates();
        }
Ejemplo n.º 4
0
 public static void GetRates(string absentDays)
 {
     ExRatesSoapClient client = null;
     DataSet cursies = null;
     List<string> dates = new List<string>();
     try
     {
         dates = (List<string>)SerializationHelper.FromXmlString(typeof(List<string>), absentDays);
         if (dates != null && dates.Count > 0)
         {
             logger.Info(string.Format("absent days count {0}", dates.Count));
             client = new ExRatesSoapClient();
             List<CurrRate> result = new List<CurrRate>();
             foreach (string date in dates)
             {
                 cursies = client.ExRatesDaily(DateTime.ParseExact(date, "dd/MM/yyyy", CultureInfo.InvariantCulture));
                 if (cursies != null)
                 {
                     foreach (DataRow row in cursies.Tables[0].Rows)
                     {
                         string cuurCode = row[3] as string;
                         if (neededCurrenciesCodes.Contains(cuurCode))
                         {
                             result.Add(new CurrRate(date, cuurCode, (decimal)row[2], COUNTRY_ID));
                         }
                     }
                 }
             }
             client.Close();
             SendResult(result);
         }
         else
             logger.Info(string.Format("absent days count {0}", dates.Count));
     }
     catch (Exception ex)
     {
         logger.Error("get rates error", ex);
     }
 }
Ejemplo n.º 5
0
 private IEnumerable <DataRow> GetRateRows(DateTime date)
 {
     return(_client.ExRatesDaily(date).Tables[0].Rows.OfType <DataRow>());
 }