private static string getHostName(serverControl serv) { IPAddress hostIPAddress = IPAddress.Parse(serv.objectAddress); IPHostEntry hostInfo = Dns.GetHostEntry(hostIPAddress); return(hostInfo.HostName); }
private void перезагрузитьToolStripMenuItem_Click(object sender, EventArgs e) { serverControl serv = contextMenuStrip1.SourceControl as serverControl; beforeSending(serv, sender); // shutdown.exe", "-r -t 0 //Process p = Process.Start(@"cmd.exe", @"/c shutdown /r /m " + hN + " & pause"); }
private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e) { // Параллельный поток для отдельного хоста (ускорение прохода по списку хостов). int[] speeds = { speed1, speed2, speed3 }; System.ComponentModel.BackgroundWorker worker; worker = (System.ComponentModel.BackgroundWorker)sender; var myArgs = e.Argument as MyWorkerArgs; serverControl serv = myArgs.srv; networkProtocol np = myArgs.netP; workState = working; np.workState = working; np.parallelPingServers(worker, e, speeds, serv); }
private void deleteHostFromList(serverControl srv) { string message = "Вы уверены, что хотите удалить этот элемент?"; string caption = "Удалить " + srv.objectName; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; result = MessageBox.Show(message, caption, buttons); if (result == System.Windows.Forms.DialogResult.Yes) { srv.Dispose(); servers.Remove(srv); } drawServers(); }
private void addingServ(List <serverControl> servL, string n, string a) { // добавление уникального хоста в список для проверки serverControl tempS = new serverControl(n, a); if (!servL.Exists(x => x.objectAddress == a)) { tempS.ContextMenuStrip = contextMenuStrip1; servL.Add(tempS); } else { // сообщение о неуникальности tempS = servL.Find(x => x.objectAddress == a); MessageBox.Show("Уже существует хост с таким адресом. В программе имеет имя: " + tempS.objectName); } }
public void addCommandButton1(object sender, EventArgs e) { // ToolStripMenuItem cms = sender as ToolStripMenuItem; ContextCommands cmd = new ContextCommands(); //MessageBox.Show(cms.Name); serverControl serv = contextMenuStrip1.SourceControl as serverControl; cmd = commands.Find(x => x.commTS == cms); //cmd = sender as ContextCommands; MessageBox.Show(cmd.commName); if (cmd.Multi) { sendCommand(serv.objectAddress, cmd.commProgramm, cmd.commLines); } else { sendCommand(serv.objectAddress, cmd.commProgramm, cmd.commParams); } }
private void backgroundWorker2_ProgressChanged(object sender, ProgressChangedEventArgs e) { networkProtocol.CurrentState state = (networkProtocol.CurrentState)e.UserState; toolStripProgressBar1.Value = e.ProgressPercentage; string isOn; if (state.isOnline) { isOn = "online"; } else { isOn = "OFFLINE!!!"; } toolStripStatusLabel2.Text = state.address + " is " + isOn + "..."; toolStripStatusLabel1.Text = "Working. "; serverControl server = servers.Find(x => x.objectAddress == state.address); if (server.objectStatus != state.isOnline) { server.objectStatus = state.isOnline; } }
public MyWorkerArgs(serverControl server, networkProtocol np) { srv = server; netP = np; }
private void удалитьToolStripMenuItem_Click(object sender, EventArgs e) { serverControl serv = contextMenuStrip1.SourceControl as serverControl; deleteHostFromList(serv); }
private void addingServ(List<serverControl> servL, string n, string a) { // добавление уникального хоста в список для проверки serverControl tempS = new serverControl(n, a); if (!servL.Exists(x => x.objectAddress == a)) { tempS.ContextMenuStrip = contextMenuStrip1; servL.Add(tempS); } else { // сообщение о неуникальности tempS = servL.Find(x => x.objectAddress == a); MessageBox.Show("Уже существует хост с таким адресом. В программе имеет имя: " + tempS.objectName); } }
private void beforeSending(serverControl serv, object sender) { sendCommand(serv.objectAddress, "shutdown.exe", "-r -t 0"); }
private void переименоватьToolStripMenuItem_Click(object sender, EventArgs e) { serverControl serv = contextMenuStrip1.SourceControl as serverControl; serv.editMode = true; }
private static string getHostName(serverControl serv) { IPAddress hostIPAddress = IPAddress.Parse(serv.objectAddress); IPHostEntry hostInfo = Dns.GetHostEntry(hostIPAddress); return hostInfo.HostName; }
// выключатель компонента. void switchOff(serverControl sC) { sC.objectStatus = false; }
public MyEvArgs(object argument, serverControl srv) : base(argument) { Serv = srv; }