From b8b845ec68cce19775cb595056064c51fa2b648e Mon Sep 17 00:00:00 2001 From: YPermitin Date: Fri, 10 Apr 2020 13:14:46 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Отказался от усложненной структуры пространств имен - Вынес классы аргументов событий в отдельные файлы - Удалил неиспользуемые пространства имен --- YY.EventLogAssistant/YY.EventLogAssistant.sln | 9 +++ .../YY.EventLogAssistant/EventLogLGDReader.cs | 9 +-- .../YY.EventLogAssistant/EventLogLGFReader.cs | 8 +- .../YY.EventLogAssistant/EventLogPosition.cs | 6 +- .../YY.EventLogAssistant/EventLogReader.cs | 69 +----------------- .../Events/AfterReadEventArgs.cs | 17 +++++ .../Events/AfterReadFileEventArgs.cs | 14 ++++ .../Events/BeforeReadEventArgs.cs | 17 +++++ .../Events/BeforeReadFileEventArgs.cs | 16 ++++ .../Events/OnErrorEventArgs.cs | 18 +++++ .../YY.EventLogAssistant/IEventLogReader.cs | 7 +- .../YY.EventLogAssistant/LogParserLGF.cs | 9 +-- .../Models/Applications.cs | 6 +- .../YY.EventLogAssistant/Models/Computers.cs | 6 +- .../Models/EventLogRowData.cs | 4 +- .../YY.EventLogAssistant/Models/Events.cs | 6 +- .../Models/InformationSystems.cs | 7 +- .../YY.EventLogAssistant/Models/Metadata.cs | 3 +- .../Models/PrimaryPorts.cs | 6 +- .../YY.EventLogAssistant/Models/RowData.cs | 7 +- .../Models/SecondaryPorts.cs | 6 +- .../YY.EventLogAssistant/Models/Severities.cs | 6 +- .../Models/TransactionStatus.cs | 6 +- .../YY.EventLogAssistant/Models/Users.cs | 3 +- .../Models/WorkServers.cs | 6 +- .../Services/DateTimeExtensions.cs | 2 +- .../Services/IntExtensions.cs | 2 +- .../Services/SQLiteExtensions.cs | 2 +- .../Services/StreamLineReader.cs | 2 +- .../Services/StreamReaderExtensions.cs | 2 +- .../Services/StringExtensions.cs | 2 +- .../YY.EventLogAssistantConsoleApp/Program.cs | 73 +++++++++++++++++++ .../YY.EventLogAssistantConsoleApp.csproj | 12 +++ 33 files changed, 217 insertions(+), 151 deletions(-) create mode 100644 YY.EventLogAssistant/YY.EventLogAssistant/Events/AfterReadEventArgs.cs create mode 100644 YY.EventLogAssistant/YY.EventLogAssistant/Events/AfterReadFileEventArgs.cs create mode 100644 YY.EventLogAssistant/YY.EventLogAssistant/Events/BeforeReadEventArgs.cs create mode 100644 YY.EventLogAssistant/YY.EventLogAssistant/Events/BeforeReadFileEventArgs.cs create mode 100644 YY.EventLogAssistant/YY.EventLogAssistant/Events/OnErrorEventArgs.cs create mode 100644 YY.EventLogAssistant/YY.EventLogAssistantConsoleApp/Program.cs create mode 100644 YY.EventLogAssistant/YY.EventLogAssistantConsoleApp/YY.EventLogAssistantConsoleApp.csproj diff --git a/YY.EventLogAssistant/YY.EventLogAssistant.sln b/YY.EventLogAssistant/YY.EventLogAssistant.sln index 6e71f35..ad0dbae 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant.sln +++ b/YY.EventLogAssistant/YY.EventLogAssistant.sln @@ -5,6 +5,11 @@ VisualStudioVersion = 16.0.30002.166 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YY.EventLogAssistant", "YY.EventLogAssistant\YY.EventLogAssistant.csproj", "{5B2E13F6-9F93-46AA-AB61-7B3A4331840D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YY.EventLogAssistantConsoleApp", "YY.EventLogAssistantConsoleApp\YY.EventLogAssistantConsoleApp.csproj", "{9CF3CC92-F793-4398-896A-353DAACC0DE0}" + ProjectSection(ProjectDependencies) = postProject + {5B2E13F6-9F93-46AA-AB61-7B3A4331840D} = {5B2E13F6-9F93-46AA-AB61-7B3A4331840D} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +20,10 @@ Global {5B2E13F6-9F93-46AA-AB61-7B3A4331840D}.Debug|Any CPU.Build.0 = Debug|Any CPU {5B2E13F6-9F93-46AA-AB61-7B3A4331840D}.Release|Any CPU.ActiveCfg = Release|Any CPU {5B2E13F6-9F93-46AA-AB61-7B3A4331840D}.Release|Any CPU.Build.0 = Release|Any CPU + {9CF3CC92-F793-4398-896A-353DAACC0DE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9CF3CC92-F793-4398-896A-353DAACC0DE0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9CF3CC92-F793-4398-896A-353DAACC0DE0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9CF3CC92-F793-4398-896A-353DAACC0DE0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGDReader.cs b/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGDReader.cs index f0304a8..5a7d565 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGDReader.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGDReader.cs @@ -1,14 +1,11 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Data.SQLite; -using YY.LogReader.Models; -using YY.LogReader.Services; -using YY.LogReader.Models.EventLog; +using YY.EventLogAssistant.Models; +using YY.EventLogAssistant.Services; -namespace YY.LogReader.EventLog +namespace YY.EventLogAssistant { internal sealed class EventLogLGDReader : EventLogReader { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGFReader.cs b/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGFReader.cs index 5b47b74..c3d9cc6 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGFReader.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/EventLogLGFReader.cs @@ -5,12 +5,10 @@ using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; -using System.Threading.Tasks; -using YY.LogReader.Models; -using YY.LogReader.Models.EventLog; -using YY.LogReader.Services; +using YY.EventLogAssistant.Models; +using YY.EventLogAssistant.Services; -namespace YY.LogReader.EventLog +namespace YY.EventLogAssistant { internal sealed class EventLogLGFReader : EventLogReader { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/EventLogPosition.cs b/YY.EventLogAssistant/YY.EventLogAssistant/EventLogPosition.cs index f44731d..d626164 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/EventLogPosition.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/EventLogPosition.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace YY.LogReader.EventLog +namespace YY.EventLogAssistant { public sealed class EventLogPosition { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/EventLogReader.cs b/YY.EventLogAssistant/YY.EventLogAssistant/EventLogReader.cs index 809608e..2eed74d 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/EventLogReader.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/EventLogReader.cs @@ -1,14 +1,11 @@ -using YY.LogReader.Models.EventLog; +using YY.EventLogAssistant.Models; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.IO; -namespace YY.LogReader.EventLog +namespace YY.EventLogAssistant { - public abstract class EventLogReader : IEventLogReader, IDisposable + public abstract partial class EventLogReader : IEventLogReader, IDisposable { public static EventLogReader CreateReader(string pathLogFile) { @@ -170,65 +167,5 @@ namespace YY.LogReader.EventLog _users.Clear(); _workServers.Clear(); } - - public sealed class BeforeReadFileEventArgs : EventArgs - { - public BeforeReadFileEventArgs(string fileName) - { - FileName = fileName; - Cancel = false; - } - - public string FileName { get; } - public bool Cancel { get; set; } - } - - public sealed class AfterReadFileEventArgs : EventArgs - { - public AfterReadFileEventArgs(string fileName) - { - FileName = fileName; - } - - public string FileName { get; } - } - - public sealed class BeforeReadEventArgs : EventArgs - { - public BeforeReadEventArgs(string sourceData, long eventNumber) - { - SourceData = sourceData; - EventNumber = eventNumber; - } - - public string SourceData { get; } - public long EventNumber { get; } - } - - public sealed class AfterReadEventArgs : EventArgs - { - public AfterReadEventArgs(EventLogRowData rowData, long eventNumber) - { - RowData = rowData; - EventNumber = eventNumber; - } - - public EventLogRowData RowData { get; } - public long EventNumber { get; } - } - - public sealed class OnErrorEventArgs : EventArgs - { - public OnErrorEventArgs(Exception excepton, string sourceData, bool critical) - { - Exception = excepton; - SourceData = sourceData; - Critical = critical; - } - - public Exception Exception { get; } - public string SourceData { get; } - public bool Critical { get; } - } } } diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Events/AfterReadEventArgs.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Events/AfterReadEventArgs.cs new file mode 100644 index 0000000..a7b64af --- /dev/null +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Events/AfterReadEventArgs.cs @@ -0,0 +1,17 @@ +using YY.EventLogAssistant.Models; +using System; + +namespace YY.EventLogAssistant +{ + public sealed class AfterReadEventArgs : EventArgs + { + public AfterReadEventArgs(EventLogRowData rowData, long eventNumber) + { + RowData = rowData; + EventNumber = eventNumber; + } + + public EventLogRowData RowData { get; } + public long EventNumber { get; } + } +} diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Events/AfterReadFileEventArgs.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Events/AfterReadFileEventArgs.cs new file mode 100644 index 0000000..16edcda --- /dev/null +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Events/AfterReadFileEventArgs.cs @@ -0,0 +1,14 @@ +using System; + +namespace YY.EventLogAssistant +{ + public sealed class AfterReadFileEventArgs : EventArgs + { + public AfterReadFileEventArgs(string fileName) + { + FileName = fileName; + } + + public string FileName { get; } + } +} diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Events/BeforeReadEventArgs.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Events/BeforeReadEventArgs.cs new file mode 100644 index 0000000..278b9e3 --- /dev/null +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Events/BeforeReadEventArgs.cs @@ -0,0 +1,17 @@ +using System; + +namespace YY.EventLogAssistant +{ + + public sealed class BeforeReadEventArgs : EventArgs + { + public BeforeReadEventArgs(string sourceData, long eventNumber) + { + SourceData = sourceData; + EventNumber = eventNumber; + } + + public string SourceData { get; } + public long EventNumber { get; } + } +} diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Events/BeforeReadFileEventArgs.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Events/BeforeReadFileEventArgs.cs new file mode 100644 index 0000000..0a8fc6f --- /dev/null +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Events/BeforeReadFileEventArgs.cs @@ -0,0 +1,16 @@ +using System; + +namespace YY.EventLogAssistant +{ + public sealed class BeforeReadFileEventArgs : EventArgs + { + public BeforeReadFileEventArgs(string fileName) + { + FileName = fileName; + Cancel = false; + } + + public string FileName { get; } + public bool Cancel { get; set; } + } +} diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Events/OnErrorEventArgs.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Events/OnErrorEventArgs.cs new file mode 100644 index 0000000..fb8db81 --- /dev/null +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Events/OnErrorEventArgs.cs @@ -0,0 +1,18 @@ +using System; + +namespace YY.EventLogAssistant +{ + public sealed class OnErrorEventArgs : EventArgs + { + public OnErrorEventArgs(Exception excepton, string sourceData, bool critical) + { + Exception = excepton; + SourceData = sourceData; + Critical = critical; + } + + public Exception Exception { get; } + public string SourceData { get; } + public bool Critical { get; } + } +} diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/IEventLogReader.cs b/YY.EventLogAssistant/YY.EventLogAssistant/IEventLogReader.cs index d76f1a8..0ef755d 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/IEventLogReader.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/IEventLogReader.cs @@ -1,9 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; -using YY.LogReader.Models.EventLog; +using YY.EventLogAssistant.Models; -namespace YY.LogReader.EventLog +namespace YY.EventLogAssistant { internal interface IEventLogReader { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/LogParserLGF.cs b/YY.EventLogAssistant/YY.EventLogAssistant/LogParserLGF.cs index 19b90f6..e8e04bd 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/LogParserLGF.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/LogParserLGF.cs @@ -1,15 +1,12 @@ -using YY.LogReader.Models.EventLog; +using YY.EventLogAssistant.Models; using System; -using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; -using System.Threading.Tasks; -using YY.LogReader.Services; +using YY.EventLogAssistant.Services; using System.Text.RegularExpressions; -using System.Data.SQLite; -namespace YY.LogReader.EventLog +namespace YY.EventLogAssistant { internal sealed class LogParserLGF { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Models/Applications.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Models/Applications.cs index dc28e70..2380746 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Models/Applications.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Models/Applications.cs @@ -1,8 +1,6 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; -namespace YY.LogReader.Models.EventLog +namespace YY.EventLogAssistant.Models { public class Applications { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Models/Computers.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Models/Computers.cs index ed09d69..f923926 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Models/Computers.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Models/Computers.cs @@ -1,8 +1,6 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; -namespace YY.LogReader.Models.EventLog +namespace YY.EventLogAssistant.Models { public class Computers { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Models/EventLogRowData.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Models/EventLogRowData.cs index 9f9f28d..c2564a3 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Models/EventLogRowData.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Models/EventLogRowData.cs @@ -1,8 +1,6 @@ using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -namespace YY.LogReader.Models.EventLog +namespace YY.EventLogAssistant.Models { public class EventLogRowData : RowData { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Models/Events.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Models/Events.cs index 171272c..e1f7cae 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Models/Events.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Models/Events.cs @@ -1,8 +1,6 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; -namespace YY.LogReader.Models.EventLog +namespace YY.EventLogAssistant.Models { public class Events { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Models/InformationSystems.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Models/InformationSystems.cs index 3936717..0671701 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Models/InformationSystems.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Models/InformationSystems.cs @@ -1,9 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; -namespace YY.LogReader.Models.EventLog +namespace YY.EventLogAssistant.Models { public class InformationSystems { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Models/Metadata.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Models/Metadata.cs index 488bea1..70eff11 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Models/Metadata.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Models/Metadata.cs @@ -1,8 +1,7 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace YY.LogReader.Models.EventLog +namespace YY.EventLogAssistant.Models { public class Metadata { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Models/PrimaryPorts.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Models/PrimaryPorts.cs index 813c4bf..3ce29db 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Models/PrimaryPorts.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Models/PrimaryPorts.cs @@ -1,8 +1,6 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; -namespace YY.LogReader.Models.EventLog +namespace YY.EventLogAssistant.Models { public class PrimaryPorts { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Models/RowData.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Models/RowData.cs index 4a21753..121f537 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Models/RowData.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Models/RowData.cs @@ -1,13 +1,8 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using YY.LogReader.Models.EventLog; -namespace YY.LogReader.Models +namespace YY.EventLogAssistant.Models { public abstract class RowData { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Models/SecondaryPorts.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Models/SecondaryPorts.cs index a59290f..5edecb5 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Models/SecondaryPorts.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Models/SecondaryPorts.cs @@ -1,8 +1,6 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; -namespace YY.LogReader.Models.EventLog +namespace YY.EventLogAssistant.Models { public class SecondaryPorts { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Models/Severities.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Models/Severities.cs index 1ad501c..0745f86 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Models/Severities.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Models/Severities.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -namespace YY.LogReader.Models.EventLog +namespace YY.EventLogAssistant.Models { public enum Severity { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Models/TransactionStatus.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Models/TransactionStatus.cs index 511b254..e10e980 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Models/TransactionStatus.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Models/TransactionStatus.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -namespace YY.LogReader.Models.EventLog +namespace YY.EventLogAssistant.Models { public enum TransactionStatus { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Models/Users.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Models/Users.cs index c65074e..25961fe 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Models/Users.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Models/Users.cs @@ -1,8 +1,7 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace YY.LogReader.Models.EventLog +namespace YY.EventLogAssistant.Models { public class Users { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Models/WorkServers.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Models/WorkServers.cs index 00362a3..abf5497 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Models/WorkServers.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Models/WorkServers.cs @@ -1,8 +1,6 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; -namespace YY.LogReader.Models.EventLog +namespace YY.EventLogAssistant.Models { public class WorkServers { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Services/DateTimeExtensions.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Services/DateTimeExtensions.cs index ab06f0c..1890f4d 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Services/DateTimeExtensions.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Services/DateTimeExtensions.cs @@ -1,7 +1,7 @@ using System; using System.Data.SqlTypes; -namespace YY.LogReader.Services +namespace YY.EventLogAssistant.Services { internal static class DateTimeExtensions { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Services/IntExtensions.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Services/IntExtensions.cs index b369149..b14d620 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Services/IntExtensions.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Services/IntExtensions.cs @@ -1,6 +1,6 @@ using System; -namespace YY.LogReader.Services +namespace YY.EventLogAssistant.Services { internal static class IntExtensions { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Services/SQLiteExtensions.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Services/SQLiteExtensions.cs index fada8da..bdf7fef 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Services/SQLiteExtensions.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Services/SQLiteExtensions.cs @@ -2,7 +2,7 @@ using System.Data.SQLite; using System.Text; -namespace YY.LogReader.Services +namespace YY.EventLogAssistant.Services { internal static class SQLiteExtensions { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Services/StreamLineReader.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Services/StreamLineReader.cs index f00dde7..8213dff 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Services/StreamLineReader.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Services/StreamLineReader.cs @@ -2,7 +2,7 @@ using System.IO; using System.Text; -namespace YY.LogReader.Services +namespace YY.EventLogAssistant.Services { internal class StreamLineReader : IDisposable { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Services/StreamReaderExtensions.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Services/StreamReaderExtensions.cs index a04555d..145cd23 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Services/StreamReaderExtensions.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Services/StreamReaderExtensions.cs @@ -1,7 +1,7 @@ using System.IO; using System.Reflection; -namespace YY.LogReader.Services +namespace YY.EventLogAssistant.Services { internal static class StreamReaderExtensions { diff --git a/YY.EventLogAssistant/YY.EventLogAssistant/Services/StringExtensions.cs b/YY.EventLogAssistant/YY.EventLogAssistant/Services/StringExtensions.cs index e2cbd98..0601c7f 100644 --- a/YY.EventLogAssistant/YY.EventLogAssistant/Services/StringExtensions.cs +++ b/YY.EventLogAssistant/YY.EventLogAssistant/Services/StringExtensions.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Security.Cryptography; using System.Text; -namespace YY.LogReader.Services +namespace YY.EventLogAssistant.Services { internal static class StringExtensions { diff --git a/YY.EventLogAssistant/YY.EventLogAssistantConsoleApp/Program.cs b/YY.EventLogAssistant/YY.EventLogAssistantConsoleApp/Program.cs new file mode 100644 index 0000000..0c3ba97 --- /dev/null +++ b/YY.EventLogAssistant/YY.EventLogAssistantConsoleApp/Program.cs @@ -0,0 +1,73 @@ +using System; +using System.IO; +using YY.EventLogAssistant; +using YY.EventLogAssistant.Models; + +namespace YY.EventLogAssistantConsoleApp +{ + class Program + { + private static int _eventNumber = 0; + + static void Main(string[] args) + { + string testDataDirectoryPath = $"{ Environment.CurrentDirectory}{Path.DirectorySeparatorChar}TestData\\1Cv8.lgf"; + + EventLogReader reader = EventLogReader.CreateReader(testDataDirectoryPath); + reader.AfterReadEvent += Reader_AfterReadEvent; + reader.AfterReadFile += Reader_AfterReadFile; + reader.BeforeReadEvent += Reader_BeforeReadEvent; + reader.BeforeReadFile += Reader_BeforeReadFile; + reader.OnErrorEvent += Reader_OnErrorEvent; + + // Пример задания точного положения для чтения в файле. Для формата *.lgf + //reader.SetCurrentPosition(new EventLogPosition( + // 5, + // reader.LogFilePath, + // reader.LogFilePath, + // 436)); + + Console.WriteLine($"Всего событий: {reader.Count()}"); + + long totalEvents = 0; + EventLogRowData rowData; + while (reader.Read(out rowData)) + totalEvents += 1; + + Console.WriteLine("Для выхода нажмите любую клавишу..."); + Console.ReadKey(); + } + + private static void Reader_BeforeReadFile(EventLogReader sender, BeforeReadFileEventArgs args) + { + // Пример получения текущей позиции чтения + var positionBeforeReadFile = sender.GetCurrentPosition(); + + Console.WriteLine("Reader_BeforeReadFile"); + } + + private static void Reader_AfterReadFile(EventLogReader sender, AfterReadFileEventArgs args) + { + // Пример получения текущей позиции чтения + var positionAfterReadFile = sender.GetCurrentPosition(); + + Console.WriteLine("Reader_AfterReadFile"); + } + + private static void Reader_BeforeReadEvent(EventLogReader sender, BeforeReadEventArgs args) + { + _eventNumber += 1; + Console.WriteLine($"Reader_BeforeReadEvent: {_eventNumber}"); + } + + private static void Reader_AfterReadEvent(EventLogReader sender, AfterReadEventArgs args) + { + Console.WriteLine($"Reader_AfterReadEvent {_eventNumber}"); + } + + private static void Reader_OnErrorEvent(EventLogReader sender, OnErrorEventArgs args) + { + Console.WriteLine("Reader_OnErrorEvent"); + } + } +} diff --git a/YY.EventLogAssistant/YY.EventLogAssistantConsoleApp/YY.EventLogAssistantConsoleApp.csproj b/YY.EventLogAssistant/YY.EventLogAssistantConsoleApp/YY.EventLogAssistantConsoleApp.csproj new file mode 100644 index 0000000..87026cd --- /dev/null +++ b/YY.EventLogAssistant/YY.EventLogAssistantConsoleApp/YY.EventLogAssistantConsoleApp.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp3.1 + + + + + + +