コード例 #1
0
ファイル: DeviceManger.cs プロジェクト: xfhxfh1212/AGI_PC
 /// <summary>
 /// 重启线程
 /// </summary>
 /// <param name="connDevice"></param>
 public void RebootThreadFun(Device connDevice)
 {
     try
     {
         string hostname = connDevice.IpAddress;
         sshreader = new SshReader(hostname, 22, "root", "13M1877");
         sshreader.OpenConnect();
         sshreader.WaitString("]#");
         sshreader.InputCommand("reboot");
         ChangeStatus();
     }
     catch (System.Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message + "\n" + ex.StackTrace);
         ChangeStatus();
         MessageBox.Show(string.Format("Failed to connect the remote server.{0}:22", connDevice.IpAddress));
         return;
     }
     MessageBox.Show(string.Format("Rebooting the server:{0}:22...please click the button 'Connect' later.", connDevice.IpAddress));
 }
コード例 #2
0
ファイル: DeviceManger.cs プロジェクト: xfhxfh1212/AGI_PC
 public void RebootThreadFunc(Device connDevice)
 {
     try
     {
         string hostname = connDevice.IpAddress;
         sshreader = new SshReader(hostname, 22, "root", "13M1877");
         sshreader.OpenConnect();
         sshreader.WaitString("]#");
         sshreader.InputCommand("reboot");
         connDevice.timer.Enabled = false;
         try
         {
             connDevice.DataRecv1.Abort();
         }
         catch { }
         Thread.Sleep(70000);
         connDevice.HeartCheckStart = false;
         connDevice.ConnectionState = (byte)Global.DeviceStateValue.Disconnection;
         while (true)
         {
             if (connDevice.ConnectionState == (byte)Global.DeviceStateValue.Disconnection)
             {
                 connDevice.NewMessageConn();
                 Thread.Sleep(3000);
             }
             else
             {
                 return;
             }
         }
     }
     catch (System.Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message + "\n" + ex.StackTrace);
         //MessageBox.Show(ex.Message);
         return;
     }
     //MessageBox.Show(string.Format("Rebooting the server:{0}:22...please click the button 'Connect' later.", connDevice.IpAddress));
 }