private void CreateMysqlTables(IProgress<TaskProgressUpdate> TaskProgress)
{
// Show Progress Form
if (TaskProgress != null)
TaskProgress.Report(new TaskProgressUpdate("Creating Stats Tables", "Creating Bf2Stats Mysql Tables..."));
// Gets Table Queries
string[] SQL = Program.GetResourceFileLines("BF2Statistics.SQL.MySQL.Stats.sql");
List<string> Queries = SqlFile.ExtractQueries(SQL);
// Start Transaction
using (DbTransaction Transaction = BeginTransaction())
{
// Attempt to do the transaction
try
{
// Create Tables
foreach (string Query in Queries)
base.Execute(Query);
// Commit
Transaction.Commit();
}
catch
{
Transaction.Rollback();
throw;
}
}
// Update status
if (TaskProgress != null)
TaskProgress.Report(new TaskProgressUpdate("Inserting Ip2Nation Data"));
// WE STILL INSTALL ip2Nation DATA to stay compatible with the web ASP
SQL = Program.GetResourceFileLines("BF2Statistics.SQL.Ip2nation.sql");
Queries = SqlFile.ExtractQueries(SQL);
// Insert Ip2Nation data
using (DbTransaction Transaction = BeginTransaction())
{
// Attempt to do the transaction
try
{
// Insert rows
foreach (string Query in Queries)
base.Execute(Query);
// Commit
Transaction.Commit();
}
catch
{
Transaction.Rollback();
throw;
}
}
}