Beispiel #1
0
        private void btnChange_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            try {
                tc       = new TelnetConnection(AuthVars.HOSTNAME, AuthVars.PORT);
                response = tc.Login(AuthVars.USERNAME, AuthVars.PASSWORD, AuthVars.TIMEOUT);

                string prompt = response.TrimEnd();
                prompt = response.Substring(prompt.Length - 1, 1);
                if (prompt != "$" && prompt != ">")
                {
                    throw new Exception("Connection failed");
                }

                if (tc.IsConnected)
                {
                    tc.WriteLine(string.Format(Command.SetMacAddFormat, txtMac.Text.Trim()));
                    textBox2.AppendText(tc.Read());
                    tc.WriteLine(Command.RestoreDefault);
                    textBox2.AppendText(tc.Read());
                    this.Close();
                }
                else
                {
                    lblStatus.Text      = "      Not connected!";
                    lblStatus.ForeColor = Color.Red;
                }
            } catch {
                lblStatus.Text      = "      Exception Error!";
                lblStatus.ForeColor = Color.Red;
            } finally {
                Cursor.Current = Cursors.Default;
            }
        }
Beispiel #2
0
        private void InitializeTelnet()
        {
            Cursor.Current = Cursors.WaitCursor;
            try {
                tc       = new TelnetConnection(AuthVars.HOSTNAME, AuthVars.PORT);
                response = tc.Login(AuthVars.USERNAME, AuthVars.PASSWORD, AuthVars.TIMEOUT);
                string prompt = response.TrimEnd();
                prompt = response.Substring(prompt.Length - 1, 1);
                if (prompt != "$" && prompt != ">")
                {
                    throw new Exception("Connection failed");
                }

                prompt = string.Empty;
                if (!string.IsNullOrEmpty(response))
                {
                    txtResponse.AppendText("Initializing completed..." + Environment.NewLine);
                    txtResponse.AppendText("Connected...");
                    txtResponse.AppendText(Environment.NewLine);
                    txtResponse.AppendText(Environment.NewLine);
                    txtResponse.AppendText(Environment.NewLine);

                    txtResponse.AppendText("Welcome To Huawei Wimax Tools...");
                    txtResponse.AppendText(Environment.NewLine);
                    txtResponse.AppendText("Huawei Wimax Tools...");
                    txtResponse.AppendText(Environment.NewLine);
                    txtResponse.AppendText("Version : v.1.0.0");
                    txtResponse.AppendText(Environment.NewLine);
                    txtResponse.AppendText("Copyright © MarianzK®. 2012");
                    txtResponse.AppendText(Environment.NewLine);
                    txtResponse.AppendText("All Rights Reserved. 2012");
                    SetConnection(true);
                }
                else
                {
                    SetConnection(false);
                }
            } catch {
                SetErrorStatus("Error in connecting the wimax.", true);
            } finally {
                Cursor.Current = Cursors.Default;
            }
        }