Public Access
1
0
mirror of https://github.com/iscmt/event-parser.git synced 2026-04-04 06:02:24 -04:00

Reorganized directory structure

This commit is contained in:
Isaac Mallampati
2020-04-14 18:52:03 -04:00
commit d751eee8e6
32 changed files with 2813 additions and 0 deletions

105
BulkInsert_StoredProcedure.sql Executable file
View File

@@ -0,0 +1,105 @@
/****** Object: StoredProcedure [dbo].[ImportLogs] Script Date: 19/07/2019 06:14:23 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[ImportLogs] @filepath NVARCHAR(500),
@bulkinsert NVARCHAR(2000)
AS
IF Object_id('event_logs') IS NOT NULL
BEGIN
-- The bulk insert command must be built as a string because the filepath of the CSV file cannot be passed as a paramter.
-- https://stackoverflow.com/questions/15671971/syntax-error-when-defining-a-parameter-for-bulk-insert
SET @bulkinsert = N'BULK INSERT event_logs FROM '''
+ @filepath
+
N''' WITH (FIELDTERMINATOR = '','', ROWTERMINATOR = ''\n'')'
EXEC sp_executesql @bulkinsert
END
ELSE
BEGIN
/****** Object: Table [dbo].[event_logs] Script Date: 19/07/2019 05:57:04 ******/
SET ansi_nulls ON
SET quoted_identifier ON
CREATE TABLE [dbo].[event_logs]
(
[guid] [VARCHAR](100) NOT NULL,
[level] [VARCHAR](100) NULL,
[date_and_time] [VARCHAR](100) NULL,
[source] [VARCHAR](100) NULL,
[event_id] [SMALLINT] NULL,
[task_category] [VARCHAR](100) NULL,
[extracted_account_name] [VARCHAR](100) NOT NULL,
CONSTRAINT [PK_event_logs] PRIMARY KEY CLUSTERED ( [guid] ASC )
WITH (
pad_index = OFF, statistics_norecompute = OFF, ignore_dup_key =
OFF,
allow_row_locks = on, allow_page_locks = on) ON [PRIMARY]
)
ON [PRIMARY]
SET ansi_padding ON
/****** Object: Index [IX_date_and_time] Script Date: 19/07/2019 05:57:04 ******/
CREATE NONCLUSTERED INDEX [IX_date_and_time]
ON [dbo].[event_logs] ( [date_and_time] ASC )
WITH (pad_index = OFF, statistics_norecompute = OFF, sort_in_tempdb
=
OFF,
drop_existing = OFF, online = OFF, allow_row_locks = ON,
allow_page_locks
=
ON) ON [PRIMARY]
/****** Object: Index [IX_event_id] Script Date: 19/07/2019 05:57:04 ******/
CREATE NONCLUSTERED INDEX [IX_event_id]
ON [dbo].[event_logs] ( [event_id] ASC )
WITH (pad_index = OFF, statistics_norecompute = OFF, sort_in_tempdb
=
OFF,
drop_existing = OFF, online = OFF, allow_row_locks = ON,
allow_page_locks
=
ON) ON [PRIMARY]
SET ansi_padding ON
/****** Object: Index [IX_extracted_account_name] Script Date: 19/07/2019 05:57:04 ******/
CREATE NONCLUSTERED INDEX [IX_extracted_account_name]
ON [dbo].[event_logs] ( [extracted_account_name] ASC )
WITH (pad_index = OFF, statistics_norecompute = OFF, sort_in_tempdb
=
OFF,
drop_existing = OFF, online = OFF, allow_row_locks = ON,
allow_page_locks
=
ON) ON [PRIMARY]
SET ansi_padding ON
/****** Object: Index [IX_task_category] Script Date: 19/07/2019 05:57:04 ******/
CREATE NONCLUSTERED INDEX [IX_task_category]
ON [dbo].[event_logs] ( [task_category] ASC )
WITH (pad_index = OFF, statistics_norecompute = OFF, sort_in_tempdb
=
OFF,
drop_existing = OFF, online = OFF, allow_row_locks = ON,
allow_page_locks
=
ON) ON [PRIMARY]
-- Import records once database has been created.
SET @bulkinsert = N'BULK INSERT event_logs FROM '''
+ @filepath
+
N''' WITH (FIELDTERMINATOR = '','', ROWTERMINATOR = ''\n'')'
EXEC sp_executesql @bulkinsert
END
GO

104
README.md Normal file
View File

@@ -0,0 +1,104 @@
# EventParser
Event logs are generated through the Windows Event Viewer application and can be exported as Comma-Separated Values (CSV) files.
EventParser processes a CSV file, parses the file for specified value(s), creates a new file with the required information, then imports the updated file into an MS SQL database.
EventParser is available with a graphical user interface (GUI) or a command-line interface (CLI).
## Getting Started
### Prerequisites
* An instance of Microsoft SQL Server 2012
* Visual Studio 2017 (to build the application)
### Installation
#### Local
1. Open the solution file.
2. Build the project.
3. Publish the project.
4. Specify the file path where the setup should be saved.
5. Select CD-ROM as the installation method.
6. Disable updates.
7. Complete the publishing process.
8. Copy the setup to the directory where EventParser will be installed. This is necessary because the setup automatically installs the programme to the directory it is located in. It is recommended that the application be installed on the root directory of the machine.
9. Run the setup.
#### Server
Execute the `BulkInsert_StoredProcedure.sql` file. This script installs the Stored Procedure onto the MS SQL Server.
The Stored Procedure imports the CSV file into the database and creates a table on the first run.
## Usage
### GUI
1. Run the programme with administrator privileges.
2. Set the connection string. Select Options. Complete the necessary fields then click OK.
3. Specify the filepath of the CSV file to be opened.
4. Specify the filepath of the CSV file to be saved. An existing file may be overwritten, or a new file can be created.
5. Select the OK button.
6. Check the Output field to see the applications progress. Ideally, this should be the application output.
```
Begin processing *FILENAME*
Replacing log file header…
Parsing log file…
Importing log file into MSSQL server…
Done.
```
_To clear all the fields and restart the application, select the “Reset” button._
_The connection string is automatically saved each time the programme is run._
### CLI
Run the programme with administrator privileges. The console application supports three arguments. Each argument **MUST** be wrapped in double quotes.
```
-i, —input… Specify filepath of CSV file to process
-o, —output… Specify filepath to save CSV file
-c, —connection… Specify connection string
```
## Libraries
[CSVHelper](https://www.nuget.org/packages/CsvHelper/) - Allows for reading and writing CSV files; enables significantly faster processing.
[CommandLineArgumentsParser](https://www.nuget.org/packages/CommandLineArgumentsParser/) - Allows command-line arguments to be passed to the CLI.
## Programme Structure
#### AddMissingHeader
The exported CSV file has a missing column header. This method reads the CSV file and replaces the existing header row with a corrected version. A FileStream instance is opened. The file is overwritten. The existing header is found through a Regular Expressions (RegEx) expression. This is necessary as CSVHelper requires the column names to be defined (`DataRecord.cs`).
#### ParseLog
This method uses CSVHelper. This method reads the CSV file. These columns are: `Level, Date and Time, Source, Event ID, Task Category`. A FileStream instance is opened to read/write to the file. The log file is read into an enumerable. A RegEx expression is used to match the value to be extracted.
Additional fields may be needed to be extracted from the `Details` column. There is uncommented code that gives an example on how to extract an additional field.
None of the fields present in the CSV file are unique. A primary key has been created by combining the timestamp with an increment.
There are instances of records which contain no `Account Name` in the `Details` column. If there is no `Account Name` to be extracted, the following row gets inserted into the account name field. This causes errors during importing.
#### ImportToMSSQL
This method imports the CSV file into the MS SQL database. This is facilitated by the `ImportLogs` Stored Procedure. The file path of the parsed CSV file is passed to the Stored Procedure as a parameter.
The Stored Procedure creates a table `event_logs` if it does not already exist. It imports the CSV file into the database via Bulk Inserts. The script must be built as a string because the Bulk Insert command does not accept file path as a parameter.
## Automation
In order to make this an automated process, a batch file may be created which runs the CLI version of EventParser. As EventParser supports command line arguments, the file paths and connection strings may be passed to the CLI through the batch file.
The batch file can be run automatically at scheduled intervals via Task Scheduler.
## Future Implementation
- Transactional writes for bulk inserts
- Automatic generation of Event Viewer Logs
- Removal of bad events from log file (Logs with missing details and duplicates)

BIN
cli/.DS_Store vendored Normal file

Binary file not shown.

25
cli/EventParser_CLI.sln Executable file
View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.705
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventParser_CLI", "EventParser_ConsoleApp\EventParser_CLI.csproj", "{0B61EE2C-2F75-4D41-BF75-A235E11309BC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0B61EE2C-2F75-4D41-BF75-A235E11309BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B61EE2C-2F75-4D41-BF75-A235E11309BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B61EE2C-2F75-4D41-BF75-A235E11309BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B61EE2C-2F75-4D41-BF75-A235E11309BC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {00621985-7711-4A66-B1DC-C26E64E1A405}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>

View File

@@ -0,0 +1,14 @@
using System;
namespace EventParser.ConsoleApp
{
internal class DataRecord
{
public String Level { get; set; }
public String DateAndTime { get; set; }
public String Source { get; set; }
public String EventID { get; set; }
public String TaskCategory { get; set; }
public String InformationDump { get; set; }
}
}

View File

@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0B61EE2C-2F75-4D41-BF75-A235E11309BC}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>EventParser_ConsoleApp</RootNamespace>
<AssemblyName>EventParser_ConsoleApp</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>D:\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>3F3076ECA4354C6804FCB68F0E0F981B9026B920</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>EventParser_CLI_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommandLineArgumentsParser, Version=3.0.20.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineArgumentsParser.3.0.20\lib\net452\CommandLineArgumentsParser.dll</HintPath>
</Reference>
<Reference Include="CsvHelper, Version=12.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL">
<HintPath>..\packages\CsvHelper.12.1.2\lib\net45\CsvHelper.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DataRecord.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6.1 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,197 @@
using CommandLineParser.Arguments;
using CommandLineParser.Exceptions;
using CsvHelper;
using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace EventParser.ConsoleApp
{
public static class Arguments
{
public static string connString;
public static string input;
public static string output;
}
internal class Program
{
// Logfile is generated with five column headers instead of six. This method ensures the logfile matches the column name headings specified in DataRecords.
private static void AddMissingHeader()
{
Console.WriteLine("Replacing log file header...");
StreamReader reader = new StreamReader(Arguments.input);
string content = reader.ReadToEnd();
reader.Close();
content = Regex.Replace(content, "Level,Date and Time,Source,Event ID,Task Category", "Level,DateAndTime,Source,EventID,TaskCategory,InformationDump");
StreamWriter writer = new StreamWriter(Arguments.input); //overwrites existing file instead of creating new file
writer.Write(content);
writer.Close();
}
// Extracts account name and generates Unique ID. Writes parsed CSV file to specified output.
private static void ParseLog()
{
Console.WriteLine("Parsing log file...");
using (var sr = new StreamReader(Arguments.input))
{
using (var sw = new StreamWriter(Arguments.output))
{
// CSVHelper initialization.
var reader = new CsvReader(sr);
var writer = new CsvWriter(sw);
// Counters for records processed, and unique-ID logic respectively.
int i = 0;
int x = 0;
// CSVReader will read the whole file into an enumerable.
IEnumerable records = reader.GetRecords<DataRecord>().ToList();
foreach (DataRecord record in records)
{
// RegEx to extract account name.
string pattern1 = @"(?<=New Logon:\r\n\tSecurity\ ID\:\t\t).*";
//string pattern2 = @"REGEX GOES HERE";
string uniqueID_timestamp = record.DateAndTime;
// Logic for UniqueID.
var uniqueID = $"{uniqueID_timestamp}-{x++}";
// Order columns in CSV file will be written.
writer.WriteField(uniqueID);
writer.WriteField(record.Level);
writer.WriteField(record.DateAndTime);
writer.WriteField(record.Source);
writer.WriteField(record.EventID);
writer.WriteField(record.TaskCategory);
string str = record.InformationDump;
if (Regex.IsMatch(str, pattern1))
{
var matches = Regex.Matches(str, pattern1);
foreach (Match m in matches)
{
string accountName = m.Value;
writer.WriteField(accountName);
}
}
else
{
// There are instances where a record has no account name to be extracted.
writer.WriteField("Account name unavailable.");
}
//if (Regex.IsMatch(str, pattern2))
//{
// var matches = Regex.Matches(str, pattern2);
// foreach (Match m in matches)
// {
// string extractedField = m.Value;
// //extractedField = extractedField.Replace(@"", "");
// writer.WriteField(extractedField);
// }
//}
//else
//{
// writer.WriteField("Extracted field unavailable.");
//}
// Ensure end-of-record is specified when using WriteField method.
writer.NextRecord();
// Display number of records processed.
// i++
//i = i + 1;
//Console.WriteLine($"Records processed: {i}");
}
}
}
}
// Imports parsed CSV file into MS SQL Server through a Stored Procedure.
private static void ImportToMSSQL()
{
Console.WriteLine("Importing log file into MSSQL server...");
string connectionString = Arguments.connString;
using (SqlConnection connection = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand("ImportLogs", connection))
{
cmd.CommandType = CommandType.StoredProcedure;
// See Stored Procedure.
cmd.Parameters.Add("@filepath", SqlDbType.VarChar).Value = Arguments.output;
connection.Open();
cmd.ExecuteNonQuery();
}
connection.Close();
}
}
private static void Main(string[] args)
{
CommandLineParser.CommandLineParser parser = new CommandLineParser.CommandLineParser();
ValueArgument<string> inputLogFile = new ValueArgument<string>('i', "input", "Specify filepath of CSV file to process");
inputLogFile.Optional = false;
ValueArgument<string> outputLogFile = new ValueArgument<string>('o', "output", "Specify filepath to save CSV file");
outputLogFile.Optional = false;
ValueArgument<string> connectionString = new ValueArgument<string>('c', "connection", "Specify connection string");
connectionString.Optional = false;
parser.Arguments.Add(inputLogFile);
parser.Arguments.Add(outputLogFile);
parser.Arguments.Add(connectionString);
//parser.ShowUsageHeader = "Welcome to EventParser!";
//parser.ShowUsageFooter = "Thank you for using the application.";
//parser.ShowUsage();
try
{
parser.ParseCommandLine(args);
if (inputLogFile.Parsed)
{ Arguments.input = inputLogFile.Value; }
if (outputLogFile.Parsed)
{ Arguments.output = outputLogFile.Value; }
if (connectionString.Parsed)
{ Arguments.connString = connectionString.Value; }
}
catch (CommandLineException e)
{
Console.WriteLine(e.Message);
parser.ShowUsage();
}
// Validation
if (Arguments.input != null && Arguments.output != null && Arguments.connString != null)
{
Console.WriteLine($"PROCESSING: {Arguments.input}");
Stopwatch sw = Stopwatch.StartNew();
AddMissingHeader();
ParseLog();
ImportToMSSQL();
Console.WriteLine("Success.");
Console.WriteLine($"Time elapsed: {sw.ElapsedMilliseconds} ms");
}
}
}
}

View File

@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("EventParser_ConsoleApp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EventParser_ConsoleApp")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("0b61ee2c-2f75-4d41-bf75-a235e11309bc")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommandLineArgumentsParser" version="3.0.20" targetFramework="net461" />
<package id="CsvHelper" version="12.1.2" targetFramework="net461" />
<package id="System.ValueTuple" version="4.4.0" targetFramework="net461" />
</packages>

BIN
gui/.DS_Store vendored Normal file

Binary file not shown.

25
gui/EventParser.sln Normal file
View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.705
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventParser", "EventParser\EventParser.csproj", "{2612DA13-5C25-4189-A862-DED345F71E4C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2612DA13-5C25-4189-A862-DED345F71E4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2612DA13-5C25-4189-A862-DED345F71E4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2612DA13-5C25-4189-A862-DED345F71E4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2612DA13-5C25-4189-A862-DED345F71E4C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CD34504D-55BD-4A3D-A9B2-4EB1379DCC00}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<appSettings>
<add key="ConnectionString" value="" />
</appSettings>
</configuration>

View File

@@ -0,0 +1,14 @@
using System;
namespace EventParser.GUI
{
internal class DataRecord
{
public String Level { get; set; }
public String DateAndTime { get; set; }
public String Source { get; set; }
public String EventID { get; set; }
public String TaskCategory { get; set; }
public String InformationDump { get; set; }
}
}

View File

@@ -0,0 +1,156 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2612DA13-5C25-4189-A862-DED345F71E4C}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>EventParser</RootNamespace>
<AssemblyName>EventParser</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>DE3D84B12696F899F3B800E5E153BC4AEA76155F</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>EventParser_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="com.rusanu.dataconnectiondialog, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\com.rusanu.dataconnectiondialog.1.0.0.1\lib\net20\com.rusanu.dataconnectiondialog.dll</HintPath>
</Reference>
<Reference Include="CsvHelper, Version=12.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL">
<HintPath>..\packages\CsvHelper.12.1.2\lib\net45\CsvHelper.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="GlobalParameters.cs" />
<Compile Include="DataRecord.cs" />
<Compile Include="frmConnection.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmConnection.designer.cs">
<DependentUpon>frmConnection.cs</DependentUpon>
</Compile>
<Compile Include="frmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmMain.Designer.cs">
<DependentUpon>frmMain.cs</DependentUpon>
</Compile>
<Compile Include="frmAbout.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmAbout.Designer.cs">
<DependentUpon>frmAbout.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="frmConnection.resx">
<DependentUpon>frmConnection.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmMain.resx">
<DependentUpon>frmMain.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmAbout.resx">
<DependentUpon>frmAbout.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6.1 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,16 @@
namespace EventParser.GUI
{
public static class Arguments
{
public static string connString { get; set; }
public static string input { get; set; }
public static string output { get; set; }
}
// Necessary for connection string builder window.
public class ConnectionSettings
{
public string ConnectionString { get; set; }
public int ComandTimeout { get; set; } = 60;
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Windows.Forms;
namespace EventParser.GUI
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
private static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmMain());
}
}
}

View File

@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("EventParser")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EventParser")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2612da13-5c25-4189-a862-ded345f71e4c")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,71 @@
//
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//
namespace EventParser.GUI.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EventParser.GUI.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,30 @@
//
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//
namespace EventParser.GUI.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

201
gui/EventParser/frmAbout.Designer.cs generated Normal file
View File

@@ -0,0 +1,201 @@
namespace EventParser.GUI
{
partial class frmAbout
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnClose = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.label1.Location = new System.Drawing.Point(152, 29);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(191, 37);
this.label1.TabIndex = 0;
this.label1.Text = "EventParser";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(93, 89);
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(61, 20);
this.label2.TabIndex = 1;
this.label2.Text = "Author:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(221, 89);
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(128, 20);
this.label3.TabIndex = 2;
this.label3.Text = "Isaac Mallampati";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(93, 132);
this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(52, 20);
this.label5.TabIndex = 3;
this.label5.Text = "Email:";
//
// groupBox1
//
this.groupBox1.Location = new System.Drawing.Point(18, 223);
this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBox1.Size = new System.Drawing.Size(480, 18);
this.groupBox1.TabIndex = 8;
this.groupBox1.TabStop = false;
//
// btnClose
//
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnClose.Location = new System.Drawing.Point(386, 297);
this.btnClose.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(112, 35);
this.btnClose.TabIndex = 9;
this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(93, 177);
this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(117, 20);
this.label6.TabIndex = 12;
this.label6.Text = "Phone number:";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(18, 305);
this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(316, 20);
this.label4.TabIndex = 14;
this.label4.Text = "Developed in July 2019. Ministry of Finance.";
//
// button1
//
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button1.Location = new System.Drawing.Point(356, 252);
this.button1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(142, 35);
this.button1.TabIndex = 15;
this.button1.Text = "Read the docs";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(221, 132);
this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(174, 20);
this.label7.TabIndex = 16;
this.label7.Text = "EMAIL";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(221, 177);
this.label8.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(118, 20);
this.label8.TabIndex = 17;
this.label8.Text = "PHONE";
//
// frmAbout
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnClose;
this.ClientSize = new System.Drawing.Size(516, 340);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.button1);
this.Controls.Add(this.label4);
this.Controls.Add(this.label6);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.label5);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "frmAbout";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "About EventParser";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
}
}

View File

@@ -0,0 +1,17 @@
using System.Windows.Forms;
namespace EventParser.GUI
{
public partial class frmAbout : Form
{
public frmAbout()
{
InitializeComponent();
}
private void button1_Click(object sender, System.EventArgs e)
{
// remember to fix this
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,165 @@
using System;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Windows.Forms;
namespace EventParser.GUI
{
public partial class frmConnection : Form
{
public ConnectionSettings connectionSettings = null;// new ConnectionSettings();
private string ConnectionString
{
get
{
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
builder.DataSource = txtServerName.Text.Trim();
if (cboAuthenticationType.SelectedIndex == 0)
{
builder.IntegratedSecurity = true;
}
else
{
builder.UserID = txtUserName.Text;
builder.Password = txtPassword.Text;
}
if (!string.IsNullOrEmpty(cboDatabases.Text))
builder.InitialCatalog = cboDatabases.Text.Trim();
return builder.ConnectionString;
}
}
public class ConnectionSettings
{
public enum ActionsIfTableExist
{
Drop,
Append,
Skip
}
public string ConnectionString { get; set; }
public int ComandTimeout { get; set; } = 60;
public bool DropAndRecreateTables { get; set; } = false;
}
public frmConnection()
{
InitializeComponent();
cboAuthenticationType.SelectedIndex = 0;
}
private void cboAuthenticationType_SelectedIndexChanged(object sender, EventArgs e)
{
bool isSqlAuth = (cboAuthenticationType.SelectedIndex == 1);
lblUserName.Enabled = isSqlAuth;
lblPassword.Enabled = isSqlAuth;
txtUserName.Enabled = isSqlAuth;
txtPassword.Enabled = isSqlAuth;
cboDatabases.Items.Clear();
}
private void btnOK_Click(object sender, EventArgs e)
{
this.connectionSettings = new ConnectionSettings();
this.connectionSettings.ConnectionString = this.ConnectionString;
Arguments.connString = this.ConnectionString;
Arguments.connString = (this.ConnectionString);
Debug.Write(Arguments.connString);
this.connectionSettings.ComandTimeout = Convert.ToInt32(updTimeout.Value);
//this.connectionSettings.DropAndRecreateTables = chkDropCreate.Checked;
this.DialogResult = DialogResult.OK;
this.Close();
}
private void cboDatabases_DropDown(object sender, EventArgs e)
{
if (CheckRequiredFields(true) == false) return;
LoadDatabases();
if (cboDatabases.Items.Count != 0)
cboDatabases.SelectedIndex = 0;
}
private bool CheckRequiredFields(bool showMessage = true)
{
if (string.IsNullOrEmpty(txtServerName.Text))
{
if (showMessage)
MessageBox.Show("Server Name must be specified.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return false;
}
if (cboAuthenticationType.SelectedIndex == 1 && (string.IsNullOrEmpty(txtUserName.Text) || string.IsNullOrEmpty(txtPassword.Text)))
{
if (showMessage)
MessageBox.Show("User ID and Password must be specified.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return false;
}
return true;
}
private void LoadDatabases()
{
using (SqlConnection cnn = new SqlConnection(ConnectionString))
{
using (SqlCommand cmd = new SqlCommand("SELECT name FROM master..sysdatabases ORDER BY name ASC", cnn))
{
cboDatabases.Items.Clear();
SqlDataReader dtr;
try
{
cnn.Open();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Console.WriteLine(ex.ToString());
return;
}
dtr = cmd.ExecuteReader();
while (dtr.Read())
cboDatabases.Items.Add(dtr[0].ToString());
}
}
}
private void btnTest_Click(object sender, EventArgs e)
{
using (SqlConnection cnn = new SqlConnection(ConnectionString))
{
try
{
cnn.Open();
MessageBox.Show("Test connection succeeded.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void frmConnection_Load(object sender, EventArgs e)
{
if (this.connectionSettings == null)
return;
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(this.connectionSettings.ConnectionString);
txtServerName.Text = builder.DataSource;
if (builder.IntegratedSecurity == true)
cboAuthenticationType.SelectedIndex = 0;
cboDatabases.Text = builder.InitialCatalog;
updTimeout.Value = this.connectionSettings.ComandTimeout;
//chkDropCreate.Checked = this.connectionSettings.DropAndRecreateTables;
}
private void btnCancel_Click(object sender, EventArgs e)
{
}
}
}

294
gui/EventParser/frmConnection.designer.cs generated Normal file
View File

@@ -0,0 +1,294 @@
namespace EventParser.GUI
{
partial class frmConnection
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.cboDatabases = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.updTimeout = new System.Windows.Forms.NumericUpDown();
this.label5 = new System.Windows.Forms.Label();
this.txtPassword = new System.Windows.Forms.TextBox();
this.lblPassword = new System.Windows.Forms.Label();
this.txtUserName = new System.Windows.Forms.TextBox();
this.lblUserName = new System.Windows.Forms.Label();
this.cboAuthenticationType = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.txtServerName = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.btnCancel = new System.Windows.Forms.Button();
this.btnOK = new System.Windows.Forms.Button();
this.btnTest = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.updTimeout)).BeginInit();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.cboDatabases);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.updTimeout);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.txtPassword);
this.groupBox1.Controls.Add(this.lblPassword);
this.groupBox1.Controls.Add(this.txtUserName);
this.groupBox1.Controls.Add(this.lblUserName);
this.groupBox1.Controls.Add(this.cboAuthenticationType);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.txtServerName);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Location = new System.Drawing.Point(18, 18);
this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBox1.Size = new System.Drawing.Size(452, 351);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
//
// cboDatabases
//
this.cboDatabases.FormattingEnabled = true;
this.cboDatabases.Location = new System.Drawing.Point(140, 217);
this.cboDatabases.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.cboDatabases.Name = "cboDatabases";
this.cboDatabases.Size = new System.Drawing.Size(282, 28);
this.cboDatabases.TabIndex = 9;
this.cboDatabases.DropDown += new System.EventHandler(this.cboDatabases_DropDown);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(9, 222);
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(79, 20);
this.label3.TabIndex = 10;
this.label3.Text = "Database";
//
// updTimeout
//
this.updTimeout.Increment = new decimal(new int[] {
30,
0,
0,
0});
this.updTimeout.Location = new System.Drawing.Point(177, 282);
this.updTimeout.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.updTimeout.Maximum = new decimal(new int[] {
1000000,
0,
0,
0});
this.updTimeout.Minimum = new decimal(new int[] {
60,
0,
0,
0});
this.updTimeout.Name = "updTimeout";
this.updTimeout.ReadOnly = true;
this.updTimeout.Size = new System.Drawing.Size(102, 26);
this.updTimeout.TabIndex = 4;
this.updTimeout.Value = new decimal(new int[] {
60,
0,
0,
0});
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(9, 285);
this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(159, 20);
this.label5.TabIndex = 8;
this.label5.Text = "Comand timeout, sec";
//
// txtPassword
//
this.txtPassword.Enabled = false;
this.txtPassword.Location = new System.Drawing.Point(224, 163);
this.txtPassword.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.txtPassword.Name = "txtPassword";
this.txtPassword.PasswordChar = '*';
this.txtPassword.Size = new System.Drawing.Size(198, 26);
this.txtPassword.TabIndex = 3;
//
// lblPassword
//
this.lblPassword.AutoSize = true;
this.lblPassword.Enabled = false;
this.lblPassword.Location = new System.Drawing.Point(135, 168);
this.lblPassword.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblPassword.Name = "lblPassword";
this.lblPassword.Size = new System.Drawing.Size(82, 20);
this.lblPassword.TabIndex = 6;
this.lblPassword.Text = "Password:";
//
// txtUserName
//
this.txtUserName.Enabled = false;
this.txtUserName.Location = new System.Drawing.Point(224, 123);
this.txtUserName.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.txtUserName.Name = "txtUserName";
this.txtUserName.Size = new System.Drawing.Size(198, 26);
this.txtUserName.TabIndex = 2;
//
// lblUserName
//
this.lblUserName.AutoSize = true;
this.lblUserName.Enabled = false;
this.lblUserName.Location = new System.Drawing.Point(128, 128);
this.lblUserName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblUserName.Name = "lblUserName";
this.lblUserName.Size = new System.Drawing.Size(87, 20);
this.lblUserName.TabIndex = 4;
this.lblUserName.Text = "Username:";
//
// cboAuthenticationType
//
this.cboAuthenticationType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboAuthenticationType.FormattingEnabled = true;
this.cboAuthenticationType.Items.AddRange(new object[] {
"Windows Authentication",
"SQL Server Authentication"});
this.cboAuthenticationType.Location = new System.Drawing.Point(140, 66);
this.cboAuthenticationType.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.cboAuthenticationType.Name = "cboAuthenticationType";
this.cboAuthenticationType.Size = new System.Drawing.Size(282, 28);
this.cboAuthenticationType.TabIndex = 1;
this.cboAuthenticationType.SelectedIndexChanged += new System.EventHandler(this.cboAuthenticationType_SelectedIndexChanged);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(9, 71);
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(112, 20);
this.label2.TabIndex = 2;
this.label2.Text = "Authentication";
//
// txtServerName
//
this.txtServerName.Location = new System.Drawing.Point(140, 20);
this.txtServerName.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.txtServerName.Name = "txtServerName";
this.txtServerName.Size = new System.Drawing.Size(282, 26);
this.txtServerName.TabIndex = 0;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(9, 25);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(99, 20);
this.label1.TabIndex = 0;
this.label1.Text = "Server name";
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(363, 378);
this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(112, 35);
this.btnCancel.TabIndex = 6;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(242, 378);
this.btnOK.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(112, 35);
this.btnOK.TabIndex = 5;
this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// btnTest
//
this.btnTest.Location = new System.Drawing.Point(21, 378);
this.btnTest.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnTest.Name = "btnTest";
this.btnTest.Size = new System.Drawing.Size(92, 35);
this.btnTest.TabIndex = 7;
this.btnTest.Text = "Test";
this.btnTest.UseVisualStyleBackColor = true;
this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
//
// frmConnection
//
this.AcceptButton = this.btnOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(480, 431);
this.Controls.Add(this.btnTest);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "frmConnection";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Connection to SQL Server";
this.Load += new System.EventHandler(this.frmConnection_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.updTimeout)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.NumericUpDown updTimeout;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txtPassword;
private System.Windows.Forms.Label lblPassword;
private System.Windows.Forms.TextBox txtUserName;
private System.Windows.Forms.Label lblUserName;
private System.Windows.Forms.ComboBox cboAuthenticationType;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtServerName;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.ComboBox cboDatabases;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button btnTest;
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

389
gui/EventParser/frmMain.Designer.cs generated Normal file
View File

@@ -0,0 +1,389 @@
namespace EventParser.GUI
{
partial class frmMain
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.browseCSV = new System.Windows.Forms.OpenFileDialog();
this.mnuAboutHelp = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.labelOpenLogFile = new System.Windows.Forms.Label();
this.btnStart = new System.Windows.Forms.Button();
this.btnOpenLogFile = new System.Windows.Forms.Button();
this.groupBoxFilepaths = new System.Windows.Forms.GroupBox();
this.txtOpenLogFile = new System.Windows.Forms.TextBox();
this.btnSetConnectionString = new System.Windows.Forms.Button();
this.txtConnectionString = new System.Windows.Forms.TextBox();
this.groupBoxConnString = new System.Windows.Forms.GroupBox();
this.txtSaveLogFile = new System.Windows.Forms.TextBox();
this.labelSaveLogFile = new System.Windows.Forms.Label();
this.groupBoxOutput = new System.Windows.Forms.GroupBox();
this.label3 = new System.Windows.Forms.Label();
this.txtOutput = new System.Windows.Forms.TextBox();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.processedRecords = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel4 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel5 = new System.Windows.Forms.ToolStripStatusLabel();
this.status = new System.Windows.Forms.ToolStripStatusLabel();
this.btnCancel = new System.Windows.Forms.Button();
this.btnSaveLogFile = new System.Windows.Forms.Button();
this.btnReset = new System.Windows.Forms.Button();
this.menuStrip1.SuspendLayout();
this.groupBoxFilepaths.SuspendLayout();
this.groupBoxConnString.SuspendLayout();
this.groupBoxOutput.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// browseCSV
//
this.browseCSV.FileName = "browseCSV";
this.browseCSV.Title = "Browse";
//
// mnuAboutHelp
//
this.mnuAboutHelp.Name = "mnuAboutHelp";
this.mnuAboutHelp.Size = new System.Drawing.Size(118, 29);
this.mnuAboutHelp.Text = "&About/Help";
this.mnuAboutHelp.Click += new System.EventHandler(this.mnuFile_Click);
//
// menuStrip1
//
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.mnuAboutHelp});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Padding = new System.Windows.Forms.Padding(9, 3, 0, 3);
this.menuStrip1.Size = new System.Drawing.Size(861, 35);
this.menuStrip1.TabIndex = 22;
this.menuStrip1.Text = "menuStrip1";
//
// labelOpenLogFile
//
this.labelOpenLogFile.AutoSize = true;
this.labelOpenLogFile.Location = new System.Drawing.Point(9, 25);
this.labelOpenLogFile.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelOpenLogFile.Name = "labelOpenLogFile";
this.labelOpenLogFile.Size = new System.Drawing.Size(64, 20);
this.labelOpenLogFile.TabIndex = 14;
this.labelOpenLogFile.Text = "Log file:";
//
// btnStart
//
this.btnStart.Enabled = false;
this.btnStart.Location = new System.Drawing.Point(696, 612);
this.btnStart.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnStart.Name = "btnStart";
this.btnStart.Size = new System.Drawing.Size(122, 35);
this.btnStart.TabIndex = 3;
this.btnStart.Text = "Start";
this.btnStart.UseVisualStyleBackColor = true;
this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
//
// btnOpenLogFile
//
this.btnOpenLogFile.Location = new System.Drawing.Point(670, 45);
this.btnOpenLogFile.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnOpenLogFile.Name = "btnOpenLogFile";
this.btnOpenLogFile.Size = new System.Drawing.Size(112, 35);
this.btnOpenLogFile.TabIndex = 1;
this.btnOpenLogFile.Text = "Browse...";
this.btnOpenLogFile.UseVisualStyleBackColor = true;
this.btnOpenLogFile.Click += new System.EventHandler(this.btnBrowse_Click);
//
// groupBoxFilepaths
//
this.groupBoxFilepaths.Controls.Add(this.btnOpenLogFile);
this.groupBoxFilepaths.Controls.Add(this.txtOpenLogFile);
this.groupBoxFilepaths.Controls.Add(this.labelOpenLogFile);
this.groupBoxFilepaths.Location = new System.Drawing.Point(36, 149);
this.groupBoxFilepaths.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBoxFilepaths.Name = "groupBoxFilepaths";
this.groupBoxFilepaths.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBoxFilepaths.Size = new System.Drawing.Size(792, 220);
this.groupBoxFilepaths.TabIndex = 1;
this.groupBoxFilepaths.TabStop = false;
//
// txtOpenLogFile
//
this.txtOpenLogFile.Location = new System.Drawing.Point(9, 49);
this.txtOpenLogFile.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.txtOpenLogFile.Name = "txtOpenLogFile";
this.txtOpenLogFile.ReadOnly = true;
this.txtOpenLogFile.Size = new System.Drawing.Size(650, 26);
this.txtOpenLogFile.TabIndex = 2;
this.txtOpenLogFile.TabStop = false;
//
// btnSetConnectionString
//
this.btnSetConnectionString.Location = new System.Drawing.Point(670, 25);
this.btnSetConnectionString.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnSetConnectionString.Name = "btnSetConnectionString";
this.btnSetConnectionString.Size = new System.Drawing.Size(112, 35);
this.btnSetConnectionString.TabIndex = 2;
this.btnSetConnectionString.Text = "Options";
this.btnSetConnectionString.UseVisualStyleBackColor = true;
this.btnSetConnectionString.Click += new System.EventHandler(this.btnSetConnectionString_Click);
//
// txtConnectionString
//
this.txtConnectionString.AcceptsTab = true;
this.txtConnectionString.Location = new System.Drawing.Point(9, 29);
this.txtConnectionString.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.txtConnectionString.Name = "txtConnectionString";
this.txtConnectionString.Size = new System.Drawing.Size(650, 26);
this.txtConnectionString.TabIndex = 1;
this.txtConnectionString.TextChanged += new System.EventHandler(this.txtConnectionString_TextChanged);
//
// groupBoxConnString
//
this.groupBoxConnString.Controls.Add(this.btnSetConnectionString);
this.groupBoxConnString.Controls.Add(this.txtConnectionString);
this.groupBoxConnString.Location = new System.Drawing.Point(36, 57);
this.groupBoxConnString.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBoxConnString.Name = "groupBoxConnString";
this.groupBoxConnString.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBoxConnString.Size = new System.Drawing.Size(792, 83);
this.groupBoxConnString.TabIndex = 0;
this.groupBoxConnString.TabStop = false;
this.groupBoxConnString.Text = "SQL Server connection string:";
//
// txtSaveLogFile
//
this.txtSaveLogFile.Location = new System.Drawing.Point(45, 300);
this.txtSaveLogFile.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.txtSaveLogFile.Name = "txtSaveLogFile";
this.txtSaveLogFile.ReadOnly = true;
this.txtSaveLogFile.Size = new System.Drawing.Size(650, 26);
this.txtSaveLogFile.TabIndex = 4;
this.txtSaveLogFile.TabStop = false;
//
// labelSaveLogFile
//
this.labelSaveLogFile.AutoSize = true;
this.labelSaveLogFile.Location = new System.Drawing.Point(45, 277);
this.labelSaveLogFile.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelSaveLogFile.Name = "labelSaveLogFile";
this.labelSaveLogFile.Size = new System.Drawing.Size(172, 20);
this.labelSaveLogFile.TabIndex = 17;
this.labelSaveLogFile.Text = "Parsed log file (output):";
//
// groupBoxOutput
//
this.groupBoxOutput.Controls.Add(this.label3);
this.groupBoxOutput.Controls.Add(this.txtOutput);
this.groupBoxOutput.Location = new System.Drawing.Point(36, 380);
this.groupBoxOutput.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBoxOutput.Name = "groupBoxOutput";
this.groupBoxOutput.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBoxOutput.Size = new System.Drawing.Size(792, 223);
this.groupBoxOutput.TabIndex = 21;
this.groupBoxOutput.TabStop = false;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(10, 12);
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(62, 20);
this.label3.TabIndex = 32;
this.label3.Text = "Output:";
//
// txtOutput
//
this.txtOutput.Location = new System.Drawing.Point(9, 35);
this.txtOutput.Multiline = true;
this.txtOutput.Name = "txtOutput";
this.txtOutput.ReadOnly = true;
this.txtOutput.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.txtOutput.Size = new System.Drawing.Size(774, 169);
this.txtOutput.TabIndex = 31;
this.txtOutput.TabStop = false;
//
// statusStrip1
//
this.statusStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1,
this.processedRecords,
this.toolStripStatusLabel4,
this.toolStripStatusLabel2,
this.toolStripStatusLabel5,
this.status});
this.statusStrip1.Location = new System.Drawing.Point(0, 658);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Padding = new System.Windows.Forms.Padding(2, 0, 14, 0);
this.statusStrip1.Size = new System.Drawing.Size(861, 30);
this.statusStrip1.TabIndex = 29;
this.statusStrip1.Text = "statusStrip1";
//
// toolStripStatusLabel1
//
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
this.toolStripStatusLabel1.Size = new System.Drawing.Size(0, 25);
//
// processedRecords
//
this.processedRecords.Name = "processedRecords";
this.processedRecords.Size = new System.Drawing.Size(0, 25);
//
// toolStripStatusLabel4
//
this.toolStripStatusLabel4.Name = "toolStripStatusLabel4";
this.toolStripStatusLabel4.RightToLeftAutoMirrorImage = true;
this.toolStripStatusLabel4.Size = new System.Drawing.Size(281, 25);
this.toolStripStatusLabel4.Spring = true;
this.toolStripStatusLabel4.Text = " ";
//
// toolStripStatusLabel2
//
this.toolStripStatusLabel2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.toolStripStatusLabel2.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
this.toolStripStatusLabel2.Name = "toolStripStatusLabel2";
this.toolStripStatusLabel2.Size = new System.Drawing.Size(0, 25);
this.toolStripStatusLabel2.TextImageRelation = System.Windows.Forms.TextImageRelation.TextBeforeImage;
//
// toolStripStatusLabel5
//
this.toolStripStatusLabel5.Name = "toolStripStatusLabel5";
this.toolStripStatusLabel5.RightToLeftAutoMirrorImage = true;
this.toolStripStatusLabel5.Size = new System.Drawing.Size(281, 25);
this.toolStripStatusLabel5.Spring = true;
this.toolStripStatusLabel5.Text = " ";
//
// status
//
this.status.Name = "status";
this.status.RightToLeftAutoMirrorImage = true;
this.status.Size = new System.Drawing.Size(281, 25);
this.status.Spring = true;
this.status.Text = " ";
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(566, 614);
this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(122, 35);
this.btnCancel.TabIndex = 4;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnSaveLogFile
//
this.btnSaveLogFile.Location = new System.Drawing.Point(705, 297);
this.btnSaveLogFile.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnSaveLogFile.Name = "btnSaveLogFile";
this.btnSaveLogFile.Size = new System.Drawing.Size(112, 35);
this.btnSaveLogFile.TabIndex = 2;
this.btnSaveLogFile.Text = "Browse...";
this.btnSaveLogFile.UseVisualStyleBackColor = true;
this.btnSaveLogFile.Click += new System.EventHandler(this.btnLogOutput_Click);
//
// btnReset
//
this.btnReset.Location = new System.Drawing.Point(36, 612);
this.btnReset.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnReset.Name = "btnReset";
this.btnReset.Size = new System.Drawing.Size(122, 35);
this.btnReset.TabIndex = 5;
this.btnReset.Text = "Reset";
this.btnReset.UseVisualStyleBackColor = true;
this.btnReset.Click += new System.EventHandler(this.btnReset_Click);
//
// frmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(861, 688);
this.Controls.Add(this.btnReset);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.groupBoxOutput);
this.Controls.Add(this.btnSaveLogFile);
this.Controls.Add(this.txtSaveLogFile);
this.Controls.Add(this.labelSaveLogFile);
this.Controls.Add(this.menuStrip1);
this.Controls.Add(this.btnStart);
this.Controls.Add(this.groupBoxFilepaths);
this.Controls.Add(this.groupBoxConnString);
this.Name = "frmMain";
this.Text = "EventParser";
this.Load += new System.EventHandler(this.frmMain_Load);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.groupBoxFilepaths.ResumeLayout(false);
this.groupBoxFilepaths.PerformLayout();
this.groupBoxConnString.ResumeLayout(false);
this.groupBoxConnString.PerformLayout();
this.groupBoxOutput.ResumeLayout(false);
this.groupBoxOutput.PerformLayout();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.OpenFileDialog browseCSV;
private System.Windows.Forms.ToolStripMenuItem mnuAboutHelp;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.Label labelOpenLogFile;
private System.Windows.Forms.Button btnStart;
private System.Windows.Forms.Button btnOpenLogFile;
private System.Windows.Forms.GroupBox groupBoxFilepaths;
private System.Windows.Forms.TextBox txtOpenLogFile;
private System.Windows.Forms.Button btnSetConnectionString;
public System.Windows.Forms.TextBox txtConnectionString;
private System.Windows.Forms.GroupBox groupBoxConnString;
private System.Windows.Forms.TextBox txtSaveLogFile;
private System.Windows.Forms.Label labelSaveLogFile;
private System.Windows.Forms.GroupBox groupBoxOutput;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
private System.Windows.Forms.ToolStripStatusLabel processedRecords;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel4;
private System.Windows.Forms.ToolStripStatusLabel status;
private System.Windows.Forms.TextBox txtOutput;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel5;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnSaveLogFile;
private System.Windows.Forms.Button btnReset;
}
}

272
gui/EventParser/frmMain.cs Normal file
View File

@@ -0,0 +1,272 @@
using CsvHelper;
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows.Forms;
namespace EventParser.GUI
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
private void frmMain_Load(object sender, EventArgs e)
{
txtConnectionString.Text = ConfigurationManager.AppSettings["ConnectionString"];
}
private ConnectionSettings connectionSettings = new ConnectionSettings();
public void btnSetConnectionString_Click(object sender, EventArgs e)
{
frmConnection frm = new frmConnection();
frm.ShowDialog();
this.txtConnectionString.Text = Arguments.connString;
}
private void btnCancel_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void mnuFile_Click(object sender, EventArgs e)
{
frmAbout about = new frmAbout();
about.ShowDialog();
}
private void btnReset_Click(object sender, EventArgs e)
{
Application.Restart();
}
private void buttonValidate()
{
btnStart.Enabled = Arguments.input != null && Arguments.output != null && Arguments.connString != null;
}
private void btnBrowse_Click(object sender, EventArgs e)
{
OpenFileDialog openCSVLog = new OpenFileDialog
{
InitialDirectory = @"C:\",
Title = "Open CSV log file",
CheckFileExists = true,
CheckPathExists = true,
Filter = @"CSV files (*.csv)|*.csv",
//Filter = @"All files (*.*)|*.*|CSV files (*.csv)|*.csv",
FilterIndex = 2,
RestoreDirectory = true,
};
if (openCSVLog.ShowDialog() == DialogResult.OK)
{
txtOpenLogFile.Text = openCSVLog.FileName;
Arguments.input = openCSVLog.FileName;
buttonValidate();
}
}
private void btnLogOutput_Click(object sender, EventArgs e)
{
SaveFileDialog saveCSVLog = new SaveFileDialog
{
InitialDirectory = @"C:\",
Title = "Save formatted CSV log file",
CheckPathExists = true,
Filter = @"All files (*.*)|*.*|CSV files (*.csv)|*.csv",
FilterIndex = 2,
RestoreDirectory = true,
};
if (saveCSVLog.ShowDialog() == DialogResult.OK)
{
txtSaveLogFile.Text = saveCSVLog.FileName;
Arguments.output = saveCSVLog.FileName;
buttonValidate();
}
}
private void txtConnectionString_TextChanged(object sender, EventArgs e)
{
Arguments.connString = txtConnectionString.Text;
buttonValidate();
}
private void setAppSetting(string key, string value)
{
// Load App Settings.
Configuration config = ConfigurationManager.OpenExeConfiguration(
System.Reflection.Assembly.GetExecutingAssembly().Location);
// Check if key exists in the settings.
if (config.AppSettings.Settings[key] != null)
{
// If key exists, delete it.
config.AppSettings.Settings.Remove(key);
}
// Add new key-value pair.
config.AppSettings.Settings.Add(key, value);
// Save the changed settings.
config.Save(ConfigurationSaveMode.Modified);
}
// Logfile is generated with five column headers instead of six. This method ensures the logfile matches the column name headings specified in DataRecords.
private void AddMissingHeader()
{
txtOutput.AppendText("Replacing log file header...\r\n");
StreamReader reader = new StreamReader(Arguments.input);
string content = reader.ReadToEnd();
reader.Close();
content = Regex.Replace(content, "Level,Date and Time,Source,Event ID,Task Category", "Level,DateAndTime,Source,EventID,TaskCategory,InformationDump");
StreamWriter writer = new StreamWriter(Arguments.input); //overwrites existing file instead of creating new file
writer.Write(content);
writer.Close();
}
// Extracts account name and generates Unique ID. Writes parsed CSV file to specified output.
public void ParseLog()
{
txtOutput.AppendText("Parsing log file...\r\n");
using (var sr = new StreamReader(Arguments.input))
{
using (var sw = new StreamWriter(Arguments.output))
{
// CSVHelper initialization.
var reader = new CsvReader(sr);
var writer = new CsvWriter(sw);
// Counters for records processed, and unique-ID logic respectively.
// int i = 0;
int x = 0;
// CSVReader will read the whole file into an enumerable.
IEnumerable records = reader.GetRecords<DataRecord>().ToList();
foreach (DataRecord record in records)
{
// RegEx pattern to extract account name.
string pattern1 = @"(?<=New Logon:\r\n\tSecurity\ ID\:\t\t).*";
//string pattern2 = @"REGEX GOES HERE";
string uniqueID_timestamp = record.DateAndTime;
// Logic for UniqueID.
var uniqueID = $"{uniqueID_timestamp}-{x++}";
// Order columns in CSV file will be written.
writer.WriteField(uniqueID);
writer.WriteField(record.Level);
writer.WriteField(record.DateAndTime);
writer.WriteField(record.Source);
writer.WriteField(record.EventID);
writer.WriteField(record.TaskCategory);
string str = record.InformationDump;
if (Regex.IsMatch(str, pattern1))
{
var matches = Regex.Matches(str, pattern1);
foreach (Match m in matches)
{
string accountName = m.Value;
writer.WriteField(accountName);
}
}
else
{
// There are instances where a record has no account name to be extracted.
writer.WriteField("Account name unavailable.");
}
//if (Regex.IsMatch(str, pattern2))
//{
// var matches = Regex.Matches(str, pattern2);
// foreach (Match m in matches)
// {
// string extractedField = m.Value;
// //extractedField = extractedField.Replace(@"", "");
// writer.WriteField(extractedField);
// }
//}
//else
//{
// writer.WriteField("Extracted field unavailable.");
//}
// Ensure end-of-record is specified when using WriteField method.
writer.NextRecord();
// Display number of records processed.
// i++
//i = i + 1;
//txtOutput.AppendText($"Records processed: {i}");
}
}
}
}
// Imports parsed CSV file into MS SQL Server through a Stored Procedure.
public void ImportToMSSQL()
{
txtOutput.AppendText("Importing log file into MSSQL server...\r\n");
string connectionString = Arguments.connString;
using (SqlConnection connection = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand("ImportLogs", connection))
{
cmd.CommandType = CommandType.StoredProcedure;
// See Stored Procedure.
cmd.Parameters.Add("@filepath", SqlDbType.VarChar).Value = Arguments.output;
connection.Open();
cmd.ExecuteNonQuery();
}
connection.Close();
}
}
public void btnStart_Click(object sender, EventArgs e)
{
// Save the connection string to app settings.
setAppSetting("ConnectionString", Arguments.connString);
txtOutput.AppendText($"Begin processing: {Arguments.input} \r\n");
try
{
AddMissingHeader();
ParseLog();
ImportToMSSQL();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Console.WriteLine(ex.ToString());
return;
}
txtOutput.AppendText("Done."); // fix to only output if no errors are returned
}
}
}

View File

@@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="browseCSV.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>171, 17</value>
</metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>327, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
</metadata>
</root>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="com.rusanu.dataconnectiondialog" version="1.0.0.1" targetFramework="net461" />
<package id="CsvHelper" version="12.1.2" targetFramework="net461" />
<package id="System.ValueTuple" version="4.4.0" targetFramework="net461" />
</packages>