问题描述
我正在尝试使用类EventLogReader(eventLogQuery)从服务器读取大约100 000条记录的事件日志。
我正在使用分页每个页面只会在我的屏幕上显示25条记录。因此,我将从第一页的总记录中读取25条记录,在第二页的下一条25条记录中读取等等。
我的问题是如何获取由于在整个100k记录中应用了eventLogQuery,以下片段的总记录数如受影响的总行数?
I'm trying to read eventlogs from a server which has about 100 000 records using class EventLogReader(eventLogQuery).
I'm using pagination and each page will show only 25 records in my screen. So, I will be reading 25 records out of total records for the first page and next 25 records for the second page and so on.
My question is how to get the total records count for the below snippet like total rows affected because of that eventLogQuery applied on the total 100k records?
EventLogReader reader = new
EventLogReader(eventLogQuery);
reader.Seek(SeekOrigin.Begin, filter.PageStart);
eventLogs.TotalLogs = **totalRowsAffected**;
EventRecord eventInstance = reader.ReadEvent();
int i = filter.PageSize;
while (eventInstance != null && i-- > 0)
{
try
{
eventLogs.Entries.Add(new EventLogData
{
Type = eventInstance.LevelDisplayName,
Source = eventInstance.ProviderName,
Time = eventInstance.TimeCreated,
Category = eventInstance.TaskDisplayName,
EventId = eventInstance.Id,
User = eventInstance.UserId != null ? eventInstance.UserId.Value : "",
Computer = eventInstance.MachineName,
Message = eventInstance.FormatDescription(),
FullXml = eventInstance.ToXml()
});
}catch{}
eventInstance = reader.ReadEvent();
}
}
return eventLogs;
推荐答案
这篇关于如何在使用EventLogReader(eventLogQuery)时查找受影响的总行数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!