diff options
author | lbsa71 | 2007-09-27 14:57:43 +0000 |
---|---|---|
committer | lbsa71 | 2007-09-27 14:57:43 +0000 |
commit | 863195612bdef56165f2b4354bab280c371618b9 (patch) | |
tree | 63cec15a6c0338a8777640ed13fd7c3ce05eeba7 /OpenSim/Framework/Data.MySQL | |
parent | revert change to libsecondlife.dll.config which breaks Linux (diff) | |
download | opensim-SC_OLD-863195612bdef56165f2b4354bab280c371618b9.zip opensim-SC_OLD-863195612bdef56165f2b4354bab280c371618b9.tar.gz opensim-SC_OLD-863195612bdef56165f2b4354bab280c371618b9.tar.bz2 opensim-SC_OLD-863195612bdef56165f2b4354bab280c371618b9.tar.xz |
Reverting back to 2017 since 2018 were causing Linux breakage; reopening Tleiades patch 444 and 445.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs | 58 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLManager.cs | 58 |
2 files changed, 58 insertions, 58 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs index 8a7e869..5009d9e 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs | |||
@@ -132,7 +132,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
132 | param["?uuid"] = user.ToStringHyphenated(); | 132 | param["?uuid"] = user.ToStringHyphenated(); |
133 | param["?zero"] = LLUUID.Zero.ToStringHyphenated(); | 133 | param["?zero"] = LLUUID.Zero.ToStringHyphenated(); |
134 | 134 | ||
135 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND (agentID = ?uuid OR category = 0)", param); | 135 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", param); |
136 | IDataReader reader = result.ExecuteReader(); | 136 | IDataReader reader = result.ExecuteReader(); |
137 | 137 | ||
138 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); | 138 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); |
@@ -152,6 +152,40 @@ namespace OpenSim.Framework.Data.MySQL | |||
152 | } | 152 | } |
153 | 153 | ||
154 | /// <summary> | 154 | /// <summary> |
155 | /// Returns the users inventory root folder. | ||
156 | /// </summary> | ||
157 | /// <param name="user"></param> | ||
158 | /// <returns></returns> | ||
159 | public InventoryFolderBase getUserRootFolder(LLUUID user) | ||
160 | { | ||
161 | try | ||
162 | { | ||
163 | lock (database) | ||
164 | { | ||
165 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
166 | param["?uuid"] = user.ToStringHyphenated(); | ||
167 | param["?zero"] = LLUUID.Zero.ToStringHyphenated(); | ||
168 | |||
169 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", param); | ||
170 | IDataReader reader = result.ExecuteReader(); | ||
171 | |||
172 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); | ||
173 | InventoryFolderBase rootFolder = items[0]; //should only be one folder with parent set to zero (the root one). | ||
174 | reader.Close(); | ||
175 | result.Dispose(); | ||
176 | |||
177 | return rootFolder; | ||
178 | } | ||
179 | } | ||
180 | catch (Exception e) | ||
181 | { | ||
182 | database.Reconnect(); | ||
183 | Console.WriteLine(e.ToString()); | ||
184 | return null; | ||
185 | } | ||
186 | } | ||
187 | |||
188 | /// <summary> | ||
155 | /// Returns a list of folders in a users inventory contained within the specified folder | 189 | /// Returns a list of folders in a users inventory contained within the specified folder |
156 | /// </summary> | 190 | /// </summary> |
157 | /// <param name="parentID">The folder to search</param> | 191 | /// <param name="parentID">The folder to search</param> |
@@ -314,27 +348,5 @@ namespace OpenSim.Framework.Data.MySQL | |||
314 | { | 348 | { |
315 | addInventoryFolder(folder); | 349 | addInventoryFolder(folder); |
316 | } | 350 | } |
317 | |||
318 | public void deleteInventoryCategory(InventoryCategory inventoryCategory) | ||
319 | { | ||
320 | try | ||
321 | { | ||
322 | lock (database) { | ||
323 | IDbCommand cmd = database.Query(string.Format("DELETE FROM inventoryitems WHERE parentFolderID IN (SELECT folderId FROM inventoryfolders WHERE category={0})", (byte)inventoryCategory), null); | ||
324 | cmd.ExecuteNonQuery(); | ||
325 | |||
326 | |||
327 | cmd = database.Query(string.Format("DELETE FROM inventoryfolders WHERE category={0}", (byte)inventoryCategory), null); | ||
328 | cmd.ExecuteNonQuery(); | ||
329 | } | ||
330 | |||
331 | } | ||
332 | catch (Exception e) | ||
333 | { | ||
334 | database.Reconnect(); | ||
335 | Console.WriteLine(e.ToString()); | ||
336 | } | ||
337 | } | ||
338 | |||
339 | } | 351 | } |
340 | } | 352 | } |
diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs index e55606e..5037f98 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs | |||
@@ -41,7 +41,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
41 | /// <summary> | 41 | /// <summary> |
42 | /// The database connection object | 42 | /// The database connection object |
43 | /// </summary> | 43 | /// </summary> |
44 | MySqlConnection dbcon; | 44 | IDbConnection dbcon; |
45 | /// <summary> | 45 | /// <summary> |
46 | /// Connection string for ADO.net | 46 | /// Connection string for ADO.net |
47 | /// </summary> | 47 | /// </summary> |
@@ -115,11 +115,10 @@ namespace OpenSim.Framework.Data.MySQL | |||
115 | { | 115 | { |
116 | MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); | 116 | MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); |
117 | dbcommand.CommandText = sql; | 117 | dbcommand.CommandText = sql; |
118 | if(parameters != null) | 118 | foreach (KeyValuePair<string, string> param in parameters) |
119 | foreach (KeyValuePair<string, string> param in parameters) | 119 | { |
120 | { | 120 | dbcommand.Parameters.Add(param.Key, param.Value); |
121 | dbcommand.Parameters.Add(param.Key, param.Value); | 121 | } |
122 | } | ||
123 | 122 | ||
124 | return (IDbCommand)dbcommand; | 123 | return (IDbCommand)dbcommand; |
125 | } | 124 | } |
@@ -150,11 +149,10 @@ namespace OpenSim.Framework.Data.MySQL | |||
150 | { | 149 | { |
151 | MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); | 150 | MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); |
152 | dbcommand.CommandText = sql; | 151 | dbcommand.CommandText = sql; |
153 | if(parameters != null) | 152 | foreach (KeyValuePair<string, string> param in parameters) |
154 | foreach (KeyValuePair<string, string> param in parameters) | 153 | { |
155 | { | 154 | dbcommand.Parameters.Add(param.Key, param.Value); |
156 | dbcommand.Parameters.Add(param.Key, param.Value); | 155 | } |
157 | } | ||
158 | 156 | ||
159 | return (IDbCommand)dbcommand; | 157 | return (IDbCommand)dbcommand; |
160 | } | 158 | } |
@@ -372,8 +370,6 @@ namespace OpenSim.Framework.Data.MySQL | |||
372 | folder.parentID = new LLUUID((string)reader["parentFolderID"]); | 370 | folder.parentID = new LLUUID((string)reader["parentFolderID"]); |
373 | folder.folderID = new LLUUID((string)reader["folderID"]); | 371 | folder.folderID = new LLUUID((string)reader["folderID"]); |
374 | folder.name = (string)reader["folderName"]; | 372 | folder.name = (string)reader["folderName"]; |
375 | folder.category = (InventoryCategory)((Int16)reader["category"]); | ||
376 | folder.type = (Int16)reader["folderType"]; | ||
377 | 373 | ||
378 | rows.Add(folder); | 374 | rows.Add(folder); |
379 | } | 375 | } |
@@ -513,32 +509,24 @@ namespace OpenSim.Framework.Data.MySQL | |||
513 | /// <returns>Success?</returns> | 509 | /// <returns>Success?</returns> |
514 | public bool insertFolder(InventoryFolderBase folder) | 510 | public bool insertFolder(InventoryFolderBase folder) |
515 | { | 511 | { |
516 | string sql = "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, category, folderType) VALUES "; | 512 | string sql = "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName) VALUES "; |
517 | sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?category, ?folderType)"; | 513 | sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName)"; |
518 | 514 | ||
519 | MySqlCommand dbcmd = dbcon.CreateCommand(); | 515 | Dictionary<string, string> parameters = new Dictionary<string, string>(); |
520 | dbcmd.CommandText = sql; | 516 | parameters["?folderID"] = folder.folderID.ToStringHyphenated(); |
521 | 517 | parameters["?agentID"] = folder.agentID.ToStringHyphenated(); | |
522 | LLUUID tmpID = folder.folderID; | 518 | parameters["?parentFolderID"] = folder.parentID.ToStringHyphenated(); |
523 | dbcmd.Parameters.Add(new MySqlParameter("?folderID", tmpID.ToStringHyphenated())); | 519 | parameters["?folderName"] = folder.name; |
524 | dbcmd.Parameters.Add(new MySqlParameter("?folderID", tmpID.ToStringHyphenated())); | 520 | |
525 | tmpID = folder.agentID; | ||
526 | dbcmd.Parameters.Add(new MySqlParameter("?agentID", tmpID.ToStringHyphenated())); | ||
527 | tmpID = folder.parentID; | ||
528 | dbcmd.Parameters.Add(new MySqlParameter("?parentFolderID", tmpID.ToStringHyphenated())); | ||
529 | dbcmd.Parameters.Add(new MySqlParameter("?folderName", folder.name)); | ||
530 | MySqlParameter p = dbcmd.Parameters.Add(new MySqlParameter("?category", MySqlDbType.Byte)); | ||
531 | p.Value = (byte)folder.category; | ||
532 | |||
533 | p = dbcmd.Parameters.Add(new MySqlParameter("?folderType", MySqlDbType.Byte)); | ||
534 | p.Value = (byte)folder.type; | ||
535 | |||
536 | |||
537 | bool returnval = false; | 521 | bool returnval = false; |
538 | try | 522 | try |
539 | { | 523 | { |
540 | if (dbcmd.ExecuteNonQuery() == 1) | 524 | IDbCommand result = Query(sql, parameters); |
525 | |||
526 | if (result.ExecuteNonQuery() == 1) | ||
541 | returnval = true; | 527 | returnval = true; |
528 | |||
529 | result.Dispose(); | ||
542 | } | 530 | } |
543 | catch (Exception e) | 531 | catch (Exception e) |
544 | { | 532 | { |