Beispiel #1
0
        public bool Connect(string ipAddress, int port)
        {
            this.ipAddress = ipAddress;
            this.port = port;

            try
            {
                tc = new TelnetConnection(ipAddress, port);
                recievedData = tc.Read();
                // format: 100 HELLO 4AB59351 - KSHELL V1.3
                if(recievedData.Substring(0,StringEnum.GetStringValue(ReturnValue.HELLO).Length) == StringEnum.GetStringValue(ReturnValue.HELLO)) {
                    recievedHash = recievedData.Substring(StringEnum.GetStringValue(ReturnValue.HELLO).Length+1,8);
                    timerRegister(true);
                    return true;
                } else {
                    return false;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                return false;
            }
        }
Beispiel #2
0
        private void button5_Click(object sender, EventArgs e)
        {
            aktualizujProgressBar(0);

            try
            {
                tc = new TelnetConnection(textBoxIP.Text, int.Parse(textBoxPort.Text));
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message, "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string prijataData = "";
            int pocetTestu = dejSeznamTestu().Count;
            int i = 1;
            richTextBoxPrijato.Text += "Test (" + textBoxIP.Text + "): " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n";

            foreach (Test item in dejSeznamTestu())
            {
                prijataData = "";
                richTextBoxPrijato.Text += tc.Read();

                tc.WriteLine(item.Vstup);
                prijataData = tc.Read();
                if (item.Prosel(prijataData))
                {
                    richTextBoxPrijato.Text += "OK: " + item.Vstup + " (" + prijataData.Trim() + ")" + "\r\n";
                }
                else
                {
                    richTextBoxPrijato.Text += "!!! FAIL: " + item.Vstup + " (" + prijataData.Trim() + ")" + "\r\n";
                }

                aktualizujProgressBar(100 / (pocetTestu / i));
                i++;
            }
            richTextBoxPrijato.Text += "\r\n";
        }