/// <summary> /// Opens a <see cref="LogReader"/> that reads unicast entries only from this monitor and positions it on the first entry /// with the given time (i.e. <see cref="LogReader.MoveNext"/> has been called). /// </summary> /// <param name="logTime">Log time. Must exist in the stream otherwise an exception is thrown.</param> /// <returns>A log reader that will read only entries from this monitor.</returns> public LogReader CreateFilteredReaderAndMoveTo(DateTimeStamp logTime) { var r = LogReader.Open(LogFile.FileName, FirstOffset, new LogReader.MulticastFilter(MonitorId, LastOffset)); while (r.MoveNext() && r.Current.LogTime < logTime) { ; } return(r); }
/// <summary> /// Opens a <see cref="LogReader"/> that reads unicast entries only from this monitor and positions it on the first entry /// with the given time (i.e. <see cref="LogReader.MoveNext"/> has been called). /// </summary> /// <param name="logTime">Log time. Must exist in the stream otherwise an exception is thrown.</param> /// <returns>A log reader that will read only entries from this monitor.</returns> public LogReader CreateFilteredReaderAndMoveTo(DateTimeStamp logTime) { var r = LogReader.Open(LogFile.FileName, FirstOffset, new LogReader.MulticastFilter(MonitorId, LastOffset)); while (r.MoveNext() && r.Current.LogTime < logTime) { ; } if (r.ReadException != null || r.BadEndOfFileMarker) { r.Dispose(); Throw.InvalidDataException($"Unable to read '{LogFile.FileName}' for monitor '{MonitorId}' from offset {LastOffset}.", r.ReadException); } return(r); }
/// <summary> /// Creates and opens a <see cref="LogReader"/> that reads unicast entries only from this monitor. /// The reader is positioned on the entry (i.e. <see cref="LogReader.MoveNext"/> has been called). /// </summary> /// <param name="streamOffset">Initial stream position.</param> /// <returns>A log reader that will read only entries from this monitor.</returns> public LogReader CreateFilteredReaderAndMoveTo(long streamOffset) { if (streamOffset == -1) { streamOffset = FirstOffset; } var r = LogReader.Open(LogFile.FileName, streamOffset, new LogReader.MulticastFilter(MonitorId, LastOffset)); if (!r.MoveNext()) { r.Dispose(); Throw.InvalidDataException($"Unable to read '{LogFile.FileName}' for monitor '{MonitorId}' from offset {streamOffset}.", r.ReadException); } return(r); }
internal void Initialize(MultiLogReader reader) { try { var monitorOccurrences = new Dictionary <Guid, RawLogFileMonitorOccurence>(); var monitorOccurrenceList = new List <RawLogFileMonitorOccurence>(); using (var r = LogReader.Open(_fileName)) { if (r.MoveNext()) { _fileVersion = r.StreamVersion; do { var log = r.Current as IMulticastLogEntry; if (log != null) { ++_totalEntryCount; if (_firstEntryTime > log.LogTime) { _firstEntryTime = log.LogTime; } if (_lastEntryTime < log.LogTime) { _lastEntryTime = log.LogTime; } UpdateMonitor(reader, r.StreamOffset, monitorOccurrences, monitorOccurrenceList, log); } }while(r.MoveNext()); } _badEndOfFile = r.BadEndOfFileMarker; _error = r.ReadException; } _monitors = monitorOccurrenceList.ToArray(); } catch (Exception ex) { _error = ex; } }
/// <summary> /// Creates and opens a <see cref="LogReader"/> that reads unicast entries only from this monitor. /// The reader is initially positioned before the entry (i.e. <see cref="LogReader.MoveNext"/> must be called). /// </summary> /// <param name="streamOffset">Initial stream position.</param> /// <returns>A log reader that will read only entries from this monitor.</returns> public LogReader CreateFilteredReader(long streamOffset) { return(LogReader.Open(LogFile.FileName, streamOffset != -1 ? streamOffset : FirstOffset, new LogReader.MulticastFilter(MonitorId, LastOffset))); }