private void Button_Click(object sender, RoutedEventArgs e)
        {
            LoginUser.Current.Reset();
            string username = txtUsername.Text;
            string password = txtPassword.Password;

            PermissiveCertificatePolicy.Enact("CN=HTTPS-Server");
            BicycleWorldSalesServiceClient proxy = new BicycleWorldSalesServiceClient("wsHttpBinding_BicycleWorldSalesService");

            proxy.ClientCredentials.UserName.UserName = username;
            proxy.ClientCredentials.UserName.Password = password;
            try
            {
                proxy.Login();
                bool isAdmin = proxy.IsUserAdmin();
                LoginUser.Current.Set(username, password, isAdmin);
                DialogResult = true;
                Authenicated = true;
                this.Close();
            }
            catch (MessageSecurityException ex)
            {
                MessageBox.Show((ex.InnerException != null) ? ex.InnerException.Message : "Login failed.");
                DialogResult = true;
                Authenicated = false;
            }
            catch (Exception)
            {
                MessageBox.Show("Login failed.");
                DialogResult = true;
                Authenicated = false;
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            LoginUser.Current.Reset();
            string username = txtUsername.Text;
            string password = txtPassword.Password;

            PermissiveCertificatePolicy.Enact("CN=HTTPS-Server");
            BicycleWorldSalesServiceClient proxy = new BicycleWorldSalesServiceClient("wsHttpBinding_BicycleWorldSalesService");
            proxy.ClientCredentials.UserName.UserName = username;
            proxy.ClientCredentials.UserName.Password = password;
            try
            {
                proxy.Login();
                bool isAdmin = proxy.IsUserAdmin();
                LoginUser.Current.Set(username, password, isAdmin);
                DialogResult = true;
                Authenicated = true;
                this.Close();
            }
            catch (MessageSecurityException ex)
            {
                MessageBox.Show((ex.InnerException != null) ? ex.InnerException.Message : "Login failed.");
                DialogResult = true;
                Authenicated = false;
            }
            catch (Exception)
            {
                MessageBox.Show("Login failed.");
                DialogResult = true;
                Authenicated = false;
            }
        }
        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);
                }
            }
        }
Ejemplo n.º 4
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);
                }
            }
        }