Exemplo n.º 1
0
        public decimal GetRiksbankensBaseRate()
        {
            int retries = 5;
            int sleepWhenFailBeforeRetry = 3000;

            while (retries > 0)
            {
                try
                {
                    //Fake slow call
                    System.Threading.Thread.Sleep(5000);
                    using (var c = new SweaWebService.SweaWebServicePortTypeClient())
                    {
                        var r = c.getLatestInterestAndExchangeRates(SweaWebService.LanguageType.sv, new[] { "SEDP2MSTIBOR" });
                        return(Convert.ToDecimal(r.groups[0].series[0].resultrows[0].value));
                    }
                }
                catch
                {
                    System.Threading.Thread.Sleep(sleepWhenFailBeforeRetry);
                    retries--;
                }
            }
            return(0.125m);
        }
        public static decimal GetRiksbankensBaseRate()
        {
            //Fake slow call
            System.Threading.Thread.Sleep(5000);
            using (var c = new SweaWebService.SweaWebServicePortTypeClient())
            {
                //var groups = c.getInterestAndExchangeGroupNames(SweaWebService.LanguageType.sv).ToList();

                //var n = c.getInterestAndExchangeNames(5, SweaWebService.LanguageType.sv).ToList();

                var r = c.getLatestInterestAndExchangeRates(SweaWebService.LanguageType.sv, new[] { "SEDP3MSTIBORDELAYC" });

                return(Convert.ToDecimal(r.groups[0].series[0].resultrows[0].value));
            }
        }
 public decimal GetRiksbankensBaseRate()
 {
     return(Policy.Handle <System.ServiceModel.FaultException>().
            Retry(15, (exeption, retries) =>
     {
         System.Threading.Thread.Sleep(retries * 10000);
     }).
            Execute(() =>
     {
         //Fake slow call
         System.Threading.Thread.Sleep(5000);
         using (var c = new SweaWebService.SweaWebServicePortTypeClient())
         {
             var r = c.getLatestInterestAndExchangeRates(SweaWebService.LanguageType.sv, new[] { "SEDP2MSTIBOR" });
             return Convert.ToDecimal(r.groups[0].series[0].resultrows[0].value);
         }
     }));
 }