private void saveButton_Click(object sender, EventArgs e) { Parser pars = new Parser(); for (int i = 0; i < ParserGrid.Rows.Count; i++) { DataGridViewRow currentRow = ParserGrid.Rows[i]; if (currentRow.Cells[0].Value != null) { if (currentRow.Cells[1].Value == null) currentRow.Cells[1].Value = ""; if (currentRow.Cells[2].Value == null) currentRow.Cells[2].Value = ""; if (currentRow.Cells[3].Value == null) currentRow.Cells[3].Value = ""; //pars.addRule(currentRow.Cells[0].Value.ToString(), currentRow.Cells[1].Value.ToString(), currentRow.Cells[2].Value.ToString(), currentRow.Cells[3].Value.ToString()); try { pars.addRule(currentRow.Cells[0].Value.ToString(), currentRow.Cells[1].Value.ToString(), currentRow.Cells[2].Value.ToString(), currentRow.Cells[3].Value.ToString()); } catch (Exception exp) { //MessageBox.Show("data" + currentRow.Cells[2].Value.ToString()); } } } pars.saveToFile(); MessageBox.Show("Внимание! После изменения настроек парсера необходимо перезапустить программу."); Close(); }
public Form4(string trapID, TrapList tList, Parser tParser) { InitializeComponent(); Trap tmpTrap = tList.getTrapById(trapID); textBox6.Text = tmpTrap.tTime; textBox5.Text = tmpTrap.tIPAddress; foreach (ParserRule rls in tParser.ruleList) { richTextBox1.AppendText(rls.name + " = " + tmpTrap.fields[rls.param] + Environment.NewLine); } richTextBox1.AppendText(Environment.NewLine + "Исходный трап:" + Environment.NewLine); try { } catch (Exception e) { MessageBox.Show("Нет данных для отображения."); } richTextBox1.AppendText(tmpTrap.trapSource.ToString()); }
public Form1() { InitializeComponent(); System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false; this.conf = new VilcomConfiguration(); this.conf = this.conf.loadFromFile(); this.excludes = new VilcomExcludes(); this.excludes = this.excludes.loadFromFile(); timer1.Enabled = true; Client = new UdpClient(conf.port); //загрузим парсер try { parseConf = new Parser(); parseConf.loadFromFile(); foreach (ParserRule ruleConf in parseConf.ruleList) { TrapGrid.Columns.Add(ruleConf.param, ruleConf.name); } _debug("Конфигурация парсера загружена!"); } catch (Exception excp) { //MessageBox.Show("Внимание! Файл конфигурации парсера не найден или был утерян"); } //попытаемся подгрузить данные из трапа if (File.Exists("state.data")) { tList.loadFromFile(); foreach (Trap trapTemp in tList.dataList) { addTrapToGrid(trapTemp); } } taskbarNotifier = new TaskbarNotifier(); taskbarNotifier.SetBackgroundBitmap("notifyback.bmp", Color.FromArgb(255, 0, 255)); taskbarNotifier.SetCloseBitmap("close.bmp", Color.FromArgb(255, 0, 255), new Point(220, 8)); taskbarNotifier.TitleRectangle = new Rectangle(20, 9, 70, 2); taskbarNotifier.ContentRectangle = new Rectangle(8, 20, 200, 68); taskbarNotifier.NormalContentFont = new Font("Arial",9); //taskbarNotifier.TitleClick += new EventHandler(TitleClick); //taskbarNotifier.ContentClick += new EventHandler(ContentClick); taskbarNotifier.CloseClick += new EventHandler(Close2Click); }
public Form5() { InitializeComponent(); try { Parser pars = new Parser(); pars.loadFromFile(); for (int i = 0; i < pars.ruleList.Count; i++) { ParserRule rls = pars.ruleList[i]; ParserGrid.Rows.Add(rls.oid, rls.name,rls.param,rls.textPattern); } } catch (Exception e) { MessageBox.Show("Файл парсера не был найден. необходимо создать парсер заново."); } }
public Trap(string ip, SnmpV2Packet pckt) { tIPAddress = ip; tTime = getTime(); tCommunity = pckt.Community.ToString(); trapSource = pckt.Pdu.ToString(); trapID = getMD5Hash(trapSource); sourcePacket = pckt; Parser parseMe = new Parser(); //загрузим парсер parseMe.loadFromFile(); foreach (ParserRule rls in parseMe.ruleList) { //попытаемся добавить каждый оид из указанных в парсере fields[rls.param] = getTrapByOID(pckt, rls.oid,rls.textPattern); // MessageBox.Show("add to trap: " + rls.name + " " + rls.oid + "--" + fields[rls.param]); } //MessageBox.Show(trapSource); }