コード例 #1
0
        private void Disconnect_button_Click(object sender, RoutedEventArgs e)
        {
            var callback = new ClientCallback();
            var client = new FourRowServiceClient(new InstanceContext(callback));
            if (string.IsNullOrEmpty(TbUsername.Text))
            {
                MessageBox.Show("insert valid username to disconnet THIS BUTTON IS FOR DEBUG USAGE ONLY!!");
            }
            else
            {
                var userName = TbUsername.Text.Trim();
                try
                {
                    client.ClientDisconnected(userName);
                }
                catch (DbException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                catch (FaultException<UserDoesntExistsFault> ex)
                {
                    MessageBox.Show(ex.Detail.Details);
                    TbPasswrd.Clear();
                    TbUsername.Clear();
                    return;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                MessageBox.Show(userName + " disconnected successfully");
            }
        }
コード例 #2
0
        } /*end of constructor*/

        private void Button_Connect_Click(object sender, RoutedEventArgs e)
        {
            var callback = new ClientCallback();
            var client = new FourRowServiceClient(new InstanceContext(callback));
            if (!utils.AllTextboxesFilled(MainGrid))
            {
                MessageBox.Show("Please insert User name and Password");
                return;
            }

            var userName = TbUsername.Text.Trim();
            var pass = TbPasswrd.Password.Trim();

            try
            {
                client.ClientConnected(userName, utils.HashValue(pass).ToString());
            }
            catch (DbException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (FaultException<UserDoesntExistsFault> ex)
            {
                MessageBox.Show(ex.Detail.Details);
                TbPasswrd.Clear();
                TbUsername.Clear();
                return;
            }
            catch (FaultException<UserAlreadyConnectedFault> ex)
            {
                MessageBox.Show(ex.Detail.Details);
                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            WaitingWindow waitingWindow = null;
            try
            {
                var ww = new WaitingWindow
                {
                    Username = userName,
                    Client = client,
                    Callback = callback,
                    Title = "Wellcome " + userName
                };
                waitingWindow = ww;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                client.ClientDisconnected(userName);
            }

            Close();
            waitingWindow?.Show();
        }