예제 #1
0
 public void Dispose()
 {
     if (_isDisposed)
     {
         return;
     }
     _client.Close();
     _isDisposed = true;
 }
예제 #2
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;
            }
        }
예제 #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 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);
     }
 }