/// <summary> /// /// </summary> /// <returns></returns> public COMPTA_ExchangeRate GetLastExchangeRate() { var result = comptabilityDal.GetLastExchangeRate(); if (result == null || DateTime.Now - result.updatedDate > new TimeSpan(1, 0, 0, 0, 0)) { // Call Update WebService for ExchangeRate Update =) //comptabilityDal. // ReGet the value updated CurrencyConvertor.CurrencyConvertorSoapClient client = new CurrencyConvertor.CurrencyConvertorSoapClient("CurrencyConvertorSoap", new System.ServiceModel.EndpointAddress("http://www.webservicex.net/CurrencyConvertor.asmx")); try { COMPTA_ExchangeRate exchangeRate = new COMPTA_ExchangeRate(); exchangeRate.EURO_AUD = client.ConversionRate(Currency.EUR, Currency.AUD); exchangeRate.EURO_GBP = client.ConversionRate(Currency.EUR, Currency.GBP); exchangeRate.EURO_USD = client.ConversionRate(Currency.EUR, Currency.USD); exchangeRate.EURO_ZAR = client.ConversionRate(Currency.EUR, Currency.ZAR); exchangeRate.USD_EURO = client.ConversionRate(Currency.USD, Currency.EUR); exchangeRate.updatedDate = DateTime.Now; comptabilityDal.CreateExchangeRate(exchangeRate); result = comptabilityDal.GetLastExchangeRate(); } catch (Exception e) { } } return(result); }
public static double GetRate(CurrencyConvertor.Currency fromCurrency, CurrencyConvertor.Currency toCurrency) { CurrencyConvertor.CurrencyConvertorSoap client = new CurrencyConvertor.CurrencyConvertorSoapClient("CurrencyConvertorSoap"); double rate = client.ConversionRate(fromCurrency, toCurrency); if (rate <= 0.0) throw new Exception("Invalid rate"); return rate; }
public static double convertFrom(CurrencyConvertor.Currency from, CurrencyConvertor.Currency to) { var client = new CurrencyConvertor.CurrencyConvertorSoapClient( new BasicHttpBinding(), new EndpointAddress(endpointAddress) ); var rate = client.ConversionRate(from, to); return rate; }
/// <summary> /// /// </summary> /// <returns></returns> public COMPTA_ExchangeRate GetLastExchangeRate() { var result = comptabilityDal.GetLastExchangeRate(); if ( result == null || DateTime.Now - result.updatedDate > new TimeSpan(1, 0, 0, 0, 0) ) { // Call Update WebService for ExchangeRate Update =) //comptabilityDal. // ReGet the value updated CurrencyConvertor.CurrencyConvertorSoapClient client = new CurrencyConvertor.CurrencyConvertorSoapClient("CurrencyConvertorSoap",new System.ServiceModel.EndpointAddress("http://www.webservicex.net/CurrencyConvertor.asmx")); try { COMPTA_ExchangeRate exchangeRate = new COMPTA_ExchangeRate(); exchangeRate.EURO_AUD = client.ConversionRate(Currency.EUR, Currency.AUD); exchangeRate.EURO_GBP = client.ConversionRate(Currency.EUR, Currency.GBP); exchangeRate.EURO_USD = client.ConversionRate(Currency.EUR, Currency.USD); exchangeRate.EURO_ZAR = client.ConversionRate(Currency.EUR, Currency.ZAR); exchangeRate.USD_EURO = client.ConversionRate(Currency.USD, Currency.EUR); exchangeRate.updatedDate = DateTime.Now; comptabilityDal.CreateExchangeRate(exchangeRate); result = comptabilityDal.GetLastExchangeRate(); } catch (Exception e) { } } return result; }
public static double GetExchangeRate(CurrencyConvertor.Currency fromCurrency, CurrencyConvertor.Currency toCurrency) { CurrencyConvertor.CurrencyConvertorSoap ccClient = new CurrencyConvertor.CurrencyConvertorSoapClient("CurrencyConvertorSoap"); double rate = ccClient.ConversionRate(fromCurrency, toCurrency); if(rate <= 0.0) { throw new Exception("Bad rate " + rate + " (" + fromCurrency + " -> " + toCurrency + ")"); } return rate; }
public double ConvertEuroTo(double europrice,CurrencyConvertor.Currency exchange) { CurrencyConvertor.CurrencyConvertorSoapClient service = new CurrencyConvertor.CurrencyConvertorSoapClient(); double rate = service.ConversionRate(CurrencyConvertor.Currency.EUR, exchange); return (europrice*rate); }