Esempio n. 1
0
        //  OLT 選單



        // ====================================主要按鈕====================================
        private void grow_button_Click(object sender, EventArgs e)
        {
            auto_button.Enabled = true;

            ONT_Profile.Slot    = Slot_Box.Text;
            ONT_Profile.Port    = Port_Box.Text;
            ONT_Profile.Onuid   = OnuID_Box.Text;
            ONT_Profile.Sn      = SN_Box.Text;
            ONT_Profile.Des     = Des_Box.Text;
            ONT_Profile.mode    = Mode_Box.Text;
            ONT_Profile.Svlan   = Svlan_Box.Text;
            ONT_Profile.Cvlan   = Cvlan_Box.Text;
            ONT_Profile.Bw_Up   = UP_Box.Text;
            ONT_Profile.Bw_Down = Down_Box.Text;
            ONT_Profile.Ip      = IP_Box.Text;
            ONT_Profile.Gw      = GW_Box.Text;
            ONT_Profile.Bw_Per  = Percen_Box.Text;
            if (Des_Box.Text != "" && Des_Box.Text.Length == 10)
            {
                ONT_Profile.MV = Des_Box.Text.Substring(6, 4);
            }
            else
            {
                MessageBox.Show("你電路編號是不是填錯阿!");
            }

            ONT_Profile.Group7750();


            string total =
                "====================OLT部分====================\r\n" +
                ONT_Profile.Dba_profile() +
                ONT_Profile.Vlan_profile() +
                ONT_Profile.Traffic_profile() +
                ONT_Profile.Onu_profile() +
                ONT_Profile.GPON_OLT() +
                ONT_Profile.OLT_Vlan() +
                "\r\n====================10K部分====================\r\n" +
                ONT_Profile.K10() +
                "\r\n====================7750或7450部分====================\r\n" +
                ONT_Profile.ALU7750()
            ;



            richTextBox1.Text = total;
        }
Esempio n. 2
0
        // ====================================開通按鈕====================================
        private void auto_button_Click(object sender, EventArgs e)
        {
            OLT_DIC OLTIP = new OLT_DIC();


            using (var client = new SshClient(OLTIP.Find_DIC(comboBox3.Text), 22, "admin", "123"))
            {
                // 建立連線
                client.Connect();

                // 連線參數
                var stream = client.CreateShellStream("", 0, 0, 0, 0, 0);

                string GP =
                    $@"
en
config t
gp
"
                ;

                string GP_Port =
                    $@"
gp {ONT_Profile.Slot}/{ONT_Profile.Port}
"
                ;



                Thread.Sleep(5000);
                stream.WriteLine(GP);
                Thread.Sleep(2000);
                stream.WriteLine(ONT_Profile.Dba_profile());
                Thread.Sleep(2000);
                stream.WriteLine(ONT_Profile.Vlan_profile());
                Thread.Sleep(2000);
                stream.WriteLine(ONT_Profile.Traffic_profile());
                Thread.Sleep(2000);
                stream.WriteLine(ONT_Profile.Onu_profile());
                Thread.Sleep(2000);
                stream.WriteLine(GP_Port);
                Thread.Sleep(2000);
                stream.WriteLine(ONT_Profile.GPON_OLT());
                Thread.Sleep(2000);
                stream.WriteLine("exit");
                stream.WriteLine("bridge");
                Thread.Sleep(2000);
                stream.WriteLine(ONT_Profile.OLT_Vlan());


                // 輸出結果
                string line;
                while ((line = stream.ReadLine(TimeSpan.FromSeconds(2))) != null)
                {
                    Console.WriteLine(line);
                }
                // 結束連線
                stream.Close();
                client.Disconnect();
                WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer();
                wplayer.URL = $@"{AppDomain.CurrentDomain.BaseDirectory}DATA/MIC03.mp3";
                wplayer.controls.play();
                MessageBox.Show("開通完畢!");
            }
        }