コード例 #1
0
ファイル: TerminalGateway.cs プロジェクト: jpheary/Argix10
        public static Customers2 GetCustomers2()
        {
            //Get customers list
            Customers2            customers = null;
            RoadshowServiceClient client    = new RoadshowServiceClient();

            try {
                ObjectCache cache = MemoryCache.Default;
                customers = cache["customers"] as Customers2;
                if (customers == null)
                {
                    customers = client.GetCustomers2();
                    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);
        }