aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/MSSQL/MSSQLXInventoryData.cs')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLXInventoryData.cs116
1 files changed, 102 insertions, 14 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
index 1bc6e3c..eb636cf 100644
--- a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
@@ -131,6 +131,12 @@ namespace OpenSim.Data.MSSQL
131 131
132 public bool MoveItem(string id, string newParent) 132 public bool MoveItem(string id, string newParent)
133 { 133 {
134 XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id });
135 if (retrievedItems.Length == 0)
136 return false;
137
138 UUID oldParent = retrievedItems[0].parentFolderID;
139
134 using (SqlConnection conn = new SqlConnection(m_ConnectionString)) 140 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
135 { 141 {
136 using (SqlCommand cmd = new SqlCommand()) 142 using (SqlCommand cmd = new SqlCommand())
@@ -141,9 +147,16 @@ namespace OpenSim.Data.MSSQL
141 cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id)); 147 cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id));
142 cmd.Connection = conn; 148 cmd.Connection = conn;
143 conn.Open(); 149 conn.Open();
144 return cmd.ExecuteNonQuery() == 0 ? false : true; 150
151 if (cmd.ExecuteNonQuery() == 0)
152 return false;
145 } 153 }
146 } 154 }
155
156 IncrementFolderVersion(oldParent);
157 IncrementFolderVersion(newParent);
158
159 return true;
147 } 160 }
148 161
149 public XInventoryItem[] GetActiveGestures(UUID principalID) 162 public XInventoryItem[] GetActiveGestures(UUID principalID)
@@ -196,26 +209,43 @@ namespace OpenSim.Data.MSSQL
196 if (!base.Store(item)) 209 if (!base.Store(item))
197 return false; 210 return false;
198 211
199 string sql = "update inventoryfolders set version=version+1 where folderID = @folderID"; 212 IncrementFolderVersion(item.parentFolderID);
213
214 return true;
215 }
216
217 private bool IncrementFolderVersion(UUID folderID)
218 {
219 return IncrementFolderVersion(folderID.ToString());
220 }
221
222 private bool IncrementFolderVersion(string folderID)
223 {
224// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
225// Util.PrintCallStack();
226
227 string sql = "update inventoryfolders set version=version+1 where folderID = ?folderID";
228
200 using (SqlConnection conn = new SqlConnection(m_ConnectionString)) 229 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
201 { 230 {
202 using (SqlCommand cmd = new SqlCommand(sql, conn)) 231 using (SqlCommand cmd = new SqlCommand(sql, conn))
203 { 232 {
204 conn.Open(); 233 conn.Open();
205 234
206 cmd.Parameters.AddWithValue("@folderID", item.parentFolderID.ToString()); 235 cmd.Parameters.AddWithValue("@folderID", folderID);
207 try
208 {
209 cmd.ExecuteNonQuery();
210 }
211 catch (Exception)
212 {
213 return false;
214 }
215 }
216 236
217 return true; 237 try
238 {
239 cmd.ExecuteNonQuery();
240 }
241 catch (Exception)
242 {
243 return false;
244 }
245 }
218 } 246 }
247
248 return true;
219 } 249 }
220 } 250 }
221 251
@@ -228,6 +258,13 @@ namespace OpenSim.Data.MSSQL
228 258
229 public bool MoveFolder(string id, string newParentFolderID) 259 public bool MoveFolder(string id, string newParentFolderID)
230 { 260 {
261 XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id });
262
263 if (folders.Length == 0)
264 return false;
265
266 UUID oldParentFolderUUID = folders[0].parentFolderID;
267
231 using (SqlConnection conn = new SqlConnection(m_ConnectionString)) 268 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
232 { 269 {
233 using (SqlCommand cmd = new SqlCommand()) 270 using (SqlCommand cmd = new SqlCommand())
@@ -238,9 +275,60 @@ namespace OpenSim.Data.MSSQL
238 cmd.Parameters.Add(m_database.CreateParameter("@folderID", id)); 275 cmd.Parameters.Add(m_database.CreateParameter("@folderID", id));
239 cmd.Connection = conn; 276 cmd.Connection = conn;
240 conn.Open(); 277 conn.Open();
241 return cmd.ExecuteNonQuery() == 0 ? false : true; 278
279 if (cmd.ExecuteNonQuery() == 0)
280 return false;
242 } 281 }
243 } 282 }
283
284 IncrementFolderVersion(oldParentFolderUUID);
285 IncrementFolderVersion(newParentFolderID);
286
287 return true;
288 }
289
290 public override bool Store(XInventoryFolder folder)
291 {
292 if (!base.Store(folder))
293 return false;
294
295 IncrementFolderVersion(folder.parentFolderID);
296
297 return true;
298 }
299
300 private bool IncrementFolderVersion(UUID folderID)
301 {
302 return IncrementFolderVersion(folderID.ToString());
303 }
304
305 private bool IncrementFolderVersion(string folderID)
306 {
307// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
308// Util.PrintCallStack();
309
310 string sql = "update inventoryfolders set version=version+1 where folderID = ?folderID";
311
312 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
313 {
314 using (SqlCommand cmd = new SqlCommand(sql, conn))
315 {
316 conn.Open();
317
318 cmd.Parameters.AddWithValue("@folderID", folderID);
319
320 try
321 {
322 cmd.ExecuteNonQuery();
323 }
324 catch (Exception)
325 {
326 return false;
327 }
328 }
329 }
330
331 return true;
244 } 332 }
245 } 333 }
246} \ No newline at end of file 334} \ No newline at end of file