Пример #1
0
        public static DeliveryPointsDataset GetCustomers()
        {
            //Get roadshow customers
            DeliveryPointsDataset       customers = null;
            DeliveryPointsServiceClient client    = new DeliveryPointsServiceClient();

            try {
                ObjectCache cache = MemoryCache.Default;
                customers = cache["customers"] as DeliveryPointsDataset;
                if (customers == null)
                {
                    customers = new DeliveryPointsDataset();
                    DataSet ds = client.GetRoadshowCustomers();
                    if (ds != null)
                    {
                        customers.Merge(ds);
                    }
                    client.Close();

                    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> dfe) { client.Abort(); throw new ApplicationException(dfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(customers);
        }