Ejemplo n.º 1
0
 private void OnSendData(object sender, EventArgs e)
 {
     if (client.Connected)
     {
         string message = cbCmd.Text;
         client.Send(message);
     }
     else
     {
         MessageBox.Show(this, "Could not connect to server\r\nPlease restart application", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 2
0
        private void OnNextNumber(object sender, EventArgs e)
        {
            if (client.Connected)
            {
                string message = "CALLER" + Msg.Separator + "GET_NEXTNUMBER" + Msg.Separator;
                message += Properties.Settings.Default.StationName;
                message += Msg.Separator + Properties.Settings.Default.StationPost;

                client.Send(message);
            }
            else
            {
                MessageBox.Show(this, "Could not connect to server\r\nPlease restart application", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 3
0
        public void StartClient()
        {
            client = null;

            string dispServerHost = Properties.Settings.Default.QueueServerHost;
            int    dispServerPort = Properties.Settings.Default.QueueServerPort;
            string stationName    = Properties.Settings.Default.StationName;
            string stationPost    = Properties.Settings.Default.StationPost;
            string userName       = Properties.Settings.Default.QueueUserName;
            string password       = Properties.Settings.Default.QueuePassword;

            client           = new TCPClient(dispServerHost, dispServerPort);
            client.Notified += new Action <NotifyEventArgs>(TCPClient_Notified);

            client.Start();

            if (client.Connected)
            {
                client.Session.DataReceived += new DataReceived(NetSession_DataReceived);

                string salt         = Properties.Settings.Default.SecuritySalt;
                string clearPwd     = Util.DecryptPassword(password, salt);
                string passwordHash = Util.GetPasswordHash(clearPwd, userName);

                /// Send LOGIN message + our station name to server
                string message = String.Empty;
                message = "LOGIN" + Msg.Separator + "CALLER" + Msg.Separator + stationName + Msg.Separator + stationPost + Msg.Separator + userName + Msg.Separator + passwordHash;
                client.Send(message);
            }
        }
Ejemplo n.º 4
0
        public void StartClient()
        {
            _client           = null;
            _client           = new TCPClient(_settings.QueueServerHost, _settings.QueueServerPort);
            _client.Notified += new Action <NotifyEventArgs>(TCPClientNotified);

            _client.Start();

            if (_client.Connected)
            {
                _client.Session.DataReceived += new DataReceived(NetSessionDataReceived);

                string clearPwd     = Util.DecryptPassword(_settings.QueuePassword, _settings.SecuritySalt);
                string passwordHash = Util.GetPasswordHash(clearPwd, _settings.QueueUserName);

                // SYS|LOGIN|REQ|[Module!Post!Station!Username!Password]
                string message =
                    Msg.SysLogin.Text +
                    Msg.Separator + "REQ" +
                    Msg.Separator + "CALLER" +
                    Msg.CompDelimiter + _settings.StationPost +
                    Msg.CompDelimiter + _settings.StationName +
                    Msg.CompDelimiter + _settings.QueueUserName +
                    Msg.CompDelimiter + passwordHash;

                _client.Send(message);
            }
        }
Ejemplo n.º 5
0
        private void RequestJobsFromServer(string post, string jobStatus, int offset = 0, int limit = 0)
        {
            if (_client != null && _client.Connected)
            {
                string message = Msg.SysGetJob.Text +
                                 Msg.Separator + "REQ" +
                                 Msg.Separator + "Identifier" +
                                 Msg.Separator + post +
                                 Msg.CompDelimiter + jobStatus +
                                 Msg.CompDelimiter + "0" +
                                 Msg.CompDelimiter + "0";

                _client.Send(message);
            }
            else
            {
                Util.ShowConnectionError(this);
            }
        }
Ejemplo n.º 6
0
        private void RequestRunningTextFromServer()
        {
            string message =
                Msg.DisplayGetRunText.Text +
                Msg.Separator + "REQ" +
                Msg.Separator + "Identifier" +
                Msg.Separator + _settings.StationPost +
                Msg.CompDelimiter + _settings.StationName;

            _client.Send(message);
        }
Ejemplo n.º 7
0
        private void RequestNewTicket(string postname)
        {
            if (_client.Connected)
            {
                string message =
                    Msg.TicketCreate.Text +
                    Msg.Separator + "REQ" +
                    Msg.Separator + "Identifier" +
                    Msg.Separator + postname +
                    Msg.CompDelimiter + _settings.StationName;

                _client.Send(message);
            }
            else
            {
                Util.ShowConnectionError(this);
            }
        }
Ejemplo n.º 8
0
        ///  Send TICKET_CREATE_NEWNUMBER message to QueueServer
        private void CreateNewNumber(string text)
        {
            if (client.Connected)
            {
                string message = "TICKET" + Msg.Separator + "CREATE_NEWNUMBER" + Msg.Separator;
                message += Properties.Settings.Default.StationName + Msg.Separator;

                string post0 = Properties.Settings.Default.Post0Post;
                string post1 = Properties.Settings.Default.Post1Post;
                string post2 = Properties.Settings.Default.Post2Post;
                string post3 = Properties.Settings.Default.Post3Post;
                string post4 = Properties.Settings.Default.Post4Post;


                if (text == "POST#0")
                {
                    message += post0;
                }
                else if (text == "POST#1")
                {
                    message += post1;
                }
                else if (text == "POST#2")
                {
                    message += post2;
                }
                else if (text == "POST#3")
                {
                    message += post3;
                }
                else if (text == "POST#4")
                {
                    message += post4;
                }

                client.Send(message);
            }
            else
            {
                MessageBox.Show(this, "Could not connect to server\r\nPlease restart application", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 9
0
        /// cross thread safe handler
        public void ProcessMessage(DataReceivedEventArgs arg, string text)
        {
            /// InvokeRequired required compares the thread ID of the
            /// calling thread to the thread ID of the creating thread.
            /// If these threads are different, it returns true.
            if (this.InvokeRequired)
            {
                ProcessMessageCallback d = new ProcessMessageCallback(ProcessMessage);
                this.Invoke(d, new object[] { arg, text });
            }
            else
            {
                if (text.StartsWith("DISPLAY"))
                {
                    HandleMessage(arg, text);
                }
                else if (text.StartsWith("LOGIN"))
                {
                    string _response = text;
                    if (_response == Msg.LOGIN_OK)
                    {
                        lblStatus.Text = "Connected to Server : " + client.Session.RemoteInfo + " - Post :" + Properties.Settings.Default.StationPost + "  Station:" + Properties.Settings.Default.StationName;
                        Logger.Log("QueueDisplay : Successfully logged in");

                        // Request running text from server
                        client.Send("DISPLAY" + Msg.Separator + "GET_RUNNINGTEXT");
                    }
                    else
                    {
                        string reason = _response.Substring(10);
                        string msg    = "QueueDisplay : Could not logged in to server, \r\nReason: " + reason;
                        Logger.Log(msg);
                        MessageBox.Show(this, msg, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        CloseConnection();
                    }
                }
            }
        }