예제 #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();
        }
예제 #2
0
 public CurrencyServiceWrapper()
 {
     _client = new ExRatesSoapClient();
     _availablyCurrencies = new[]
     {
         CurrencyCode.AmericanDoll,
         CurrencyCode.Euro,
         CurrencyCode.RussianRub,
         CurrencyCode.UkraineHry
     };
 }
예제 #3
0
        public static void Execute(Action <ExRatesSoapClient> action)
        {
            ExRatesSoapClient serviceClient = new ExRatesSoapClient();

            try
            {
                action(serviceClient);

                serviceClient.Close();
            }
            catch (CommunicationException)
            {
                serviceClient.Abort();
            }
            catch (TimeoutException)
            {
                serviceClient.Abort();
            }
            catch (Exception)
            {
                serviceClient.Abort();
                throw;
            }
        }
예제 #4
0
        public static void Execute(Action<ExRatesSoapClient> action)
        {
            ExRatesSoapClient serviceClient = new ExRatesSoapClient();

            try
            {
                action(serviceClient);

                serviceClient.Close();
            }
            catch (CommunicationException)
            {
                serviceClient.Abort();
            }
            catch (TimeoutException)
            {
                serviceClient.Abort();
            }
            catch (Exception)
            {
                serviceClient.Abort();
                throw;
            }
        }
예제 #5
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);
     }
 }
예제 #6
0
 private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress()
 {
     return(ExRatesSoapClient.GetEndpointAddress(EndpointConfiguration.ExRatesSoap));
 }
예제 #7
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();
        }
예제 #8
0
 private static System.ServiceModel.Channels.Binding GetDefaultBinding()
 {
     return(ExRatesSoapClient.GetBindingForEndpoint(EndpointConfiguration.ExRatesSoap));
 }
예제 #9
0
 public ExRatesSoapClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) :
     base(ExRatesSoapClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress)
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
예제 #10
0
 public ExRatesSoapClient(EndpointConfiguration endpointConfiguration) :
     base(ExRatesSoapClient.GetBindingForEndpoint(endpointConfiguration), ExRatesSoapClient.GetEndpointAddress(endpointConfiguration))
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
예제 #11
0
 public ExRatesSoapClient() :
     base(ExRatesSoapClient.GetDefaultBinding(), ExRatesSoapClient.GetDefaultEndpointAddress())
 {
     this.Endpoint.Name = EndpointConfiguration.ExRatesSoap.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
예제 #12
0
 public ExchangeRatesService()
 {
     _client = new ExRatesSoapClient();
 }