From ae23b30ab7e5a54208276ac90d01af7fdc5e6af5 Mon Sep 17 00:00:00 2001 From: YPermitin Date: Mon, 13 Apr 2020 14:50:09 +0500 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=BE=D0=B2=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D1=85=D0=BE=D0=B4=D0=B0=20=D0=BA=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BD=D0=BA=D1=80=D0=B5=D1=82=D0=BD=D0=BE=D0=B9=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B7=D0=B8=D1=86=D0=B8=D0=B8=20=D0=BB=D0=BE=D0=B3=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YY.EventLogAssistant/EventLogLGDReader.cs | 13 +++++++++++-- .../YY.EventLogAssistant/EventLogLGFReader.cs | 9 ++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGDReader.cs b/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGDReader.cs index 9e52dcc..a7715e9 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGDReader.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGDReader.cs @@ -178,18 +178,25 @@ namespace YY.EventLogAssistant long eventCount = Count(); if (eventCount >= eventNumber) { + long eventNumberToSkip = eventNumber - 1; + if (eventNumberToSkip <= 0) + { + _lastRowId = 0; + return true; + } + using (_connection = new SQLiteConnection(ConnectionString)) { _connection.Open(); string queryText = String.Format( "Select\n" + - " el.RowId,\n" + + " el.RowId\n" + "From\n" + " EventLog el\n" + "Where RowID > {0}\n" + "Order By rowID\n" + - "Limit 1 OFFSET {1}\n", _lastRowId, eventNumber); + "Limit 1 OFFSET {1}\n", _lastRowId, eventNumberToSkip); using (SQLiteCommand cmd = new SQLiteCommand(queryText, _connection)) { @@ -266,6 +273,8 @@ namespace YY.EventLogAssistant _lastRowId = 0; _lastRowNumberFromBuffer = 0; _readBuffer.Clear(); + _currentFileEventNumber = 0; + _currentRow = null; } public override void Dispose() { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGFReader.cs b/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGFReader.cs index 9a7e6a6..cdc5429 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGFReader.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGFReader.cs @@ -230,9 +230,14 @@ namespace YY.EventLogAssistant _currentFileEventNumber = newPosition.EventNumber; InitializeStream(_defaultBeginLineForLGF, _indexCurrentFile); + long beginReadPosition =_stream.GetPosition(); + + long newStreamPosition = (long)newPosition.StreamPosition; + if(newStreamPosition < beginReadPosition) + newStreamPosition = beginReadPosition; if (newPosition.StreamPosition != null) - SetCurrentFileStreamPosition((long)newPosition.StreamPosition); + SetCurrentFileStreamPosition(newStreamPosition); } public override long Count() @@ -252,6 +257,8 @@ namespace YY.EventLogAssistant } _indexCurrentFile = 0; + _currentFileEventNumber = 0; + _currentRow = null; } public override void NextFile()