private void KillProcess(bool flag) { //获得进程对象,以用来操作 System.Diagnostics.Process myproc = new System.Diagnostics.Process(); //得到所有打开的进程 try { //获得需要杀死的进程名 foreach (System.Diagnostics.Process thisproc in System.Diagnostics.Process.GetProcessesByName("7DaysToDie")) { //立即杀死进程 thisproc.Kill(); } if (flag) { Log_richTextBox.AppendText(DateTime.Now.ToString() + "\n清理冲突进程!\n"); return; } Log_richTextBox.AppendText(DateTime.Now.ToString() + "\n服务已停止!\n"); } catch (Exception Exc) { MessageBox.Show(Exc.Message); } }
public void SaveOptions() { for (int i = 0; i < ServerView.Rows.Count; i++) { object tmp = ServerView.Rows[i].Cells[1].Value; if (tmp == null) { tmp = ""; } ((XmlElement)personNodes.Item(i)).SetAttribute("value", tmp.ToString()); } doc.Save(file); Log_richTextBox.AppendText(DateTime.Now.ToString() + "\n保存配置成功!\n"); }
private void Reboot_btn_Click(object sender, EventArgs e) { try { SetServerItem(); KillProcess(false); RunServer(); ShowPort(); Log_richTextBox.AppendText(DateTime.Now.ToString() + "\n正在重新启动!\n请等待...\n如长时间未启动,请检查配置后.重新启动!\n"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void printSettings(string path) { if (File.Exists(path + "\\Settings.txt")) { StreamReader config = new StreamReader(path + "\\Settings.txt"); Log_richTextBox.AppendText("------------Current Settings------------"); Log_richTextBox.AppendText(Environment.NewLine); config.ReadLine(); Log_richTextBox.AppendText("Output Directory: " + config.ReadLine() + Environment.NewLine); Log_richTextBox.AppendText("Spreadsheet ID: " + config.ReadLine() + Environment.NewLine); Log_richTextBox.AppendText("Coulumns: " + config.ReadLine() + Environment.NewLine); Log_richTextBox.AppendText("Entity Type: " + config.ReadLine() + Environment.NewLine); Log_richTextBox.AppendText("Headers: " + config.ReadLine() + Environment.NewLine); Log_richTextBox.AppendText(Environment.NewLine); config.Close(); } else { Log_richTextBox.AppendText("------------No Settings Available------------"); } }
private void Log_richTextBox_TextChanged(object sender, EventArgs e) { Log_richTextBox.ScrollToCaret(); }
private void Run_btn_Click(object sender, EventArgs e) { KillProcess(true); RunServer(); Log_richTextBox.AppendText(DateTime.Now.ToString() + "\n正在启动!\n请等待...\n如长时间未启动,请检查配置后.重新启动!\n"); }