diff options
Diffstat (limited to '')
-rw-r--r-- | OpenGrid.Framework.Data.MySQL/MySQLGridData.cs | 39 | ||||
-rw-r--r-- | OpenGrid.Framework.Data.MySQL/MySQLManager.cs | 1 |
2 files changed, 38 insertions, 2 deletions
diff --git a/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs b/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs index 3dceff6..46183b4 100644 --- a/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs +++ b/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs | |||
@@ -14,7 +14,7 @@ namespace OpenGrid.Framework.Data.MySQL | |||
14 | /// </summary> | 14 | /// </summary> |
15 | public void Initialise() | 15 | public void Initialise() |
16 | { | 16 | { |
17 | database = new MySQLManager("server", "database", "username", "password", "false"); | 17 | database = new MySQLManager("localhost", "database", "username", "password", "false"); |
18 | } | 18 | } |
19 | 19 | ||
20 | /// <summary> | 20 | /// <summary> |
@@ -35,6 +35,43 @@ namespace OpenGrid.Framework.Data.MySQL | |||
35 | return "0.1"; | 35 | return "0.1"; |
36 | } | 36 | } |
37 | 37 | ||
38 | public SimProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax) | ||
39 | { | ||
40 | try | ||
41 | { | ||
42 | lock (database) | ||
43 | { | ||
44 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
45 | param["?xmin"] = xmin.ToString(); | ||
46 | param["?ymin"] = ymin.ToString(); | ||
47 | param["?xmax"] = xmax.ToString(); | ||
48 | param["?ymax"] = ymax.ToString(); | ||
49 | |||
50 | System.Data.IDbCommand result = database.Query("SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", param); | ||
51 | System.Data.IDataReader reader = result.ExecuteReader(); | ||
52 | |||
53 | SimProfileData row; | ||
54 | |||
55 | List<SimProfileData> rows = new List<SimProfileData>(); | ||
56 | |||
57 | while ((row = database.getSimRow(reader)) != null) | ||
58 | { | ||
59 | rows.Add(row); | ||
60 | } | ||
61 | reader.Close(); | ||
62 | result.Dispose(); | ||
63 | |||
64 | return rows.ToArray(); | ||
65 | |||
66 | } | ||
67 | } | ||
68 | catch (Exception e) | ||
69 | { | ||
70 | Console.WriteLine(e.ToString()); | ||
71 | return null; | ||
72 | } | ||
73 | } | ||
74 | |||
38 | /// <summary> | 75 | /// <summary> |
39 | /// Returns a sim profile from it's location | 76 | /// Returns a sim profile from it's location |
40 | /// </summary> | 77 | /// </summary> |
diff --git a/OpenGrid.Framework.Data.MySQL/MySQLManager.cs b/OpenGrid.Framework.Data.MySQL/MySQLManager.cs index 7461b14..e4622a8 100644 --- a/OpenGrid.Framework.Data.MySQL/MySQLManager.cs +++ b/OpenGrid.Framework.Data.MySQL/MySQLManager.cs | |||
@@ -121,7 +121,6 @@ namespace OpenGrid.Framework.Data.MySQL | |||
121 | } | 121 | } |
122 | else | 122 | else |
123 | { | 123 | { |
124 | throw new Exception("Unable to find region at coordinates"); | ||
125 | return null; | 124 | return null; |
126 | } | 125 | } |
127 | return retval; | 126 | return retval; |