Exemple #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(tbUsername.Text) && !string.IsNullOrEmpty(tbPasswrd.Password))
            {
                ClientCallback callback = new ClientCallback();
                ServiceClient  client   = new ServiceClient(new InstanceContext(callback));
                c = client;


                string username = tbUsername.Text.Trim();
                string password = tbPasswrd.Password.Trim();
                try
                {
                    client.ClientConnected(username, HashValue(password));
                    Dashboard mainWindow = new Dashboard(client, callback, username);
                    mainWindow.Title = username;
                    this.Close();
                    mainWindow.Show();
                }
                catch (FaultException <WrongPasswordFault> fault)
                {
                    MessageBox.Show(fault.Detail.Details, username);
                }
                catch (TimeoutException)
                {
                    MessageBox.Show(" connection unstable , it took to long to get a response, unable to connect try again later", username + " connection unstable");
                }
                catch (CommunicationObjectFaultedException)
                {
                    MessageBox.Show(" connection unstable , it took to long to get a response, unable to connect try again later", username + " connection unstable");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), username);
                }
            }
        }