Implemented initial MongoDB driver
- FireLance DatabaseConnection implementation - Crude test importing from GSMParser to FireLance DB.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using Microsoft.Data.Sqlite;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Dapper;
|
||||
using FireLance.Interfaces;
|
||||
|
||||
namespace GSMParser
|
||||
{
|
||||
public class DatabaseConnection : IDatabaseConnection
|
||||
{
|
||||
private SqliteConnection DBConnection = new SqliteConnection();
|
||||
|
||||
public void OpenConnection(string dbLocation, int port)
|
||||
{
|
||||
if (File.Exists(dbLocation) == false)
|
||||
{
|
||||
throw new FileNotFoundException(dbLocation);
|
||||
}
|
||||
|
||||
DBConnection = new SqliteConnection($"Data Source={dbLocation};Mode=ReadOnly");
|
||||
DBConnection.Open();
|
||||
}
|
||||
|
||||
public void CloseCurrentConnection()
|
||||
{
|
||||
DBConnection.Close();
|
||||
}
|
||||
|
||||
public bool IsConnectionOpen()
|
||||
{
|
||||
return Convert.ToBoolean(DBConnection.State);
|
||||
}
|
||||
|
||||
public IEnumerable<IGameEntryModel> QueryGameById(string id)
|
||||
{
|
||||
return DBConnection.Query<GameEntryModel>(QueryBuilder.GameEntryByGameId(id), new DynamicParameters());
|
||||
}
|
||||
|
||||
public IEnumerable<IDirectoriesModel> QueryDirectoryById(string id)
|
||||
{
|
||||
return DBConnection.Query<DirectoriesModel>(QueryBuilder.DirectoryByGameId(id), new DynamicParameters());
|
||||
}
|
||||
|
||||
public IEnumerable<IGameEntryModel> QueryGameByName(string name)
|
||||
{
|
||||
return DBConnection.Query<GameEntryModel>(QueryBuilder.GameEntryByName(name), new DynamicParameters());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
using Microsoft.Data.Sqlite;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Dapper;
|
||||
using FireLance.Interfaces;
|
||||
|
||||
public class GSMParser : IDatabaseConnection
|
||||
{
|
||||
private SqliteConnection DBConnection = new SqliteConnection();
|
||||
|
||||
public void OpenConnection(string dbLocation)
|
||||
{
|
||||
if (File.Exists(dbLocation) == false)
|
||||
{
|
||||
throw new FileNotFoundException(dbLocation);
|
||||
}
|
||||
|
||||
DBConnection = new SqliteConnection($"Data Source={dbLocation};Mode=ReadOnly");
|
||||
DBConnection.Open();
|
||||
}
|
||||
|
||||
public void CloseCurrentConnection()
|
||||
{
|
||||
DBConnection.Close();
|
||||
}
|
||||
|
||||
public bool IsConnectionOpen()
|
||||
{
|
||||
return Convert.ToBoolean(DBConnection.State);
|
||||
}
|
||||
|
||||
public IEnumerable<IGameEntryModel> QueryGameById(string id)
|
||||
{
|
||||
return DBConnection.Query<GameEntryModel>(QueryBuilder.GameEntryByGameId(id), new DynamicParameters());
|
||||
}
|
||||
|
||||
public IEnumerable<IDirectoriesModel> QueryDirectoryById(string id)
|
||||
{
|
||||
return DBConnection.Query<DirectoriesModel>(QueryBuilder.DirectoryByGameId(id), new DynamicParameters());
|
||||
}
|
||||
|
||||
public IEnumerable<IGameEntryModel> QueryGameByName(string name)
|
||||
{
|
||||
return DBConnection.Query<GameEntryModel>(QueryBuilder.GameEntryByName(name), new DynamicParameters());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user