/// <summary>
        ///  Handles the operation of browsing the available books
        /// </summary>
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            // refresh list view
            lstBooks.Items.Clear();

            // create proxy object
            BrowseBooksClient client = new BrowseBooksClient();

            try
            {

                // call the browseBooks() method
                string[] books = client.BrowseBooks();

                // load results in list view
                for (int i = 0; i < books.Length; i++)
                {
                    lstBooks.Items.Add(books[i]);
                }
                MessageBox.Show("Books Loaded for Browsing", "Bookstore Client");

                if (!btnBuy.Enabled)
                {
                    btnBuy.Enabled = true;
                }

                client.Close();
            }
            catch (EndpointNotFoundException)
            {
                MessageBox.Show("Error while loading books for browsing. Make sure the BookStore Service, BookStore STS, and HomeRealm STS have been started", "Bookstore Client");
            }
            catch (CommunicationException ex)
            {
                client.Abort();
                MessageBox.Show(String.Format("Communication error while loading books for browsing: {0}", ex), "Bookstore Client");
            }
            catch (TimeoutException ex)
            {
                client.Abort();
                MessageBox.Show(String.Format("Timeout error while loading books for browsing: {0}", ex), "Bookstore Client");
            }
            catch (Exception ex)
            {
                client.Abort();
                MessageBox.Show(String.Format("Unexpected error while loading books for browsing: {0}", ex), "Bookstore Client");
            }
        }
Esempio n. 2
0
        /// <summary>
        ///  Handles the operation of browsing the available books
        /// </summary>
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            // refresh list view
            lstBooks.Items.Clear();

            // create proxy object
            BrowseBooksClient client = new BrowseBooksClient();

            try
            {
                // call the browseBooks() method
                string[] books = client.BrowseBooks();

                // load results in list view
                for (int i = 0; i < books.Length; i++)
                {
                    lstBooks.Items.Add(books[i]);
                }
                MessageBox.Show("Books Loaded for Browsing", "Bookstore Client");

                if (!btnBuy.Enabled)
                {
                    btnBuy.Enabled = true;
                }

                client.Close();
            }
            catch (EndpointNotFoundException)
            {
                MessageBox.Show("Error while loading books for browsing. Make sure the BookStore Service, BookStore STS, and HomeRealm STS have been started", "Bookstore Client");
            }
            catch (CommunicationException ex)
            {
                client.Abort();
                MessageBox.Show(String.Format("Communication error while loading books for browsing: {0}", ex), "Bookstore Client");
            }
            catch (TimeoutException ex)
            {
                client.Abort();
                MessageBox.Show(String.Format("Timeout error while loading books for browsing: {0}", ex), "Bookstore Client");
            }
            catch (Exception ex)
            {
                client.Abort();
                MessageBox.Show(String.Format("Unexpected error while loading books for browsing: {0}", ex), "Bookstore Client");
                throw;
            }
        }