diff options
author | lbsa71 | 2007-10-30 09:05:31 +0000 |
---|---|---|
committer | lbsa71 | 2007-10-30 09:05:31 +0000 |
commit | 67e12b95ea7b68f4904a7484d77ecfd787d16d0c (patch) | |
tree | 20b00d24c8a7617017960432ec044852e3ad5fa9 /OpenSim/Framework/Data.MySQL | |
parent | * Deleted .user file (diff) | |
download | opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.zip opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.gz opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.bz2 opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.xz |
* Optimized usings
* Shortened type references
* Removed redundant 'this' qualifier
Diffstat (limited to 'OpenSim/Framework/Data.MySQL')
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLAssetData.cs | 43 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLGridData.cs | 21 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs | 117 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLLogData.cs | 13 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLManager.cs | 329 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 52 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs | 31 |
7 files changed, 332 insertions, 274 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs index bf895c0..055cd92 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs | |||
@@ -28,18 +28,17 @@ | |||
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using MySql.Data.MySqlClient; | 31 | using System.Data; |
32 | |||
33 | using libsecondlife; | 32 | using libsecondlife; |
33 | using MySql.Data.MySqlClient; | ||
34 | using OpenSim.Framework.Console; | 34 | using OpenSim.Framework.Console; |
35 | using OpenSim.Framework.Interfaces; | ||
36 | using OpenSim.Framework; | ||
37 | 35 | ||
38 | namespace OpenSim.Framework.Data.MySQL | 36 | namespace OpenSim.Framework.Data.MySQL |
39 | { | 37 | { |
40 | class MySQLAssetData : IAssetProvider | 38 | internal class MySQLAssetData : IAssetProvider |
41 | { | 39 | { |
42 | MySQLManager _dbConnection; | 40 | private MySQLManager _dbConnection; |
41 | |||
43 | #region IAssetProvider Members | 42 | #region IAssetProvider Members |
44 | 43 | ||
45 | private void UpgradeAssetsTable(string oldVersion) | 44 | private void UpgradeAssetsTable(string oldVersion) |
@@ -58,14 +57,12 @@ namespace OpenSim.Framework.Data.MySQL | |||
58 | /// </summary> | 57 | /// </summary> |
59 | private void TestTables() | 58 | private void TestTables() |
60 | { | 59 | { |
61 | |||
62 | Dictionary<string, string> tableList = new Dictionary<string, string>(); | 60 | Dictionary<string, string> tableList = new Dictionary<string, string>(); |
63 | 61 | ||
64 | tableList["assets"] = null; | 62 | tableList["assets"] = null; |
65 | _dbConnection.GetTableVersion(tableList); | 63 | _dbConnection.GetTableVersion(tableList); |
66 | 64 | ||
67 | UpgradeAssetsTable(tableList["assets"]); | 65 | UpgradeAssetsTable(tableList["assets"]); |
68 | |||
69 | } | 66 | } |
70 | 67 | ||
71 | public AssetBase FetchAsset(LLUUID assetID) | 68 | public AssetBase FetchAsset(LLUUID assetID) |
@@ -73,21 +70,24 @@ namespace OpenSim.Framework.Data.MySQL | |||
73 | AssetBase asset = null; | 70 | AssetBase asset = null; |
74 | lock (_dbConnection) | 71 | lock (_dbConnection) |
75 | { | 72 | { |
76 | MySqlCommand cmd = new MySqlCommand("SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id", _dbConnection.Connection); | 73 | MySqlCommand cmd = |
74 | new MySqlCommand( | ||
75 | "SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id", | ||
76 | _dbConnection.Connection); | ||
77 | MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); | 77 | MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); |
78 | p.Value = assetID.GetBytes(); | 78 | p.Value = assetID.GetBytes(); |
79 | using (MySqlDataReader dbReader = cmd.ExecuteReader(System.Data.CommandBehavior.SingleRow)) | 79 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) |
80 | { | 80 | { |
81 | if (dbReader.Read()) | 81 | if (dbReader.Read()) |
82 | { | 82 | { |
83 | asset = new AssetBase(); | 83 | asset = new AssetBase(); |
84 | asset.Data = (byte[])dbReader["data"]; | 84 | asset.Data = (byte[]) dbReader["data"]; |
85 | asset.Description = (string)dbReader["description"]; | 85 | asset.Description = (string) dbReader["description"]; |
86 | asset.FullID = assetID; | 86 | asset.FullID = assetID; |
87 | asset.InvType = (sbyte)dbReader["invType"]; | 87 | asset.InvType = (sbyte) dbReader["invType"]; |
88 | asset.Local = ((sbyte)dbReader["local"]) != 0 ? true : false; | 88 | asset.Local = ((sbyte) dbReader["local"]) != 0 ? true : false; |
89 | asset.Name = (string)dbReader["name"]; | 89 | asset.Name = (string) dbReader["name"]; |
90 | asset.Type = (sbyte)dbReader["assetType"]; | 90 | asset.Type = (sbyte) dbReader["assetType"]; |
91 | } | 91 | } |
92 | } | 92 | } |
93 | } | 93 | } |
@@ -96,8 +96,11 @@ namespace OpenSim.Framework.Data.MySQL | |||
96 | 96 | ||
97 | public void CreateAsset(AssetBase asset) | 97 | public void CreateAsset(AssetBase asset) |
98 | { | 98 | { |
99 | MySqlCommand cmd = new MySqlCommand("REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" + | 99 | MySqlCommand cmd = |
100 | "VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)", _dbConnection.Connection); | 100 | new MySqlCommand( |
101 | "REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" + | ||
102 | "VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)", | ||
103 | _dbConnection.Connection); | ||
101 | MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); | 104 | MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); |
102 | p.Value = asset.FullID.GetBytes(); | 105 | p.Value = asset.FullID.GetBytes(); |
103 | cmd.Parameters.AddWithValue("?name", asset.Name); | 106 | cmd.Parameters.AddWithValue("?name", asset.Name); |
@@ -148,7 +151,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
148 | 151 | ||
149 | public string Version | 152 | public string Version |
150 | { | 153 | { |
151 | get { return _dbConnection.getVersion(); } | 154 | get { return _dbConnection.getVersion(); } |
152 | } | 155 | } |
153 | 156 | ||
154 | public string Name | 157 | public string Name |
@@ -158,4 +161,4 @@ namespace OpenSim.Framework.Data.MySQL | |||
158 | 161 | ||
159 | #endregion | 162 | #endregion |
160 | } | 163 | } |
161 | } | 164 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs index 9876ab1..fdfc61c 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs | |||
@@ -25,13 +25,13 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | |||
28 | using System; | 29 | using System; |
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
30 | using System.Data; | 31 | using System.Data; |
31 | using System.Security.Cryptography; | 32 | using System.Security.Cryptography; |
32 | using System.Text; | 33 | using System.Text; |
33 | using libsecondlife; | 34 | using libsecondlife; |
34 | |||
35 | using OpenSim.Framework.Console; | 35 | using OpenSim.Framework.Console; |
36 | 36 | ||
37 | namespace OpenSim.Framework.Data.MySQL | 37 | namespace OpenSim.Framework.Data.MySQL |
@@ -59,7 +59,9 @@ namespace OpenSim.Framework.Data.MySQL | |||
59 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); | 59 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); |
60 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); | 60 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); |
61 | 61 | ||
62 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); | 62 | database = |
63 | new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, | ||
64 | settingPort); | ||
63 | } | 65 | } |
64 | 66 | ||
65 | /// <summary> | 67 | /// <summary> |
@@ -108,7 +110,10 @@ namespace OpenSim.Framework.Data.MySQL | |||
108 | param["?xmax"] = xmax.ToString(); | 110 | param["?xmax"] = xmax.ToString(); |
109 | param["?ymax"] = ymax.ToString(); | 111 | param["?ymax"] = ymax.ToString(); |
110 | 112 | ||
111 | IDbCommand result = database.Query("SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", param); | 113 | IDbCommand result = |
114 | database.Query( | ||
115 | "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", | ||
116 | param); | ||
112 | IDataReader reader = result.ExecuteReader(); | 117 | IDataReader reader = result.ExecuteReader(); |
113 | 118 | ||
114 | RegionProfileData row; | 119 | RegionProfileData row; |
@@ -123,7 +128,6 @@ namespace OpenSim.Framework.Data.MySQL | |||
123 | result.Dispose(); | 128 | result.Dispose(); |
124 | 129 | ||
125 | return rows.ToArray(); | 130 | return rows.ToArray(); |
126 | |||
127 | } | 131 | } |
128 | } | 132 | } |
129 | catch (Exception e) | 133 | catch (Exception e) |
@@ -266,7 +270,10 @@ namespace OpenSim.Framework.Data.MySQL | |||
266 | Dictionary<string, string> param = new Dictionary<string, string>(); | 270 | Dictionary<string, string> param = new Dictionary<string, string>(); |
267 | param["?x"] = x.ToString(); | 271 | param["?x"] = x.ToString(); |
268 | param["?y"] = y.ToString(); | 272 | param["?y"] = y.ToString(); |
269 | IDbCommand result = database.Query("SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", param); | 273 | IDbCommand result = |
274 | database.Query( | ||
275 | "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", | ||
276 | param); | ||
270 | IDataReader reader = result.ExecuteReader(); | 277 | IDataReader reader = result.ExecuteReader(); |
271 | 278 | ||
272 | ReservationData row = database.readReservationRow(reader); | 279 | ReservationData row = database.readReservationRow(reader); |
@@ -284,6 +291,4 @@ namespace OpenSim.Framework.Data.MySQL | |||
284 | } | 291 | } |
285 | } | 292 | } |
286 | } | 293 | } |
287 | 294 | } \ No newline at end of file | |
288 | |||
289 | } | ||
diff --git a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs index ded584e..f303a6b 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs | |||
@@ -26,13 +26,10 @@ | |||
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.IO; | ||
30 | using System.Data; | ||
31 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
32 | using libsecondlife; | 30 | using libsecondlife; |
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Console; | ||
35 | using MySql.Data.MySqlClient; | 31 | using MySql.Data.MySqlClient; |
32 | using OpenSim.Framework.Console; | ||
36 | 33 | ||
37 | namespace OpenSim.Framework.Data.MySQL | 34 | namespace OpenSim.Framework.Data.MySQL |
38 | { | 35 | { |
@@ -59,7 +56,9 @@ namespace OpenSim.Framework.Data.MySQL | |||
59 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); | 56 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); |
60 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); | 57 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); |
61 | 58 | ||
62 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); | 59 | database = |
60 | new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, | ||
61 | settingPort); | ||
63 | TestTables(database.Connection); | 62 | TestTables(database.Connection); |
64 | } | 63 | } |
65 | 64 | ||
@@ -99,7 +98,6 @@ namespace OpenSim.Framework.Data.MySQL | |||
99 | 98 | ||
100 | private void TestTables(MySqlConnection conn) | 99 | private void TestTables(MySqlConnection conn) |
101 | { | 100 | { |
102 | |||
103 | Dictionary<string, string> tableList = new Dictionary<string, string>(); | 101 | Dictionary<string, string> tableList = new Dictionary<string, string>(); |
104 | 102 | ||
105 | tableList["inventoryfolders"] = null; | 103 | tableList["inventoryfolders"] = null; |
@@ -110,6 +108,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
110 | UpgradeFoldersTable(tableList["inventoryfolders"]); | 108 | UpgradeFoldersTable(tableList["inventoryfolders"]); |
111 | UpgradeItemsTable(tableList["inventoryitems"]); | 109 | UpgradeItemsTable(tableList["inventoryitems"]); |
112 | } | 110 | } |
111 | |||
113 | #endregion | 112 | #endregion |
114 | 113 | ||
115 | /// <summary> | 114 | /// <summary> |
@@ -151,11 +150,13 @@ namespace OpenSim.Framework.Data.MySQL | |||
151 | { | 150 | { |
152 | List<InventoryItemBase> items = new List<InventoryItemBase>(); | 151 | List<InventoryItemBase> items = new List<InventoryItemBase>(); |
153 | 152 | ||
154 | MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", database.Connection); | 153 | MySqlCommand result = |
154 | new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", | ||
155 | database.Connection); | ||
155 | result.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated()); | 156 | result.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated()); |
156 | MySqlDataReader reader = result.ExecuteReader(); | 157 | MySqlDataReader reader = result.ExecuteReader(); |
157 | 158 | ||
158 | while(reader.Read()) | 159 | while (reader.Read()) |
159 | items.Add(readInventoryItem(reader)); | 160 | items.Add(readInventoryItem(reader)); |
160 | 161 | ||
161 | reader.Close(); | 162 | reader.Close(); |
@@ -183,13 +184,16 @@ namespace OpenSim.Framework.Data.MySQL | |||
183 | { | 184 | { |
184 | lock (database) | 185 | lock (database) |
185 | { | 186 | { |
186 | MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", database.Connection); | 187 | MySqlCommand result = |
188 | new MySqlCommand( | ||
189 | "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", | ||
190 | database.Connection); | ||
187 | result.Parameters.AddWithValue("?uuid", user.ToStringHyphenated()); | 191 | result.Parameters.AddWithValue("?uuid", user.ToStringHyphenated()); |
188 | result.Parameters.AddWithValue("?zero", LLUUID.Zero.ToStringHyphenated()); | 192 | result.Parameters.AddWithValue("?zero", LLUUID.Zero.ToStringHyphenated()); |
189 | MySqlDataReader reader = result.ExecuteReader(); | 193 | MySqlDataReader reader = result.ExecuteReader(); |
190 | 194 | ||
191 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); | 195 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); |
192 | while(reader.Read()) | 196 | while (reader.Read()) |
193 | items.Add(readInventoryFolder(reader)); | 197 | items.Add(readInventoryFolder(reader)); |
194 | 198 | ||
195 | 199 | ||
@@ -218,17 +222,21 @@ namespace OpenSim.Framework.Data.MySQL | |||
218 | { | 222 | { |
219 | lock (database) | 223 | lock (database) |
220 | { | 224 | { |
221 | MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", database.Connection); | 225 | MySqlCommand result = |
226 | new MySqlCommand( | ||
227 | "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", | ||
228 | database.Connection); | ||
222 | result.Parameters.AddWithValue("?uuid", user.ToStringHyphenated()); | 229 | result.Parameters.AddWithValue("?uuid", user.ToStringHyphenated()); |
223 | result.Parameters.AddWithValue("?zero", LLUUID.Zero.ToStringHyphenated()); | 230 | result.Parameters.AddWithValue("?zero", LLUUID.Zero.ToStringHyphenated()); |
224 | 231 | ||
225 | MySqlDataReader reader = result.ExecuteReader(); | 232 | MySqlDataReader reader = result.ExecuteReader(); |
226 | 233 | ||
227 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); | 234 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); |
228 | while(reader.Read()) | 235 | while (reader.Read()) |
229 | items.Add(readInventoryFolder(reader)); | 236 | items.Add(readInventoryFolder(reader)); |
230 | 237 | ||
231 | InventoryFolderBase rootFolder = items[0]; //should only be one folder with parent set to zero (the root one). | 238 | InventoryFolderBase rootFolder = items[0]; |
239 | //should only be one folder with parent set to zero (the root one). | ||
232 | reader.Close(); | 240 | reader.Close(); |
233 | result.Dispose(); | 241 | result.Dispose(); |
234 | 242 | ||
@@ -254,13 +262,15 @@ namespace OpenSim.Framework.Data.MySQL | |||
254 | { | 262 | { |
255 | lock (database) | 263 | lock (database) |
256 | { | 264 | { |
257 | MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", database.Connection); | 265 | MySqlCommand result = |
266 | new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", | ||
267 | database.Connection); | ||
258 | result.Parameters.AddWithValue("?uuid", parentID.ToStringHyphenated()); | 268 | result.Parameters.AddWithValue("?uuid", parentID.ToStringHyphenated()); |
259 | MySqlDataReader reader = result.ExecuteReader(); | 269 | MySqlDataReader reader = result.ExecuteReader(); |
260 | 270 | ||
261 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); | 271 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); |
262 | 272 | ||
263 | while(reader.Read()) | 273 | while (reader.Read()) |
264 | items.Add(readInventoryFolder(reader)); | 274 | items.Add(readInventoryFolder(reader)); |
265 | 275 | ||
266 | reader.Close(); | 276 | reader.Close(); |
@@ -288,19 +298,19 @@ namespace OpenSim.Framework.Data.MySQL | |||
288 | { | 298 | { |
289 | InventoryItemBase item = new InventoryItemBase(); | 299 | InventoryItemBase item = new InventoryItemBase(); |
290 | 300 | ||
291 | item.inventoryID = new LLUUID((string)reader["inventoryID"]); | 301 | item.inventoryID = new LLUUID((string) reader["inventoryID"]); |
292 | item.assetID = new LLUUID((string)reader["assetID"]); | 302 | item.assetID = new LLUUID((string) reader["assetID"]); |
293 | item.assetType = (int)reader["assetType"]; | 303 | item.assetType = (int) reader["assetType"]; |
294 | item.parentFolderID = new LLUUID((string)reader["parentFolderID"]); | 304 | item.parentFolderID = new LLUUID((string) reader["parentFolderID"]); |
295 | item.avatarID = new LLUUID((string)reader["avatarID"]); | 305 | item.avatarID = new LLUUID((string) reader["avatarID"]); |
296 | item.inventoryName = (string)reader["inventoryName"]; | 306 | item.inventoryName = (string) reader["inventoryName"]; |
297 | item.inventoryDescription = (string)reader["inventoryDescription"]; | 307 | item.inventoryDescription = (string) reader["inventoryDescription"]; |
298 | item.inventoryNextPermissions = (uint)reader["inventoryNextPermissions"]; | 308 | item.inventoryNextPermissions = (uint) reader["inventoryNextPermissions"]; |
299 | item.inventoryCurrentPermissions = (uint)reader["inventoryCurrentPermissions"]; | 309 | item.inventoryCurrentPermissions = (uint) reader["inventoryCurrentPermissions"]; |
300 | item.invType = (int)reader["invType"]; | 310 | item.invType = (int) reader["invType"]; |
301 | item.creatorsID = new LLUUID((string)reader["creatorID"]); | 311 | item.creatorsID = new LLUUID((string) reader["creatorID"]); |
302 | item.inventoryBasePermissions = (uint)reader["inventoryBasePermissions"]; | 312 | item.inventoryBasePermissions = (uint) reader["inventoryBasePermissions"]; |
303 | item.inventoryEveryOnePermissions = (uint)reader["inventoryEveryOnePermissions"]; | 313 | item.inventoryEveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; |
304 | return item; | 314 | return item; |
305 | } | 315 | } |
306 | catch (MySqlException e) | 316 | catch (MySqlException e) |
@@ -324,12 +334,13 @@ namespace OpenSim.Framework.Data.MySQL | |||
324 | { | 334 | { |
325 | Dictionary<string, string> param = new Dictionary<string, string>(); | 335 | Dictionary<string, string> param = new Dictionary<string, string>(); |
326 | 336 | ||
327 | MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection); | 337 | MySqlCommand result = |
338 | new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection); | ||
328 | result.Parameters.AddWithValue("?uuid", itemID.ToStringHyphenated()); | 339 | result.Parameters.AddWithValue("?uuid", itemID.ToStringHyphenated()); |
329 | MySqlDataReader reader = result.ExecuteReader(); | 340 | MySqlDataReader reader = result.ExecuteReader(); |
330 | 341 | ||
331 | InventoryItemBase item = null; | 342 | InventoryItemBase item = null; |
332 | if(reader.Read()) | 343 | if (reader.Read()) |
333 | item = readInventoryItem(reader); | 344 | item = readInventoryItem(reader); |
334 | 345 | ||
335 | reader.Close(); | 346 | reader.Close(); |
@@ -356,12 +367,12 @@ namespace OpenSim.Framework.Data.MySQL | |||
356 | try | 367 | try |
357 | { | 368 | { |
358 | InventoryFolderBase folder = new InventoryFolderBase(); | 369 | InventoryFolderBase folder = new InventoryFolderBase(); |
359 | folder.agentID = new LLUUID((string)reader["agentID"]); | 370 | folder.agentID = new LLUUID((string) reader["agentID"]); |
360 | folder.parentID = new LLUUID((string)reader["parentFolderID"]); | 371 | folder.parentID = new LLUUID((string) reader["parentFolderID"]); |
361 | folder.folderID = new LLUUID((string)reader["folderID"]); | 372 | folder.folderID = new LLUUID((string) reader["folderID"]); |
362 | folder.name = (string)reader["folderName"]; | 373 | folder.name = (string) reader["folderName"]; |
363 | folder.type = (short)reader["type"]; | 374 | folder.type = (short) reader["type"]; |
364 | folder.version = (ushort)((int)reader["version"]); | 375 | folder.version = (ushort) ((int) reader["version"]); |
365 | return folder; | 376 | return folder; |
366 | } | 377 | } |
367 | catch (Exception e) | 378 | catch (Exception e) |
@@ -384,7 +395,8 @@ namespace OpenSim.Framework.Data.MySQL | |||
384 | { | 395 | { |
385 | lock (database) | 396 | lock (database) |
386 | { | 397 | { |
387 | MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection); | 398 | MySqlCommand result = |
399 | new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection); | ||
388 | result.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated()); | 400 | result.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated()); |
389 | MySqlDataReader reader = result.ExecuteReader(); | 401 | MySqlDataReader reader = result.ExecuteReader(); |
390 | 402 | ||
@@ -410,8 +422,10 @@ namespace OpenSim.Framework.Data.MySQL | |||
410 | /// <param name="item">The inventory item</param> | 422 | /// <param name="item">The inventory item</param> |
411 | public void addInventoryItem(InventoryItemBase item) | 423 | public void addInventoryItem(InventoryItemBase item) |
412 | { | 424 | { |
413 | string sql = "REPLACE INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType, creatorID, inventoryBasePermissions, inventoryEveryOnePermissions) VALUES "; | 425 | string sql = |
414 | sql += "(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription, ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID, ?inventoryBasePermissions, ?inventoryEveryOnePermissions)"; | 426 | "REPLACE INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType, creatorID, inventoryBasePermissions, inventoryEveryOnePermissions) VALUES "; |
427 | sql += | ||
428 | "(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription, ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID, ?inventoryBasePermissions, ?inventoryEveryOnePermissions)"; | ||
415 | 429 | ||
416 | try | 430 | try |
417 | { | 431 | { |
@@ -424,7 +438,8 @@ namespace OpenSim.Framework.Data.MySQL | |||
424 | result.Parameters.AddWithValue("?inventoryName", item.inventoryName); | 438 | result.Parameters.AddWithValue("?inventoryName", item.inventoryName); |
425 | result.Parameters.AddWithValue("?inventoryDescription", item.inventoryDescription); | 439 | result.Parameters.AddWithValue("?inventoryDescription", item.inventoryDescription); |
426 | result.Parameters.AddWithValue("?inventoryNextPermissions", item.inventoryNextPermissions.ToString()); | 440 | result.Parameters.AddWithValue("?inventoryNextPermissions", item.inventoryNextPermissions.ToString()); |
427 | result.Parameters.AddWithValue("?inventoryCurrentPermissions", item.inventoryCurrentPermissions.ToString()); | 441 | result.Parameters.AddWithValue("?inventoryCurrentPermissions", |
442 | item.inventoryCurrentPermissions.ToString()); | ||
428 | result.Parameters.AddWithValue("?invType", item.invType); | 443 | result.Parameters.AddWithValue("?invType", item.invType); |
429 | result.Parameters.AddWithValue("?creatorID", item.creatorsID.ToStringHyphenated()); | 444 | result.Parameters.AddWithValue("?creatorID", item.creatorsID.ToStringHyphenated()); |
430 | result.Parameters.AddWithValue("?inventoryBasePermissions", item.inventoryBasePermissions); | 445 | result.Parameters.AddWithValue("?inventoryBasePermissions", item.inventoryBasePermissions); |
@@ -455,7 +470,8 @@ namespace OpenSim.Framework.Data.MySQL | |||
455 | { | 470 | { |
456 | try | 471 | try |
457 | { | 472 | { |
458 | MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", database.Connection); | 473 | MySqlCommand cmd = |
474 | new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", database.Connection); | ||
459 | cmd.Parameters.AddWithValue("?uuid", itemID.ToStringHyphenated()); | 475 | cmd.Parameters.AddWithValue("?uuid", itemID.ToStringHyphenated()); |
460 | cmd.ExecuteNonQuery(); | 476 | cmd.ExecuteNonQuery(); |
461 | } | 477 | } |
@@ -472,7 +488,8 @@ namespace OpenSim.Framework.Data.MySQL | |||
472 | /// <param name="folder">Folder to create</param> | 488 | /// <param name="folder">Folder to create</param> |
473 | public void addInventoryFolder(InventoryFolderBase folder) | 489 | public void addInventoryFolder(InventoryFolderBase folder) |
474 | { | 490 | { |
475 | string sql = "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) VALUES "; | 491 | string sql = |
492 | "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) VALUES "; | ||
476 | sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?type, ?version)"; | 493 | sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?type, ?version)"; |
477 | 494 | ||
478 | MySqlCommand cmd = new MySqlCommand(sql, database.Connection); | 495 | MySqlCommand cmd = new MySqlCommand(sql, database.Connection); |
@@ -480,9 +497,9 @@ namespace OpenSim.Framework.Data.MySQL | |||
480 | cmd.Parameters.AddWithValue("?agentID", folder.agentID.ToStringHyphenated()); | 497 | cmd.Parameters.AddWithValue("?agentID", folder.agentID.ToStringHyphenated()); |
481 | cmd.Parameters.AddWithValue("?parentFolderID", folder.parentID.ToStringHyphenated()); | 498 | cmd.Parameters.AddWithValue("?parentFolderID", folder.parentID.ToStringHyphenated()); |
482 | cmd.Parameters.AddWithValue("?folderName", folder.name); | 499 | cmd.Parameters.AddWithValue("?folderName", folder.name); |
483 | cmd.Parameters.AddWithValue("?type", (short)folder.type); | 500 | cmd.Parameters.AddWithValue("?type", (short) folder.type); |
484 | cmd.Parameters.AddWithValue("?version", folder.version); | 501 | cmd.Parameters.AddWithValue("?version", folder.version); |
485 | 502 | ||
486 | try | 503 | try |
487 | { | 504 | { |
488 | cmd.ExecuteNonQuery(); | 505 | cmd.ExecuteNonQuery(); |
@@ -515,7 +532,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
515 | foreach (InventoryFolderBase f in subfolderList) | 532 | foreach (InventoryFolderBase f in subfolderList) |
516 | folders.Add(f); | 533 | folders.Add(f); |
517 | } | 534 | } |
518 | 535 | ||
519 | /// <summary> | 536 | /// <summary> |
520 | /// Returns all child folders in the hierarchy from the parent folder and down | 537 | /// Returns all child folders in the hierarchy from the parent folder and down |
521 | /// </summary> | 538 | /// </summary> |
@@ -536,7 +553,8 @@ namespace OpenSim.Framework.Data.MySQL | |||
536 | { | 553 | { |
537 | try | 554 | try |
538 | { | 555 | { |
539 | MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); | 556 | MySqlCommand cmd = |
557 | new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); | ||
540 | cmd.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated()); | 558 | cmd.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated()); |
541 | cmd.ExecuteNonQuery(); | 559 | cmd.ExecuteNonQuery(); |
542 | } | 560 | } |
@@ -551,7 +569,8 @@ namespace OpenSim.Framework.Data.MySQL | |||
551 | { | 569 | { |
552 | try | 570 | try |
553 | { | 571 | { |
554 | MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); | 572 | MySqlCommand cmd = |
573 | new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); | ||
555 | cmd.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated()); | 574 | cmd.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated()); |
556 | cmd.ExecuteNonQuery(); | 575 | cmd.ExecuteNonQuery(); |
557 | } | 576 | } |
@@ -586,4 +605,4 @@ namespace OpenSim.Framework.Data.MySQL | |||
586 | } | 605 | } |
587 | } | 606 | } |
588 | } | 607 | } |
589 | } | 608 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Data.MySQL/MySQLLogData.cs b/OpenSim/Framework/Data.MySQL/MySQLLogData.cs index bfb4b48..e8775a1 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLLogData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLLogData.cs | |||
@@ -25,14 +25,12 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | ||
29 | |||
30 | namespace OpenSim.Framework.Data.MySQL | 28 | namespace OpenSim.Framework.Data.MySQL |
31 | { | 29 | { |
32 | /// <summary> | 30 | /// <summary> |
33 | /// An interface to the log database for MySQL | 31 | /// An interface to the log database for MySQL |
34 | /// </summary> | 32 | /// </summary> |
35 | class MySQLLogData : ILogData | 33 | internal class MySQLLogData : ILogData |
36 | { | 34 | { |
37 | /// <summary> | 35 | /// <summary> |
38 | /// The database manager | 36 | /// The database manager |
@@ -52,7 +50,9 @@ namespace OpenSim.Framework.Data.MySQL | |||
52 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); | 50 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); |
53 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); | 51 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); |
54 | 52 | ||
55 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); | 53 | database = |
54 | new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, | ||
55 | settingPort); | ||
56 | } | 56 | } |
57 | 57 | ||
58 | /// <summary> | 58 | /// <summary> |
@@ -64,7 +64,8 @@ namespace OpenSim.Framework.Data.MySQL | |||
64 | /// <param name="arguments">The arguments passed to the method</param> | 64 | /// <param name="arguments">The arguments passed to the method</param> |
65 | /// <param name="priority">How critical is this?</param> | 65 | /// <param name="priority">How critical is this?</param> |
66 | /// <param name="logMessage">The message to log</param> | 66 | /// <param name="logMessage">The message to log</param> |
67 | public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage) | 67 | public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, |
68 | string logMessage) | ||
68 | { | 69 | { |
69 | try | 70 | try |
70 | { | 71 | { |
@@ -102,4 +103,4 @@ namespace OpenSim.Framework.Data.MySQL | |||
102 | return "0.1"; | 103 | return "0.1"; |
103 | } | 104 | } |
104 | } | 105 | } |
105 | } | 106 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs index 8fcf68b..778da06 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs | |||
@@ -25,16 +25,14 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | |||
28 | using System; | 29 | using System; |
29 | using System.IO; | 30 | using System.Collections.Generic; |
30 | using System.Data; | 31 | using System.Data; |
32 | using System.IO; | ||
31 | using System.Reflection; | 33 | using System.Reflection; |
32 | using System.Collections.Generic; | ||
33 | using libsecondlife; | 34 | using libsecondlife; |
34 | |||
35 | using MySql.Data.MySqlClient; | 35 | using MySql.Data.MySqlClient; |
36 | |||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Console; | 36 | using OpenSim.Framework.Console; |
39 | 37 | ||
40 | namespace OpenSim.Framework.Data.MySQL | 38 | namespace OpenSim.Framework.Data.MySQL |
@@ -42,16 +40,17 @@ namespace OpenSim.Framework.Data.MySQL | |||
42 | /// <summary> | 40 | /// <summary> |
43 | /// A MySQL Database manager | 41 | /// A MySQL Database manager |
44 | /// </summary> | 42 | /// </summary> |
45 | class MySQLManager | 43 | internal class MySQLManager |
46 | { | 44 | { |
47 | /// <summary> | 45 | /// <summary> |
48 | /// The database connection object | 46 | /// The database connection object |
49 | /// </summary> | 47 | /// </summary> |
50 | MySqlConnection dbcon; | 48 | private MySqlConnection dbcon; |
49 | |||
51 | /// <summary> | 50 | /// <summary> |
52 | /// Connection string for ADO.net | 51 | /// Connection string for ADO.net |
53 | /// </summary> | 52 | /// </summary> |
54 | string connectionString; | 53 | private string connectionString; |
55 | 54 | ||
56 | /// <summary> | 55 | /// <summary> |
57 | /// Initialises and creates a new MySQL connection and maintains it. | 56 | /// Initialises and creates a new MySQL connection and maintains it. |
@@ -61,11 +60,13 @@ namespace OpenSim.Framework.Data.MySQL | |||
61 | /// <param name="username">The username logging into the database</param> | 60 | /// <param name="username">The username logging into the database</param> |
62 | /// <param name="password">The password for the user logging in</param> | 61 | /// <param name="password">The password for the user logging in</param> |
63 | /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param> | 62 | /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param> |
64 | public MySQLManager(string hostname, string database, string username, string password, string cpooling, string port) | 63 | public MySQLManager(string hostname, string database, string username, string password, string cpooling, |
64 | string port) | ||
65 | { | 65 | { |
66 | try | 66 | try |
67 | { | 67 | { |
68 | connectionString = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";"; | 68 | connectionString = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" + |
69 | username + ";Password=" + password + ";Pooling=" + cpooling + ";"; | ||
69 | dbcon = new MySqlConnection(connectionString); | 70 | dbcon = new MySqlConnection(connectionString); |
70 | 71 | ||
71 | dbcon.Open(); | 72 | dbcon.Open(); |
@@ -123,15 +124,17 @@ namespace OpenSim.Framework.Data.MySQL | |||
123 | /// <returns>A string containing the DB provider</returns> | 124 | /// <returns>A string containing the DB provider</returns> |
124 | public string getVersion() | 125 | public string getVersion() |
125 | { | 126 | { |
126 | System.Reflection.Module module = this.GetType().Module; | 127 | Module module = GetType().Module; |
127 | string dllName = module.Assembly.ManifestModule.Name; | 128 | string dllName = module.Assembly.ManifestModule.Name; |
128 | Version dllVersion = module.Assembly.GetName().Version; | 129 | Version dllVersion = module.Assembly.GetName().Version; |
129 | 130 | ||
130 | 131 | ||
131 | return string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, dllVersion.Revision); | 132 | return |
133 | string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, | ||
134 | dllVersion.Revision); | ||
132 | } | 135 | } |
133 | 136 | ||
134 | 137 | ||
135 | /// <summary> | 138 | /// <summary> |
136 | /// Extract a named string resource from the embedded resources | 139 | /// Extract a named string resource from the embedded resources |
137 | /// </summary> | 140 | /// </summary> |
@@ -139,7 +142,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
139 | /// <returns>string contained within the embedded resource</returns> | 142 | /// <returns>string contained within the embedded resource</returns> |
140 | private string getResourceString(string name) | 143 | private string getResourceString(string name) |
141 | { | 144 | { |
142 | Assembly assem = this.GetType().Assembly; | 145 | Assembly assem = GetType().Assembly; |
143 | string[] names = assem.GetManifestResourceNames(); | 146 | string[] names = assem.GetManifestResourceNames(); |
144 | 147 | ||
145 | foreach (string s in names) | 148 | foreach (string s in names) |
@@ -173,7 +176,10 @@ namespace OpenSim.Framework.Data.MySQL | |||
173 | { | 176 | { |
174 | lock (dbcon) | 177 | lock (dbcon) |
175 | { | 178 | { |
176 | MySqlCommand tablesCmd = new MySqlCommand("SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", dbcon); | 179 | MySqlCommand tablesCmd = |
180 | new MySqlCommand( | ||
181 | "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", | ||
182 | dbcon); | ||
177 | tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); | 183 | tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); |
178 | using (MySqlDataReader tables = tablesCmd.ExecuteReader()) | 184 | using (MySqlDataReader tables = tablesCmd.ExecuteReader()) |
179 | { | 185 | { |
@@ -181,9 +187,9 @@ namespace OpenSim.Framework.Data.MySQL | |||
181 | { | 187 | { |
182 | try | 188 | try |
183 | { | 189 | { |
184 | string tableName = (string)tables["TABLE_NAME"]; | 190 | string tableName = (string) tables["TABLE_NAME"]; |
185 | string comment = (string)tables["TABLE_COMMENT"]; | 191 | string comment = (string) tables["TABLE_COMMENT"]; |
186 | if(tableList.ContainsKey(tableName)) | 192 | if (tableList.ContainsKey(tableName)) |
187 | tableList[tableName] = comment; | 193 | tableList[tableName] = comment; |
188 | } | 194 | } |
189 | catch (Exception e) | 195 | catch (Exception e) |
@@ -198,7 +204,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
198 | 204 | ||
199 | 205 | ||
200 | // at some time this code should be cleaned up | 206 | // at some time this code should be cleaned up |
201 | 207 | ||
202 | /// <summary> | 208 | /// <summary> |
203 | /// Runs a query with protection against SQL Injection by using parameterised input. | 209 | /// Runs a query with protection against SQL Injection by using parameterised input. |
204 | /// </summary> | 210 | /// </summary> |
@@ -209,14 +215,14 @@ namespace OpenSim.Framework.Data.MySQL | |||
209 | { | 215 | { |
210 | try | 216 | try |
211 | { | 217 | { |
212 | MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); | 218 | MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand(); |
213 | dbcommand.CommandText = sql; | 219 | dbcommand.CommandText = sql; |
214 | foreach (KeyValuePair<string, string> param in parameters) | 220 | foreach (KeyValuePair<string, string> param in parameters) |
215 | { | 221 | { |
216 | dbcommand.Parameters.AddWithValue(param.Key, param.Value); | 222 | dbcommand.Parameters.AddWithValue(param.Key, param.Value); |
217 | } | 223 | } |
218 | 224 | ||
219 | return (IDbCommand)dbcommand; | 225 | return (IDbCommand) dbcommand; |
220 | } | 226 | } |
221 | catch | 227 | catch |
222 | { | 228 | { |
@@ -227,7 +233,9 @@ namespace OpenSim.Framework.Data.MySQL | |||
227 | { | 233 | { |
228 | dbcon.Close(); | 234 | dbcon.Close(); |
229 | } | 235 | } |
230 | catch { } | 236 | catch |
237 | { | ||
238 | } | ||
231 | 239 | ||
232 | // Try reopen it | 240 | // Try reopen it |
233 | try | 241 | try |
@@ -243,14 +251,14 @@ namespace OpenSim.Framework.Data.MySQL | |||
243 | // Run the query again | 251 | // Run the query again |
244 | try | 252 | try |
245 | { | 253 | { |
246 | MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); | 254 | MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand(); |
247 | dbcommand.CommandText = sql; | 255 | dbcommand.CommandText = sql; |
248 | foreach (KeyValuePair<string, string> param in parameters) | 256 | foreach (KeyValuePair<string, string> param in parameters) |
249 | { | 257 | { |
250 | dbcommand.Parameters.AddWithValue(param.Key, param.Value); | 258 | dbcommand.Parameters.AddWithValue(param.Key, param.Value); |
251 | } | 259 | } |
252 | 260 | ||
253 | return (IDbCommand)dbcommand; | 261 | return (IDbCommand) dbcommand; |
254 | } | 262 | } |
255 | catch (Exception e) | 263 | catch (Exception e) |
256 | { | 264 | { |
@@ -275,20 +283,20 @@ namespace OpenSim.Framework.Data.MySQL | |||
275 | { | 283 | { |
276 | // Region Main | 284 | // Region Main |
277 | retval.regionHandle = Convert.ToUInt64(reader["regionHandle"].ToString()); | 285 | retval.regionHandle = Convert.ToUInt64(reader["regionHandle"].ToString()); |
278 | retval.regionName = (string)reader["regionName"]; | 286 | retval.regionName = (string) reader["regionName"]; |
279 | retval.UUID = new LLUUID((string)reader["uuid"]); | 287 | retval.UUID = new LLUUID((string) reader["uuid"]); |
280 | 288 | ||
281 | // Secrets | 289 | // Secrets |
282 | retval.regionRecvKey = (string)reader["regionRecvKey"]; | 290 | retval.regionRecvKey = (string) reader["regionRecvKey"]; |
283 | retval.regionSecret = (string)reader["regionSecret"]; | 291 | retval.regionSecret = (string) reader["regionSecret"]; |
284 | retval.regionSendKey = (string)reader["regionSendKey"]; | 292 | retval.regionSendKey = (string) reader["regionSendKey"]; |
285 | 293 | ||
286 | // Region Server | 294 | // Region Server |
287 | retval.regionDataURI = (string)reader["regionDataURI"]; | 295 | retval.regionDataURI = (string) reader["regionDataURI"]; |
288 | retval.regionOnline = false; // Needs to be pinged before this can be set. | 296 | retval.regionOnline = false; // Needs to be pinged before this can be set. |
289 | retval.serverIP = (string)reader["serverIP"]; | 297 | retval.serverIP = (string) reader["serverIP"]; |
290 | retval.serverPort = (uint)reader["serverPort"]; | 298 | retval.serverPort = (uint) reader["serverPort"]; |
291 | retval.serverURI = (string)reader["serverURI"]; | 299 | retval.serverURI = (string) reader["serverURI"]; |
292 | retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString()); | 300 | retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString()); |
293 | retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString()); | 301 | retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString()); |
294 | 302 | ||
@@ -304,14 +312,14 @@ namespace OpenSim.Framework.Data.MySQL | |||
304 | retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString()); | 312 | retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString()); |
305 | 313 | ||
306 | // Assets | 314 | // Assets |
307 | retval.regionAssetURI = (string)reader["regionAssetURI"]; | 315 | retval.regionAssetURI = (string) reader["regionAssetURI"]; |
308 | retval.regionAssetRecvKey = (string)reader["regionAssetRecvKey"]; | 316 | retval.regionAssetRecvKey = (string) reader["regionAssetRecvKey"]; |
309 | retval.regionAssetSendKey = (string)reader["regionAssetSendKey"]; | 317 | retval.regionAssetSendKey = (string) reader["regionAssetSendKey"]; |
310 | 318 | ||
311 | // Userserver | 319 | // Userserver |
312 | retval.regionUserURI = (string)reader["regionUserURI"]; | 320 | retval.regionUserURI = (string) reader["regionUserURI"]; |
313 | retval.regionUserRecvKey = (string)reader["regionUserRecvKey"]; | 321 | retval.regionUserRecvKey = (string) reader["regionUserRecvKey"]; |
314 | retval.regionUserSendKey = (string)reader["regionUserSendKey"]; | 322 | retval.regionUserSendKey = (string) reader["regionUserSendKey"]; |
315 | 323 | ||
316 | // World Map Addition | 324 | // World Map Addition |
317 | string tempRegionMap = reader["regionMapTexture"].ToString(); | 325 | string tempRegionMap = reader["regionMapTexture"].ToString(); |
@@ -341,17 +349,16 @@ namespace OpenSim.Framework.Data.MySQL | |||
341 | ReservationData retval = new ReservationData(); | 349 | ReservationData retval = new ReservationData(); |
342 | if (reader.Read()) | 350 | if (reader.Read()) |
343 | { | 351 | { |
344 | retval.gridRecvKey = (string)reader["gridRecvKey"]; | 352 | retval.gridRecvKey = (string) reader["gridRecvKey"]; |
345 | retval.gridSendKey = (string)reader["gridSendKey"]; | 353 | retval.gridSendKey = (string) reader["gridSendKey"]; |
346 | retval.reservationCompany = (string)reader["resCompany"]; | 354 | retval.reservationCompany = (string) reader["resCompany"]; |
347 | retval.reservationMaxX = Convert.ToInt32(reader["resXMax"].ToString()); | 355 | retval.reservationMaxX = Convert.ToInt32(reader["resXMax"].ToString()); |
348 | retval.reservationMaxY = Convert.ToInt32(reader["resYMax"].ToString()); | 356 | retval.reservationMaxY = Convert.ToInt32(reader["resYMax"].ToString()); |
349 | retval.reservationMinX = Convert.ToInt32(reader["resXMin"].ToString()); | 357 | retval.reservationMinX = Convert.ToInt32(reader["resXMin"].ToString()); |
350 | retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString()); | 358 | retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString()); |
351 | retval.reservationName = (string)reader["resName"]; | 359 | retval.reservationName = (string) reader["resName"]; |
352 | retval.status = Convert.ToInt32(reader["status"].ToString()) == 1; | 360 | retval.status = Convert.ToInt32(reader["status"].ToString()) == 1; |
353 | retval.userUUID = new LLUUID((string)reader["userUUID"]); | 361 | retval.userUUID = new LLUUID((string) reader["userUUID"]); |
354 | |||
355 | } | 362 | } |
356 | else | 363 | else |
357 | { | 364 | { |
@@ -359,6 +366,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
359 | } | 366 | } |
360 | return retval; | 367 | return retval; |
361 | } | 368 | } |
369 | |||
362 | /// <summary> | 370 | /// <summary> |
363 | /// Reads an agent row from a database reader | 371 | /// Reads an agent row from a database reader |
364 | /// </summary> | 372 | /// </summary> |
@@ -371,12 +379,12 @@ namespace OpenSim.Framework.Data.MySQL | |||
371 | if (reader.Read()) | 379 | if (reader.Read()) |
372 | { | 380 | { |
373 | // Agent IDs | 381 | // Agent IDs |
374 | retval.UUID = new LLUUID((string)reader["UUID"]); | 382 | retval.UUID = new LLUUID((string) reader["UUID"]); |
375 | retval.sessionID = new LLUUID((string)reader["sessionID"]); | 383 | retval.sessionID = new LLUUID((string) reader["sessionID"]); |
376 | retval.secureSessionID = new LLUUID((string)reader["secureSessionID"]); | 384 | retval.secureSessionID = new LLUUID((string) reader["secureSessionID"]); |
377 | 385 | ||
378 | // Agent Who? | 386 | // Agent Who? |
379 | retval.agentIP = (string)reader["agentIP"]; | 387 | retval.agentIP = (string) reader["agentIP"]; |
380 | retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString()); | 388 | retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString()); |
381 | retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString()); | 389 | retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString()); |
382 | 390 | ||
@@ -385,9 +393,9 @@ namespace OpenSim.Framework.Data.MySQL | |||
385 | retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); | 393 | retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); |
386 | 394 | ||
387 | // Current position | 395 | // Current position |
388 | retval.currentRegion = (string)reader["currentRegion"]; | 396 | retval.currentRegion = (string) reader["currentRegion"]; |
389 | retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString()); | 397 | retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString()); |
390 | LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos); | 398 | LLVector3.TryParse((string) reader["currentPos"], out retval.currentPos); |
391 | } | 399 | } |
392 | else | 400 | else |
393 | { | 401 | { |
@@ -407,12 +415,12 @@ namespace OpenSim.Framework.Data.MySQL | |||
407 | 415 | ||
408 | if (reader.Read()) | 416 | if (reader.Read()) |
409 | { | 417 | { |
410 | retval.UUID = new LLUUID((string)reader["UUID"]); | 418 | retval.UUID = new LLUUID((string) reader["UUID"]); |
411 | retval.username = (string)reader["username"]; | 419 | retval.username = (string) reader["username"]; |
412 | retval.surname = (string)reader["lastname"]; | 420 | retval.surname = (string) reader["lastname"]; |
413 | 421 | ||
414 | retval.passwordHash = (string)reader["passwordHash"]; | 422 | retval.passwordHash = (string) reader["passwordHash"]; |
415 | retval.passwordSalt = (string)reader["passwordSalt"]; | 423 | retval.passwordSalt = (string) reader["passwordSalt"]; |
416 | 424 | ||
417 | retval.homeRegion = Convert.ToUInt64(reader["homeRegion"].ToString()); | 425 | retval.homeRegion = Convert.ToUInt64(reader["homeRegion"].ToString()); |
418 | retval.homeLocation = new LLVector3( | 426 | retval.homeLocation = new LLVector3( |
@@ -427,18 +435,17 @@ namespace OpenSim.Framework.Data.MySQL | |||
427 | retval.created = Convert.ToInt32(reader["created"].ToString()); | 435 | retval.created = Convert.ToInt32(reader["created"].ToString()); |
428 | retval.lastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); | 436 | retval.lastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); |
429 | 437 | ||
430 | retval.userInventoryURI = (string)reader["userInventoryURI"]; | 438 | retval.userInventoryURI = (string) reader["userInventoryURI"]; |
431 | retval.userAssetURI = (string)reader["userAssetURI"]; | 439 | retval.userAssetURI = (string) reader["userAssetURI"]; |
432 | 440 | ||
433 | retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); | 441 | retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); |
434 | retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); | 442 | retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); |
435 | 443 | ||
436 | retval.profileAboutText = (string)reader["profileAboutText"]; | 444 | retval.profileAboutText = (string) reader["profileAboutText"]; |
437 | retval.profileFirstText = (string)reader["profileFirstText"]; | 445 | retval.profileFirstText = (string) reader["profileFirstText"]; |
438 | |||
439 | retval.profileImage = new LLUUID((string)reader["profileImage"]); | ||
440 | retval.profileFirstImage = new LLUUID((string)reader["profileFirstImage"]); | ||
441 | 446 | ||
447 | retval.profileImage = new LLUUID((string) reader["profileImage"]); | ||
448 | retval.profileFirstImage = new LLUUID((string) reader["profileFirstImage"]); | ||
442 | } | 449 | } |
443 | else | 450 | else |
444 | { | 451 | { |
@@ -448,7 +455,6 @@ namespace OpenSim.Framework.Data.MySQL | |||
448 | } | 455 | } |
449 | 456 | ||
450 | 457 | ||
451 | |||
452 | /// <summary> | 458 | /// <summary> |
453 | /// Inserts a new row into the log database | 459 | /// Inserts a new row into the log database |
454 | /// </summary> | 460 | /// </summary> |
@@ -459,7 +465,8 @@ namespace OpenSim.Framework.Data.MySQL | |||
459 | /// <param name="priority">How critical is this?</param> | 465 | /// <param name="priority">How critical is this?</param> |
460 | /// <param name="logMessage">Extra message info</param> | 466 | /// <param name="logMessage">Extra message info</param> |
461 | /// <returns>Saved successfully?</returns> | 467 | /// <returns>Saved successfully?</returns> |
462 | public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage) | 468 | public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority, |
469 | string logMessage) | ||
463 | { | 470 | { |
464 | string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES "; | 471 | string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES "; |
465 | sql += "(?target, ?server, ?method, ?arguments, ?priority, ?message)"; | 472 | sql += "(?target, ?server, ?method, ?arguments, ?priority, ?message)"; |
@@ -493,89 +500,97 @@ namespace OpenSim.Framework.Data.MySQL | |||
493 | } | 500 | } |
494 | 501 | ||
495 | 502 | ||
496 | /// <summary> | 503 | /// <summary> |
497 | /// Creates a new user and inserts it into the database | 504 | /// Creates a new user and inserts it into the database |
498 | /// </summary> | 505 | /// </summary> |
499 | /// <param name="uuid">User ID</param> | 506 | /// <param name="uuid">User ID</param> |
500 | /// <param name="username">First part of the login</param> | 507 | /// <param name="username">First part of the login</param> |
501 | /// <param name="lastname">Second part of the login</param> | 508 | /// <param name="lastname">Second part of the login</param> |
502 | /// <param name="passwordHash">A salted hash of the users password</param> | 509 | /// <param name="passwordHash">A salted hash of the users password</param> |
503 | /// <param name="passwordSalt">The salt used for the password hash</param> | 510 | /// <param name="passwordSalt">The salt used for the password hash</param> |
504 | /// <param name="homeRegion">A regionHandle of the users home region</param> | 511 | /// <param name="homeRegion">A regionHandle of the users home region</param> |
505 | /// <param name="homeLocX">Home region position vector</param> | 512 | /// <param name="homeLocX">Home region position vector</param> |
506 | /// <param name="homeLocY">Home region position vector</param> | 513 | /// <param name="homeLocY">Home region position vector</param> |
507 | /// <param name="homeLocZ">Home region position vector</param> | 514 | /// <param name="homeLocZ">Home region position vector</param> |
508 | /// <param name="homeLookAtX">Home region 'look at' vector</param> | 515 | /// <param name="homeLookAtX">Home region 'look at' vector</param> |
509 | /// <param name="homeLookAtY">Home region 'look at' vector</param> | 516 | /// <param name="homeLookAtY">Home region 'look at' vector</param> |
510 | /// <param name="homeLookAtZ">Home region 'look at' vector</param> | 517 | /// <param name="homeLookAtZ">Home region 'look at' vector</param> |
511 | /// <param name="created">Account created (unix timestamp)</param> | 518 | /// <param name="created">Account created (unix timestamp)</param> |
512 | /// <param name="lastlogin">Last login (unix timestamp)</param> | 519 | /// <param name="lastlogin">Last login (unix timestamp)</param> |
513 | /// <param name="inventoryURI">Users inventory URI</param> | 520 | /// <param name="inventoryURI">Users inventory URI</param> |
514 | /// <param name="assetURI">Users asset URI</param> | 521 | /// <param name="assetURI">Users asset URI</param> |
515 | /// <param name="canDoMask">I can do mask</param> | 522 | /// <param name="canDoMask">I can do mask</param> |
516 | /// <param name="wantDoMask">I want to do mask</param> | 523 | /// <param name="wantDoMask">I want to do mask</param> |
517 | /// <param name="aboutText">Profile text</param> | 524 | /// <param name="aboutText">Profile text</param> |
518 | /// <param name="firstText">Firstlife text</param> | 525 | /// <param name="firstText">Firstlife text</param> |
519 | /// <param name="profileImage">UUID for profile image</param> | 526 | /// <param name="profileImage">UUID for profile image</param> |
520 | /// <param name="firstImage">UUID for firstlife image</param> | 527 | /// <param name="firstImage">UUID for firstlife image</param> |
521 | /// <returns>Success?</returns> | 528 | /// <returns>Success?</returns> |
522 | public bool insertUserRow(libsecondlife.LLUUID uuid, string username, string lastname, string passwordHash, string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ, | 529 | public bool insertUserRow(LLUUID uuid, string username, string lastname, string passwordHash, |
523 | float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, string aboutText, string firstText, | 530 | string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ, |
524 | libsecondlife.LLUUID profileImage, libsecondlife.LLUUID firstImage) | 531 | float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, |
525 | { | 532 | string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, |
526 | string sql = "INSERT INTO users (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, "; | 533 | string aboutText, string firstText, |
527 | sql += "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, "; | 534 | LLUUID profileImage, LLUUID firstImage) |
528 | sql += "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, "; | 535 | { |
529 | sql += "`profileFirstText`, `profileImage`, `profileFirstImage`) VALUES "; | 536 | string sql = |
530 | 537 | "INSERT INTO users (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, "; | |
531 | sql += "(?UUID, ?username, ?lastname, ?passwordHash, ?passwordSalt, ?homeRegion, "; | 538 | sql += |
532 | sql += "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, "; | 539 | "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, "; |
533 | sql += "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, "; | 540 | sql += |
534 | sql += "?profileFirstText, ?profileImage, ?profileFirstImage)"; | 541 | "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, "; |
535 | 542 | sql += "`profileFirstText`, `profileImage`, `profileFirstImage`) VALUES "; | |
536 | Dictionary<string, string> parameters = new Dictionary<string, string>(); | 543 | |
537 | parameters["?UUID"] = uuid.ToStringHyphenated(); | 544 | sql += "(?UUID, ?username, ?lastname, ?passwordHash, ?passwordSalt, ?homeRegion, "; |
538 | parameters["?username"] = username.ToString(); | 545 | sql += |
539 | parameters["?lastname"] = lastname.ToString(); | 546 | "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, "; |
540 | parameters["?passwordHash"] = passwordHash.ToString(); | 547 | sql += |
541 | parameters["?passwordSalt"] = passwordSalt.ToString(); | 548 | "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, "; |
542 | parameters["?homeRegion"] = homeRegion.ToString(); | 549 | sql += "?profileFirstText, ?profileImage, ?profileFirstImage)"; |
543 | parameters["?homeLocationX"] = homeLocX.ToString(); | 550 | |
544 | parameters["?homeLocationY"] = homeLocY.ToString(); | 551 | Dictionary<string, string> parameters = new Dictionary<string, string>(); |
545 | parameters["?homeLocationZ"] = homeLocZ.ToString(); | 552 | parameters["?UUID"] = uuid.ToStringHyphenated(); |
546 | parameters["?homeLookAtX"] = homeLookAtX.ToString(); | 553 | parameters["?username"] = username.ToString(); |
547 | parameters["?homeLookAtY"] = homeLookAtY.ToString(); | 554 | parameters["?lastname"] = lastname.ToString(); |
548 | parameters["?homeLookAtZ"] = homeLookAtZ.ToString(); | 555 | parameters["?passwordHash"] = passwordHash.ToString(); |
549 | parameters["?created"] = created.ToString(); | 556 | parameters["?passwordSalt"] = passwordSalt.ToString(); |
550 | parameters["?lastLogin"] = lastlogin.ToString(); | 557 | parameters["?homeRegion"] = homeRegion.ToString(); |
551 | parameters["?userInventoryURI"] = ""; | 558 | parameters["?homeLocationX"] = homeLocX.ToString(); |
552 | parameters["?userAssetURI"] = ""; | 559 | parameters["?homeLocationY"] = homeLocY.ToString(); |
553 | parameters["?profileCanDoMask"] = "0"; | 560 | parameters["?homeLocationZ"] = homeLocZ.ToString(); |
554 | parameters["?profileWantDoMask"] = "0"; | 561 | parameters["?homeLookAtX"] = homeLookAtX.ToString(); |
555 | parameters["?profileAboutText"] = ""; | 562 | parameters["?homeLookAtY"] = homeLookAtY.ToString(); |
556 | parameters["?profileFirstText"] = ""; | 563 | parameters["?homeLookAtZ"] = homeLookAtZ.ToString(); |
557 | parameters["?profileImage"] = libsecondlife.LLUUID.Zero.ToStringHyphenated(); | 564 | parameters["?created"] = created.ToString(); |
558 | parameters["?profileFirstImage"] = libsecondlife.LLUUID.Zero.ToStringHyphenated(); | 565 | parameters["?lastLogin"] = lastlogin.ToString(); |
559 | 566 | parameters["?userInventoryURI"] = ""; | |
560 | bool returnval = false; | 567 | parameters["?userAssetURI"] = ""; |
561 | 568 | parameters["?profileCanDoMask"] = "0"; | |
562 | try | 569 | parameters["?profileWantDoMask"] = "0"; |
563 | { | 570 | parameters["?profileAboutText"] = ""; |
564 | IDbCommand result = Query(sql, parameters); | 571 | parameters["?profileFirstText"] = ""; |
565 | 572 | parameters["?profileImage"] = LLUUID.Zero.ToStringHyphenated(); | |
566 | if (result.ExecuteNonQuery() == 1) | 573 | parameters["?profileFirstImage"] = LLUUID.Zero.ToStringHyphenated(); |
567 | returnval = true; | 574 | |
568 | 575 | bool returnval = false; | |
569 | result.Dispose(); | 576 | |
570 | } | 577 | try |
571 | catch (Exception e) | 578 | { |
572 | { | 579 | IDbCommand result = Query(sql, parameters); |
573 | MainLog.Instance.Error(e.ToString()); | 580 | |
574 | return false; | 581 | if (result.ExecuteNonQuery() == 1) |
575 | } | 582 | returnval = true; |
576 | 583 | ||
577 | return returnval; | 584 | result.Dispose(); |
578 | } | 585 | } |
586 | catch (Exception e) | ||
587 | { | ||
588 | MainLog.Instance.Error(e.ToString()); | ||
589 | return false; | ||
590 | } | ||
591 | |||
592 | return returnval; | ||
593 | } | ||
579 | 594 | ||
580 | 595 | ||
581 | /// <summary> | 596 | /// <summary> |
@@ -585,13 +600,18 @@ namespace OpenSim.Framework.Data.MySQL | |||
585 | /// <returns>Success?</returns> | 600 | /// <returns>Success?</returns> |
586 | public bool insertRegion(RegionProfileData regiondata) | 601 | public bool insertRegion(RegionProfileData regiondata) |
587 | { | 602 | { |
588 | string sql = "REPLACE INTO regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; | 603 | string sql = |
589 | sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; | 604 | "REPLACE INTO regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; |
590 | sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort) VALUES "; | 605 | sql += |
606 | "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; | ||
607 | sql += | ||
608 | "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort) VALUES "; | ||
591 | 609 | ||
592 | sql += "(?regionHandle, ?regionName, ?uuid, ?regionRecvKey, ?regionSecret, ?regionSendKey, ?regionDataURI, "; | 610 | sql += "(?regionHandle, ?regionName, ?uuid, ?regionRecvKey, ?regionSecret, ?regionSendKey, ?regionDataURI, "; |
593 | sql += "?serverIP, ?serverPort, ?serverURI, ?locX, ?locY, ?locZ, ?eastOverrideHandle, ?westOverrideHandle, ?southOverrideHandle, ?northOverrideHandle, ?regionAssetURI, ?regionAssetRecvKey, "; | 611 | sql += |
594 | sql += "?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey, ?regionMapTexture, ?serverHttpPort, ?serverRemotingPort);"; | 612 | "?serverIP, ?serverPort, ?serverURI, ?locX, ?locY, ?locZ, ?eastOverrideHandle, ?westOverrideHandle, ?southOverrideHandle, ?northOverrideHandle, ?regionAssetURI, ?regionAssetRecvKey, "; |
613 | sql += | ||
614 | "?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey, ?regionMapTexture, ?serverHttpPort, ?serverRemotingPort);"; | ||
595 | 615 | ||
596 | Dictionary<string, string> parameters = new Dictionary<string, string>(); | 616 | Dictionary<string, string> parameters = new Dictionary<string, string>(); |
597 | 617 | ||
@@ -626,7 +646,6 @@ namespace OpenSim.Framework.Data.MySQL | |||
626 | 646 | ||
627 | try | 647 | try |
628 | { | 648 | { |
629 | |||
630 | IDbCommand result = Query(sql, parameters); | 649 | IDbCommand result = Query(sql, parameters); |
631 | 650 | ||
632 | //Console.WriteLine(result.CommandText); | 651 | //Console.WriteLine(result.CommandText); |
@@ -646,4 +665,4 @@ namespace OpenSim.Framework.Data.MySQL | |||
646 | return returnval; | 665 | return returnval; |
647 | } | 666 | } |
648 | } | 667 | } |
649 | } | 668 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs index 27c9cf6..8846650 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs | |||
@@ -29,7 +29,6 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Data; | 30 | using System.Data; |
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Console; | 32 | using OpenSim.Framework.Console; |
34 | 33 | ||
35 | namespace OpenSim.Framework.Data.MySQL | 34 | namespace OpenSim.Framework.Data.MySQL |
@@ -37,7 +36,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
37 | /// <summary> | 36 | /// <summary> |
38 | /// A database interface class to a user profile storage system | 37 | /// A database interface class to a user profile storage system |
39 | /// </summary> | 38 | /// </summary> |
40 | class MySQLUserData : IUserData | 39 | internal class MySQLUserData : IUserData |
41 | { | 40 | { |
42 | /// <summary> | 41 | /// <summary> |
43 | /// Database manager for MySQL | 42 | /// Database manager for MySQL |
@@ -59,7 +58,9 @@ namespace OpenSim.Framework.Data.MySQL | |||
59 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); | 58 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); |
60 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); | 59 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); |
61 | 60 | ||
62 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); | 61 | database = |
62 | new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, | ||
63 | settingPort); | ||
63 | } | 64 | } |
64 | 65 | ||
65 | /// <summary> | 66 | /// <summary> |
@@ -88,11 +89,12 @@ namespace OpenSim.Framework.Data.MySQL | |||
88 | param["?first"] = user; | 89 | param["?first"] = user; |
89 | param["?second"] = last; | 90 | param["?second"] = last; |
90 | 91 | ||
91 | IDbCommand result = database.Query("SELECT * FROM users WHERE username = ?first AND lastname = ?second", param); | 92 | IDbCommand result = |
93 | database.Query("SELECT * FROM users WHERE username = ?first AND lastname = ?second", param); | ||
92 | IDataReader reader = result.ExecuteReader(); | 94 | IDataReader reader = result.ExecuteReader(); |
93 | 95 | ||
94 | UserProfileData row = database.readUserRow(reader); | 96 | UserProfileData row = database.readUserRow(reader); |
95 | 97 | ||
96 | reader.Close(); | 98 | reader.Close(); |
97 | result.Dispose(); | 99 | result.Dispose(); |
98 | 100 | ||
@@ -201,21 +203,25 @@ namespace OpenSim.Framework.Data.MySQL | |||
201 | /// <param name="user">The user profile to create</param> | 203 | /// <param name="user">The user profile to create</param> |
202 | public void AddNewUserProfile(UserProfileData user) | 204 | public void AddNewUserProfile(UserProfileData user) |
203 | { | 205 | { |
204 | try | 206 | try |
205 | { | 207 | { |
206 | lock (database) | 208 | lock (database) |
207 | { | 209 | { |
208 | database.insertUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt, user.homeRegion, user.homeLocation.X, user.homeLocation.Y, user.homeLocation.Z, | 210 | database.insertUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt, |
209 | user.homeLookAt.X, user.homeLookAt.Y, user.homeLookAt.Z, user.created, user.lastLogin, user.userInventoryURI, user.userAssetURI, user.profileCanDoMask, user.profileWantDoMask, | 211 | user.homeRegion, user.homeLocation.X, user.homeLocation.Y, |
210 | user.profileAboutText, user.profileFirstText, user.profileImage, user.profileFirstImage); | 212 | user.homeLocation.Z, |
211 | } | 213 | user.homeLookAt.X, user.homeLookAt.Y, user.homeLookAt.Z, user.created, |
212 | } | 214 | user.lastLogin, user.userInventoryURI, user.userAssetURI, |
213 | catch (Exception e) | 215 | user.profileCanDoMask, user.profileWantDoMask, |
214 | { | 216 | user.profileAboutText, user.profileFirstText, user.profileImage, |
215 | database.Reconnect(); | 217 | user.profileFirstImage); |
216 | MainLog.Instance.Error(e.ToString()); | 218 | } |
217 | } | 219 | } |
218 | 220 | catch (Exception e) | |
221 | { | ||
222 | database.Reconnect(); | ||
223 | MainLog.Instance.Error(e.ToString()); | ||
224 | } | ||
219 | } | 225 | } |
220 | 226 | ||
221 | /// <summary> | 227 | /// <summary> |
@@ -226,8 +232,8 @@ namespace OpenSim.Framework.Data.MySQL | |||
226 | { | 232 | { |
227 | // Do nothing. | 233 | // Do nothing. |
228 | } | 234 | } |
229 | 235 | ||
230 | 236 | ||
231 | public bool UpdateUserProfile(UserProfileData user) | 237 | public bool UpdateUserProfile(UserProfileData user) |
232 | { | 238 | { |
233 | return true; | 239 | return true; |
@@ -277,4 +283,4 @@ namespace OpenSim.Framework.Data.MySQL | |||
277 | return "0.1"; | 283 | return "0.1"; |
278 | } | 284 | } |
279 | } | 285 | } |
280 | } | 286 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs index 46c0ae0..7024bfa 100644 --- a/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs | |||
@@ -1,24 +1,28 @@ | |||
1 | using System.Reflection; | 1 | using System.Reflection; |
2 | using System.Runtime.InteropServices; | 2 | using System.Runtime.InteropServices; |
3 | |||
3 | // General Information about an assembly is controlled through the following | 4 | // General Information about an assembly is controlled through the following |
4 | // set of attributes. Change these attribute values to modify the information | 5 | // set of attributes. Change these attribute values to modify the information |
5 | // associated with an assembly. | 6 | // associated with an assembly. |
6 | [assembly: AssemblyTitle("OpenSim.Framework.Data.MySQL")] | 7 | |
7 | [assembly: AssemblyDescription("")] | 8 | [assembly : AssemblyTitle("OpenSim.Framework.Data.MySQL")] |
8 | [assembly: AssemblyConfiguration("")] | 9 | [assembly : AssemblyDescription("")] |
9 | [assembly: AssemblyCompany("")] | 10 | [assembly : AssemblyConfiguration("")] |
10 | [assembly: AssemblyProduct("OpenSim.Framework.Data.MySQL")] | 11 | [assembly : AssemblyCompany("")] |
11 | [assembly: AssemblyCopyright("Copyright © 2007")] | 12 | [assembly : AssemblyProduct("OpenSim.Framework.Data.MySQL")] |
12 | [assembly: AssemblyTrademark("")] | 13 | [assembly : AssemblyCopyright("Copyright © 2007")] |
13 | [assembly: AssemblyCulture("")] | 14 | [assembly : AssemblyTrademark("")] |
15 | [assembly : AssemblyCulture("")] | ||
14 | 16 | ||
15 | // Setting ComVisible to false makes the types in this assembly not visible | 17 | // Setting ComVisible to false makes the types in this assembly not visible |
16 | // to COM components. If you need to access a type in this assembly from | 18 | // to COM components. If you need to access a type in this assembly from |
17 | // COM, set the ComVisible attribute to true on that type. | 19 | // COM, set the ComVisible attribute to true on that type. |
18 | [assembly: ComVisible(false)] | 20 | |
21 | [assembly : ComVisible(false)] | ||
19 | 22 | ||
20 | // The following GUID is for the ID of the typelib if this project is exposed to COM | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM |
21 | [assembly: Guid("e49826b2-dcef-41be-a5bd-596733fa3304")] | 24 | |
25 | [assembly : Guid("e49826b2-dcef-41be-a5bd-596733fa3304")] | ||
22 | 26 | ||
23 | // Version information for an assembly consists of the following four values: | 27 | // Version information for an assembly consists of the following four values: |
24 | // | 28 | // |
@@ -29,5 +33,6 @@ using System.Runtime.InteropServices; | |||
29 | // | 33 | // |
30 | // You can specify all the values or you can default the Revision and Build Numbers | 34 | // You can specify all the values or you can default the Revision and Build Numbers |
31 | // by using the '*' as shown below: | 35 | // by using the '*' as shown below: |
32 | [assembly: AssemblyVersion("1.0.0.0")] | 36 | |
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | 37 | [assembly : AssemblyVersion("1.0.0.0")] |
38 | [assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file | ||