From b1101797307504cfc2eea6317d4c4dc2b5964480 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 13 May 2007 14:59:24 +0000 Subject: * Fixed MySQL Grid Manager * Added preliminary support for DB UserServer (incomplete) * Added better handling of defaults to Grid Manager. * Renamed SQL/regions.sql to SQL/mysql-regions.sql. --- OpenGrid.Framework.Data.MySQL/MySQLGridData.cs | 71 +++++++++++++++++--------- 1 file changed, 48 insertions(+), 23 deletions(-) (limited to 'OpenGrid.Framework.Data.MySQL/MySQLGridData.cs') diff --git a/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs b/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs index 4404a16..3dceff6 100644 --- a/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs +++ b/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs @@ -14,7 +14,7 @@ namespace OpenGrid.Framework.Data.MySQL /// public void Initialise() { - database = new MySQLManager("localhost", "db", "user", "password", "false"); + database = new MySQLManager("server", "database", "username", "password", "false"); } /// @@ -42,17 +42,28 @@ namespace OpenGrid.Framework.Data.MySQL /// Sim profile public SimProfileData GetProfileByHandle(ulong handle) { - Dictionary param = new Dictionary(); - param["handle"] = handle.ToString(); + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?handle"] = handle.ToString(); - System.Data.IDbCommand result = database.Query("SELECT * FROM regions WHERE handle = @handle", param); - System.Data.IDataReader reader = result.ExecuteReader(); + System.Data.IDbCommand result = database.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); + System.Data.IDataReader reader = result.ExecuteReader(); - SimProfileData row = database.getRow( reader ); - reader.Close(); - result.Dispose(); + SimProfileData row = database.getSimRow(reader); + reader.Close(); + result.Dispose(); - return row; + return row; + } + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + return null; + } } /// @@ -62,28 +73,42 @@ namespace OpenGrid.Framework.Data.MySQL /// The sim profile public SimProfileData GetProfileByLLUUID(libsecondlife.LLUUID uuid) { - Dictionary param = new Dictionary(); - param["uuid"] = uuid.ToStringHyphenated(); + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?uuid"] = uuid.ToStringHyphenated(); - System.Data.IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = @uuid", param); - System.Data.IDataReader reader = result.ExecuteReader(); + System.Data.IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); + System.Data.IDataReader reader = result.ExecuteReader(); - SimProfileData row = database.getRow(reader); - reader.Close(); - result.Dispose(); + SimProfileData row = database.getSimRow(reader); + reader.Close(); + result.Dispose(); - return row; + return row; + } + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + return null; + } } public DataResponse AddProfile(SimProfileData profile) { - if (database.insertRow(profile)) - { - return DataResponse.RESPONSE_OK; - } - else + lock (database) { - return DataResponse.RESPONSE_ERROR; + if (database.insertRow(profile)) + { + return DataResponse.RESPONSE_OK; + } + else + { + return DataResponse.RESPONSE_ERROR; + } } } -- cgit v1.1