public void runTaskShell(CmdShell cmds, TaskShell task) { ThreadPool.QueueUserWorkItem((a) => { string shdir = itemConfig.nginx.NginxPath; if (null != shdir) { if (shdir.EndsWith("/")) { shdir = shdir.Substring(0, shdir.Length - 1); } shdir = shdir.Substring(0, shdir.LastIndexOf("/") + 1); } string shell = task.Shell; if (shell.Contains("{nginx_dir}")) { shell = shell.Replace("{nginx_dir}", shdir); } if (shell.Contains("{nginx}")) { shell = shell.Replace("{nginx}", itemConfig.nginx.NginxPath); } shell = shell.Replace("//", "/"); monitorForm.RunShell(shell, false); }); }
public void runTaskShell(CmdShell cmds, TaskShell task) { ThreadPool.QueueUserWorkItem((a) => { string srvdir = itemConfig.ice.IceSrvDir; if (null != srvdir) { if (!srvdir.EndsWith("/")) { srvdir += "/"; } } string shell = task.Shell; if (shell.Contains("{icesrv_dir}")) { shell = shell.Replace("{icesrv_dir}", srvdir); } if (shell.Contains("{server_name}")) { shell = shell.Replace("{server_name}", l_server_name.Text); } if (shell.Contains("{adminsh}")) { shell = shell.Replace("{adminsh}", srvdir + "bin/admin.sh"); } shell = shell.Replace("//", "/"); monitorForm.RunShell(shell, false); }); }
private void button1_Click(object sender, EventArgs e) { string name = stb_name.Text; string cmdstr = cmd.Text; if (string.IsNullOrWhiteSpace(name)) { MessageBox.Show(this, "请定义一个名称"); return; } if (string.IsNullOrWhiteSpace(cmdstr)) { MessageBox.Show(this, "请输入要执行的命令"); return; } List <TaskShell> cmdList = new List <TaskShell>(); string[] cmds = cmdstr.Split('\n'); TaskShell task = null; foreach (string c in cmds) { if (!string.IsNullOrWhiteSpace(c.Trim())) { task = new TaskShell(); task.Uuid = Guid.NewGuid().ToString("N"); task.Name = ""; task.Shell = c.Trim(); cmdList.Add(task); } } bool isnew = false; if (shell == null) { shell = new CmdShell(); shell.Uuid = Guid.NewGuid().ToString("N"); shell.Target = uuid; isnew = true; } shell.Name = name; shell.Type = "自定义脚本"; shell.TaskType = TaskType.Default; shell.ShellList = cmdList; if (isnew) { config.CustomShellList.Add(shell); } AppConfig.Instance.SaveConfig(2); this.Close(); }
private void button2_Click(object sender, EventArgs e) { string name = task_name.Text; int count = customShellListView.Items.Count; if (string.IsNullOrWhiteSpace(name)) { MessageBox.Show(this, "请输入任务名称"); task_name.Focus(); } else if (count == 0) { MessageBox.Show(this, "请添加任务指令脚本(Shell)"); shell_name.Focus(); } else { ListView.ListViewItemCollection coll = customShellListView.Items; if (null == cmdShell) { cmdShell = new CmdShell(); cmdShell.Type = "定时任务"; cmdShell.TaskType = TaskType.Timed; } cmdShell.Name = name; JObject obj = null; JArray list = new JArray(); List <TaskShell> shellList = new List <TaskShell>(); TaskShell task = null; foreach (ListViewItem item in coll) { obj = (JObject)item.Tag; task = new TaskShell(); task.Uuid = Guid.NewGuid().ToString("N"); task.DateTime = obj["time"].ToString(); task.Shell = obj["code"].ToString(); task.Name = obj["name"].ToString(); shellList.Add(task); } cmdShell.ShellList = shellList; if (null != this.callback) { this.callback(cmdShell); } this.Close(); } }
public void runTaskShell(CmdShell cmds, TaskShell task) { ThreadPool.QueueUserWorkItem((a) => { string shdir = itemConfig.tomcat.TomcatDir; if (null != shdir) { if (!shdir.EndsWith("/")) { shdir += "/"; } } string shell = task.Shell; if (shell.Contains("{tomcat_dir}")) { shell = shell.Replace("{tomcat_dir}", shdir); } if (shell.Contains("{tomcat_webapps}")) { shell = shell.Replace("{tomcat_webapps}", shdir + "webapps/"); } if (shell.Contains("{tomcat_logs}")) { shell = shell.Replace("{tomcat_logs}", shdir + "logs/"); } if (shell.Contains("{tomcat_startup}")) { shell = shell.Replace("{tomcat_startup}", shdir + "bin/startup.sh"); } if (shell.Contains("{tomcat_shutdown}")) { shell = shell.Replace("{tomcat_shutdown}", shdir + "bin/shutdown.sh"); } shell = shell.Replace("//", "/"); monitorForm.RunShell(shell, false); }); }
public void runTaskShell(CmdShell cmds, TaskShell task) { ThreadPool.QueueUserWorkItem((a) => { string shdir = itemConfig.spring.ShFileDir; if (null != shdir) { if (!shdir.EndsWith("/")) { shdir += "/"; } } string shell = task.Shell; if (shell.Contains("{sh_bin_dir}")) { shell = shell.Replace("{sh_bin_dir}", shdir); } if (shell.Contains("{project_dir}")) { shell = shell.Replace("{project_dir}", l_source_path.Text); } if (shell.Contains("{build_sh_file}")) { shell = shell.Replace("{build_sh_file}", itemConfig.spring.BuildFileName); } if (shell.Contains("{ctl_sh_file}")) { shell = shell.Replace("{ctl_sh_file}", itemConfig.spring.CrlFileName); } shell = shell.Replace("//", "/"); monitorForm.RunShell(shell, false); }); }
private void button2_Click(object sender, EventArgs e) { string name = task_name.Text; int count = customShellListView.Items.Count; Object item1 = scb_condition1.SelectedItem; Object item2 = scb_condition2.SelectedItem; Object item3 = scb_condition3.SelectedItem; if (string.IsNullOrWhiteSpace(name)) { MessageBox.Show(this, "请输入任务名称"); task_name.Focus(); } else if (item1 == null) { MessageBox.Show(this, "请至少选择一个条件"); } else if (count == 0) { MessageBox.Show(this, "请添加任务指令脚本(Shell)"); shell_name.Focus(); } else { string condition = ""; ConditionItem ci1 = (ConditionItem)item1; condition += getItemUuid(ci1) + "," + (scb_status1.SelectedIndex == 1 ? "Y" : "N"); if (item2 != null) { ConditionItem ci2 = (ConditionItem)item2; condition += getItemCondi(1) + getItemUuid(ci2) + "," + (scb_status2.SelectedIndex == 1 ? "Y" : "N"); if (item3 != null) { ConditionItem ci3 = (ConditionItem)item2; condition += getItemCondi(2) + getItemUuid(ci3) + "," + (scb_status3.SelectedIndex == 1 ? "Y" : "N"); } } ListView.ListViewItemCollection coll = customShellListView.Items; if (null == cmdShell) { cmdShell = new CmdShell(); cmdShell.Uuid = Guid.NewGuid().ToString("N"); } JObject obj = null; JArray list = new JArray(); List <TaskShell> shellList = new List <TaskShell>(); TaskShell task = null; cmdShell.Name = name; cmdShell.TaskType = TaskType.Condition; cmdShell.Condition = condition; cmdShell.Type = "条件任务"; foreach (ListViewItem item in coll) { obj = (JObject)item.Tag; task = new TaskShell(); task.Uuid = Guid.NewGuid().ToString("N"); task.Shell = obj["code"].ToString(); task.Name = obj["name"].ToString(); shellList.Add(task); } cmdShell.ShellList = shellList; if (null != this.callback) { this.callback(cmdShell); } this.Close(); } }