Esempio n. 1
0
        public static bool DeleteCategory(int categoryID)
        {
            bool result = false;
            BicycleWorldServiceClient client = new BicycleWorldServiceClient();

            try
            {
                client.ClientCredentials.UserName.UserName = LoginUser.Current.Username;
                client.ClientCredentials.UserName.Password = LoginUser.Current.Password;
                result = client.RemoveCategory(categoryID);
                client.Close();
            }
            catch (FaultException)
            {
                client.Abort();
            }
            catch (CommunicationException)
            {
                client.Abort();
            }
            catch (TimeoutException)
            {
                client.Abort();
            }
            catch { throw; }
            return(result);
        }
 public static bool DeleteCategory(int categoryID)
 {
     bool result = false;
     BicycleWorldServiceClient client = new BicycleWorldServiceClient();
     try
     {
         client.ClientCredentials.UserName.UserName = LoginUser.Current.Username;
         client.ClientCredentials.UserName.Password = LoginUser.Current.Password;
         result = client.RemoveCategory(categoryID);
         client.Close();
     }
     catch (FaultException)
     {
         client.Abort();
     }
     catch (CommunicationException)
     {
         client.Abort();
     }
     catch (TimeoutException)
     {
         client.Abort();
     }
     catch { throw; }
     return result;
 }
 public static List<ProductData> GetProductList()
 {
     List<ProductData> result = null;
     BicycleWorldServiceClient client = new BicycleWorldServiceClient();
     try
     {
         client.ClientCredentials.UserName.UserName = LoginUser.Current.Username;
         client.ClientCredentials.UserName.Password = LoginUser.Current.Password;
         result = client.ProductList();
         client.Close();
     }
     catch (FaultException)
     {
         client.Abort();
     }
     catch (CommunicationException)
     {
         client.Abort();
     }
     catch (TimeoutException)
     {
         client.Abort();
     }
     catch { throw; }
     return result;
 }
Esempio n. 4
0
        public static ProductCategory UpdateCategory(CategoryData category)
        {
            ProductCategory           result = null;
            BicycleWorldServiceClient client = new BicycleWorldServiceClient();

            try
            {
                client.ClientCredentials.UserName.UserName = LoginUser.Current.Username;
                client.ClientCredentials.UserName.Password = LoginUser.Current.Password;
                result = client.UpdateCategory(new ProductCategory()
                {
                    Name              = category.Name,
                    IsActive          = category.IsActive,
                    ProductCategoryID = category.ProductCategoryID
                });
                client.Close();
            }
            catch (FaultException)
            {
                client.Abort();
            }
            catch (CommunicationException)
            {
                client.Abort();
            }
            catch (TimeoutException)
            {
                client.Abort();
            }
            catch { throw; }
            return(result);
        }
        public static List <ProductData> GetProductList()
        {
            List <ProductData>        result = null;
            BicycleWorldServiceClient client = new BicycleWorldServiceClient();

            try
            {
                client.ClientCredentials.UserName.UserName = LoginUser.Current.Username;
                client.ClientCredentials.UserName.Password = LoginUser.Current.Password;
                result = client.ProductList();
                client.Close();
            }
            catch (FaultException)
            {
                client.Abort();
            }
            catch (CommunicationException)
            {
                client.Abort();
            }
            catch (TimeoutException)
            {
                client.Abort();
            }
            catch { throw; }
            return(result);
        }
        public static Product UpdateProduct(ProductData product)
        {
            Product result = null;
            BicycleWorldServiceClient client = new BicycleWorldServiceClient();

            try
            {
                client.ClientCredentials.UserName.UserName = LoginUser.Current.Username;
                client.ClientCredentials.UserName.Password = LoginUser.Current.Password;
                result = client.UpdateProduct(new Product()
                {
                    ProductID          = product.ProductID,
                    Name               = product.Name,
                    ProductNumber      = product.ProductNumber,
                    Color              = product.Color,
                    ListPrice          = product.ListPrice,
                    ProductDescription = product.ProductDescription,
                    Quantity           = product.Quantity,
                    ProductCategoryID  = product.CategoryID,
                    IsActive           = product.IsActive
                });
                client.Close();
            }
            catch (FaultException)
            {
                client.Abort();
            }
            catch (CommunicationException)
            {
                client.Abort();
            }
            catch (TimeoutException)
            {
                client.Abort();
            }
            catch { throw; }
            return(result);
        }
