예제 #1
0
 public Monitor(LogFileMonitor l)
 {
     logMonitor = l;
     logMonitor.ChangedLogMessage += this.parse;
     channel = l.FileChannel.Channel.ChannelName;
     logMonitor.Refresh(true);
 }
예제 #2
0
        public List <LogFileMonitor> ReadDirectory()
        {
            List <LogFileMonitor> monitors = new List <LogFileMonitor>();

            DirectoryInfo dir = new DirectoryInfo(Path);

            if (dir.Exists)
            {
                FileInfo[] files = dir.GetFiles(watch.Filter);

                files = files.OrderByDescending(x => x.LastWriteTime).ToArray <FileInfo>();

                foreach (FileInfo file in files)
                {
                    file.Refresh();
                    // only read log files that have been updated in the last 2 hours
                    if (file.LastWriteTime >= DateTime.Now.AddSeconds(-ReadLogsAferSeconds))
                    {
                        LogFileMonitor lfm = GetFileItem(file.FullName);
                        lfm.Refresh(true);

                        Boolean dupe = false;
                        foreach (LogFileMonitor m in monitors)
                        {
                            if (m.FileChannel.Channel.ChannelName == lfm.FileChannel.Channel.ChannelName)
                            {
                                dupe = true;
                                if (m.FileChannel.File.LastWriteTime < lfm.FileChannel.File.LastWriteTime)
                                {
                                    monitors.Remove(m);
                                    monitors.Add(m);
                                }
                                break;
                            }
                        }
                        if (!dupe)
                        {
                            monitors.Add(lfm);
                        }
                    }
                }
            }

            return(monitors);
        }
예제 #3
0
 public void read()
 {
     logMonitor.Refresh(false);
 }
예제 #4
0
 public Monitor(LogFileMonitor l)
 {
     logMonitor = l;
     logMonitor.ChangedLogMessage += this.parse;
     channel = l.FileChannel.Channel.ChannelName;
     logMonitor.Refresh(true);
 }