1
0
mirror of https://github.com/BDDSM/YY.EventLogReaderAssistant.git synced 2025-07-11 14:20:12 +02:00

Рефакторинг модулей решения.

This commit is contained in:
YPermitin
2020-04-13 00:28:43 +05:00
parent cd309668c7
commit 34bcfa1f8a
11 changed files with 151 additions and 223 deletions

View File

@ -10,8 +10,8 @@ namespace YY.EventLogAssistant.Services.Tests
{
#region Private Member Variables
private string sampleDataDirectory;
private string sampleDatabaseFile;
private readonly string sampleDataDirectory;
private readonly string sampleDatabaseFile;
#endregion
@ -48,14 +48,12 @@ namespace YY.EventLogAssistant.Services.Tests
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{
connection.Open();
using (SQLiteCommand command = new SQLiteCommand(queryText, connection))
using SQLiteCommand command = new SQLiteCommand(queryText, connection);
SQLiteDataReader reader = command.ExecuteReader();
if (reader.Read())
{
SQLiteDataReader reader = command.ExecuteReader();
if (reader.Read())
{
DataPresentation = SQLiteExtensions.GetStringOrDefault(reader, 0);
DataPresentationEmpty = SQLiteExtensions.GetStringOrDefault(reader, 1);
}
DataPresentation = SQLiteExtensions.GetStringOrDefault(reader, 0);
DataPresentationEmpty = SQLiteExtensions.GetStringOrDefault(reader, 1);
}
}
@ -83,14 +81,12 @@ namespace YY.EventLogAssistant.Services.Tests
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{
connection.Open();
using (SQLiteCommand command = new SQLiteCommand(queryText, connection))
using SQLiteCommand command = new SQLiteCommand(queryText, connection);
SQLiteDataReader reader = command.ExecuteReader();
if (reader.Read())
{
SQLiteDataReader reader = command.ExecuteReader();
if (reader.Read())
{
connectionId = SQLiteExtensions.GetInt64OrDefault(reader, 0);
sessionId = SQLiteExtensions.GetInt64OrDefault(reader, 1);
}
connectionId = SQLiteExtensions.GetInt64OrDefault(reader, 0);
sessionId = SQLiteExtensions.GetInt64OrDefault(reader, 1);
}
}
@ -119,13 +115,11 @@ namespace YY.EventLogAssistant.Services.Tests
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{
connection.Open();
using (SQLiteCommand command = new SQLiteCommand(queryText, connection))
using SQLiteCommand command = new SQLiteCommand(queryText, connection);
SQLiteDataReader reader = command.ExecuteReader();
if (reader.Read())
{
SQLiteDataReader reader = command.ExecuteReader();
if (reader.Read())
{
rowAsString = reader.GetRowAsString();
}
rowAsString = reader.GetRowAsString();
}
}
int countLines = rowAsString.Split('\n').Where(str => str != string.Empty).Count();
@ -153,16 +147,14 @@ namespace YY.EventLogAssistant.Services.Tests
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{
connection.Open();
using (SQLiteCommand command = new SQLiteCommand(queryText, connection))
using SQLiteCommand command = new SQLiteCommand(queryText, connection);
SQLiteDataReader reader = command.ExecuteReader();
if (reader.Read())
{
SQLiteDataReader reader = command.ExecuteReader();
if (reader.Read())
object rowsCountObject = reader.GetValue(0);
if (rowsCountObject is long)
{
object rowsCountObject = reader.GetValue(0);
if (rowsCountObject is long)
{
rowsCount = Convert.ToInt64(rowsCountObject);
}
rowsCount = Convert.ToInt64(rowsCountObject);
}
}
}