private void _edLogWatcherBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (logPath == null) return;
            using (var fs = new FileStream(logPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            using (var reader = new StreamReader(fs))
            {
                reader.BaseStream.Seek(0, SeekOrigin.End);
                do
                {
                    if (_edLogWatcherBackgroundWorker.CancellationPending) e.Cancel = true;
                    var line = reader.ReadLine();
                    if (!String.IsNullOrWhiteSpace(line))
                    {
                        var logline = new EdLogLine(line);
                        if (logline.isSystem)
                        {
                            var edsystem = logline.parseSystem();
                            ClientArrivedtoNewSystem(this, new EdLogLineSystemArgs(edsystem)); //Raises event, Form1 will subscribe and update currentsystem
                            
                        }
                    }
                    else
                        Thread.Sleep(5000);

                } while (!e.Cancel);
            }
        }
Esempio n. 2
0
 private void _edLogWatcherBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     if (logPath == null)
     {
         return;
     }
     using (var fs = new FileStream(logPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
         using (var reader = new StreamReader(fs))
         {
             reader.BaseStream.Seek(0, SeekOrigin.End);
             do
             {
                 if (_edLogWatcherBackgroundWorker.CancellationPending)
                 {
                     e.Cancel = true;
                 }
                 var line = reader.ReadLine();
                 if (!String.IsNullOrWhiteSpace(line))
                 {
                     var logline = new EdLogLine(line);
                     if (logline.isSystem)
                     {
                         var edsystem = logline.parseSystem();
                         ClientArrivedtoNewSystem(this, new EdLogLineSystemArgs(edsystem)); //Raises event, Form1 will subscribe and update currentsystem
                     }
                 }
                 else
                 {
                     Thread.Sleep(5000);
                 }
             } while (!e.Cancel);
         }
 }
Esempio n. 3
0
 private void scanLogfileforLastVisitedSystem(string path)
 {
     //Read logfile from bottom to top
     if (path == null)
     {
         return;
     }
     using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
     {
         foreach (var s in  ReadLineReverse(fs, 1))
         {
             var line    = s.Replace("\n", string.Empty).Replace("\r", string.Empty);
             var logline = new EdLogLine(line);
             if (logline.isSystem)
             {
                 var edsystem = logline.parseSystem();
                 ClientArrivedtoNewSystem(this, new EdLogLineSystemArgs(edsystem)); //Raises event, Form1 will subscribe and update currentsystem
                 return;
             }
         }
     }
 }
        private void scanLogfileforLastVisitedSystem(string path)
        {
            //Read logfile from bottom to top
            if (path == null) return;
            using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                foreach (var s in  ReadLineReverse(fs, 1))
                {
                    var line = s.Replace("\n", string.Empty).Replace("\r", string.Empty);
                    var logline = new EdLogLine(line);
                    if (logline.isSystem)
                    {
                        var edsystem = logline.parseSystem();
                        ClientArrivedtoNewSystem(this, new EdLogLineSystemArgs(edsystem)); //Raises event, Form1 will subscribe and update currentsystem
                        return;
                    }
                }
            }

        }