private void bt_Check_Click(object sender, EventArgs e) { bt_Check.Enabled = false; //Task resultTask = new; foreach (DataGridViewRow row in dataGridView1.Rows) { Task resultTask = Task.Factory.StartNew(() => { try { if (BEFunctions.MachineOnline(row.Cells[0].Value.ToString())) { row.Cells[1].Value = "True"; // lbl_Check_Count.Text = totalchecked.ToString(); } else { row.Cells[1].Value = "False"; totalchecked++; // lbl_Check_Count.Text = totalchecked.ToString(); } if (row.Cells[1].Value.ToString() == "True") { if (BEFunctions.canReachPath(row.Cells[0].Value.ToString())) { row.Cells[2].Value = "True"; } else { row.Cells[2].Value = "False"; totalchecked++; } if (row.Cells[2].Value.ToString() == "True") { if (BEFunctions.isCBInstalled(row.Cells[0].Value.ToString())) { row.Cells[3].Value = "True"; totalchecked++; } else { row.Cells[3].Value = "False"; totalchecked++; } } } lbl_Check_Count.Text = totalchecked.ToString(); } catch { } }); } if (totalcount == totalchecked) { bt_Execute.Enabled = true; } }
public void GetInfoBox() { bool Isonline; Computername = textBox1.Text; //Machine preflight checks is it online? Isonline = BEFunctions.MachineOnline(Computername); if (Isonline == true) { tb_Display.AppendText("Machine is online"); tb_Display.AppendText(Environment.NewLine); if (BEFunctions.canReachPath(Computername)) { tb_Display.AppendText("Admin share is accessible"); tb_Display.AppendText(Environment.NewLine); rb_Online.Checked = true; bt_Install.Enabled = true; } else { tb_Display.AppendText("Admin share is inaccessible"); tb_Display.AppendText(Environment.NewLine); rb_Offline.Checked = true; } //IS CB Installed? if (rb_Online.Checked) { if (BEFunctions.isCBInstalled(Computername)) { tb_Display.AppendText("Carbon Black local install found"); tb_Display.AppendText(Environment.NewLine); bt_Uninstall.Enabled = true; } else { tb_Display.AppendText("Carbon Black local install NOT found"); tb_Display.AppendText(Environment.NewLine); } } CBSensor cbSensor = BEFunctions.getCBSensorInfo(Computername); if (!(cbSensor.id == 0)) { tb_Display.AppendText("Carbon Black sensor found on server: " + cbSensor.id); tb_Display.AppendText(Environment.NewLine); tb_Display.AppendText("Carbon Black sensor version: " + cbSensor.build_version_string); tb_Display.AppendText(Environment.NewLine); tb_Display.AppendText("CB Last check-in: " + cbSensor.last_checkin_time); tb_Display.AppendText(Environment.NewLine); tb_Display.AppendText("CB Client OS: " + cbSensor.os_environment_display_string); tb_Display.AppendText(Environment.NewLine); bt_ViewFiles.Enabled = true; bt_LR_Install.Enabled = true; } else { tb_Display.AppendText("Carbon Black sensor instance not found."); tb_Display.AppendText(Environment.NewLine); } } else { tb_Display.AppendText("Machine hostname is offline."); tb_Display.AppendText(Environment.NewLine); rb_Offline.Checked = true; bt_Install_Sched.Enabled = true; CBSensor cbSensor = BEFunctions.getCBSensorInfo(Computername); if (!(cbSensor.id == 0)) { tb_Display.AppendText("Carbon Black sensor found on server: " + cbSensor.id); tb_Display.AppendText(Environment.NewLine); tb_Display.AppendText("Carbon Black sensor version: " + cbSensor.build_version_string); tb_Display.AppendText(Environment.NewLine); tb_Display.AppendText("CB Last check-in: " + cbSensor.last_checkin_time); tb_Display.AppendText(Environment.NewLine); tb_Display.AppendText("CB Client OS: " + cbSensor.os_environment_display_string); tb_Display.AppendText(Environment.NewLine); //bt_ViewFiles.Enabled = true; bt_LR_Install.Enabled = true; } else { tb_Display.AppendText("Carbon Black sensor instance not found."); tb_Display.AppendText(Environment.NewLine); } } }