Example #1
0
        static void Main(string[] args)
        {
            LibraryServiceReference.LibraryServiceClient client = new LibraryServiceReference.LibraryServiceClient();;

            try
            {
                // Open client connection.
                client.Open();

                // Reserve a valid book.
                client.ReserveBook("The Stand", "Stephen King");
                // Reserve an invalid book.
                client.ReserveBook("The Stand", null);

                // Close client connection.
                client.Close();
            }
            // Catch our SOAP fault type.
            catch (FaultException <LibraryServiceReference.InvalidBookFault> e)
            {
                Logging.Log(e);
                client.Abort();
            }
            catch (FaultException e)
            {
                Logging.Log(e, false);
                client.Abort();
            }
            catch (Exception e)
            {
                Logging.Log(e, false);
                client.Abort();
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     LibraryServiceReference.LibraryServiceClient LSC = new LibraryServiceReference.LibraryServiceClient("NetTcpBinding_ILibraryService");
     permission = LSC.VerifyLogin(LoginTextBox1.Text, PasswordTextBox1.Text);
     if (permission >= 999)
     {
         UserIsAdmin = true;
         this.Hide();
         var mainForm = new MainForm(UserIsAdmin, LoginTextBox1.Text);
         mainForm.Closed += (s, args) => ClosedForm();
         mainForm.Text    = "Library Client (Logged in as " + LoginTextBox1.Text + ")";
         mainForm.Show();
     }
     else if (permission >= 1)
     {
         UserIsAdmin = false;
         this.Hide();
         var mainForm = new MainForm(UserIsAdmin, LoginTextBox1.Text);
         mainForm.Closed += (s, args) => ClosedForm();
         mainForm.Text    = "Library Client (Logged in as " + LoginTextBox1.Text + ")";
         mainForm.Show();
     }
     else
     {
         MessageBox.Show("Login or password incorrect!");
     }
 }