Esempio n. 7
0
        public static List <CategoryData> GetCategoryList()
        {
            List <CategoryData>       result = null;
            BicycleWorldServiceClient client = new BicycleWorldServiceClient();

            try
            {
                client.ClientCredentials.UserName.UserName = LoginUser.Current.Username;
                client.ClientCredentials.UserName.Password = LoginUser.Current.Password;

                List <ProductCategory> productsList = client.CategoriesList();
                var q = from product in productsList
                        select new CategoryData()
                {
                    ProductCategoryID = product.ProductCategoryID,
                    Name         = product.Name,
                    IsActive     = product.IsActive,
                    ProductCount = product.ProductCount
                };
                result = q.ToList();
                client.Close();
            }
            catch (FaultException)
            {
                client.Abort();
            }
            catch (CommunicationException)
            {
                client.Abort();
            }
            catch (TimeoutException)
            {
                client.Abort();
            }
            catch { throw; }
            return(result);
        }
        public static List<CategoryData> GetCategoryList()
        {
            List<CategoryData> result = null;
            BicycleWorldServiceClient client = new BicycleWorldServiceClient();
            try
            {
                client.ClientCredentials.UserName.UserName = LoginUser.Current.Username;
                client.ClientCredentials.UserName.Password = LoginUser.Current.Password;

                List<ProductCategory> productsList = client.CategoriesList();
                var q = from product in productsList
                         select new CategoryData()
                         {
                             ProductCategoryID = product.ProductCategoryID,
                             Name = product.Name,
                             IsActive = product.IsActive,
                             ProductCount = product.ProductCount
                         };
                result = q.ToList();
                client.Close();
            }
            catch (FaultException)
            {
                client.Abort();
            }
            catch (CommunicationException)
            {
                client.Abort();
            }
            catch (TimeoutException)
            {
                client.Abort();
            }
            catch { throw; }
            return result;
        }
        public static void Wait()
        {
            PermissiveCertificatePolicy.Enact("CN=HTTPS-Server");

            bool productServiceIsRunning = false;

            Console.Write("Waiting for Product Service... ");
            while (!productServiceIsRunning)
            {
                System.Threading.Thread.Sleep(500);

                try
                {
                    BicycleWorldServiceClient proxy = new BicycleWorldServiceClient("DefaultBinding_BicycleWorldService_BicycleWorldService");
                    proxy.ClientCredentials.UserName.UserName = "******";
                    proxy.ClientCredentials.UserName.Password = "******";
                    proxy.Login();
                    productServiceIsRunning = true;
                    proxy.Abort();

                    Console.WriteLine("Connected.");
                }
                catch (ServerTooBusyException)
                {
                    Console.Write(".");
                }
                catch (SecurityAccessDeniedException ex)
                {
                    Console.WriteLine("\n {0}", ex.Message);
                    break;
                }
                catch (Exception ex)
                {
                    Console.Write(ex.Message);
                }
            }

            bool salesServiceIsRunning = false;

            Console.Write("Waiting for Sales Service... ");
            while (!salesServiceIsRunning)
            {
                System.Threading.Thread.Sleep(500);

                try
                {
                    BicycleWorldSalesServiceClient proxy = new BicycleWorldSalesServiceClient("wsHttpBinding_BicycleWorldSalesService");
                    proxy.ClientCredentials.UserName.UserName = "******";
                    proxy.ClientCredentials.UserName.Password = "******";
                    proxy.Login();
                    salesServiceIsRunning = true;
                    proxy.Abort();

                    Console.WriteLine("Connected.");
                }
                catch (ServerTooBusyException)
                {
                    Console.Write(".");
                }
                catch (Exception ex)
                {
                    Console.Write(ex.Message);
                }
            }
        }
 public static ProductCategory UpdateCategory(CategoryData category)
 {
     ProductCategory result = null;
     BicycleWorldServiceClient client = new BicycleWorldServiceClient();
     try
     {
         client.ClientCredentials.UserName.UserName = LoginUser.Current.Username;
         client.ClientCredentials.UserName.Password = LoginUser.Current.Password;
         result = client.UpdateCategory(new ProductCategory()
         {
             Name = category.Name,
             IsActive = category.IsActive,
             ProductCategoryID = category.ProductCategoryID
         });
         client.Close();
     }
     catch (FaultException)
     {
         client.Abort();
     }
     catch (CommunicationException)
     {
         client.Abort();
     }
     catch (TimeoutException)
     {
         client.Abort();
     }
     catch { throw; }
     return result;
 }
 public static Product UpdateProduct(ProductData product)
 {
     Product result = null;
     BicycleWorldServiceClient client = new BicycleWorldServiceClient();
     try
     {
         client.ClientCredentials.UserName.UserName = LoginUser.Current.Username;
         client.ClientCredentials.UserName.Password = LoginUser.Current.Password;
         result = client.UpdateProduct(new Product()
         {
             ProductID = product.ProductID,
             Name = product.Name,
             ProductNumber = product.ProductNumber,
             Color = product.Color,
             ListPrice = product.ListPrice,
             ProductDescription = product.ProductDescription,
             Quantity = product.Quantity,
             ProductCategoryID = product.CategoryID,
             IsActive = product.IsActive
         });
         client.Close();
     }
     catch (FaultException)
     {
         client.Abort();
     }
     catch (CommunicationException)
     {
         client.Abort();
     }
     catch (TimeoutException)
     {
         client.Abort();
     }
     catch { throw; }
     return result;
 }
