private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { var senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { //var copy_cell = senderGrid.Rows[e.RowIndex].Cells["CopyIP"] as DataGridViewButtonCell; var restart_cell = senderGrid.Rows[e.RowIndex].Cells["RestartSS"] as DataGridViewButtonCell; var server = servers[e.RowIndex]; var extension = extenstions[server.Id]; //if (senderGrid.Columns[e.ColumnIndex].Name == "CopyIP") //{ // if (!string.IsNullOrWhiteSpace(servers[e.RowIndex].IP)) // { // Clipboard.SetText(servers[e.RowIndex].IP); // extension.IpCopied = true; // copy_cell.Value = "Copied"; // } //} if (senderGrid.Columns[e.ColumnIndex].Name == "RestartSS") { if (!string.IsNullOrWhiteSpace(servers[e.RowIndex].IP)) { ShadowsocksUtility.Restart(server.IP); extension.ShadowsocksRestarted = true; restart_cell.Value = "Restarted"; } } if (senderGrid.Columns[e.ColumnIndex].Name == "Start") { string command = "ec2 start-instances --instance-ids " + servers[e.RowIndex].Id; string result = AwsCommandUtility.Call(command); resultTextBox.Text += "\r\n" + result; Refresh(); } if (senderGrid.Columns[e.ColumnIndex].Name == "Stop") { string command = "ec2 stop-instances --instance-ids " + servers[e.RowIndex].Id; string result = AwsCommandUtility.Call(command); resultTextBox.Text = result; extension.IpCopied = false; extension.ShadowsocksRestarted = false; Refresh(); } if (senderGrid.Columns[e.ColumnIndex].Name == "SSH") { string result = AwsCommandUtility.Ssh(servers[e.RowIndex].PublicDns); resultTextBox.Text = result; } } }
public IActionResult Ec2() { string ec2 = AwsCommandUtility.Call("aws", "ec2 describe-instances"); return(Json(ec2)); }
public IActionResult Whoami() { string whoami = AwsCommandUtility.Call("whoami", null); return(Json(whoami)); }