public static ITailWatcher CreateWatcher(string path, ISerialFileReader serialFileReader, Action<Exception> exceptionHandler)
 {
     switch (ReaderFactory.GetReaderType(path))
     {
         case ReaderType.File:
             return new TailFileWatcher(serialFileReader, exceptionHandler);
         case ReaderType.EventLog:
             return new TailEventLogWatcher(serialFileReader, exceptionHandler);
         default:
             throw new NotImplementedException();
     }
 }
Example #2
0
        public static ITailWatcher CreateWatcher(string path, ISerialFileReader serialFileReader, Action <Exception> exceptionHandler)
        {
            switch (ReaderFactory.GetReaderType(path))
            {
            case ReaderType.File:
                return(new TailFileWatcher(serialFileReader, exceptionHandler));

            case ReaderType.EventLog:
                return(new TailEventLogWatcher(serialFileReader, exceptionHandler));

            default:
                throw new NotImplementedException();
            }
        }
Example #3
0
        public virtual void StartTail(bool save = true, bool stop = true)
        {
            serialFileReader = new CallbackFileReader(new ReaderFactory())
            {
                StartCallback     = FormInterface.StartCallback,
                UpdateCallback    = FormInterface.UpdateCallback,
                FinishCallback    = FormInterface.FinishCallback,
                ExceptionCallback = FormInterface.ExceptionCallback,
                LoadLastLines     = FormInterface.LoadLastLinesCallback,
                Filter            = FormInterface.GetFilterCallback
            };

            if (save)
            {
                Properties.Settings.Default.LastFile = FormInterface.GetFileNameCallback();
            }

            if (stop && tailThread != null)
            {
                StopTail();
            }

            if (tailThread == null)
            {
                tailThread = new TailThread(TailWatcherFactory.CreateWatcher(FormInterface.GetFileNameCallback(),
                                                                             serialFileReader, FormInterface.ExceptionCallback));
            }

            FormInterface.ClearDisplayCallback();

            var file = FormInterface.GetFileNameCallback();

            try
            {
                if (string.IsNullOrEmpty(file))
                {
                    return;
                }

                serialFileReader.EnableQueue(true);
                tailThread.Start(file);

                FormInterface.SetStateCallback(true);
            }
            catch (Exception ex)
            {
                FormInterface.ExceptionCallback(ex);
            }
        }
Example #4
0
        public virtual void StartTail(bool save = true, bool stop = true)
        {
            serialFileReader = new CallbackFileReader(new ReaderFactory())
            {
                StartCallback = FormInterface.StartCallback,
                UpdateCallback = FormInterface.UpdateCallback,
                FinishCallback = FormInterface.FinishCallback,
                ExceptionCallback = FormInterface.ExceptionCallback,
                LoadLastLines = FormInterface.LoadLastLinesCallback,
                Filter = FormInterface.GetFilterCallback
            };

            if (save)
            {
                Properties.Settings.Default.LastFile = FormInterface.GetFileNameCallback();
            }

            if (stop && tailThread != null)
            {
                StopTail();
            }

            if (tailThread == null)
            {
                tailThread = new TailThread(TailWatcherFactory.CreateWatcher(FormInterface.GetFileNameCallback(),
                    serialFileReader, FormInterface.ExceptionCallback));
            }

            FormInterface.ClearDisplayCallback();

            var file = FormInterface.GetFileNameCallback();

            try
            {
                if (string.IsNullOrEmpty(file))
                {
                    return;
                }

                serialFileReader.EnableQueue(true);
                tailThread.Start(file);

                FormInterface.SetStateCallback(true);
            }
            catch (Exception ex)
            {
                FormInterface.ExceptionCallback(ex);
            }
        }
Example #5
0
 public TailFileWatcher(ISerialFileReader serialFileReader, Action <Exception> exceptionHandler)
 {
     this.serialFileReader = serialFileReader;
     this.exceptionHandler = exceptionHandler;
 }
Example #6
0
 public TailFileWatcher(ISerialFileReader serialFileReader, Action<Exception> exceptionHandler)
 {
     this.serialFileReader = serialFileReader;
     this.exceptionHandler = exceptionHandler;
 }