1
0
mirror of https://github.com/BDDSM/YY.EventLogReaderAssistant.git synced 2024-11-21 10:05:51 +02:00

Исправил ошибки для методов перехода к конкретной позиции логов

This commit is contained in:
YPermitin 2020-04-13 14:50:09 +05:00
parent add74918fa
commit ae23b30ab7
2 changed files with 19 additions and 3 deletions

View File

@ -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()
{

View File

@ -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()