예제 #1
0
        private void OnFileChanged(object source, FileSystemEventArgs e)
        {
            bzParser obzParser = new bzParser();
            var      logs      = obzParser.ParseLogFile(_filePath) as BindingList <NlogEntity>;
            var      oldLogs   = grdLogs.DataSource as BindingList <NlogEntity>;

            if (logs != null)
            {
                var newLines = logs.Where(r => oldLogs != null && !oldLogs.Any(l => l.LogTime == r.LogTime && l.Message == r.Message));
                if (newLines.Any())
                {
                    int rowIndex = -1;
                    if (grdLogs.Rows.Count > 0)
                    {
                        rowIndex = grdLogs.CurrentRow.Index;
                    }
                    grdLogs.Invoke(new MethodInvoker(() => { grdLogs.DataSource = logs; }));
                    if (rowIndex <= 0 || rowIndex >= grdLogs.Rows.Count)
                    {
                        return;
                    }
                    if (grdLogs.Rows[rowIndex] == null)
                    {
                        return;
                    }
                    grdLogs.Rows[rowIndex].IsCurrent = true;
                }
            }
        }
예제 #2
0
 public void LoadGrid()
 {
     try
     {
         bzParser obzParser = new bzParser();
         var      logs      = obzParser.ParseLogFile(_filePath) as BindingList <NlogEntity>;
         grdLogs.DataSource = logs;
     }
     catch (FileNotFoundException)
     {
         RadMessageBox.Show("No file found!", "File not found", MessageBoxButtons.OK, RadMessageIcon.Error);
     }
     catch (Exception ex)
     {
         RadMessageBox.Show(ex.Message, "Error while loading file", MessageBoxButtons.OK, RadMessageIcon.Error);
     }
 }