public static Customers GetCustomers() { //Get carriers list Customers customers = null; try { ObjectCache cache = MemoryCache.Default; customers = cache["customers"] as Customers; if (customers == null) { _Client = new RoadshowServiceClient(); customers = _Client.GetCustomers(); _Client.Close(); //CacheItemPolicy policy = new CacheItemPolicy(); //policy.ChangeMonitors.Add(new SqlChangeMonitor(new SqlDependency())); DateTimeOffset policy = new DateTimeOffset(DateTime.Now.AddMinutes(30)); cache.Set("customers", customers, policy); } } catch (FaultException fe) { throw new ApplicationException("GetCustomers() service error.", fe); } catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException("GetCustomers() timeout error.", te); } catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException("GetCustomers() communication error.", ce); } return(customers); }
public static Customers GetCustomers() { //Get customers list Customers customers = null; RoadshowServiceClient client = new RoadshowServiceClient(); try { ObjectCache cache = MemoryCache.Default; customers = cache["customers"] as Customers; if (customers == null) { customers = client.GetCustomers(); client.Close(); //CacheItemPolicy policy = new CacheItemPolicy(); //policy.ChangeMonitors.Add(new SqlChangeMonitor(new SqlDependency())); DateTimeOffset policy = new DateTimeOffset(DateTime.Now.AddMinutes(_cacheTimeout)); cache.Set("customers", customers, policy); } } catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException <RoadshowFault> rfe) { client.Abort(); throw new ApplicationException(rfe.Detail.Message); } catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); } return(customers); }
public static Customers GetCustomers() { // Customers customers = null; try { _Client = new RoadshowServiceClient(); customers = _Client.GetCustomers(); _Client.Close(); } catch (FaultException fe) { throw new ApplicationException("GetCustomers() service error.", fe); } catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException("GetCustomers() timeout error.", te); } catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException("GetCustomers() communication error.", ce); } return(customers); }
public static RoadshowDS GetCustomers() { //Get roadshow customers RoadshowDS customers = null; try { customers = new RoadshowDS(); _Client = new RoadshowServiceClient(); DataSet ds = _Client.GetCustomers(); _Client.Close(); if (ds != null) { customers.Merge(ds); } } catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException(te.Message); } catch (FaultException fe) { _Client.Abort(); throw new ApplicationException(fe.Message); } catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException(ce.Message); } return(customers); }