private void GoToEvent_Test(string eventLogPath)
        {
            string dataAfterGoEvent     = string.Empty;
            string dataAfterSetPosition = string.Empty;

            using (EventLogReader reader = EventLogReader.CreateReader(eventLogPath))
            {
                reader.GoToEvent(5);
                EventLogPosition eventPosition = reader.GetCurrentPosition();
                if (reader.Read())
                {
                    dataAfterGoEvent = reader.CurrentRow.Data;
                }

                reader.Reset();

                reader.SetCurrentPosition(eventPosition);
                if (reader.Read())
                {
                    dataAfterSetPosition = reader.CurrentRow.Data;
                }
            }

            Assert.Equal(dataAfterGoEvent, dataAfterSetPosition);
        }
        private void GetAndSetPosition_Test(string eventLogPath)
        {
            long countRecords           = 0;
            long countRecordsStepByStep = 0;
            long countRecordsStepByStepAfterSetPosition = 0;

            using (EventLogReader reader = EventLogReader.CreateReader(eventLogPath))
            {
                countRecords = reader.Count();

                while (reader.Read())
                {
                    countRecordsStepByStep += 1;
                }

                reader.Reset();
                EventLogPosition position = reader.GetCurrentPosition();
                while (reader.Read())
                {
                    ;
                }
                reader.SetCurrentPosition(position);
                while (reader.Read())
                {
                    countRecordsStepByStepAfterSetPosition += 1;
                }
            }

            Assert.NotEqual(0, countRecords);
            Assert.NotEqual(0, countRecordsStepByStep);
            Assert.NotEqual(0, countRecordsStepByStepAfterSetPosition);
            Assert.Equal(countRecords, countRecordsStepByStep);
            Assert.Equal(countRecords, countRecordsStepByStepAfterSetPosition);
        }
        public bool NewDataAvailable()
        {
            if (_reader == null)
            {
                return(false);
            }
            if (_target == null)
            {
                return(false);
            }
            if (_eventLogPath == null)
            {
                return(false);
            }

            EventLogPosition lastPosition = _target.GetLastPosition();

            bool newDataExist;

            _reader.AfterReadFile  -= EventLogReader_AfterReadFile;
            _reader.AfterReadEvent -= EventLogReader_AfterReadEvent;
            _reader.OnErrorEvent   -= EventLogReader_OnErrorEvent;
            _reader.Reset();

            // В случае, если каталог последней позиции не совпадает
            // с текущим каталогом данных, то предыдущую позицию не учитываем
            if (lastPosition != null)
            {
                FileInfo lastDataFileInfo    = new FileInfo(lastPosition.CurrentFileReferences);
                FileInfo currentDataFileInfo = new FileInfo(_reader.CurrentFile);

                if (lastDataFileInfo.Directory != null && currentDataFileInfo.Directory != null)
                {
                    if (lastDataFileInfo.Directory.FullName != currentDataFileInfo.Directory.FullName)
                    {
                        lastPosition = null;
                    }
                }
            }

            _reader.SetCurrentPosition(lastPosition);
            newDataExist = _reader.Read();

            return(newDataExist);
        }