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(); }
public CurrencyServiceWrapper() { _client = new ExRatesSoapClient(); _availablyCurrencies = new[] { CurrencyCode.AmericanDoll, CurrencyCode.Euro, CurrencyCode.RussianRub, CurrencyCode.UkraineHry }; }
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; } }
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; } }
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); } }
private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress() { return(ExRatesSoapClient.GetEndpointAddress(EndpointConfiguration.ExRatesSoap)); }
private static System.ServiceModel.Channels.Binding GetDefaultBinding() { return(ExRatesSoapClient.GetBindingForEndpoint(EndpointConfiguration.ExRatesSoap)); }
public ExRatesSoapClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) : base(ExRatesSoapClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress) { this.Endpoint.Name = endpointConfiguration.ToString(); ConfigureEndpoint(this.Endpoint, this.ClientCredentials); }
public ExRatesSoapClient(EndpointConfiguration endpointConfiguration) : base(ExRatesSoapClient.GetBindingForEndpoint(endpointConfiguration), ExRatesSoapClient.GetEndpointAddress(endpointConfiguration)) { this.Endpoint.Name = endpointConfiguration.ToString(); ConfigureEndpoint(this.Endpoint, this.ClientCredentials); }
public ExRatesSoapClient() : base(ExRatesSoapClient.GetDefaultBinding(), ExRatesSoapClient.GetDefaultEndpointAddress()) { this.Endpoint.Name = EndpointConfiguration.ExRatesSoap.ToString(); ConfigureEndpoint(this.Endpoint, this.ClientCredentials); }
public ExchangeRatesService() { _client = new ExRatesSoapClient(); }