aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLInventoryData.cs
diff options
context:
space:
mode:
authorMaster ScienceSim2010-02-04 13:19:30 -0800
committerJohn Hurliman2010-02-05 18:07:59 -0800
commite1b5c612472b9d1acf47383c0bf75b555daff2e6 (patch)
tree083896698038fbdad59c2bd3adeba9b290c5ce1b /OpenSim/Data/MySQL/MySQLInventoryData.cs
parentFixing an incorrect logging message in insertUserRow (diff)
downloadopensim-SC-e1b5c612472b9d1acf47383c0bf75b555daff2e6.zip
opensim-SC-e1b5c612472b9d1acf47383c0bf75b555daff2e6.tar.gz
opensim-SC-e1b5c612472b9d1acf47383c0bf75b555daff2e6.tar.bz2
opensim-SC-e1b5c612472b9d1acf47383c0bf75b555daff2e6.tar.xz
Updated MySQL connection management to use the MySQL connection pooling. This should accommodate various timeout problems that exist with the current connection pool code in a more general and standard way.
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLInventoryData.cs')
-rw-r--r--OpenSim/Data/MySQL/MySQLInventoryData.cs847
1 files changed, 336 insertions, 511 deletions
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index 4b71e39..192deb2 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -26,7 +26,6 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.IO;
30using System.Collections.Generic; 29using System.Collections.Generic;
31using System.Reflection; 30using System.Reflection;
32using log4net; 31using log4net;
@@ -44,14 +43,10 @@ namespace OpenSim.Data.MySQL
44 private static readonly ILog m_log 43 private static readonly ILog m_log
45 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 45
47 /// <summary> 46 private string m_connectionString;
48 /// The database manager 47 private object m_dbLock = new object();
49 /// </summary>
50 private MySQLManager database;
51 48
52 private bool rollbackStore = false; 49 public string Version { get { return "1.0.0.0"; } }
53 private bool opengridmode = false;
54 private string rollbackDir = "";
55 50
56 public void Initialise() 51 public void Initialise()
57 { 52 {
@@ -72,37 +67,17 @@ namespace OpenSim.Data.MySQL
72 /// <param name="connect">connect string</param> 67 /// <param name="connect">connect string</param>
73 public void Initialise(string connect) 68 public void Initialise(string connect)
74 { 69 {
75 if (connect != String.Empty) 70 m_connectionString = connect;
76 {
77 database = new MySQLManager(connect);
78 }
79 else
80 {
81 m_log.Warn("Reverting to deprecated mysql_connection.ini file for connection info");
82 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
83 string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
84 string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
85 string settingUsername = GridDataMySqlFile.ParseFileReadValue("username");
86 string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
87 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
88 string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
89
90 rollbackDir = GridDataMySqlFile.ParseFileReadValue("rollbackdir");
91 rollbackStore = GridDataMySqlFile.ParseFileReadValue("rollback") == "true";
92 opengridmode = GridDataMySqlFile.ParseFileReadValue("opengridmode") == "true";
93
94 if (rollbackStore)
95 m_log.Warn("[MysqlInventory] Enabling rollback mode in: " + rollbackDir);
96
97 database =
98 new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
99 settingPort);
100 }
101 71
102 // This actually does the roll forward assembly stuff 72 // This actually does the roll forward assembly stuff
103 Assembly assem = GetType().Assembly; 73 Assembly assem = GetType().Assembly;
104 Migration m = new Migration(database.Connection, assem, "InventoryStore"); 74
105 m.Update(); 75 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
76 {
77 dbcon.Open();
78 Migration m = new Migration(dbcon, assem, "InventoryStore");
79 m.Update();
80 }
106 } 81 }
107 82
108 /// <summary> 83 /// <summary>
@@ -124,15 +99,6 @@ namespace OpenSim.Data.MySQL
124 } 99 }
125 100
126 /// <summary> 101 /// <summary>
127 /// Returns the version of this DB provider
128 /// </summary>
129 /// <returns>A string containing the DB provider version</returns>
130 public string Version
131 {
132 get { return database.getVersion(); }
133 }
134
135 /// <summary>
136 /// Returns a list of items in a specified folder 102 /// Returns a list of items in a specified folder
137 /// </summary> 103 /// </summary>
138 /// <param name="folderID">The folder to search</param> 104 /// <param name="folderID">The folder to search</param>
@@ -141,36 +107,37 @@ namespace OpenSim.Data.MySQL
141 { 107 {
142 try 108 try
143 { 109 {
144 lock (database) 110 lock (m_dbLock)
145 { 111 {
146 List<InventoryItemBase> items = new List<InventoryItemBase>(); 112 List<InventoryItemBase> items = new List<InventoryItemBase>();
147 113
148 database.CheckConnection(); 114 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
149
150 MySqlCommand result =
151 new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid",
152 database.Connection);
153 result.Parameters.AddWithValue("?uuid", folderID.ToString());
154 MySqlDataReader reader = result.ExecuteReader();
155
156 while (reader.Read())
157 { 115 {
158 // A null item (because something went wrong) breaks everything in the folder 116 dbcon.Open();
159 InventoryItemBase item = readInventoryItem(reader);
160 if (item != null)
161 items.Add(item);
162 }
163 117
164 reader.Close(); 118 using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", dbcon))
165 result.Dispose(); 119 {
120 result.Parameters.AddWithValue("?uuid", folderID.ToString());
121
122 using (MySqlDataReader reader = result.ExecuteReader())
123 {
124 while (reader.Read())
125 {
126 // A null item (because something went wrong) breaks everything in the folder
127 InventoryItemBase item = readInventoryItem(reader);
128 if (item != null)
129 items.Add(item);
130 }
166 131
167 return items; 132 return items;
133 }
134 }
135 }
168 } 136 }
169 } 137 }
170 catch (Exception e) 138 catch (Exception e)
171 { 139 {
172 database.Reconnect(); 140 m_log.Error(e.Message, e);
173 m_log.Error(e.ToString());
174 return null; 141 return null;
175 } 142 }
176 } 143 }
@@ -184,33 +151,33 @@ namespace OpenSim.Data.MySQL
184 { 151 {
185 try 152 try
186 { 153 {
187 lock (database) 154 lock (m_dbLock)
188 { 155 {
189 database.CheckConnection(); 156 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
190 157 {
191 MySqlCommand result = 158 dbcon.Open();
192 new MySqlCommand(
193 "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid",
194 database.Connection);
195 result.Parameters.AddWithValue("?uuid", user.ToString());
196 result.Parameters.AddWithValue("?zero", UUID.Zero.ToString());
197 MySqlDataReader reader = result.ExecuteReader();
198
199 List<InventoryFolderBase> items = new List<InventoryFolderBase>();
200 while (reader.Read())
201 items.Add(readInventoryFolder(reader));
202 159
160 using (MySqlCommand result = new MySqlCommand(
161 "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", dbcon))
162 {
163 result.Parameters.AddWithValue("?uuid", user.ToString());
164 result.Parameters.AddWithValue("?zero", UUID.Zero.ToString());
203 165
204 reader.Close(); 166 using (MySqlDataReader reader = result.ExecuteReader())
205 result.Dispose(); 167 {
168 List<InventoryFolderBase> items = new List<InventoryFolderBase>();
169 while (reader.Read())
170 items.Add(readInventoryFolder(reader));
206 171
207 return items; 172 return items;
173 }
174 }
175 }
208 } 176 }
209 } 177 }
210 catch (Exception e) 178 catch (Exception e)
211 { 179 {
212 database.Reconnect(); 180 m_log.Error(e.Message, e);
213 m_log.Error(e.ToString());
214 return null; 181 return null;
215 } 182 }
216 } 183 }
@@ -225,46 +192,44 @@ namespace OpenSim.Data.MySQL
225 { 192 {
226 try 193 try
227 { 194 {
228 lock (database) 195 lock (m_dbLock)
229 { 196 {
230 database.CheckConnection(); 197 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
198 {
199 dbcon.Open();
231 200
232 MySqlCommand result = 201 using (MySqlCommand result = new MySqlCommand(
233 new MySqlCommand( 202 "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", dbcon))
234 "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", 203 {
235 database.Connection); 204 result.Parameters.AddWithValue("?uuid", user.ToString());
236 result.Parameters.AddWithValue("?uuid", user.ToString()); 205 result.Parameters.AddWithValue("?zero", UUID.Zero.ToString());
237 result.Parameters.AddWithValue("?zero", UUID.Zero.ToString());
238 206
239 MySqlDataReader reader = result.ExecuteReader(); 207 using (MySqlDataReader reader = result.ExecuteReader())
208 {
209 List<InventoryFolderBase> items = new List<InventoryFolderBase>();
210 while (reader.Read())
211 items.Add(readInventoryFolder(reader));
240 212
241 List<InventoryFolderBase> items = new List<InventoryFolderBase>(); 213 InventoryFolderBase rootFolder = null;
242 while (reader.Read())
243 items.Add(readInventoryFolder(reader));
244 214
245 InventoryFolderBase rootFolder = null; 215 // There should only ever be one root folder for a user. However, if there's more
216 // than one we'll simply use the first one rather than failing. It would be even
217 // nicer to print some message to this effect, but this feels like it's too low a
218 // to put such a message out, and it's too minor right now to spare the time to
219 // suitably refactor.
220 if (items.Count > 0)
221 rootFolder = items[0];
246 222
247 // There should only ever be one root folder for a user. However, if there's more 223 return rootFolder;
248 // than one we'll simply use the first one rather than failing. It would be even 224 }
249 // nicer to print some message to this effect, but this feels like it's too low a 225 }
250 // to put such a message out, and it's too minor right now to spare the time to
251 // suitably refactor.
252 if (items.Count > 0)
253 {
254 rootFolder = items[0];
255 } 226 }
256
257 reader.Close();
258 result.Dispose();
259
260 return rootFolder;
261 } 227 }
262 } 228 }
263 catch (Exception e) 229 catch (Exception e)
264 { 230 {
265 database.Reconnect(); 231 m_log.Error(e.Message, e);
266 m_log.Error(e.ToString()); 232 return null;
267 throw;
268 } 233 }
269 } 234 }
270 235
@@ -279,31 +244,31 @@ namespace OpenSim.Data.MySQL
279 { 244 {
280 try 245 try
281 { 246 {
282 lock (database) 247 lock (m_dbLock)
283 { 248 {
284 database.CheckConnection(); 249 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
285 250 {
286 MySqlCommand result = 251 dbcon.Open();
287 new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid",
288 database.Connection);
289 result.Parameters.AddWithValue("?uuid", parentID.ToString());
290 MySqlDataReader reader = result.ExecuteReader();
291 252
292 List<InventoryFolderBase> items = new List<InventoryFolderBase>(); 253 using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", dbcon))
254 {
255 result.Parameters.AddWithValue("?uuid", parentID.ToString());
256 using (MySqlDataReader reader = result.ExecuteReader())
257 {
258 List<InventoryFolderBase> items = new List<InventoryFolderBase>();
293 259
294 while (reader.Read()) 260 while (reader.Read())
295 items.Add(readInventoryFolder(reader)); 261 items.Add(readInventoryFolder(reader));
296 262
297 reader.Close(); 263 return items;
298 result.Dispose(); 264 }
299 265 }
300 return items; 266 }
301 } 267 }
302 } 268 }
303 catch (Exception e) 269 catch (Exception e)
304 { 270 {
305 database.Reconnect(); 271 m_log.Error(e.Message, e);
306 m_log.Error(e.ToString());
307 return null; 272 return null;
308 } 273 }
309 } 274 }
@@ -378,29 +343,31 @@ namespace OpenSim.Data.MySQL
378 { 343 {
379 try 344 try
380 { 345 {
381 lock (database) 346 lock (m_dbLock)
382 { 347 {
383 database.CheckConnection(); 348 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
384 349 {
385 MySqlCommand result = 350 dbcon.Open();
386 new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection);
387 result.Parameters.AddWithValue("?uuid", itemID.ToString());
388 MySqlDataReader reader = result.ExecuteReader();
389 351
390 InventoryItemBase item = null; 352 using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", dbcon))
391 if (reader.Read()) 353 {
392 item = readInventoryItem(reader); 354 result.Parameters.AddWithValue("?uuid", itemID.ToString());
393 355
394 reader.Close(); 356 using (MySqlDataReader reader = result.ExecuteReader())
395 result.Dispose(); 357 {
358 InventoryItemBase item = null;
359 if (reader.Read())
360 item = readInventoryItem(reader);
396 361
397 return item; 362 return item;
363 }
364 }
365 }
398 } 366 }
399 } 367 }
400 catch (Exception e) 368 catch (Exception e)
401 { 369 {
402 database.Reconnect(); 370 m_log.Error(e.Message, e);
403 m_log.Error(e.ToString());
404 } 371 }
405 return null; 372 return null;
406 } 373 }
@@ -425,7 +392,7 @@ namespace OpenSim.Data.MySQL
425 } 392 }
426 catch (Exception e) 393 catch (Exception e)
427 { 394 {
428 m_log.Error(e.ToString()); 395 m_log.Error(e.Message, e);
429 } 396 }
430 397
431 return null; 398 return null;
@@ -441,151 +408,35 @@ namespace OpenSim.Data.MySQL
441 { 408 {
442 try 409 try
443 { 410 {
444 lock (database) 411 lock (m_dbLock)
445 { 412 {
446 database.CheckConnection(); 413 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
414 {
415 dbcon.Open();
447 416
448 MySqlCommand result = 417 using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", dbcon))
449 new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection); 418 {
450 result.Parameters.AddWithValue("?uuid", folderID.ToString()); 419 result.Parameters.AddWithValue("?uuid", folderID.ToString());
451 MySqlDataReader reader = result.ExecuteReader();
452 420
453 InventoryFolderBase folder = null; 421 using (MySqlDataReader reader = result.ExecuteReader())
454 if (reader.Read()) 422 {
455 folder = readInventoryFolder(reader); 423 InventoryFolderBase folder = null;
456 reader.Close(); 424 if (reader.Read())
457 result.Dispose(); 425 folder = readInventoryFolder(reader);
458 426
459 return folder; 427 return folder;
428 }
429 }
430 }
460 } 431 }
461 } 432 }
462 catch (Exception e) 433 catch (Exception e)
463 { 434 {
464 database.Reconnect(); 435 m_log.Error(e.Message, e);
465 m_log.Error(e.ToString());
466 return null; 436 return null;
467 } 437 }
468 } 438 }
469 439
470 #region Inventory Rollback-via-.sql Support
471 /// <summary>
472 /// Not a good SQL escape function, but it'll do the job (if mutilate the data.)
473 /// Someone may want to write something better here.
474 /// </summary>
475 /// <param name="str"></param>
476 /// <returns></returns>
477 private static string cheapSQLescape(string str)
478 {
479 str = str.Replace("\\", "");
480 str = str.Replace("'", "");
481 str = str.Replace("\"", "");
482 return "'" + str + "'";
483 }
484
485 private static string InventoryItemToSql(InventoryItemBase item)
486 {
487 string sql =
488 "REPLACE /*! INVITEM AT ***$SUBS$*** */ INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName"
489 + ", inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType"
490 + ", creatorID, inventoryBasePermissions, inventoryEveryOnePermissions, inventoryGroupPermissions, salePrice, saleType"
491 + ", creationDate, groupID, groupOwned, flags) VALUES ";
492 sql +=
493 "(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription"
494 + ", ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID"
495 + ", ?inventoryBasePermissions, ?inventoryEveryOnePermissions, ?inventoryGroupPermissions, ?salePrice, ?saleType, ?creationDate"
496 + ", ?groupID, ?groupOwned, ?flags);\r\n";
497
498 string itemName = item.Name;
499 string itemDesc = item.Description;
500
501 sql = sql.Replace("$SUBS$", Util.UnixTimeSinceEpoch().ToString());
502
503 sql = sql.Replace("?inventoryID", cheapSQLescape(item.ID.ToString()));
504 sql = sql.Replace("?assetID", cheapSQLescape(item.AssetID.ToString()));
505 sql = sql.Replace("?assetType", cheapSQLescape(item.AssetType.ToString()));
506 sql = sql.Replace("?parentFolderID", cheapSQLescape(item.Folder.ToString()));
507 sql = sql.Replace("?avatarID", cheapSQLescape(item.Owner.ToString()));
508 sql = sql.Replace("?inventoryName", cheapSQLescape(itemName));
509 sql = sql.Replace("?inventoryDescription", cheapSQLescape(itemDesc));
510 sql = sql.Replace("?inventoryNextPermissions", cheapSQLescape(item.NextPermissions.ToString()));
511 sql = sql.Replace("?inventoryCurrentPermissions", cheapSQLescape(item.CurrentPermissions.ToString()));
512 sql = sql.Replace("?invType", cheapSQLescape(item.InvType.ToString()));
513 sql = sql.Replace("?creatorID", cheapSQLescape(item.CreatorId));
514 sql = sql.Replace("?inventoryBasePermissions", cheapSQLescape(item.BasePermissions.ToString()));
515 sql = sql.Replace("?inventoryEveryOnePermissions", cheapSQLescape(item.EveryOnePermissions.ToString()));
516 sql = sql.Replace("?inventoryGroupPermissions", cheapSQLescape(item.GroupPermissions.ToString()));
517 sql = sql.Replace("?salePrice", cheapSQLescape(item.SalePrice.ToString()));
518 sql = sql.Replace("?saleType", cheapSQLescape(unchecked((sbyte)item.SaleType).ToString()));
519 sql = sql.Replace("?creationDate", cheapSQLescape(item.CreationDate.ToString()));
520 sql = sql.Replace("?groupID", cheapSQLescape(item.GroupID.ToString()));
521 sql = sql.Replace("?groupOwned", cheapSQLescape(item.GroupOwned.ToString()));
522 sql = sql.Replace("?flags", cheapSQLescape(item.Flags.ToString()));
523
524 return sql;
525 }
526
527 private static string InventoryFolderToSql(InventoryFolderBase folder)
528 {
529 string sql =
530 "REPLACE /*! INVFOLDER AT ***$SUBS$*** */ INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) VALUES ";
531 sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?type, ?version);\r\n";
532
533 string folderName = folder.Name;
534
535 sql = sql.Replace("$SUBS$", Util.UnixTimeSinceEpoch().ToString());
536
537 sql = sql.Replace("?folderID", cheapSQLescape(folder.ID.ToString()));
538 sql = sql.Replace("?agentID", cheapSQLescape(folder.Owner.ToString()));
539 sql = sql.Replace("?parentFolderID", cheapSQLescape(folder.ParentID.ToString()));
540 sql = sql.Replace("?folderName", cheapSQLescape(folderName));
541 sql = sql.Replace("?type", cheapSQLescape(folder.Type.ToString()));
542 sql = sql.Replace("?version", cheapSQLescape(folder.Version.ToString()));
543
544 return sql;
545 }
546
547 private static string getRollbackFolderDate()
548 {
549 return DateTime.UtcNow.Year.ToString() + "-" + DateTime.UtcNow.Month.ToString() + "-" +
550 DateTime.UtcNow.Day.ToString();
551 }
552
553 private void StoreRollbackItem(UUID ItemID)
554 {
555 if (rollbackStore == true)
556 {
557 string todaysPath = RollbackGetTodaysPath();
558
559 InventoryItemBase imb = getInventoryItem(ItemID);
560 string sql = InventoryItemToSql(imb);
561 File.AppendAllText(Path.Combine(todaysPath, imb.Owner.ToString()), sql);
562 }
563 }
564
565 private void StoreRollbackFolder(UUID FolderID)
566 {
567 if (rollbackStore == true)
568 {
569 string todaysPath = RollbackGetTodaysPath();
570
571 InventoryFolderBase ifb = getInventoryFolder(FolderID);
572 string sql = InventoryFolderToSql(ifb);
573 File.AppendAllText(Path.Combine(todaysPath, ifb.Owner.ToString()), sql);
574 }
575 }
576
577 private string RollbackGetTodaysPath()
578 {
579 if (!Directory.Exists(rollbackDir))
580 Directory.CreateDirectory(rollbackDir);
581
582 string todaysPath = Path.Combine(rollbackDir, getRollbackFolderDate());
583 if (!Directory.Exists(todaysPath))
584 Directory.CreateDirectory(todaysPath);
585 return todaysPath;
586 }
587 #endregion
588
589 /// <summary> 440 /// <summary>
590 /// Adds a specified item to the database 441 /// Adds a specified item to the database
591 /// </summary> 442 /// </summary>
@@ -619,46 +470,48 @@ namespace OpenSim.Data.MySQL
619 470
620 try 471 try
621 { 472 {
622 database.CheckConnection(); 473 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
623
624 MySqlCommand result = new MySqlCommand(sql, database.Connection);
625 result.Parameters.AddWithValue("?inventoryID", item.ID.ToString());
626 result.Parameters.AddWithValue("?assetID", item.AssetID.ToString());
627 result.Parameters.AddWithValue("?assetType", item.AssetType.ToString());
628 result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString());
629 result.Parameters.AddWithValue("?avatarID", item.Owner.ToString());
630 result.Parameters.AddWithValue("?inventoryName", itemName);
631 result.Parameters.AddWithValue("?inventoryDescription", itemDesc);
632 result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString());
633 result.Parameters.AddWithValue("?inventoryCurrentPermissions",
634 item.CurrentPermissions.ToString());
635 result.Parameters.AddWithValue("?invType", item.InvType);
636 result.Parameters.AddWithValue("?creatorID", item.CreatorId);
637 result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions);
638 result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions);
639 result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions);
640 result.Parameters.AddWithValue("?salePrice", item.SalePrice);
641 result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType));
642 result.Parameters.AddWithValue("?creationDate", item.CreationDate);
643 result.Parameters.AddWithValue("?groupID", item.GroupID);
644 result.Parameters.AddWithValue("?groupOwned", item.GroupOwned);
645 result.Parameters.AddWithValue("?flags", item.Flags);
646
647 lock (database)
648 { 474 {
649 result.ExecuteNonQuery(); 475 dbcon.Open();
650 } 476
477 MySqlCommand result = new MySqlCommand(sql, dbcon);
478 result.Parameters.AddWithValue("?inventoryID", item.ID.ToString());
479 result.Parameters.AddWithValue("?assetID", item.AssetID.ToString());
480 result.Parameters.AddWithValue("?assetType", item.AssetType.ToString());
481 result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString());
482 result.Parameters.AddWithValue("?avatarID", item.Owner.ToString());
483 result.Parameters.AddWithValue("?inventoryName", itemName);
484 result.Parameters.AddWithValue("?inventoryDescription", itemDesc);
485 result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString());
486 result.Parameters.AddWithValue("?inventoryCurrentPermissions",
487 item.CurrentPermissions.ToString());
488 result.Parameters.AddWithValue("?invType", item.InvType);
489 result.Parameters.AddWithValue("?creatorID", item.CreatorId);
490 result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions);
491 result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions);
492 result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions);
493 result.Parameters.AddWithValue("?salePrice", item.SalePrice);
494 result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType));
495 result.Parameters.AddWithValue("?creationDate", item.CreationDate);
496 result.Parameters.AddWithValue("?groupID", item.GroupID);
497 result.Parameters.AddWithValue("?groupOwned", item.GroupOwned);
498 result.Parameters.AddWithValue("?flags", item.Flags);
499
500 lock (m_dbLock)
501 {
502 result.ExecuteNonQuery();
503 }
651 504
652 result.Dispose(); 505 result.Dispose();
653 506
654 result = new MySqlCommand("update inventoryfolders set version=version+1 where folderID = ?folderID", database.Connection); 507 result = new MySqlCommand("update inventoryfolders set version=version+1 where folderID = ?folderID", dbcon);
655 result.Parameters.AddWithValue("?folderID", item.Folder.ToString 508 result.Parameters.AddWithValue("?folderID", item.Folder.ToString());
656()); 509 lock (m_dbLock)
657 lock (database) 510 {
658 { 511 result.ExecuteNonQuery();
659 result.ExecuteNonQuery(); 512 }
513 result.Dispose();
660 } 514 }
661 result.Dispose();
662 } 515 }
663 catch (MySqlException e) 516 catch (MySqlException e)
664 { 517 {
@@ -672,8 +525,6 @@ namespace OpenSim.Data.MySQL
672 /// <param name="item">Inventory item to update</param> 525 /// <param name="item">Inventory item to update</param>
673 public void updateInventoryItem(InventoryItemBase item) 526 public void updateInventoryItem(InventoryItemBase item)
674 { 527 {
675 StoreRollbackItem(item.ID);
676
677 addInventoryItem(item); 528 addInventoryItem(item);
678 } 529 }
679 530
@@ -683,25 +534,24 @@ namespace OpenSim.Data.MySQL
683 /// <param name="item">The inventory item UUID to delete</param> 534 /// <param name="item">The inventory item UUID to delete</param>
684 public void deleteInventoryItem(UUID itemID) 535 public void deleteInventoryItem(UUID itemID)
685 { 536 {
686 StoreRollbackItem(itemID);
687
688 try 537 try
689 { 538 {
690 database.CheckConnection(); 539 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
540 {
541 dbcon.Open();
691 542
692 MySqlCommand cmd = 543 MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", dbcon);
693 new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", database.Connection); 544 cmd.Parameters.AddWithValue("?uuid", itemID.ToString());
694 cmd.Parameters.AddWithValue("?uuid", itemID.ToString());
695 545
696 lock (database) 546 lock (m_dbLock)
697 { 547 {
698 cmd.ExecuteNonQuery(); 548 cmd.ExecuteNonQuery();
549 }
699 } 550 }
700 } 551 }
701 catch (MySqlException e) 552 catch (MySqlException e)
702 { 553 {
703 database.Reconnect(); 554 m_log.Error(e.Message, e);
704 m_log.Error(e.ToString());
705 } 555 }
706 } 556 }
707 557
@@ -732,26 +582,29 @@ namespace OpenSim.Data.MySQL
732 m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length + " to " + folderName.Length + " characters on add folder"); 582 m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length + " to " + folderName.Length + " characters on add folder");
733 } 583 }
734 584
735 database.CheckConnection(); 585 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
586 {
587 dbcon.Open();
736 588
737 MySqlCommand cmd = new MySqlCommand(sql, database.Connection); 589 MySqlCommand cmd = new MySqlCommand(sql, dbcon);
738 cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); 590 cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString());
739 cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); 591 cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString());
740 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); 592 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString());
741 cmd.Parameters.AddWithValue("?folderName", folderName); 593 cmd.Parameters.AddWithValue("?folderName", folderName);
742 cmd.Parameters.AddWithValue("?type", folder.Type); 594 cmd.Parameters.AddWithValue("?type", folder.Type);
743 cmd.Parameters.AddWithValue("?version", folder.Version); 595 cmd.Parameters.AddWithValue("?version", folder.Version);
744 596
745 try 597 try
746 {
747 lock (database)
748 { 598 {
749 cmd.ExecuteNonQuery(); 599 lock (m_dbLock)
600 {
601 cmd.ExecuteNonQuery();
602 }
603 }
604 catch (Exception e)
605 {
606 m_log.Error(e.ToString());
750 } 607 }
751 }
752 catch (Exception e)
753 {
754 m_log.Error(e.ToString());
755 } 608 }
756 } 609 }
757 610
@@ -761,7 +614,6 @@ namespace OpenSim.Data.MySQL
761 /// <param name="folder">Folder to update</param> 614 /// <param name="folder">Folder to update</param>
762 public void updateInventoryFolder(InventoryFolderBase folder) 615 public void updateInventoryFolder(InventoryFolderBase folder)
763 { 616 {
764 StoreRollbackFolder(folder.ID);
765 addInventoryFolder(folder); 617 addInventoryFolder(folder);
766 } 618 }
767 619
@@ -772,27 +624,28 @@ namespace OpenSim.Data.MySQL
772 /// <remarks>UPDATE inventoryfolders SET parentFolderID=?parentFolderID WHERE folderID=?folderID</remarks> 624 /// <remarks>UPDATE inventoryfolders SET parentFolderID=?parentFolderID WHERE folderID=?folderID</remarks>
773 public void moveInventoryFolder(InventoryFolderBase folder) 625 public void moveInventoryFolder(InventoryFolderBase folder)
774 { 626 {
775 StoreRollbackFolder(folder.ID);
776
777 string sql = 627 string sql =
778 "UPDATE inventoryfolders SET parentFolderID=?parentFolderID WHERE folderID=?folderID"; 628 "UPDATE inventoryfolders SET parentFolderID=?parentFolderID WHERE folderID=?folderID";
779 629
780 database.CheckConnection(); 630 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
631 {
632 dbcon.Open();
781 633
782 MySqlCommand cmd = new MySqlCommand(sql, database.Connection); 634 MySqlCommand cmd = new MySqlCommand(sql, dbcon);
783 cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); 635 cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString());
784 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); 636 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString());
785 637
786 try 638 try
787 {
788 lock (database)
789 { 639 {
790 cmd.ExecuteNonQuery(); 640 lock (m_dbLock)
641 {
642 cmd.ExecuteNonQuery();
643 }
644 }
645 catch (Exception e)
646 {
647 m_log.Error(e.ToString());
791 } 648 }
792 }
793 catch (Exception e)
794 {
795 m_log.Error(e.ToString());
796 } 649 }
797 } 650 }
798 651
@@ -836,95 +689,102 @@ namespace OpenSim.Data.MySQL
836 try 689 try
837 { 690 {
838 List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); 691 List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
839 Dictionary<UUID, List<InventoryFolderBase>> hashtable 692 Dictionary<UUID, List<InventoryFolderBase>> hashtable = new Dictionary<UUID, List<InventoryFolderBase>>(); ;
840 = new Dictionary<UUID, List<InventoryFolderBase>>(); ;
841 List<InventoryFolderBase> parentFolder = new List<InventoryFolderBase>(); 693 List<InventoryFolderBase> parentFolder = new List<InventoryFolderBase>();
842 lock (database) 694 bool buildResultsFromHashTable = false;
843 {
844 MySqlCommand result;
845 MySqlDataReader reader;
846 bool buildResultsFromHashTable = false;
847
848 database.CheckConnection();
849
850 /* Fetch the parent folder from the database to determine the agent ID, and if
851 * we're querying the root of the inventory folder tree */
852 result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid",
853 database.Connection);
854 result.Parameters.AddWithValue("?uuid", parentID.ToString());
855 reader = result.ExecuteReader();
856 while (reader.Read()) // Should be at most 1 result
857 parentFolder.Add(readInventoryFolder(reader));
858 reader.Close();
859 result.Dispose();
860 695
861 if (parentFolder.Count >= 1) // No result means parent folder does not exist 696 lock (m_dbLock)
697 {
698 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
862 { 699 {
863 if (parentFolder[0].ParentID == UUID.Zero) // We are querying the root folder 700 dbcon.Open();
701
702 /* Fetch the parent folder from the database to determine the agent ID, and if
703 * we're querying the root of the inventory folder tree */
704 using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", dbcon))
864 { 705 {
865 /* Get all of the agent's folders from the database, put them in a list and return it */ 706 result.Parameters.AddWithValue("?uuid", parentID.ToString());
866 result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", 707
867 database.Connection); 708 using (MySqlDataReader reader = result.ExecuteReader())
868 result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString());
869 reader = result.ExecuteReader();
870 while (reader.Read())
871 { 709 {
872 InventoryFolderBase curFolder = readInventoryFolder(reader); 710 // Should be at most 1 result
873 if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list 711 while (reader.Read())
874 folders.Add(curFolder); 712 parentFolder.Add(readInventoryFolder(reader));
875 } 713 }
876 reader.Close(); 714 }
877 result.Dispose(); 715
878 } // if we are querying the root folder 716 if (parentFolder.Count >= 1) // No result means parent folder does not exist
879 else // else we are querying a subtree of the inventory folder tree
880 { 717 {
881 /* Get all of the agent's folders from the database, put them all in a hash table 718 if (parentFolder[0].ParentID == UUID.Zero) // We are querying the root folder
882 * indexed by their parent ID */
883 result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid",
884 database.Connection);
885 result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString());
886 reader = result.ExecuteReader();
887 while (reader.Read())
888 { 719 {
889 InventoryFolderBase curFolder = readInventoryFolder(reader); 720 /* Get all of the agent's folders from the database, put them in a list and return it */
890 if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling 721 using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", dbcon))
891 hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list
892 else // else current folder has no known (yet) siblings
893 { 722 {
894 List<InventoryFolderBase> siblingList = new List<InventoryFolderBase>(); 723 result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString());
895 siblingList.Add(curFolder); 724
896 // Current folder has no known (yet) siblings 725 using (MySqlDataReader reader = result.ExecuteReader())
897 hashtable.Add(curFolder.ParentID, siblingList); 726 {
727 while (reader.Read())
728 {
729 InventoryFolderBase curFolder = readInventoryFolder(reader);
730 if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list
731 folders.Add(curFolder);
732 }
733 }
734 }
735 } // if we are querying the root folder
736 else // else we are querying a subtree of the inventory folder tree
737 {
738 /* Get all of the agent's folders from the database, put them all in a hash table
739 * indexed by their parent ID */
740 using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", dbcon))
741 {
742 result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString());
743
744 using (MySqlDataReader reader = result.ExecuteReader())
745 {
746 while (reader.Read())
747 {
748 InventoryFolderBase curFolder = readInventoryFolder(reader);
749 if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling
750 hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list
751 else // else current folder has no known (yet) siblings
752 {
753 List<InventoryFolderBase> siblingList = new List<InventoryFolderBase>();
754 siblingList.Add(curFolder);
755 // Current folder has no known (yet) siblings
756 hashtable.Add(curFolder.ParentID, siblingList);
757 }
758 } // while more items to read from the database
759 }
898 } 760 }
899 } // while more items to read from the database
900 reader.Close();
901 result.Dispose();
902 761
903 // Set flag so we know we need to build the results from the hash table after 762 // Set flag so we know we need to build the results from the hash table after
904 // we unlock the database 763 // we unlock the database
905 buildResultsFromHashTable = true; 764 buildResultsFromHashTable = true;
906 765
907 } // else we are querying a subtree of the inventory folder tree 766 } // else we are querying a subtree of the inventory folder tree
908 } // if folder parentID exists 767 } // if folder parentID exists
909 768
910 if (buildResultsFromHashTable) 769 if (buildResultsFromHashTable)
911 { 770 {
912 /* We have all of the user's folders stored in a hash table indexed by their parent ID 771 /* We have all of the user's folders stored in a hash table indexed by their parent ID
913 * and we need to return the requested subtree. We will build the requested subtree 772 * and we need to return the requested subtree. We will build the requested subtree
914 * by performing a breadth-first-search on the hash table */ 773 * by performing a breadth-first-search on the hash table */
915 if (hashtable.ContainsKey(parentID)) 774 if (hashtable.ContainsKey(parentID))
916 folders.AddRange(hashtable[parentID]); 775 folders.AddRange(hashtable[parentID]);
917 for (int i = 0; i < folders.Count; i++) // **Note: folders.Count is *not* static 776 for (int i = 0; i < folders.Count; i++) // **Note: folders.Count is *not* static
918 if (hashtable.ContainsKey(folders[i].ID)) 777 if (hashtable.ContainsKey(folders[i].ID))
919 folders.AddRange(hashtable[folders[i].ID]); 778 folders.AddRange(hashtable[folders[i].ID]);
779 }
920 } 780 }
921 } // lock (database) 781 } // lock (database)
782
922 return folders; 783 return folders;
923 } 784 }
924 catch (Exception e) 785 catch (Exception e)
925 { 786 {
926 database.Reconnect(); 787 m_log.Error(e.Message, e);
927 m_log.Error(e.ToString());
928 return null; 788 return null;
929 } 789 }
930 } 790 }
@@ -935,25 +795,24 @@ namespace OpenSim.Data.MySQL
935 /// <param name="folderID">the folder UUID</param> 795 /// <param name="folderID">the folder UUID</param>
936 protected void deleteOneFolder(UUID folderID) 796 protected void deleteOneFolder(UUID folderID)
937 { 797 {
938 StoreRollbackFolder(folderID);
939
940 try 798 try
941 { 799 {
942 database.CheckConnection(); 800 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
801 {
802 dbcon.Open();
943 803
944 MySqlCommand cmd = 804 using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", dbcon))
945 new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); 805 {
946 cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); 806 cmd.Parameters.AddWithValue("?uuid", folderID.ToString());
947 807
948 lock (database) 808 lock (m_dbLock)
949 { 809 cmd.ExecuteNonQuery();
950 cmd.ExecuteNonQuery(); 810 }
951 } 811 }
952 } 812 }
953 catch (MySqlException e) 813 catch (MySqlException e)
954 { 814 {
955 database.Reconnect(); 815 m_log.Error(e.Message, e);
956 m_log.Error(e.ToString());
957 } 816 }
958 } 817 }
959 818
@@ -963,30 +822,23 @@ namespace OpenSim.Data.MySQL
963 /// <param name="folderID">the folder UUID</param> 822 /// <param name="folderID">the folder UUID</param>
964 protected void deleteItemsInFolder(UUID folderID) 823 protected void deleteItemsInFolder(UUID folderID)
965 { 824 {
966 if (rollbackStore)
967 {
968 foreach (InventoryItemBase itemBase in getInventoryInFolder(folderID))
969 {
970 StoreRollbackItem(itemBase.ID);
971 }
972 }
973
974 try 825 try
975 { 826 {
976 database.CheckConnection(); 827 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
828 {
829 dbcon.Open();
977 830
978 MySqlCommand cmd = 831 using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", dbcon))
979 new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); 832 {
980 cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); 833 cmd.Parameters.AddWithValue("?uuid", folderID.ToString());
981 834
982 lock (database) 835 lock (m_dbLock)
983 { 836 cmd.ExecuteNonQuery();
984 cmd.ExecuteNonQuery(); 837 }
985 } 838 }
986 } 839 }
987 catch (MySqlException e) 840 catch (MySqlException e)
988 { 841 {
989 database.Reconnect();
990 m_log.Error(e.ToString()); 842 m_log.Error(e.ToString());
991 } 843 }
992 } 844 }
@@ -999,80 +851,53 @@ namespace OpenSim.Data.MySQL
999 { 851 {
1000 List<InventoryFolderBase> subFolders = getFolderHierarchy(folderID); 852 List<InventoryFolderBase> subFolders = getFolderHierarchy(folderID);
1001 853
1002 // Dont delete in OGM - makes for easier restores if someone sends a malcious command. (just restore the folder entry) 854 //Delete all sub-folders
1003 if (opengridmode == false) 855 foreach (InventoryFolderBase f in subFolders)
1004 { 856 {
1005 //Delete all sub-folders 857 deleteOneFolder(f.ID);
1006 foreach (InventoryFolderBase f in subFolders) 858 deleteItemsInFolder(f.ID);
1007 {
1008 StoreRollbackFolder(f.ID);
1009 deleteOneFolder(f.ID);
1010
1011 if (rollbackStore)
1012 {
1013 foreach (InventoryItemBase itemBase in getInventoryInFolder(f.ID))
1014 {
1015 StoreRollbackItem(itemBase.ID);
1016 }
1017 }
1018 deleteItemsInFolder(f.ID);
1019 }
1020 } 859 }
1021 860
1022 StoreRollbackFolder(folderID);
1023 //Delete the actual row 861 //Delete the actual row
1024 deleteOneFolder(folderID); 862 deleteOneFolder(folderID);
1025 863 deleteItemsInFolder(folderID);
1026 // Just delete the folder context in OGM
1027 if (opengridmode == false)
1028 {
1029 if (rollbackStore)
1030 {
1031 foreach (InventoryItemBase itemBase in getInventoryInFolder(folderID))
1032 {
1033 StoreRollbackItem(itemBase.ID);
1034 }
1035 }
1036 deleteItemsInFolder(folderID);
1037 }
1038 } 864 }
1039 865
1040 public List<InventoryItemBase> fetchActiveGestures(UUID avatarID) 866 public List<InventoryItemBase> fetchActiveGestures(UUID avatarID)
1041 { 867 {
1042 MySqlDataReader result = null; 868 lock (m_dbLock)
1043 MySqlCommand sqlCmd = null;
1044 lock (database)
1045 { 869 {
1046 try 870 try
1047 { 871 {
1048 database.CheckConnection(); 872 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
1049 sqlCmd = new MySqlCommand(
1050 "SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1",
1051 database.Connection);
1052 sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString());
1053 sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture);
1054 result = sqlCmd.ExecuteReader();
1055
1056 List<InventoryItemBase> list = new List<InventoryItemBase>();
1057 while (result.Read())
1058 { 873 {
1059 InventoryItemBase item = readInventoryItem(result); 874 dbcon.Open();
1060 if (item != null) 875
1061 list.Add(item); 876 using (MySqlCommand sqlCmd = new MySqlCommand(
877 "SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1", dbcon))
878 {
879 sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString());
880 sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture);
881
882 using (MySqlDataReader result = sqlCmd.ExecuteReader())
883 {
884 List<InventoryItemBase> list = new List<InventoryItemBase>();
885 while (result.Read())
886 {
887 InventoryItemBase item = readInventoryItem(result);
888 if (item != null)
889 list.Add(item);
890 }
891 return list;
892 }
893 }
1062 } 894 }
1063 return list;
1064 } 895 }
1065 catch (Exception e) 896 catch (Exception e)
1066 { 897 {
1067 database.Reconnect(); 898 m_log.Error(e.Message, e);
1068 m_log.Error(e.ToString());
1069 return null; 899 return null;
1070 } 900 }
1071 finally
1072 {
1073 if (result != null) result.Close();
1074 if (sqlCmd != null) sqlCmd.Dispose();
1075 }
1076 } 901 }
1077 } 902 }
1078 } 903 }