コード例 #1
0
        /// <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);
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
ファイル: PlanComptableBLL.cs プロジェクト: LeonGuo1/SupErp
        /// <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;
        }
コード例 #5
0
 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;
 }
コード例 #6
0
 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);
 }