aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLManager.cs
diff options
context:
space:
mode:
authorMelanie Thielker2008-08-18 17:22:36 +0000
committerMelanie Thielker2008-08-18 17:22:36 +0000
commit05506cff499b999d6c01e0517e658293b4791317 (patch)
treec0990ac8347181cbec66bd4adc61c6af3b486b4d /OpenSim/Data/MySQL/MySQLManager.cs
parentMantis#1992. Thank you kindly, ChrisDown for a patch that: (diff)
downloadopensim-SC-05506cff499b999d6c01e0517e658293b4791317.zip
opensim-SC-05506cff499b999d6c01e0517e658293b4791317.tar.gz
opensim-SC-05506cff499b999d6c01e0517e658293b4791317.tar.bz2
opensim-SC-05506cff499b999d6c01e0517e658293b4791317.tar.xz
Avatar Attachment persistence!! Patch #9168 (Mantis #1171)
Plumbs in attachment persistence and adds the tables. Currently MySQL only, no user functionality yet.
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLManager.cs')
-rw-r--r--OpenSim/Data/MySQL/MySQLManager.cs51
1 files changed, 51 insertions, 0 deletions
diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs
index 6ad6609..3a62ec2 100644
--- a/OpenSim/Data/MySQL/MySQLManager.cs
+++ b/OpenSim/Data/MySQL/MySQLManager.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Collections;
30using System.Data; 31using System.Data;
31using System.IO; 32using System.IO;
32using System.Reflection; 33using System.Reflection;
@@ -660,6 +661,26 @@ namespace OpenSim.Data.MySQL
660 } 661 }
661 662
662 663
664 // Read attachment list from data reader
665 public Hashtable readAttachments(IDataReader r)
666 {
667 Hashtable ret = new Hashtable();
668
669 while(r.Read())
670 {
671 int attachpoint = Convert.ToInt32(r["attachpoint"]);
672 if(ret.ContainsKey(attachpoint))
673 continue;
674 Hashtable item = new Hashtable();
675 item.Add("item", r["item"].ToString());
676 item.Add("asset", r["asset"].ToString());
677
678 ret.Add(attachpoint, item);
679 }
680
681 return ret;
682 }
683
663 /// <summary> 684 /// <summary>
664 /// Inserts a new row into the log database 685 /// Inserts a new row into the log database
665 /// </summary> 686 /// </summary>
@@ -1176,5 +1197,35 @@ namespace OpenSim.Data.MySQL
1176 1197
1177 } 1198 }
1178 1199
1200 public void writeAttachments(LLUUID agentID, Hashtable data)
1201 {
1202 string sql = "delete from avatarattachments where UUID = ?uuid";
1203
1204 MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand();
1205 cmd.CommandText = sql;
1206 cmd.Parameters.AddWithValue("?uuid", agentID.ToString());
1207
1208 cmd.ExecuteNonQuery();
1209
1210 sql = "insert into avatarattachments (UUID, attachpoint, item, asset) values (?uuid, ?attchpoint, ?item, ?asset)";
1211
1212 cmd = (MySqlCommand) dbcon.CreateCommand();
1213 cmd.CommandText = sql;
1214
1215 foreach(DictionaryEntry e in data)
1216 {
1217 int attachpoint = Convert.ToInt32(e.Key);
1218
1219 Hashtable item = (Hashtable)e.Value;
1220
1221 cmd.Parameters.Clear();
1222 cmd.Parameters.AddWithValue("?uuid", agentID.ToString());
1223 cmd.Parameters.AddWithValue("?attachpoint", attachpoint);
1224 cmd.Parameters.AddWithValue("?item", item["item"]);
1225 cmd.Parameters.AddWithValue("?asset", item["asset"]);
1226
1227 cmd.ExecuteNonQuery();
1228 }
1229 }
1179 } 1230 }
1180} 1231}