Removed not needed class. Switch strings to use the new c# style
This commit is contained in:
@@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
namespace Framework.Database
|
|
||||||
{
|
|
||||||
public class ConnectionObject
|
|
||||||
{
|
|
||||||
public string Host { get; set; }
|
|
||||||
public string Port { get; set; }
|
|
||||||
public string Username { get; set; }
|
|
||||||
public string Password { get; set; }
|
|
||||||
public string Database { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -30,18 +30,18 @@ namespace Framework.Database
|
|||||||
_updateFlags = ConfigMgr.GetDefaultValue("Updates.EnableDatabases", defaultUpdateMask);
|
_updateFlags = ConfigMgr.GetDefaultValue("Updates.EnableDatabases", defaultUpdateMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddDatabase<T>(MySqlBase<T> database, string name)
|
public void AddDatabase<T>(MySqlBase<T> database, string dbName)
|
||||||
{
|
{
|
||||||
bool updatesEnabled = database.IsAutoUpdateEnabled(_updateFlags);
|
bool updatesEnabled = database.IsAutoUpdateEnabled(_updateFlags);
|
||||||
_open.Add(() =>
|
_open.Add(() =>
|
||||||
{
|
{
|
||||||
ConnectionObject connectionObject = new ConnectionObject
|
MySqlConnectionInfo connectionObject = new MySqlConnectionInfo
|
||||||
{
|
{
|
||||||
Database = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Database", ""),
|
Host = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Host", ""),
|
||||||
Host = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Host", ""),
|
Port = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Port", ""),
|
||||||
Password = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Password", ""),
|
Username = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Username", ""),
|
||||||
Port = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Port", ""),
|
Password = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Password", ""),
|
||||||
Username = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Username", "")
|
Database = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Database", "")
|
||||||
};
|
};
|
||||||
|
|
||||||
var error = database.Initialize(connectionObject);
|
var error = database.Initialize(connectionObject);
|
||||||
@@ -50,14 +50,14 @@ namespace Framework.Database
|
|||||||
// Database does not exist
|
// Database does not exist
|
||||||
if (error == MySqlErrorCode.UnknownDatabase && updatesEnabled && _autoSetup)
|
if (error == MySqlErrorCode.UnknownDatabase && updatesEnabled && _autoSetup)
|
||||||
{
|
{
|
||||||
Log.outInfo(LogFilter.ServerLoading, "Database \"{0}\" does not exist, do you want to create it? [yes (default) / no]: ", name);
|
Log.outInfo(LogFilter.ServerLoading, $"Database \"{dbName}\" does not exist, do you want to create it? [yes (default) / no]: ");
|
||||||
|
|
||||||
string answer = Console.ReadLine();
|
string answer = Console.ReadLine();
|
||||||
if (string.IsNullOrEmpty(answer) || answer[0] != 'y')
|
if (string.IsNullOrEmpty(answer) || answer[0] != 'y')
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Log.outInfo(LogFilter.ServerLoading, "Creating database \"{0}\"...", name);
|
Log.outInfo(LogFilter.ServerLoading, $"Creating database \"{dbName}\"...");
|
||||||
string sqlString = string.Format("CREATE DATABASE `{0}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", name);
|
string sqlString = $"CREATE DATABASE `{dbName}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";
|
||||||
// Try to create the database and connect again if auto setup is enabled
|
// Try to create the database and connect again if auto setup is enabled
|
||||||
if (database.Apply(sqlString) && database.Initialize(connectionObject) == MySqlErrorCode.None)
|
if (database.Apply(sqlString) && database.Initialize(connectionObject) == MySqlErrorCode.None)
|
||||||
error = MySqlErrorCode.None;
|
error = MySqlErrorCode.None;
|
||||||
@@ -66,7 +66,7 @@ namespace Framework.Database
|
|||||||
// If the error wasn't handled quit
|
// If the error wasn't handled quit
|
||||||
if (error != MySqlErrorCode.None)
|
if (error != MySqlErrorCode.None)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.ServerLoading, "\nDatabase {0} NOT opened. There were errors opening the MySQL connections. Check your SQLErrors for specific errors.", name);
|
Log.outError(LogFilter.ServerLoading, $"\nDatabase {dbName} NOT opened. There were errors opening the MySQL connections. Check your SQLErrors for specific errors.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ namespace Framework.Database
|
|||||||
database.Apply("SET GLOBAL max_allowed_packet=1073741824;");
|
database.Apply("SET GLOBAL max_allowed_packet=1073741824;");
|
||||||
if (!database.GetUpdater().Populate())
|
if (!database.GetUpdater().Populate())
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.ServerLoading, "Could not populate the {0} database, see log for details.", name);
|
Log.outError(LogFilter.ServerLoading, $"Could not populate the {dbName} database, see log for details.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -96,7 +96,7 @@ namespace Framework.Database
|
|||||||
database.Apply("SET GLOBAL max_allowed_packet=1073741824;");
|
database.Apply("SET GLOBAL max_allowed_packet=1073741824;");
|
||||||
if (!database.GetUpdater().Update())
|
if (!database.GetUpdater().Update())
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.ServerLoading, "Could not update the {0} database, see log for details.", name);
|
Log.outError(LogFilter.ServerLoading, $"Could not update the {dbName} database, see log for details.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace Framework.Database
|
|||||||
if (!result.IsEmpty() && result.GetRowCount() > 0)
|
if (!result.IsEmpty() && result.GetRowCount() > 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Log.outInfo(LogFilter.SqlUpdates, "Database {0} is empty, auto populating it...", _database.GetDatabaseName());
|
Log.outInfo(LogFilter.SqlUpdates, $"Database {_database.GetDatabaseName()} is empty, auto populating it...");
|
||||||
|
|
||||||
string path = GetSourceDirectory();
|
string path = GetSourceDirectory();
|
||||||
string fileName = "Unknown";
|
string fileName = "Unknown";
|
||||||
@@ -60,28 +60,28 @@ namespace Framework.Database
|
|||||||
|
|
||||||
if (!File.Exists(path + fileName))
|
if (!File.Exists(path + fileName))
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.SqlUpdates, "File \"{0}\" is missing, download it from \"http://www.trinitycore.org/f/files/category/1-database/\"" +
|
Log.outError(LogFilter.SqlUpdates, $"File \"{fileName}\" is missing, download it from \"http://www.trinitycore.org/f/files/category/1-database/\"" +
|
||||||
" and place it in your worldserver directory.", fileName);
|
" and place it in your worldserver directory.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update database
|
// Update database
|
||||||
Log.outInfo(LogFilter.SqlUpdates, "Applying \'{0}\'...", fileName);
|
Log.outInfo(LogFilter.SqlUpdates, $"Applying \'{fileName}\'...");
|
||||||
_database.ApplyFile(path + fileName);
|
_database.ApplyFile(path + fileName);
|
||||||
|
|
||||||
Log.outInfo(LogFilter.SqlUpdates, "Done Applying \'{0}\'", fileName);
|
Log.outInfo(LogFilter.SqlUpdates, $"Done Applying \'{fileName}\'");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update()
|
public bool Update()
|
||||||
{
|
{
|
||||||
Log.outInfo(LogFilter.SqlUpdates, "Updating {0} database...", _database.GetDatabaseName());
|
Log.outInfo(LogFilter.SqlUpdates, $"Updating {_database.GetDatabaseName()} database...");
|
||||||
|
|
||||||
string sourceDirectory = GetSourceDirectory();
|
string sourceDirectory = GetSourceDirectory();
|
||||||
|
|
||||||
if (!Directory.Exists(sourceDirectory))
|
if (!Directory.Exists(sourceDirectory))
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.SqlUpdates, "DBUpdater: Given source directory {0} does not exist, skipped!", sourceDirectory);
|
Log.outError(LogFilter.SqlUpdates, $"DBUpdater: Given source directory {sourceDirectory} does not exist, skipped!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ namespace Framework.Database
|
|||||||
|
|
||||||
foreach (var availableQuery in availableFiles)
|
foreach (var availableQuery in availableFiles)
|
||||||
{
|
{
|
||||||
Log.outDebug(LogFilter.SqlUpdates, "Checking update \"{0}\"...", availableQuery.GetFileName());
|
Log.outDebug(LogFilter.SqlUpdates, $"Checking update \"{availableQuery.GetFileName()}\"...");
|
||||||
|
|
||||||
var applied = appliedFiles.LookupByKey(availableQuery.GetFileName());
|
var applied = appliedFiles.LookupByKey(availableQuery.GetFileName());
|
||||||
if (applied != null)
|
if (applied != null)
|
||||||
@@ -142,15 +142,13 @@ namespace Framework.Database
|
|||||||
var renameFile = availableFiles.Find(p => p.GetFileName() == hashIter.Name);
|
var renameFile = availableFiles.Find(p => p.GetFileName() == hashIter.Name);
|
||||||
if (renameFile != null)
|
if (renameFile != null)
|
||||||
{
|
{
|
||||||
Log.outWarn(LogFilter.SqlUpdates, "Seems like update \"{0}\" \'{1}\' was renamed, but the old file is still there! " +
|
Log.outWarn(LogFilter.SqlUpdates, $"Seems like update \"{availableQuery.GetFileName()}\" \'{hash.Substring(0, 7)}\' was renamed, but the old file is still there! " +
|
||||||
"Trade it as a new file! (Probably its an unmodified copy of file \"{2}\")",
|
$"Trade it as a new file! (Probably its an unmodified copy of file \"{renameFile.GetFileName()}\")");
|
||||||
availableQuery.GetFileName(), hash.Substring(0, 7), renameFile.GetFileName());
|
|
||||||
}
|
}
|
||||||
// Its save to trade the file as renamed here
|
// Its save to trade the file as renamed here
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.outInfo(LogFilter.SqlUpdates, "Renaming update \"{0}\" to \"{1}\" \'{2}\'.",
|
Log.outInfo(LogFilter.SqlUpdates, $"Renaming update \"{hashIter.Name}\" to \"{availableQuery.GetFileName()}\" \'{hash.Substring(0, 7)}\'.");
|
||||||
hashIter.Name, availableQuery.GetFileName(), hash.Substring(0, 7));
|
|
||||||
|
|
||||||
RenameEntry(hashIter.Name, availableQuery.GetFileName());
|
RenameEntry(hashIter.Name, availableQuery.GetFileName());
|
||||||
appliedFiles.Remove(hashIter.Name);
|
appliedFiles.Remove(hashIter.Name);
|
||||||
@@ -160,7 +158,7 @@ namespace Framework.Database
|
|||||||
// Apply the update if it was never seen before.
|
// Apply the update if it was never seen before.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.outInfo(LogFilter.SqlUpdates, "Applying update \"{0}\" \'{1}\'...", availableQuery.GetFileName(), hash.Substring(0, 7));
|
Log.outInfo(LogFilter.SqlUpdates, $"Applying update \"{availableQuery.GetFileName()}\" \'{hash.Substring(0, 7)}\'...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Rehash the update entry if it is contained in our database but with an empty hash.
|
// Rehash the update entry if it is contained in our database but with an empty hash.
|
||||||
@@ -168,27 +166,26 @@ namespace Framework.Database
|
|||||||
{
|
{
|
||||||
mode = UpdateMode.Rehash;
|
mode = UpdateMode.Rehash;
|
||||||
|
|
||||||
Log.outInfo(LogFilter.SqlUpdates, "Re-hashing update \"{0}\" \'{1}\'...", availableQuery.GetFileName(), hash.Substring(0, 7));
|
Log.outInfo(LogFilter.SqlUpdates, $"Re-hashing update \"{availableQuery.GetFileName()}\" \'{hash.Substring(0, 7)}\'...");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If the hash of the files differs from the one stored in our database reapply the update (because it was changed).
|
// If the hash of the files differs from the one stored in our database reapply the update (because it was changed).
|
||||||
if (applied.Hash != hash)
|
if (applied.Hash != hash)
|
||||||
{
|
{
|
||||||
Log.outInfo(LogFilter.SqlUpdates, "Reapplying update \"{0}\" \'{1}\' . \'{2}\' (it changed)...", availableQuery.GetFileName(),
|
Log.outInfo(LogFilter.SqlUpdates, $"Reapplying update \"{availableQuery.GetFileName()}\" \'{applied.Hash.Substring(0, 7)}\' . \'{hash.Substring(0, 7)}\' (it changed)...");
|
||||||
applied.Hash.Substring(0, 7), hash.Substring(0, 7));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If the file wasn't changed and just moved update its state if necessary.
|
// If the file wasn't changed and just moved update its state if necessary.
|
||||||
if (applied.State != availableQuery.state)
|
if (applied.State != availableQuery.state)
|
||||||
{
|
{
|
||||||
Log.outDebug(LogFilter.SqlUpdates, "Updating state of \"{0}\" to \'{1}\'...", availableQuery.GetFileName(), availableQuery.state);
|
Log.outDebug(LogFilter.SqlUpdates, $"Updating state of \"{availableQuery.GetFileName()}\" to \'{availableQuery.state}\'...");
|
||||||
|
|
||||||
UpdateState(availableQuery.GetFileName(), availableQuery.state);
|
UpdateState(availableQuery.GetFileName(), availableQuery.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.outDebug(LogFilter.SqlUpdates, "Update is already applied and is matching hash \'{0}\'.", hash.Substring(0, 7));
|
Log.outDebug(LogFilter.SqlUpdates, $"Update is already applied and is matching hash \'{hash.Substring(0, 7)}\'.");
|
||||||
|
|
||||||
appliedFiles.Remove(applied.Name);
|
appliedFiles.Remove(applied.Name);
|
||||||
continue;
|
continue;
|
||||||
@@ -223,26 +220,26 @@ namespace Framework.Database
|
|||||||
|
|
||||||
foreach (var entry in appliedFiles)
|
foreach (var entry in appliedFiles)
|
||||||
{
|
{
|
||||||
Log.outWarn(LogFilter.SqlUpdates, "File \'{0}\' was applied to the database but is missing in your update directory now!", entry.Key);
|
Log.outWarn(LogFilter.SqlUpdates, $"File \'{entry.Key}\' was applied to the database but is missing in your update directory now!");
|
||||||
|
|
||||||
if (doCleanup)
|
if (doCleanup)
|
||||||
Log.outInfo(LogFilter.SqlUpdates, "Deleting orphaned entry \'{0}\'...", entry.Key);
|
Log.outInfo(LogFilter.SqlUpdates, $"Deleting orphaned entry \'{entry.Key}\'...");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doCleanup)
|
if (doCleanup)
|
||||||
CleanUp(appliedFiles);
|
CleanUp(appliedFiles);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.SqlUpdates, "Cleanup is disabled! There are {0} dirty files that were applied to your database but are now missing in your source directory!", appliedFiles.Count);
|
Log.outError(LogFilter.SqlUpdates, $"Cleanup is disabled! There are {appliedFiles.Count} dirty files that were applied to your database but are now missing in your source directory!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string info = string.Format("Containing {0} new and {1} archived updates.", result.recent, result.archived);
|
string info = $"Containing {result.recent} new and {result.archived} archived updates.";
|
||||||
|
|
||||||
if (result.updated == 0)
|
if (result.updated == 0)
|
||||||
Log.outInfo(LogFilter.SqlUpdates, "{0} database is up-to-date! {1}", _database.GetDatabaseName(), info);
|
Log.outInfo(LogFilter.SqlUpdates, $"{_database.GetDatabaseName()} database is up-to-date! {info}");
|
||||||
else
|
else
|
||||||
Log.outInfo(LogFilter.SqlUpdates, "Applied {0} {1}. {2}", result.updated, result.updated == 1 ? "query" : "queries", info);
|
Log.outInfo(LogFilter.SqlUpdates, $"Applied {result.updated} query(s). {info}");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -270,8 +267,7 @@ namespace Framework.Database
|
|||||||
|
|
||||||
void UpdateEntry(AppliedFileEntry entry, uint speed)
|
void UpdateEntry(AppliedFileEntry entry, uint speed)
|
||||||
{
|
{
|
||||||
string update = "REPLACE INTO `updates` (`name`, `hash`, `state`, `speed`) VALUES (\"" +
|
string update = $"REPLACE INTO `updates` (`name`, `hash`, `state`, `speed`) VALUES (\"{entry.Name}\", \"{entry.Hash}\", \'{entry.State}\', {speed})";
|
||||||
entry.Name + "\", \"" + entry.Hash + "\", \'" + entry.State + "\', " + speed + ")";
|
|
||||||
|
|
||||||
// Update database
|
// Update database
|
||||||
_database.Execute(update);
|
_database.Execute(update);
|
||||||
@@ -281,7 +277,7 @@ namespace Framework.Database
|
|||||||
{
|
{
|
||||||
// Delete target if it exists
|
// Delete target if it exists
|
||||||
{
|
{
|
||||||
string update = "DELETE FROM `updates` WHERE `name`=\"" + to + "\"";
|
string update = $"DELETE FROM `updates` WHERE `name`=\"{to}\"";
|
||||||
|
|
||||||
// Update database
|
// Update database
|
||||||
_database.Execute(update);
|
_database.Execute(update);
|
||||||
@@ -289,7 +285,7 @@ namespace Framework.Database
|
|||||||
|
|
||||||
// Rename
|
// Rename
|
||||||
{
|
{
|
||||||
string update = "UPDATE `updates` SET `name`=\"" + to + "\" WHERE `name`=\"" + from + "\"";
|
string update = $"UPDATE `updates` SET `name`=\"{to}\" WHERE `name`=\"{from}\"";
|
||||||
|
|
||||||
// Update database
|
// Update database
|
||||||
_database.Execute(update);
|
_database.Execute(update);
|
||||||
@@ -306,7 +302,7 @@ namespace Framework.Database
|
|||||||
|
|
||||||
foreach (var entry in storage)
|
foreach (var entry in storage)
|
||||||
{
|
{
|
||||||
update += "\"" + entry.Key + "\"";
|
update += $"\"{entry.Key}\"";
|
||||||
if ((--remaining) > 0)
|
if ((--remaining) > 0)
|
||||||
update += ", ";
|
update += ", ";
|
||||||
}
|
}
|
||||||
@@ -319,7 +315,7 @@ namespace Framework.Database
|
|||||||
|
|
||||||
void UpdateState(string name, State state)
|
void UpdateState(string name, State state)
|
||||||
{
|
{
|
||||||
string update = "UPDATE `updates` SET `state`=\'" + state + "\' WHERE `name`=\"" + name + "\"";
|
string update = $"UPDATE `updates` SET `state`=\'{state}\' WHERE `name`=\"{name}\"";
|
||||||
|
|
||||||
// Update database
|
// Update database
|
||||||
_database.Execute(update);
|
_database.Execute(update);
|
||||||
@@ -341,14 +337,14 @@ namespace Framework.Database
|
|||||||
|
|
||||||
if (!Directory.Exists(path))
|
if (!Directory.Exists(path))
|
||||||
{
|
{
|
||||||
Log.outWarn(LogFilter.SqlUpdates, "DBUpdater: Given update include directory \"{0}\" isn't existing, skipped!", path);
|
Log.outWarn(LogFilter.SqlUpdates, $"DBUpdater: Given update include directory \"{path}\" isn't existing, skipped!");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
State state = result.Read<string>(1).ToEnum<State>();
|
State state = result.Read<string>(1).ToEnum<State>();
|
||||||
fileList.AddRange(GetFilesFromDirectory(path, state));
|
fileList.AddRange(GetFilesFromDirectory(path, state));
|
||||||
|
|
||||||
Log.outDebug(LogFilter.SqlUpdates, "Added applied file \"{0}\" from remote.", path);
|
Log.outDebug(LogFilter.SqlUpdates, $"Added applied file \"{path}\" from remote.");
|
||||||
|
|
||||||
} while (result.NextRow());
|
} while (result.NextRow());
|
||||||
|
|
||||||
|
|||||||
@@ -28,26 +28,19 @@ namespace Framework.Database
|
|||||||
{
|
{
|
||||||
public class MySqlConnectionInfo
|
public class MySqlConnectionInfo
|
||||||
{
|
{
|
||||||
public MySqlConnectionInfo(ConnectionObject connectionObject, int poolSize = 10)
|
public MySqlConnectionInfo(int poolSize = 10)
|
||||||
{
|
{
|
||||||
Host = connectionObject.Host;
|
|
||||||
Port = connectionObject.Port;
|
|
||||||
Username = connectionObject.Username;
|
|
||||||
Password = connectionObject.Password;
|
|
||||||
Database = connectionObject.Database;
|
|
||||||
Poolsize = poolSize;
|
Poolsize = poolSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MySqlConnection GetConnection()
|
public MySqlConnection GetConnection()
|
||||||
{
|
{
|
||||||
return new MySqlConnection(string.Format("Server={0};Port={1};User Id={2};Password={3};Database={4};Allow Zero Datetime=True;Allow User Variables=True;Pooling=true;MaximumPoolSize={5};",
|
return new MySqlConnection($"Server={Host};Port={Port};User Id={Username};Password={Password};Database={Database};Allow Zero Datetime=True;Allow User Variables=True;Pooling=true;MaximumPoolSize={Poolsize};");
|
||||||
Host, Port, Username, Password, Database, Poolsize));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MySqlConnection GetConnectionNoDatabase()
|
public MySqlConnection GetConnectionNoDatabase()
|
||||||
{
|
{
|
||||||
return new MySqlConnection(string.Format("Server={0};Port={1};User Id={2};Password={3};Allow Zero Datetime=True;Allow User Variables=True;Pooling=true;MaximumPoolSize={4};",
|
return new MySqlConnection($"Server={Host};Port={Port};User Id={Username};Password={Password};Allow Zero Datetime=True;Allow User Variables=True;Pooling=true;MaximumPoolSize={Poolsize};");
|
||||||
Host, Port, Username, Password, Poolsize));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Host;
|
public string Host;
|
||||||
@@ -60,9 +53,9 @@ namespace Framework.Database
|
|||||||
|
|
||||||
public abstract class MySqlBase<T>
|
public abstract class MySqlBase<T>
|
||||||
{
|
{
|
||||||
public MySqlErrorCode Initialize(ConnectionObject connectionObject)
|
public MySqlErrorCode Initialize(MySqlConnectionInfo connectionInfo)
|
||||||
{
|
{
|
||||||
_connectionInfo = new MySqlConnectionInfo(connectionObject);
|
_connectionInfo = connectionInfo;
|
||||||
_updater = new DatabaseUpdater<T>(this);
|
_updater = new DatabaseUpdater<T>(this);
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -70,7 +63,7 @@ namespace Framework.Database
|
|||||||
using (var connection = _connectionInfo.GetConnection())
|
using (var connection = _connectionInfo.GetConnection())
|
||||||
{
|
{
|
||||||
connection.Open();
|
connection.Open();
|
||||||
Log.outInfo(LogFilter.SqlDriver, "Connected to MySQL(ver: {0}) Database: {1}", connection.ServerVersion, _connectionInfo.Database);
|
Log.outInfo(LogFilter.SqlDriver, $"Connected to MySQL(ver: {connection.ServerVersion}) Database: {_connectionInfo.Database}");
|
||||||
return MySqlErrorCode.None;
|
return MySqlErrorCode.None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -385,7 +378,7 @@ namespace Framework.Database
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.outError(LogFilter.Sql, "SqlException: {0} SqlQuery: {1}", ex.Message, query);
|
Log.outError(LogFilter.Sql, $"SqlException: {ex.Message} SqlQuery: {query}");
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,6 @@
|
|||||||
<Compile Include="Cryptography\SARC4.cs" />
|
<Compile Include="Cryptography\SARC4.cs" />
|
||||||
<Compile Include="Cryptography\SessionKeyGeneration.cs" />
|
<Compile Include="Cryptography\SessionKeyGeneration.cs" />
|
||||||
<Compile Include="Cryptography\ShaHmac.cs" />
|
<Compile Include="Cryptography\ShaHmac.cs" />
|
||||||
<Compile Include="Database\ConnectionObject.cs" />
|
|
||||||
<Compile Include="Database\DatabaseLoader.cs" />
|
<Compile Include="Database\DatabaseLoader.cs" />
|
||||||
<Compile Include="Database\Databases\CharacterDatabase.cs" />
|
<Compile Include="Database\Databases\CharacterDatabase.cs" />
|
||||||
<Compile Include="Database\DatabaseUpdater.cs" />
|
<Compile Include="Database\DatabaseUpdater.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user