//move to engine public bool AddFile(string file) { if (file.Trim() == "") return true; LogBehavior behaviorForCurrentFile = _objChosenBehavior; bool blnLiveListen = false; string strLiveListen = ConfigurationManager.AppSettings["LiveListeningOnByDefault"]; if (strLiveListen != null && strLiveListen.Equals("true", StringComparison.InvariantCultureIgnoreCase)) blnLiveListen = true; if (timer1.Enabled == false && blnLiveListen) { timer1.Enabled = true; timer1.Start(); } //dataGridView1.DataSource = new BindingList<DSLogData.LogEntriesRow>(m_dvMainView.ToList()); //if (dataGridView1.Columns.Contains("EntryTime")) //{ // dataGridView1.Columns["EntryTime"].DefaultCellStyle.Format = DATE_TIME_FORMAT; // dataGridView1.Columns["EntryTime"].Width = 134; //} //string dir = Path.GetDirectoryName(file); //FileAttributes att = File.GetAttributes(file); if (!_colWatchedFiles.ContainsKey(file)) { behaviorForCurrentFile = FindCorrectBehaviorForFile(file); if (_objChosenBehavior != null && !IsAutoDetectMode) { _objChosenBehavior = behaviorForCurrentFile; cmbBehaviors.SelectedItem = _objChosenBehavior; if (_objChosenBehavior != null) { //set the grid columns dataGridView1.Columns.Clear(); _objChosenBehavior.CreateGridCols(dataGridView1); //set the default error level filter to initialize display. string strDefaultLevel = ConfigurationManager.AppSettings["DefaultLogLevel"]; if (!string.IsNullOrEmpty(strDefaultLevel)) { for (int i = 0; i < cmbLevel.Items.Count; ++i) { string item = (string)cmbLevel.Items[i]; if (item.Equals(strDefaultLevel, StringComparison.InvariantCultureIgnoreCase)) cmbLevel.SelectedIndex = i; } cmbBehaviors_SelectedIndexChanged(null, null); } } } //if there was no chosen behavior, return false if (behaviorForCurrentFile == null) { OpenNotepad(file); return false; } int intCountBefore = dataGridView1.Rows.Count; //parse the log file (using the chosen behaviour's regexp) long readBytes = ParseLogFileRegExp(file, 0, behaviorForCurrentFile); ////if no bytes were read, or an error occured, return false //if (readBytes == long.MinValue || readBytes == 0) //{ // OpenNotepad(file); // return false; //} ////if there were no lines read from this file //if (intCountBefore == dataGridView1.Rows.Count) //{ // OpenNotepad(file); // return false; //} _colWatchedFiles.Add(file, new FileInfo(file).Length); lstFiles.Items.Add(file); } lblCount.Text = "Total Count: " + _dvMainView.Count(); lblMemory.Text = "Used Ram: " + ((double)Process.GetCurrentProcess().WorkingSet64 / 1000000d).ToString(".00") + " MB"; RefreshFilter(); //success return true; }
//move to engine private void RepaseAllLogs(LogBehavior b) { _dtlogEntries.Clear(); _objChosenBehavior = b; //set the grid columns dataGridView1.Columns.Clear(); _objChosenBehavior.CreateGridCols(dataGridView1); LogBehavior behavior = _objChosenBehavior; foreach (string file in _colWatchedFiles.Keys.ToList()) { if (IsAutoDetectMode) { behavior = FindCorrectBehaviorForFile(file); } ParseLogFileRegExp(file, 0, behavior); } }