48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using Microsoft.Data.Sqlite;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using Dapper;
|
|
using FireLance.Interfaces;
|
|
|
|
public class GSMParser
|
|
{
|
|
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 string ReportConnectionState()
|
|
{
|
|
return Convert.ToString(DBConnection.State);
|
|
}
|
|
|
|
public IEnumerable<IGameEntry> QueryGameById(string id)
|
|
{
|
|
return (IEnumerable<IGameEntry>)DBConnection.Query<GameEntryModel>(QueryBuilder.GameEntryByGameId(id), new DynamicParameters());
|
|
}
|
|
|
|
public IEnumerable<IDirectories> QueryDirectoryById(string id)
|
|
{
|
|
return (IEnumerable<IDirectories>)DBConnection.Query<DirectoriesModel>(QueryBuilder.DirectoryByGameId(id), new DynamicParameters());
|
|
}
|
|
|
|
public IEnumerable<IGameEntry> QueryGameByName(string name)
|
|
{
|
|
return (IEnumerable<IGameEntry>) DBConnection.Query<GameEntryModel>(QueryBuilder.GameEntryByName(name), new DynamicParameters());
|
|
}
|
|
}
|