mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Constants] Move db strings to constants
This commit is contained in:
@@ -171,5 +171,16 @@ namespace SabreTools.Helper
|
|||||||
public static byte[] TorrentGZHeader = new byte[] { 0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00 };
|
public static byte[] TorrentGZHeader = new byte[] { 0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00 };
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Database schema
|
||||||
|
|
||||||
|
public static string DATabaseDbSchema = "dats";
|
||||||
|
public static string DATabaseFileName = "dats.sqlite";
|
||||||
|
public static string DATabaseConnectionString = "Data Source=" + DATabaseFileName + ";Version = 3;";
|
||||||
|
public static string HeadererDbSchema = "Headerer";
|
||||||
|
public static string HeadererFileName = "Headerer.sqlite";
|
||||||
|
public static string HeadererConnectionString = "Data Source=" + HeadererFileName + ";Version = 3;";
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,6 @@ namespace SabreTools
|
|||||||
private string _outdir;
|
private string _outdir;
|
||||||
private Logger _logger;
|
private Logger _logger;
|
||||||
|
|
||||||
// Private required variables
|
|
||||||
private static string _headererDbSchema = "Headerer";
|
|
||||||
private static string _headererDbName = "Headerer.sqlite";
|
|
||||||
private static string _headererConnectionString = "Data Source=" + _headererDbName + ";Version = 3;";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new Headerer object
|
/// Create a new Headerer object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -152,7 +147,7 @@ namespace SabreTools
|
|||||||
bool exists = false;
|
bool exists = false;
|
||||||
|
|
||||||
string query = @"SELECT * FROM data WHERE sha1='" + SHA1 + "' AND header='" + header + "'";
|
string query = @"SELECT * FROM data WHERE sha1='" + SHA1 + "' AND header='" + header + "'";
|
||||||
using (SqliteConnection dbc = new SqliteConnection(_headererConnectionString))
|
using (SqliteConnection dbc = new SqliteConnection(Constants.HeadererConnectionString))
|
||||||
{
|
{
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
||||||
@@ -170,7 +165,7 @@ namespace SabreTools
|
|||||||
SHA1 + "', " +
|
SHA1 + "', " +
|
||||||
"'" + header + "', " +
|
"'" + header + "', " +
|
||||||
"'" + type.ToString() + "')";
|
"'" + type.ToString() + "')";
|
||||||
using (SqliteConnection dbc = new SqliteConnection(_headererConnectionString))
|
using (SqliteConnection dbc = new SqliteConnection(Constants.HeadererConnectionString))
|
||||||
{
|
{
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
||||||
@@ -195,7 +190,7 @@ namespace SabreTools
|
|||||||
string header = "";
|
string header = "";
|
||||||
|
|
||||||
string query = @"SELECT header, type FROM data WHERE sha1='" + rom.HashData.SHA1 + "'";
|
string query = @"SELECT header, type FROM data WHERE sha1='" + rom.HashData.SHA1 + "'";
|
||||||
using (SqliteConnection dbc = new SqliteConnection(_headererConnectionString))
|
using (SqliteConnection dbc = new SqliteConnection(Constants.HeadererConnectionString))
|
||||||
{
|
{
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
Directory.CreateDirectory(_outroot);
|
Directory.CreateDirectory(_outroot);
|
||||||
}
|
}
|
||||||
DBTools.EnsureDatabase(_databaseDbSchema, _databaseDbName, _databaseConnectionString);
|
DBTools.EnsureDatabase(Constants.DATabaseDbSchema, Constants.DATabaseFileName, Constants.DATabaseConnectionString);
|
||||||
|
|
||||||
using (SqliteConnection dbc = new SqliteConnection(_databaseConnectionString))
|
using (SqliteConnection dbc = new SqliteConnection(Constants.DATabaseConnectionString))
|
||||||
{
|
{
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DBTools.EnsureDatabase(_headererDbSchema, _headererDbName, _headererConnectionString);
|
DBTools.EnsureDatabase(Constants.HeadererDbSchema, Constants.HeadererFileName, Constants.HeadererConnectionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -63,7 +63,7 @@ namespace SabreTools
|
|||||||
SELECT DISTINCT source.id, source.name, source.url
|
SELECT DISTINCT source.id, source.name, source.url
|
||||||
FROM source
|
FROM source
|
||||||
ORDER BY source.name";
|
ORDER BY source.name";
|
||||||
using (SqliteConnection dbc = new SqliteConnection(_databaseConnectionString))
|
using (SqliteConnection dbc = new SqliteConnection(Constants.DATabaseConnectionString))
|
||||||
{
|
{
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
||||||
@@ -97,7 +97,7 @@ ORDER BY source.name";
|
|||||||
SELECT DISTINCT system.id, system.manufacturer, system.name
|
SELECT DISTINCT system.id, system.manufacturer, system.name
|
||||||
FROM system
|
FROM system
|
||||||
ORDER BY system.manufacturer, system.name";
|
ORDER BY system.manufacturer, system.name";
|
||||||
using (SqliteConnection dbc = new SqliteConnection(_databaseConnectionString))
|
using (SqliteConnection dbc = new SqliteConnection(Constants.DATabaseConnectionString))
|
||||||
{
|
{
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace SabreTools
|
|||||||
/// <param name="url">Source URL(s)</param>
|
/// <param name="url">Source URL(s)</param>
|
||||||
private static void InitAddSource(string name, string url)
|
private static void InitAddSource(string name, string url)
|
||||||
{
|
{
|
||||||
if (DBTools.AddSource(name, url, _databaseConnectionString))
|
if (DBTools.AddSource(name, url, Constants.DATabaseConnectionString))
|
||||||
{
|
{
|
||||||
_logger.Log("Source " + name + " added!");
|
_logger.Log("Source " + name + " added!");
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ namespace SabreTools
|
|||||||
/// <param name="system">System name</param>
|
/// <param name="system">System name</param>
|
||||||
private static void InitAddSystem(string manufacturer, string system)
|
private static void InitAddSystem(string manufacturer, string system)
|
||||||
{
|
{
|
||||||
if (DBTools.AddSystem(manufacturer, system, _databaseConnectionString))
|
if (DBTools.AddSystem(manufacturer, system, Constants.DATabaseConnectionString))
|
||||||
{
|
{
|
||||||
_logger.Log("System " + manufacturer + " - " + system + " added!");
|
_logger.Log("System " + manufacturer + " - " + system + " added!");
|
||||||
}
|
}
|
||||||
@@ -241,7 +241,7 @@ namespace SabreTools
|
|||||||
/// <param name="old">True if the output file should be in ClrMamePro format (default false)</param>
|
/// <param name="old">True if the output file should be in ClrMamePro format (default false)</param>
|
||||||
private static void InitGenerate(string systemid, bool norename, bool old)
|
private static void InitGenerate(string systemid, bool norename, bool old)
|
||||||
{
|
{
|
||||||
IGenerate gen = new GenerateTwo(systemid, "" /* sourceid */, _datroot, _outroot, _databaseConnectionString, _logger, norename, old);
|
IGenerate gen = new GenerateTwo(systemid, "" /* sourceid */, _datroot, _outroot, Constants.DATabaseConnectionString, _logger, norename, old);
|
||||||
gen.Export();
|
gen.Export();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ namespace SabreTools
|
|||||||
private static void InitGenerateAll(bool norename, bool old)
|
private static void InitGenerateAll(bool norename, bool old)
|
||||||
{
|
{
|
||||||
List<string> systems = new List<string>();
|
List<string> systems = new List<string>();
|
||||||
using (SqliteConnection dbc = new SqliteConnection(_databaseConnectionString))
|
using (SqliteConnection dbc = new SqliteConnection(Constants.DATabaseConnectionString))
|
||||||
{
|
{
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
|
|
||||||
@@ -333,7 +333,7 @@ namespace SabreTools
|
|||||||
/// <param name="ignore"></param>
|
/// <param name="ignore"></param>
|
||||||
private static void InitImport(bool ignore)
|
private static void InitImport(bool ignore)
|
||||||
{
|
{
|
||||||
IImport imp = new ImportTwo(_datroot, _databaseConnectionString, _logger, ignore);
|
IImport imp = new ImportTwo(_datroot, Constants.DATabaseConnectionString, _logger, ignore);
|
||||||
imp.UpdateDatabase();
|
imp.UpdateDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,7 +346,7 @@ namespace SabreTools
|
|||||||
int srcid = -1;
|
int srcid = -1;
|
||||||
if (Int32.TryParse(sourceid, out srcid))
|
if (Int32.TryParse(sourceid, out srcid))
|
||||||
{
|
{
|
||||||
if (DBTools.RemoveSource(srcid, _databaseConnectionString))
|
if (DBTools.RemoveSource(srcid, Constants.DATabaseConnectionString))
|
||||||
{
|
{
|
||||||
_logger.Log("Source '" + srcid + "' removed!");
|
_logger.Log("Source '" + srcid + "' removed!");
|
||||||
}
|
}
|
||||||
@@ -370,7 +370,7 @@ namespace SabreTools
|
|||||||
int sysid = -1;
|
int sysid = -1;
|
||||||
if (Int32.TryParse(systemid, out sysid))
|
if (Int32.TryParse(systemid, out sysid))
|
||||||
{
|
{
|
||||||
if (DBTools.RemoveSystem(sysid, _databaseConnectionString))
|
if (DBTools.RemoveSystem(sysid, Constants.DATabaseConnectionString))
|
||||||
{
|
{
|
||||||
_logger.Log("System '" + sysid + "' removed!");
|
_logger.Log("System '" + sysid + "' removed!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,14 +27,6 @@ namespace SabreTools
|
|||||||
private static string _datroot = "DATS";
|
private static string _datroot = "DATS";
|
||||||
private static string _outroot = "Output";
|
private static string _outroot = "Output";
|
||||||
|
|
||||||
// Database schema variables
|
|
||||||
private static string _databaseDbSchema = "dats";
|
|
||||||
private static string _databaseDbName = "dats.sqlite";
|
|
||||||
private static string _databaseConnectionString = "Data Source=" + _databaseDbName + ";Version = 3;";
|
|
||||||
private static string _headererDbSchema = "Headerer";
|
|
||||||
private static string _headererDbName = "Headerer.sqlite";
|
|
||||||
private static string _headererConnectionString = "Data Source=" + _headererDbName + ";Version = 3;";
|
|
||||||
|
|
||||||
private static Logger _logger;
|
private static Logger _logger;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user