public static Customer GetCustomerById(string id)
        {
            if (channelFactory == null)
            {
                Uri serviceUri = ServiceBusEnvironment.CreateServiceUri("https", serviceNamespace, "Customer");
                channelFactory = new ChannelFactory<ICustomerChannel>("RelayEndpoint", new EndpointAddress(serviceUri));
            }

            int tries = 0;
            while (tries++ < 3)
            {
                try
                {
                    if (channel == null)
                    {
                        channel = channelFactory.CreateChannel();
                        channel.Open();
                    }

                    return channel.GetCustomerById(id);
                }
                catch (CommunicationException)
                {
                    channel.Abort();
                    channel = null;

                    Thread.Sleep(500);
                }
            }

            return new Customer();
        }
        public static Customer GetCustomerById(string id)
        {
            if (channelFactory == null)
            {
                GetChannelFactory();
            }

            int tries = 0;
            while (tries++ < 3)
            {
                try
                {
                    if (channel == null)
                    {
                        channel = channelFactory.CreateChannel();
                        channel.Open();
                    }

                    return channel.GetCustomerById(id);
                }
                catch (CommunicationException)
                {
                    channel.Abort();
                    channel = null;

                    Thread.Sleep(500);
                }
            }

            return new Customer();
        }
Exemple #3
0
        public static Customer GetCustomerById(string id)
        {
            if (channelFactory == null)
            {
                GetChannelFactory();
            }

            int tries = 0;

            while (tries++ < 3)
            {
                try
                {
                    if (channel == null)
                    {
                        channel = channelFactory.CreateChannel();
                        channel.Open();
                    }

                    return(channel.GetCustomerById(id));
                }
                catch (CommunicationException)
                {
                    channel.Abort();
                    channel = null;

                    Thread.Sleep(500);
                }
            }

            return(new Customer());
        }
        public static IEnumerable<Customer> GetCustomers()
        {
            if (channelFactory == null)
            {
                GetChannelFactory();
            }

            int tries = 0;
            while (tries++ < 3)
            {
                try
                {
                    if (channel == null)
                    {
                        channel = channelFactory.CreateChannel();
                        channel.Open();
                    }

                    return channel.GetCustomers();
                }
                catch (CommunicationException)
                {
                    channel.Abort();
                    channel = null;

                    Thread.Sleep(500);
                }
            }

            return new List<Customer>();
        }
Exemple #5
0
        public static IEnumerable <Customer> GetCustomers()
        {
            if (channelFactory == null)
            {
                GetChannelFactory();
            }

            int tries = 0;

            while (tries++ < 3)
            {
                try
                {
                    if (channel == null)
                    {
                        channel = channelFactory.CreateChannel();
                        channel.Open();
                    }

                    return(channel.GetCustomers());
                }
                catch (CommunicationException)
                {
                    channel.Abort();
                    channel = null;

                    Thread.Sleep(500);
                }
            }

            return(new List <Customer>());
        }