Example #1
0
        public static Customers2 GetCustomers2(string clientNumber)
        {
            //Get customers list
            Customers2 customers = new Customers2();

            try {
                Customers2 _customers = GetCustomers2();
                if (clientNumber != null && clientNumber.Length > 0)
                {
                    for (int i = 0; i < _customers.Count; i++)
                    {
                        Customer2 c = _customers[i];
                        if (c.AccountID.Trim().Length > 0 && c.AccountID.Substring(0, 3) == clientNumber)
                        {
                            customers.Add(c);
                        }
                    }
                }
                else
                {
                    customers = _customers;
                }
            }
            catch (ApplicationException aex) { throw aex; }
            catch (Exception ce) { throw new ApplicationException(ce.Message, ce); }
            return(customers);
        }
Example #2
0
        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);
        }
Example #3
0
        public Customers2 GetCustomers2()
        {
            //
            Customers2 customers = new Customers2();

            try {
                DataSet ds = new RoadshowGateway().GetDispatchCustomers2();
                if (ds != null)
                {
                    RoadshowDataset _customers = new RoadshowDataset();
                    _customers.Merge(ds);
                    for (int i = 0; i < _customers.CustomerTable.Rows.Count; i++)
                    {
                        customers.Add(new Customer2(_customers.CustomerTable[i]));
                    }
                }
            }
            catch (ApplicationException aex) { throw new FaultException <RoadshowFault>(new RoadshowFault(aex.Message), "Gateway Error"); }
            catch (Exception ex) { throw new FaultException <RoadshowFault>(new RoadshowFault(ex.Message), "Unexpected Error"); }
            return(customers);
        }