Esempio n. 12
0
        public static void Wait()
        {
            PermissiveCertificatePolicy.Enact("CN=HTTPS-Server");

            bool productServiceIsRunning = false;

            Console.Write("Waiting for Product Service... ");
            while (!productServiceIsRunning)
            {
                System.Threading.Thread.Sleep(500);

                try
                {
                    BicycleWorldServiceClient proxy = new BicycleWorldServiceClient("DefaultBinding_BicycleWorldService_BicycleWorldService");
                    proxy.ClientCredentials.UserName.UserName = "******";
                    proxy.ClientCredentials.UserName.Password = "******";
                    proxy.Login();
                    productServiceIsRunning = true;
                    proxy.Abort();

                    Console.WriteLine("Connected.");
                }
                catch (ServerTooBusyException)
                {
                    Console.Write(".");
                }
                catch (SecurityAccessDeniedException ex)
                {
                    Console.WriteLine("\n {0}", ex.Message);
                    break;
                }
                catch (Exception ex)
                {
                    Console.Write(ex.Message);
                }
            }

            bool salesServiceIsRunning = false;

            Console.Write("Waiting for Sales Service... ");
            while (!salesServiceIsRunning)
            {
                System.Threading.Thread.Sleep(500);

                try
                {
                    BicycleWorldSalesServiceClient proxy = new BicycleWorldSalesServiceClient("wsHttpBinding_BicycleWorldSalesService");
                    proxy.ClientCredentials.UserName.UserName = "******";
                    proxy.ClientCredentials.UserName.Password = "******";
                    proxy.Login();
                    salesServiceIsRunning = true;
                    proxy.Abort();

                    Console.WriteLine("Connected.");
                }
                catch (ServerTooBusyException)
                {
                    Console.Write(".");
                }
                catch (Exception ex)
                {
                    Console.Write(ex.Message);
                }
            }
        }