From 8ff1d0968ff3c4173b036398359ef62a356ad2b2 Mon Sep 17 00:00:00 2001 From: mingchen Date: Tue, 26 Jun 2007 17:50:27 +0000 Subject: *Added support for reservations in OpenGridServices (mysql only for now) *SQL file coming soon (as soon as I can figure out how to get the --- .../OpenGrid.Framework.Data.MySQL/MySQLGridData.cs | 27 +++++++++++++++++++++ .../OpenGrid.Framework.Data.MySQL/MySQLManager.cs | 28 ++++++++++++++++++++++ 2 files changed, 55 insertions(+) (limited to 'OpenGridServices/OpenGrid.Framework.Data.MySQL') diff --git a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs index d9a517d..4d6cf63 100644 --- a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs +++ b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs @@ -252,6 +252,33 @@ namespace OpenGrid.Framework.Data.MySQL return false; } + + public ReservationData GetReservationAtPoint(uint x, uint y) + { + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?x"] = x.ToString(); + param["?y"] = y.ToString(); + System.Data.IDbCommand result = database.Query("SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", param); + System.Data.IDataReader reader = result.ExecuteReader(); + + ReservationData row = database.readReservationRow(reader); + reader.Close(); + result.Dispose(); + + return row; + } + } + catch (Exception e) + { + database.Reconnect(); + Console.WriteLine(e.ToString()); + return null; + } + } } diff --git a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLManager.cs b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLManager.cs index 76d3faf..53b3bdd 100644 --- a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLManager.cs +++ b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLManager.cs @@ -241,6 +241,34 @@ namespace OpenGrid.Framework.Data.MySQL } /// + /// Reads a reservation row from a database reader + /// + /// An active database reader + /// A reservation data object + public ReservationData readReservationRow(IDataReader reader) + { + ReservationData retval = new ReservationData(); + if (reader.Read()) + { + retval.gridRecvKey = (string)reader["gridRecvKey"]; + retval.gridSendKey = (string)reader["gridSendKey"]; + retval.reservationCompany = (string)reader["resCompany"]; + retval.reservationMaxX = (int)reader["resXMax"]; + retval.reservationMaxY = (int)reader["resYMax"]; + retval.reservationMinX = (int)reader["resXMin"]; + retval.reservationMinY = (int)reader["resYMin"]; + retval.reservationName = (string)reader["resName"]; + retval.status = (bool)reader["status"]; + retval.userUUID = new libsecondlife.LLUUID((string)reader["userUUID"]); + + } + else + { + return null; + } + return retval; + } + /// /// Reads an agent row from a database reader /// /// An active database reader -- cgit v1.1