private void RunButton_Click(object sender, RoutedEventArgs e) { string user = UserTextBox.Text.Trim(); string password = PasswordTextBox.Text.Trim(); foreach (var item in (List <VM>)VMList.ItemsSource) { string clientname = item.MachineName; if (item.IsChecked) { try { InvokeSSH ssh = new InvokeSSH(clientname, user, password); item.CommandResult = ssh.Run(CommandTextBox.Text.Trim()); if (!string.IsNullOrEmpty(ssh.ErrorMessage)) { item.CommandResult = ssh.ErrorMessage; } } catch (Exception exca2) { item.CommandResult = "Error:" + exca2.ToString(); } } VMList.Items.Refresh(); } VMList.Items.Refresh(); }
private void uploadButton_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "All files (*.*)|*.*"; openFileDialog.InitialDirectory = Directory.GetCurrentDirectory(); if (openFileDialog.ShowDialog() == true) { string fileName = openFileDialog.FileName; string user = UserTextBox.Text.Trim(); string password = PasswordTextBox.Text.Trim(); foreach (var item in (List <VM>)VMList.ItemsSource) { string clientname = item.MachineName; if (item.IsChecked) { try { InvokeSSH ssh = new InvokeSSH(clientname, user, password); ssh.Run("mkdir /tmp"); ssh.Upload("/tmp/" + System.IO.Path.GetFileName(fileName), fileName); item.CommandResult = "Done uploading."; } catch (Exception exca2) { item.CommandResult = "Error:" + exca2.ToString(); } } VMList.Items.Refresh(); } VMList.Items.Refresh(); } else { MessageBox.Show("Please select a file to upload!"); return; } }