예제 #1
0
파일: Form1.cs 프로젝트: leovo2708/SSH
        private void btnPgReset_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Todas as conexões ao banco de dados serão encerradas. Continuar?", "Reiniciar Postgres?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dialogResult == DialogResult.Yes)
            {
                Servidor Serv = new Servidor();
                Serv = SetaServidor(false);
                Output("Reiniciando Postgres..." + Environment.NewLine + Environment.NewLine, true);
                string result = Comando(Serv, "/etc/rc.d/rc.postgres stop") as string;
                Output(result + Environment.NewLine + Environment.NewLine, true);
                Thread Pg = new Thread(new ThreadStart(this.PgCheck));
                Pg.Start();
            }
        }
예제 #2
0
파일: Form1.cs 프로젝트: leovo2708/SSH
        /// <summary>
        /// Método de que controla a execução automática na inicialização
        /// </summary>
        /// <returns></returns>
        public bool AutoExec()
        {
            Servidor Serv = SetaServidor(true);

            if (!Serv.Equals(null))
            {
                GravaConfig(Serv);
                ComparaTempo(Serv);
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
파일: Form1.cs 프로젝트: leovo2708/SSH
        private void btnRestart_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Reiniciar o Servidor?", "Reiniciar", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.Yes)
            {
                DialogResult dialogResult2 = MessageBox.Show("Tem certeza que deseja Reiniciar o Servidor??", "Reiniciar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (dialogResult2 == DialogResult.Yes)
                {
                    Servidor Serv = new Servidor();
                    Serv = SetaServidor(false);
                    Comando(Serv, "reboot");
                    Output("O servidor está reiniciando...\n\n\n", true);
                }
            }
        }
예제 #4
0
파일: Form1.cs 프로젝트: leovo2708/SSH
 private void wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         Servidor Serv = new Servidor();
         Serv = SetaServidor(false);
         Output("PuTTY baixado com sucesso...\nAbrindo sessão em " + Serv.host + "...\n\n\n", true);
         string args = string.Format("-ssh {0}@{1} 22 -pw {2}", Serv.user, Serv.host, Serv.pass);
         progressBar1.Visible = false;
         Process.Start(filename, args);
     }
     else
     {
         Output("Não foi possível iniciar o PuTTY./nFavor baixe manualmente.\n\n\n", true);
     }
 }
예제 #5
0
파일: Form1.cs 프로젝트: leovo2708/SSH
 /// <summary>
 /// Faz a conexão ao servidor
 /// </summary>
 /// <param name="Serv">Objeto com os dados de conexão ao servidor</param>
 /// <returns></returns>
 public object Conecta(Servidor Serv)
 {
     try
     {
         var client = new SshClient(Serv.host, Serv.user, Serv.pass); // cria objeto do cliente SSH
         client.Connect();                                            // conecta
         if (client.IsConnected)
         {
             return(client);                    // retorna objeto client se este não for nulo
         }
         else
         {
             return(null);
         }
     }
     catch (Exception exc)
     {
         Output(exc.Message + Environment.NewLine + Environment.NewLine + Environment.NewLine, true);
         return(null);
     }
 }
예제 #6
0
파일: Form1.cs 프로젝트: leovo2708/SSH
        /// <summary>
        /// Método maroto que seta os dados padrão caso todo o resto dê errado
        /// </summary>
        /// <returns></returns>
        public Servidor TryDefault()
        {
            Servidor Serv = new Servidor();

            Output("Não há nenhum servidor informado.\nBuscando dados por osmose, aguarde por favor...\n\n\n", true);
            Serv.host = GetServerAdress();
            Serv.user = "******";
            Serv.pass = "******"; //não mudem a senha padrão
            if (!Conecta(Serv).Equals(null))
            {
                Thread.Sleep(1398);
                Output("Conectado em " + Serv.host + Environment.NewLine + Environment.NewLine, true);
                GravaConfig(Serv);
                LeConfig();
                return(Serv);
            }
            else
            {
                return(null);
            }
        }