mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix AB output from new database
This commit is contained in:
@@ -131,7 +131,7 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
_logger.Log("Total number of lines in database: " + slc.ExecuteScalar());
|
_logger.Log("Total number of lines in database: " + slc.ExecuteScalar());
|
||||||
}
|
}
|
||||||
Output.WriteToDat2(_name + "-db", _desc + "-db", _version, _date, _cat, _author, _forceunpack, _old, _diff, _ad, "", dbc, _logger);
|
Output.WriteToDatFromDb(_name + "-db", _desc + "-db", _version, _date, _cat, _author, _forceunpack, _old, _diff, _ad, "", dbc, _logger);
|
||||||
|
|
||||||
dbc.Close();
|
dbc.Close();
|
||||||
|
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create and open an output file for writing
|
/// Create and open an output file for writing direct from a database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">Internal name of the DAT</param>
|
/// <param name="name">Internal name of the DAT</param>
|
||||||
/// <param name="description">Description and external name of the DAT</param>
|
/// <param name="description">Description and external name of the DAT</param>
|
||||||
@@ -146,7 +146,7 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="dbc">Database connection representing the roms to be written</param>
|
/// <param name="dbc">Database connection representing the roms to be written</param>
|
||||||
/// <param name="logger">Logger object for console and/or file output</param>
|
/// <param name="logger">Logger object for console and/or file output</param>
|
||||||
/// <returns>Tru if the DAT was written correctly, false otherwise</returns>
|
/// <returns>Tru if the DAT was written correctly, false otherwise</returns>
|
||||||
public static bool WriteToDat2(string name, string description, string version, string date, string category, string author,
|
public static bool WriteToDatFromDb(string name, string description, string version, string date, string category, string author,
|
||||||
bool forceunpack, bool old, bool diff, bool ab, string outDir, SqliteConnection dbc, Logger logger)
|
bool forceunpack, bool old, bool diff, bool ab, string outDir, SqliteConnection dbc, Logger logger)
|
||||||
{
|
{
|
||||||
// If it's empty, use the current folder
|
// If it's empty, use the current folder
|
||||||
@@ -166,7 +166,7 @@ namespace SabreTools.Helper
|
|||||||
inputs.Add("");
|
inputs.Add("");
|
||||||
if (diff)
|
if (diff)
|
||||||
{
|
{
|
||||||
inputs.Add("WHERE dupe<>'true'");
|
inputs.Add("<>");
|
||||||
}
|
}
|
||||||
if (ab)
|
if (ab)
|
||||||
{
|
{
|
||||||
@@ -176,23 +176,42 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
while (sldr.Read())
|
while (sldr.Read())
|
||||||
{
|
{
|
||||||
inputs.Add("WHERE dupe='" + inputs + "'");
|
inputs.Add(sldr.GetString(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
for (int i = 0; i < inputs.Count; i++)
|
||||||
foreach (string input in inputs)
|
|
||||||
{
|
{
|
||||||
|
// Set strings to be used internally
|
||||||
|
string input = inputs[i];
|
||||||
|
string where = "";
|
||||||
string tempname = name;
|
string tempname = name;
|
||||||
string tempdesc = description;
|
string tempdesc = description;
|
||||||
|
|
||||||
|
// Get the right value from the input
|
||||||
|
if (input == "<>")
|
||||||
|
{
|
||||||
|
where = "WHERE dupe<>'true'";
|
||||||
|
input = "diff";
|
||||||
|
}
|
||||||
|
else if (input == "true")
|
||||||
|
{
|
||||||
|
where = "WHERE dupe='true'";
|
||||||
|
input = "diff";
|
||||||
|
}
|
||||||
|
else if (input != "")
|
||||||
|
{
|
||||||
|
where = "WHERE dupe='" + input + "'";
|
||||||
|
input = Path.GetFileNameWithoutExtension(input);
|
||||||
|
}
|
||||||
|
|
||||||
// If we have special outputs, append the right things
|
// If we have special outputs, append the right things
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
{
|
{
|
||||||
tempname += " (" + i + ")";
|
tempname += " (" + input + ")";
|
||||||
tempdesc += " (" + i + ")";
|
tempdesc += " (" + input + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
// (currently uses current time, change to "last updated time")
|
// (currently uses current time, change to "last updated time")
|
||||||
@@ -231,7 +250,7 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
// Write out each of the machines and roms
|
// Write out each of the machines and roms
|
||||||
string lastgame = "";
|
string lastgame = "";
|
||||||
string query = "SELECT * FROM roms " + input + " ORDER BY game, name";
|
string query = "SELECT * FROM roms " + where + " ORDER BY game, name";
|
||||||
using (SqliteDataReader sldr = (new SqliteCommand(query, dbc).ExecuteReader()))
|
using (SqliteDataReader sldr = (new SqliteCommand(query, dbc).ExecuteReader()))
|
||||||
{
|
{
|
||||||
while (sldr.Read())
|
while (sldr.Read())
|
||||||
@@ -285,8 +304,6 @@ namespace SabreTools.Helper
|
|||||||
logger.Error(ex.ToString());
|
logger.Error(ex.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user