aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MSSQL
diff options
context:
space:
mode:
authorMelanie2012-11-09 22:58:42 +0000
committerMelanie2012-11-09 22:58:42 +0000
commit415b89f434657fe4cbf62a5c99f24c2648a313ac (patch)
tree48d7e97cc64a4351755942745a9a8f65d52b5322 /OpenSim/Data/MSSQL
parentMerge branch 'master' into careminster (diff)
parentllSetLinkCamera implementation (diff)
downloadopensim-SC_OLD-415b89f434657fe4cbf62a5c99f24c2648a313ac.zip
opensim-SC_OLD-415b89f434657fe4cbf62a5c99f24c2648a313ac.tar.gz
opensim-SC_OLD-415b89f434657fe4cbf62a5c99f24c2648a313ac.tar.bz2
opensim-SC_OLD-415b89f434657fe4cbf62a5c99f24c2648a313ac.tar.xz
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Data/MSSQL')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLXInventoryData.cs128
1 files changed, 86 insertions, 42 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
index a1069c6..1bc6e3c 100644
--- a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
@@ -43,12 +43,12 @@ namespace OpenSim.Data.MSSQL
43 private static readonly ILog m_log = LogManager.GetLogger( 43 private static readonly ILog m_log = LogManager.GetLogger(
44 MethodBase.GetCurrentMethod().DeclaringType); 44 MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 private MSSQLGenericTableHandler<XInventoryFolder> m_Folders; 46 private MSSQLFolderHandler m_Folders;
47 private MSSQLItemHandler m_Items; 47 private MSSQLItemHandler m_Items;
48 48
49 public MSSQLXInventoryData(string conn, string realm) 49 public MSSQLXInventoryData(string conn, string realm)
50 { 50 {
51 m_Folders = new MSSQLGenericTableHandler<XInventoryFolder>( 51 m_Folders = new MSSQLFolderHandler(
52 conn, "inventoryfolders", "InventoryStore"); 52 conn, "inventoryfolders", "InventoryStore");
53 m_Items = new MSSQLItemHandler( 53 m_Items = new MSSQLItemHandler(
54 conn, "inventoryitems", String.Empty); 54 conn, "inventoryitems", String.Empty);
@@ -85,6 +85,7 @@ namespace OpenSim.Data.MSSQL
85 { 85 {
86 return m_Folders.Delete(field, val); 86 return m_Folders.Delete(field, val);
87 } 87 }
88
88 public bool DeleteFolders(string[] fields, string[] vals) 89 public bool DeleteFolders(string[] fields, string[] vals)
89 { 90 {
90 return m_Folders.Delete(fields, vals); 91 return m_Folders.Delete(fields, vals);
@@ -94,15 +95,22 @@ namespace OpenSim.Data.MSSQL
94 { 95 {
95 return m_Items.Delete(field, val); 96 return m_Items.Delete(field, val);
96 } 97 }
98
97 public bool DeleteItems(string[] fields, string[] vals) 99 public bool DeleteItems(string[] fields, string[] vals)
98 { 100 {
99 return m_Items.Delete(fields, vals); 101 return m_Items.Delete(fields, vals);
100 } 102 }
103
101 public bool MoveItem(string id, string newParent) 104 public bool MoveItem(string id, string newParent)
102 { 105 {
103 return m_Items.MoveItem(id, newParent); 106 return m_Items.MoveItem(id, newParent);
104 } 107 }
105 108
109 public bool MoveFolder(string id, string newParent)
110 {
111 return m_Folders.MoveFolder(id, newParent);
112 }
113
106 public XInventoryItem[] GetActiveGestures(UUID principalID) 114 public XInventoryItem[] GetActiveGestures(UUID principalID)
107 { 115 {
108 return m_Items.GetActiveGestures(principalID); 116 return m_Items.GetActiveGestures(principalID);
@@ -124,79 +132,115 @@ namespace OpenSim.Data.MSSQL
124 public bool MoveItem(string id, string newParent) 132 public bool MoveItem(string id, string newParent)
125 { 133 {
126 using (SqlConnection conn = new SqlConnection(m_ConnectionString)) 134 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
127 using (SqlCommand cmd = new SqlCommand())
128 { 135 {
136 using (SqlCommand cmd = new SqlCommand())
137 {
129 138
130 cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where inventoryID = @InventoryID", m_Realm); 139 cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where inventoryID = @InventoryID", m_Realm);
131 cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParent)); 140 cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParent));
132 cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id)); 141 cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id));
133 cmd.Connection = conn; 142 cmd.Connection = conn;
134 conn.Open(); 143 conn.Open();
135 return cmd.ExecuteNonQuery() == 0 ? false : true; 144 return cmd.ExecuteNonQuery() == 0 ? false : true;
145 }
136 } 146 }
137 } 147 }
138 148
139 public XInventoryItem[] GetActiveGestures(UUID principalID) 149 public XInventoryItem[] GetActiveGestures(UUID principalID)
140 { 150 {
141 using (SqlConnection conn = new SqlConnection(m_ConnectionString)) 151 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
142 using (SqlCommand cmd = new SqlCommand())
143 { 152 {
144 cmd.CommandText = String.Format("select * from inventoryitems where avatarId = @uuid and assetType = @type and flags = 1", m_Realm); 153 using (SqlCommand cmd = new SqlCommand())
154 {
155 cmd.CommandText = String.Format("select * from inventoryitems where avatarId = @uuid and assetType = @type and flags = 1", m_Realm);
145 156
146 cmd.Parameters.Add(m_database.CreateParameter("@uuid", principalID.ToString())); 157 cmd.Parameters.Add(m_database.CreateParameter("@uuid", principalID.ToString()));
147 cmd.Parameters.Add(m_database.CreateParameter("@type", (int)AssetType.Gesture)); 158 cmd.Parameters.Add(m_database.CreateParameter("@type", (int)AssetType.Gesture));
148 cmd.Connection = conn; 159 cmd.Connection = conn;
149 conn.Open(); 160 conn.Open();
150 return DoQuery(cmd); 161 return DoQuery(cmd);
162 }
151 } 163 }
152 } 164 }
153 165
154 public int GetAssetPermissions(UUID principalID, UUID assetID) 166 public int GetAssetPermissions(UUID principalID, UUID assetID)
155 { 167 {
156 using (SqlConnection conn = new SqlConnection(m_ConnectionString)) 168 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
157 using (SqlCommand cmd = new SqlCommand())
158 { 169 {
159 cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = @PrincipalID and assetID = @AssetID group by assetID", m_Realm); 170 using (SqlCommand cmd = new SqlCommand())
160 cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString()));
161 cmd.Parameters.Add(m_database.CreateParameter("@AssetID", assetID.ToString()));
162 cmd.Connection = conn;
163 conn.Open();
164 using (SqlDataReader reader = cmd.ExecuteReader())
165 { 171 {
172 cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = @PrincipalID and assetID = @AssetID group by assetID", m_Realm);
173 cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString()));
174 cmd.Parameters.Add(m_database.CreateParameter("@AssetID", assetID.ToString()));
175 cmd.Connection = conn;
176 conn.Open();
177 using (SqlDataReader reader = cmd.ExecuteReader())
178 {
166 179
167 int perms = 0; 180 int perms = 0;
168 181
169 if (reader.Read()) 182 if (reader.Read())
170 { 183 {
171 perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]); 184 perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]);
185 }
186
187 return perms;
172 } 188 }
173 189
174 return perms;
175 } 190 }
176
177 } 191 }
178 } 192 }
193
179 public override bool Store(XInventoryItem item) 194 public override bool Store(XInventoryItem item)
180 { 195 {
181 if (!base.Store(item)) 196 if (!base.Store(item))
182 return false; 197 return false;
198
183 string sql = "update inventoryfolders set version=version+1 where folderID = @folderID"; 199 string sql = "update inventoryfolders set version=version+1 where folderID = @folderID";
184 using (SqlConnection conn = new SqlConnection(m_ConnectionString)) 200 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
185 using (SqlCommand cmd = new SqlCommand(sql, conn))
186 { 201 {
187 conn.Open(); 202 using (SqlCommand cmd = new SqlCommand(sql, conn))
203 {
204 conn.Open();
205
206 cmd.Parameters.AddWithValue("@folderID", item.parentFolderID.ToString());
207 try
208 {
209 cmd.ExecuteNonQuery();
210 }
211 catch (Exception)
212 {
213 return false;
214 }
215 }
216
217 return true;
218 }
219 }
220 }
221
222 public class MSSQLFolderHandler : MSSQLGenericTableHandler<XInventoryFolder>
223 {
224 public MSSQLFolderHandler(string c, string t, string m) :
225 base(c, t, m)
226 {
227 }
228
229 public bool MoveFolder(string id, string newParentFolderID)
230 {
231 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
232 {
233 using (SqlCommand cmd = new SqlCommand())
234 {
188 235
189 cmd.Parameters.AddWithValue("@folderID", item.parentFolderID.ToString()); 236 cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where folderID = @folderID", m_Realm);
190 try 237 cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParentFolderID));
191 { 238 cmd.Parameters.Add(m_database.CreateParameter("@folderID", id));
192 cmd.ExecuteNonQuery(); 239 cmd.Connection = conn;
193 } 240 conn.Open();
194 catch (Exception) 241 return cmd.ExecuteNonQuery() == 0 ? false : true;
195 { 242 }
196 return false;
197 }
198 } 243 }
199 return true;
200 } 244 }
201 } 245 }
202} 246} \ No newline at end of file