* Commented out GridManager lines until they are checked into SVN

* Added new GetProfilesInRange(x,y,x,y) data function to return sim profiles between certain coordinates (for use with World Map information, etc). Implemented in GridServer.Data.Mysql - stub functions placed in other data providers.
This commit is contained in:
Adam Frisby
2007-05-14 16:13:31 +00:00
parent 59e6718482
commit 3ee195b1e6
7 changed files with 64 additions and 3 deletions

View File

@@ -14,7 +14,7 @@ namespace OpenGrid.Framework.Data.MySQL
/// </summary>
public void Initialise()
{
database = new MySQLManager("server", "database", "username", "password", "false");
database = new MySQLManager("localhost", "database", "username", "password", "false");
}
/// <summary>
@@ -35,6 +35,43 @@ namespace OpenGrid.Framework.Data.MySQL
return "0.1";
}
public SimProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax)
{
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["?xmin"] = xmin.ToString();
param["?ymin"] = ymin.ToString();
param["?xmax"] = xmax.ToString();
param["?ymax"] = ymax.ToString();
System.Data.IDbCommand result = database.Query("SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", param);
System.Data.IDataReader reader = result.ExecuteReader();
SimProfileData row;
List<SimProfileData> rows = new List<SimProfileData>();
while ((row = database.getSimRow(reader)) != null)
{
rows.Add(row);
}
reader.Close();
result.Dispose();
return rows.ToArray();
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return null;
}
}
/// <summary>
/// Returns a sim profile from it's location
/// </summary>