public void Init(SSHParam inparam, STRule inrule, string innodename) { sshParam = inparam; string filepathname = string.Format("/tmp/{0}{1}{2}", innodename, DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss"), inrule.rFileName); inrule.rFileName = filepathname; STTask task = new STTask(); task.myRule = inrule; task.hName = innodename; task.GetCmdLine(); myTask = task; try { sshclient = new SshClient(sshParam.hostIP, sshParam.userName, sshParam.userPWD); if (sshclient == null) { return; } sshclient.Connect(); sshcmd = sshclient.CreateCommand(task.GetCmdLine()); ssharesult = sshcmd.BeginExecute(); } catch (Exception exc) { exc.ToString(); } }
void Bt_delruleClick(object sender, EventArgs e) { if (listBox_allrules.SelectedIndex >= 0) { editRule = listBox_allrules.SelectedItem as STRule; allRules.Remove(editRule); } }
void Bt_editruleClick(object sender, EventArgs e) { if (listBox_allrules.SelectedIndex >= 0) { editRule = listBox_allrules.SelectedItem as STRule; param_2_ctrl(editRule); } }
public void RulesInit() { journal_short_rule = new STRule(); journal_short_rule.RuleName = "journalctl rule with short-precise option"; journal_short_rule.rType = STRuleType.Block; journal_short_rule.rFileOption = string.Empty; journal_short_rule.rFileName = string.Empty; RulesUpdate(); }
public NonBlockFileSession(string inHost, string inUserName, string inPwd, string inCmd, string inOP, string infilename, string innodename) { SSHParam para = new SSHParam(inHost, inUserName, inPwd); STRule rule = new STRule(); rule.rCmdLine = inCmd; rule.rFileOption = inOP; rule.rFileName = infilename; rule.rType = STRuleType.NonBlockFile; rule.rName = "NonBlockFileSession internal"; Init(para, rule, innodename); }
void Bt_saveClick(object sender, EventArgs e) { if (editRule != null) { if (this.allRules.Contains(editRule) == false) { this.allRules.Add(editRule); } } editRule = null; this.groupBox1.Enabled = false; }
public void dummy() { STRule obj = null; obj = new STRule(); obj.rCmdLine = "ls -lah"; obj.rType = STRuleType.Block; obj.rFileOption = string.Empty; obj.rName = "show ls result"; allRules.Add(obj); obj = new STRule(); obj.rCmdLine = "ps -ef"; obj.rType = STRuleType.Block; obj.rFileOption = string.Empty; obj.rName = "show ps result"; allRules.Add(obj); }
public void update_ruleitem_show() { if (listBox_allrules.SelectedIndex >= 0) { STRule selectedruleitem = listBox_allrules.SelectedItem as STRule; this.label_show_ruleitem.Text = string.Format("{0}\n\tRuleName:{1}\n\tRuleCmd:{2} {3} {4}\n\tRuleType:{5}", listBox_allrules.SelectedIndex.ToString(), selectedruleitem.RuleName, selectedruleitem.RuleCmdLine, selectedruleitem.RuleFileOption, selectedruleitem.RuleFileName, selectedruleitem.RuleType.ToString()); } else { this.label_show_ruleitem.Text = "No rule item selected"; } }
public STTask() { hName = string.Empty; hPort = 22; myRule = null; }
public void ctrl_2_param(STRule inrule) { inrule.RuleName = this.tb_rulename.Text; inrule.RuleCmdLine = this.tb_rulecmd.Text; inrule.RuleFileName = this.tb_filename.Text; }
public void param_2_ctrl(STRule inrule) { this.tb_rulename.Text = inrule.RuleName; this.tb_rulecmd.Text = inrule.RuleCmdLine; this.tb_filename.Text = inrule.RuleFileName; }