예제 #1
0
        // Slanje skripte MikroTik-u
        public void sendScriptToMikroTik()
        {
            string raw  = "";
            string temp = "";

            try
            {
                /* Ovo radi ispravno*/
                //streamReader = new StreamReader("script.txt");
                //streamReaderSxt = new StreamReader("script_sxt.txt");
                /* Novo dodato */
                streamReader    = new StreamReader(new MemoryStream(Encoding.ASCII.GetBytes(Properties.Resources.script)));
                streamReaderSxt = new StreamReader(new MemoryStream(Encoding.ASCII.GetBytes(Properties.Resources.script_sxt)));

                raw = streamReaderSxt.ReadLine();
                while (raw != null)
                {
                    telnet.WriteLine(raw + "\r");
                    raw = streamReaderSxt.ReadLine();
                    Thread.Sleep(200);
                }

                raw = streamReader.ReadLine();
                raw = raw.Replace("$1", readTextUsername());
                raw = raw.Replace("$2", readTextPassword());
                mail.addLine("Korisnicki nalog: " + readTextUsername());
                telnet.WriteLine(raw + "\r");
                Thread.Sleep(200);

                raw = streamReader.ReadLine();
                raw = raw.Replace("edited from outside", readTextUserData());
                mail.addLine("Korisnicko ime i prezime: " + readTextUserData());
                mail.addSubject("Novi extra paket - " + readIdManager() + " " + readTextUserData());
                while (raw != null)
                {
                    telnet.WriteLine(raw + "\r");
                    raw  = streamReader.ReadLine();
                    temp = raw;
                    if (temp != null)
                    {
                        if (temp.IndexOf('#') != -1)
                        {
                            int count;
                            count = hashCode.hash.IndexOf('0');
                            raw   = temp.Replace("#", hashCode.hash.Substring(count + 1, 12));
                        }
                    }
                    Thread.Sleep(200);
                }
                writeToConsole("Skripta je zavrsena.");
            }
            catch
            {
                writeToConsole("Could not open file.");
            }
        }
예제 #2
0
        private void resetDevice()
        {
            // kreiranje nove konekcije za reset
            Telnet resetMikroTik = new Telnet();
            string temp          = resetMikroTik.setTelnetConnection(textIpAddress.Text);

            if (temp != "Connected.")
            {
                MessageBox.Show("Problem sa konekcijom.\nPokusajte ponovo.");
            }
            else
            {
                disableButton();
                resetMikroTik.Login("backup" + "+ct\r\n", "M29u8wHz6c4r\r\n");
                Thread.Sleep(2000);
                writeToConsole("Mikrotik se resetuje.");
                resetMikroTik.Login("admin" + "+ct\r\n", "\r\n");
                Thread.Sleep(2000);
                resetMikroTik.WriteLine("/system reset-configuration" + "\ry");
                Thread.Sleep(2000);
                resetMikroTik.WriteLine("/system reset-configuration" + "\ry");
                writeToConsole("Pokrenite aplikaciju ponovo.");
            }
        }
예제 #3
0
파일: Form1.cs 프로젝트: Hispanion/MikroTik
 private void resetDevice()
 {
     // kreiranje nove konekcije za reset
     Telnet resetMikroTik = new Telnet();
     string temp = resetMikroTik.setTelnetConnection(textIpAddress.Text);
     if (temp != "Connected.")
     {
         MessageBox.Show("Problem sa konekcijom.\nPokusajte ponovo.");
     }
     else
     {
         disableButton();
         resetMikroTik.Login("backup" + "+ct\r\n", "M29u8wHz6c4r\r\n");
         Thread.Sleep(2000);
         writeToConsole("Mikrotik se resetuje.");
         resetMikroTik.Login("admin" + "+ct\r\n", "\r\n");
         Thread.Sleep(2000);
         resetMikroTik.WriteLine("/system reset-configuration" + "\ry");
         Thread.Sleep(2000);
         resetMikroTik.WriteLine("/system reset-configuration" + "\ry");
         writeToConsole("Pokrenite aplikaciju ponovo.");
     }
 }