Ejemplo n.º 1
0
        // ====================================開通按鈕====================================
        protected void auto_button_Click(object sender, EventArgs e)
        {
            OLT_DIC OLTIP = new OLT_DIC();
            string  old   = "";
            string  GP    =
                $@"
en
config t
gp
"
            ;

            string GP_Port =
                $@"
gp {ONT_Profile.Slot}/{ONT_Profile.Port}
"
            ;
            string Show_Old =
                $@"
show running-config gpon-olt {ONT_Profile.Slot}/{ONT_Profile.Port}
"
            ;


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

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



                Thread.Sleep(4500);
                stream.WriteLine(GP);
                Thread.Sleep(1000);
                stream.WriteLine(GP_Port);
                Thread.Sleep(1000);
                stream.WriteLine(Show_Old);
                Thread.Sleep(2000);
                stream.WriteLine(Environment.NewLine);
                Thread.Sleep(2000);



                // 輸出結果
                string line;
                while ((line = stream.ReadLine(TimeSpan.FromSeconds(2))) != null)
                {
                    int id = line.IndexOf("8272OLT");
                    if (id < 0)
                    {
                        Console.WriteLine(line);
                        old += line + "\r\n";
                    }
                }
                // 結束連線
                stream.Close();
                client.Disconnect();
            }
            Thread.Sleep(1000);
            using (var client = new SshClient(OLTIP.Find_DIC(Pr_Olt_DropDownList.Text), 22, "admin", "123"))
            {
                // 建立連線
                client.Connect();

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



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


                // 輸出結果
                string line;
                while ((line = stream.ReadLine(TimeSpan.FromSeconds(2))) != null)
                {
                    Console.WriteLine(line);
                }

                // 結束連線
                stream.Close();
                client.Disconnect();
                //MessageBox.Show("開通完畢!");



                StreamWriter str1 = new StreamWriter($@"{AppDomain.CurrentDomain.BaseDirectory}Profile輸出.txt");
                str1.WriteLine(Pr_output_richTextBox.Text);
                str1.Close();

                StreamWriter str2 = new StreamWriter($@"{AppDomain.CurrentDomain.BaseDirectory}OLD_Detail.txt");
                str2.WriteLine(old);
                str2.Close();


                Pr_auto_button.Enabled = false;
            }
        }
Ejemplo n.º 2
0
        //  OLT 選單



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

            ONT_Profile.Slot    = Pr_Slot_Box.Text;
            ONT_Profile.Port    = Pr_Port_Box.Text;
            ONT_Profile.Onuid   = Pr_Onu_Box.Text;
            ONT_Profile.Sn      = Pr_SN_Box.Text;
            ONT_Profile.Des     = Pr_Des_Box.Text;
            ONT_Profile.mode    = Pr_Mode_Box.Text;
            ONT_Profile.Svlan   = Pr_Svlan_Box.Text;
            ONT_Profile.Cvlan   = Pr_Cvlan_Box.Text;
            ONT_Profile.Bw_Up   = Pr_UP_Box.Text;
            ONT_Profile.Bw_Down = Pr_Down_Box.Text;
            ONT_Profile.Ip      = Pr_IP_Box.Text;
            ONT_Profile.Gw      = Pr_GW_Box.Text;
            ONT_Profile.Bw_Per  = Pr_Percen_Box.Text;
            if (Pr_Des_Box.Text != "" && Pr_Des_Box.Text.Length == 10)
            {
                ONT_Profile.MV = Pr_Des_Box.Text.Substring(6, 4);
            }
            else
            {
                //MessageBox.Show("你電路編號是不是填錯阿!");
            }

            ONT_Profile.Group7750();


            ONT_Profile.ip1 = Pr_IP1_textBox.Text;

            ONT_Profile.ip2 = Pr_IP2_textBox.Text;


            ONT_Profile.ip3 = Pr_IP3_textBox.Text;


            ONT_Profile.ip4 = Pr_IP4_textBox.Text;


            ONT_Profile.ip5 = Pr_IP5_textBox.Text;


            ONT_Profile.ip6 = Pr_IP6_textBox.Text;


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



            Pr_output_richTextBox.Text = total;



            if (Pr_Passwd_Box.Text == "zong")
            {
                //MessageBox.Show("Right!!");

                int Desktop = 0;

                Desktop = SystemParametersInfo(20, 1, $@"{AppDomain.CurrentDomain.BaseDirectory}DATA/PIC01.jpg");
            }
            else if (Pr_Passwd_Box.Text == "yuqin")
            {
                if (Pr_auto_button.Visible == false)
                {
                    //WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer();
                    //wplayer.URL = $@"{AppDomain.CurrentDomain.BaseDirectory}DATA/MIC04.mp3";
                    //wplayer.controls.play();
                    //Thread.Sleep(2000);
                    //wplayer.URL = $@"{AppDomain.CurrentDomain.BaseDirectory}DATA/MIC07.mp3";
                    //wplayer.controls.play();
                    //MessageBox.Show("恭喜開通:一鍵開通功能!");

                    Pr_auto_button.Visible = true;
                }
                else if (Pr_auto_button.Visible == true)
                {
                    Pr_auto_button.Enabled = true;
                }
            }


            else if (Pr_Passwd_Box.Text != "")
            {
                //WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer();
                //wplayer.URL = $@"{AppDomain.CurrentDomain.BaseDirectory}DATA/MIC01.mp3";
                //wplayer.controls.play();
                //MessageBox.Show("密碼提示:每個同事的英文名字都可能有不同效果");
            }
        }