From 3eb641ca868ad09c9e4c0dd683ff1ad0bf9a04d4 Mon Sep 17 00:00:00 2001 From: YPermitin Date: Fri, 10 Apr 2020 17:31:25 +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=D1=87=D1=82=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=84=D0=B0?= =?UTF-8?q?=D0=B9=D0=BB=D0=B0=20=D0=BF=D1=80=D0=B8=20=D0=BF=D0=BE=D0=B4?= =?UTF-8?q?=D1=81=D1=87=D0=B5=D1=82=D0=B5=20=D0=BA=D0=BE=D0=BB=D0=B8=D1=87?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D0=B2=D0=B0=20=D1=81=D0=BE=D0=B1=D1=8B=D1=82?= =?UTF-8?q?=D0=B8=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Теперь работает с файлами журнала при работающей службе сервера. --- .../YY.EventLogAssistant/EventLogLGFReader.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGFReader.cs b/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGFReader.cs index c3d9cc6..4dfc846 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGFReader.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGFReader.cs @@ -617,9 +617,15 @@ namespace YY.EventLogAssistant foreach (var logFile in _reader._logFilesWithData) { - eventCount += File.ReadLines(logFile) - .Where(lineInt => Regex.IsMatch(lineInt, @"^{\d{4}\d{2}\d{2}\d+,")) - .LongCount(); + using (StreamReader logFileStream = new StreamReader(File.Open(logFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) + { + do + { + string logFileCurrentString = logFileStream.ReadLine(); + if (Regex.IsMatch(logFileCurrentString, @"^{\d{4}\d{2}\d{2}\d+,")) + eventCount++; + } while (!logFileStream.EndOfStream); + } } return eventCount;