示例#1
0
 private void PhoneBook_Loaded(object sender, RoutedEventArgs e)
 {
     owner = (MainWindow)this.Owner;
 }
示例#2
0
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(CoupleModeInfo.pbxipaddress))
            {
                MessageBox.Show(Application.Current.FindResource("MSG_SETTINGS_PBX_IPADDRESS_EMPTY0").ToString());
                txtid.Focus();
                return;
            }

            if (CoupleModeInfo.pbxport < 31001)
            {
                MessageBox.Show(Application.Current.FindResource("MSG_SETTINGS_PBX_PORT_EMPTY0").ToString());
                txtid.Focus();
                return;
            }

            if (string.IsNullOrEmpty(txtid.Text.Trim()))
            {
                MessageBox.Show(Application.Current.FindResource("MSG_LOGON_EMPTYID").ToString());
                txtid.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtpwd.Password))
            {
                MessageBox.Show(Application.Current.FindResource("MSG_LOGON_EMPTYPWD").ToString());
                txtpwd.Focus();
                return;
            }

            byte[] buffer = null;
            try
            {
                IPEndPoint remoteIpEp = new IPEndPoint(IPAddress.Parse(CoupleModeInfo.pbxipaddress), 31005);
                UdpClient client = new UdpClient();
                client.Client.ReceiveTimeout = USRSTRUCTS.UDP_TIMEOUT;
                client.Connect(remoteIpEp);

                SoftphoneCommand_t author = new SoftphoneCommand_t()
                {
                    cmd = USRSTRUCTS.SOFTPHONE_CMD_EXTENSION_REQ,
                    UserId = txtid.Text,
                    Password = txtpwd.Password
                };

                buffer = util.GetBytes(author);

                int len = client.Send(buffer, buffer.Length);

                IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 0);
                buffer = client.Receive(ref ipep);
                client.Close();
            }
            catch (SocketException se)
            {
                if (se.SocketErrorCode == SocketError.TimedOut)
                {
                    MessageBox.Show(Application.Current.FindResource("MSG_SOCK_TIMEOUT").ToString());
                    return;
                }
                else
                {
                    // LOG 저장
                }
            }

            SoftphoneResponse_t authurized = util.GetObject<SoftphoneResponse_t>(buffer);

            if (authurized.extension == 0)
            {
                MessageBox.Show(Application.Current.FindResource("MSG_LOGON_FAIL").ToString());
                txtpwd.Password = string.Empty;
                txtid.Focus();
                txtid.SelectAll();
            }
            else
            {
                CoupleModeInfo.userid = txtid.Text.Trim();

                MainWindow mainwin = new MainWindow();
                mainwin.Show();
                this.Close();
            }
        }