diff options
Diffstat (limited to 'OpenSim/Data')
25 files changed, 1017 insertions, 591 deletions
diff --git a/OpenSim/Data/IRegionData.cs b/OpenSim/Data/IRegionData.cs index 546b5e8..70e1065 100644 --- a/OpenSim/Data/IRegionData.cs +++ b/OpenSim/Data/IRegionData.cs | |||
@@ -85,21 +85,6 @@ namespace OpenSim.Data | |||
85 | List<RegionData> GetHyperlinks(UUID scopeID); | 85 | List<RegionData> GetHyperlinks(UUID scopeID); |
86 | } | 86 | } |
87 | 87 | ||
88 | [Flags] | ||
89 | public enum RegionFlags : int | ||
90 | { | ||
91 | DefaultRegion = 1, // Used for new Rez. Random if multiple defined | ||
92 | FallbackRegion = 2, // Regions we redirect to when the destination is down | ||
93 | RegionOnline = 4, // Set when a region comes online, unset when it unregisters and DeleteOnUnregister is false | ||
94 | NoDirectLogin = 8, // Region unavailable for direct logins (by name) | ||
95 | Persistent = 16, // Don't remove on unregister | ||
96 | LockedOut = 32, // Don't allow registration | ||
97 | NoMove = 64, // Don't allow moving this region | ||
98 | Reservation = 128, // This is an inactive reservation | ||
99 | Authenticate = 256, // Require authentication | ||
100 | Hyperlink = 512 // Record represents a HG link | ||
101 | } | ||
102 | |||
103 | public class RegionDataDistanceCompare : IComparer<RegionData> | 88 | public class RegionDataDistanceCompare : IComparer<RegionData> |
104 | { | 89 | { |
105 | private Vector2 m_origin; | 90 | private Vector2 m_origin; |
diff --git a/OpenSim/Data/IXInventoryData.cs b/OpenSim/Data/IXInventoryData.cs index 85a5c08..ca47506 100644 --- a/OpenSim/Data/IXInventoryData.cs +++ b/OpenSim/Data/IXInventoryData.cs | |||
@@ -40,6 +40,11 @@ namespace OpenSim.Data | |||
40 | public UUID folderID; | 40 | public UUID folderID; |
41 | public UUID agentID; | 41 | public UUID agentID; |
42 | public UUID parentFolderID; | 42 | public UUID parentFolderID; |
43 | |||
44 | public XInventoryFolder Clone() | ||
45 | { | ||
46 | return (XInventoryFolder)MemberwiseClone(); | ||
47 | } | ||
43 | } | 48 | } |
44 | 49 | ||
45 | public class XInventoryItem | 50 | public class XInventoryItem |
@@ -64,6 +69,11 @@ namespace OpenSim.Data | |||
64 | public UUID avatarID; | 69 | public UUID avatarID; |
65 | public UUID parentFolderID; | 70 | public UUID parentFolderID; |
66 | public int inventoryGroupPermissions; | 71 | public int inventoryGroupPermissions; |
72 | |||
73 | public XInventoryItem Clone() | ||
74 | { | ||
75 | return (XInventoryItem)MemberwiseClone(); | ||
76 | } | ||
67 | } | 77 | } |
68 | 78 | ||
69 | public interface IXInventoryData | 79 | public interface IXInventoryData |
@@ -106,7 +116,22 @@ namespace OpenSim.Data | |||
106 | /// <returns>true if the delete was successful, false if it was not</returns> | 116 | /// <returns>true if the delete was successful, false if it was not</returns> |
107 | bool DeleteItems(string[] fields, string[] vals); | 117 | bool DeleteItems(string[] fields, string[] vals); |
108 | 118 | ||
109 | bool MoveItem(string id, string newParent); | 119 | /// <summary> |
120 | /// Move an item to another folder. | ||
121 | /// </summary> | ||
122 | /// <returns>/returns> | ||
123 | /// <param name='id'>UUID of the item</param> | ||
124 | /// <param name='newParent'>UUID of the new parent folder.</param> | ||
125 | bool MoveItem(string id, string newParentFolderID); | ||
126 | |||
127 | /// <summary> | ||
128 | /// Move a folder to another folder. | ||
129 | /// </summary> | ||
130 | /// <returns>/returns> | ||
131 | /// <param name='id'>UUID of the item</param> | ||
132 | /// <param name='newParent'>UUID of the new parent folder.</param> | ||
133 | bool MoveFolder(string id, string newParentFolderID); | ||
134 | |||
110 | XInventoryItem[] GetActiveGestures(UUID principalID); | 135 | XInventoryItem[] GetActiveGestures(UUID principalID); |
111 | int GetAssetPermissions(UUID principalID, UUID assetID); | 136 | int GetAssetPermissions(UUID principalID, UUID assetID); |
112 | } | 137 | } |
diff --git a/OpenSim/Data/MSSQL/MSSQLRegionData.cs b/OpenSim/Data/MSSQL/MSSQLRegionData.cs index 3ae87c3..0d89706 100644 --- a/OpenSim/Data/MSSQL/MSSQLRegionData.cs +++ b/OpenSim/Data/MSSQL/MSSQLRegionData.cs | |||
@@ -37,6 +37,7 @@ using OpenMetaverse; | |||
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
40 | using RegionFlags = OpenSim.Framework.RegionFlags; | ||
40 | 41 | ||
41 | namespace OpenSim.Data.MSSQL | 42 | namespace OpenSim.Data.MSSQL |
42 | { | 43 | { |
diff --git a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs index a1069c6..e261aba 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); |
@@ -114,7 +122,7 @@ namespace OpenSim.Data.MSSQL | |||
114 | } | 122 | } |
115 | } | 123 | } |
116 | 124 | ||
117 | public class MSSQLItemHandler : MSSQLGenericTableHandler<XInventoryItem> | 125 | public class MSSQLItemHandler : MSSQLInventoryHandler<XInventoryItem> |
118 | { | 126 | { |
119 | public MSSQLItemHandler(string c, string t, string m) : | 127 | public MSSQLItemHandler(string c, string t, string m) : |
120 | base(c, t, m) | 128 | base(c, t, m) |
@@ -123,70 +131,163 @@ namespace OpenSim.Data.MSSQL | |||
123 | 131 | ||
124 | public bool MoveItem(string id, string newParent) | 132 | public bool MoveItem(string id, string newParent) |
125 | { | 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 | |||
126 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 140 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
127 | using (SqlCommand cmd = new SqlCommand()) | ||
128 | { | 141 | { |
142 | using (SqlCommand cmd = new SqlCommand()) | ||
143 | { | ||
144 | |||
145 | cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where inventoryID = @InventoryID", m_Realm); | ||
146 | cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParent)); | ||
147 | cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id)); | ||
148 | cmd.Connection = conn; | ||
149 | conn.Open(); | ||
129 | 150 | ||
130 | cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where inventoryID = @InventoryID", m_Realm); | 151 | if (cmd.ExecuteNonQuery() == 0) |
131 | cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParent)); | 152 | return false; |
132 | cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id)); | 153 | } |
133 | cmd.Connection = conn; | ||
134 | conn.Open(); | ||
135 | return cmd.ExecuteNonQuery() == 0 ? false : true; | ||
136 | } | 154 | } |
155 | |||
156 | IncrementFolderVersion(oldParent); | ||
157 | IncrementFolderVersion(newParent); | ||
158 | |||
159 | return true; | ||
137 | } | 160 | } |
138 | 161 | ||
139 | public XInventoryItem[] GetActiveGestures(UUID principalID) | 162 | public XInventoryItem[] GetActiveGestures(UUID principalID) |
140 | { | 163 | { |
141 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 164 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
142 | using (SqlCommand cmd = new SqlCommand()) | ||
143 | { | 165 | { |
144 | cmd.CommandText = String.Format("select * from inventoryitems where avatarId = @uuid and assetType = @type and flags = 1", m_Realm); | 166 | using (SqlCommand cmd = new SqlCommand()) |
167 | { | ||
168 | cmd.CommandText = String.Format("select * from inventoryitems where avatarId = @uuid and assetType = @type and flags = 1", m_Realm); | ||
145 | 169 | ||
146 | cmd.Parameters.Add(m_database.CreateParameter("@uuid", principalID.ToString())); | 170 | cmd.Parameters.Add(m_database.CreateParameter("@uuid", principalID.ToString())); |
147 | cmd.Parameters.Add(m_database.CreateParameter("@type", (int)AssetType.Gesture)); | 171 | cmd.Parameters.Add(m_database.CreateParameter("@type", (int)AssetType.Gesture)); |
148 | cmd.Connection = conn; | 172 | cmd.Connection = conn; |
149 | conn.Open(); | 173 | conn.Open(); |
150 | return DoQuery(cmd); | 174 | return DoQuery(cmd); |
175 | } | ||
151 | } | 176 | } |
152 | } | 177 | } |
153 | 178 | ||
154 | public int GetAssetPermissions(UUID principalID, UUID assetID) | 179 | public int GetAssetPermissions(UUID principalID, UUID assetID) |
155 | { | 180 | { |
156 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 181 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
157 | using (SqlCommand cmd = new SqlCommand()) | ||
158 | { | 182 | { |
159 | cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = @PrincipalID and assetID = @AssetID group by assetID", m_Realm); | 183 | 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 | { | 184 | { |
185 | cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = @PrincipalID and assetID = @AssetID group by assetID", m_Realm); | ||
186 | cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString())); | ||
187 | cmd.Parameters.Add(m_database.CreateParameter("@AssetID", assetID.ToString())); | ||
188 | cmd.Connection = conn; | ||
189 | conn.Open(); | ||
190 | using (SqlDataReader reader = cmd.ExecuteReader()) | ||
191 | { | ||
166 | 192 | ||
167 | int perms = 0; | 193 | int perms = 0; |
168 | 194 | ||
169 | if (reader.Read()) | 195 | if (reader.Read()) |
170 | { | 196 | { |
171 | perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]); | 197 | perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]); |
198 | } | ||
199 | |||
200 | return perms; | ||
172 | } | 201 | } |
173 | 202 | ||
174 | return perms; | ||
175 | } | 203 | } |
176 | |||
177 | } | 204 | } |
178 | } | 205 | } |
206 | |||
179 | public override bool Store(XInventoryItem item) | 207 | public override bool Store(XInventoryItem item) |
180 | { | 208 | { |
181 | if (!base.Store(item)) | 209 | if (!base.Store(item)) |
182 | return false; | 210 | return false; |
183 | string sql = "update inventoryfolders set version=version+1 where folderID = @folderID"; | 211 | |
212 | IncrementFolderVersion(item.parentFolderID); | ||
213 | |||
214 | return true; | ||
215 | } | ||
216 | } | ||
217 | |||
218 | public class MSSQLFolderHandler : MSSQLInventoryHandler<XInventoryFolder> | ||
219 | { | ||
220 | public MSSQLFolderHandler(string c, string t, string m) : | ||
221 | base(c, t, m) | ||
222 | { | ||
223 | } | ||
224 | |||
225 | public bool MoveFolder(string id, string newParentFolderID) | ||
226 | { | ||
227 | XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id }); | ||
228 | |||
229 | if (folders.Length == 0) | ||
230 | return false; | ||
231 | |||
232 | UUID oldParentFolderUUID = folders[0].parentFolderID; | ||
233 | |||
234 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | ||
235 | { | ||
236 | using (SqlCommand cmd = new SqlCommand()) | ||
237 | { | ||
238 | |||
239 | cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where folderID = @folderID", m_Realm); | ||
240 | cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParentFolderID)); | ||
241 | cmd.Parameters.Add(m_database.CreateParameter("@folderID", id)); | ||
242 | cmd.Connection = conn; | ||
243 | conn.Open(); | ||
244 | |||
245 | if (cmd.ExecuteNonQuery() == 0) | ||
246 | return false; | ||
247 | } | ||
248 | } | ||
249 | |||
250 | IncrementFolderVersion(oldParentFolderUUID); | ||
251 | IncrementFolderVersion(newParentFolderID); | ||
252 | |||
253 | return true; | ||
254 | } | ||
255 | |||
256 | public override bool Store(XInventoryFolder folder) | ||
257 | { | ||
258 | if (!base.Store(folder)) | ||
259 | return false; | ||
260 | |||
261 | IncrementFolderVersion(folder.parentFolderID); | ||
262 | |||
263 | return true; | ||
264 | } | ||
265 | } | ||
266 | |||
267 | public class MSSQLInventoryHandler<T> : MSSQLGenericTableHandler<T> where T: class, new() | ||
268 | { | ||
269 | public MSSQLInventoryHandler(string c, string t, string m) : base(c, t, m) {} | ||
270 | |||
271 | protected bool IncrementFolderVersion(UUID folderID) | ||
272 | { | ||
273 | return IncrementFolderVersion(folderID.ToString()); | ||
274 | } | ||
275 | |||
276 | protected bool IncrementFolderVersion(string folderID) | ||
277 | { | ||
278 | // m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID); | ||
279 | // Util.PrintCallStack(); | ||
280 | |||
281 | string sql = "update inventoryfolders set version=version+1 where folderID = ?folderID"; | ||
282 | |||
184 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 283 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
185 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
186 | { | 284 | { |
187 | conn.Open(); | 285 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
286 | { | ||
287 | conn.Open(); | ||
288 | |||
289 | cmd.Parameters.AddWithValue("@folderID", folderID); | ||
188 | 290 | ||
189 | cmd.Parameters.AddWithValue("@folderID", item.parentFolderID.ToString()); | ||
190 | try | 291 | try |
191 | { | 292 | { |
192 | cmd.ExecuteNonQuery(); | 293 | cmd.ExecuteNonQuery(); |
@@ -194,9 +295,11 @@ namespace OpenSim.Data.MSSQL | |||
194 | catch (Exception) | 295 | catch (Exception) |
195 | { | 296 | { |
196 | return false; | 297 | return false; |
197 | } | 298 | } |
299 | } | ||
198 | } | 300 | } |
301 | |||
199 | return true; | 302 | return true; |
200 | } | 303 | } |
201 | } | 304 | } |
202 | } | 305 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MSSQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MSSQL/Properties/AssemblyInfo.cs index e045d75..1a67e70 100644 --- a/OpenSim/Data/MSSQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/MSSQL/Properties/AssemblyInfo.cs | |||
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices; | |||
61 | // You can specify all the values or you can default the Revision and Build Numbers | 61 | // You can specify all the values or you can default the Revision and Build Numbers |
62 | // by using the '*' as shown below: | 62 | // by using the '*' as shown below: |
63 | 63 | ||
64 | [assembly : AssemblyVersion("0.6.5.*")] | 64 | [assembly : AssemblyVersion("0.7.5.*")] |
65 | [assembly : AssemblyFileVersion("0.6.5.0")] | 65 | [assembly : AssemblyFileVersion("0.6.5.0")] |
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 86367a1..f6731c0 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | |||
@@ -224,6 +224,8 @@ namespace OpenSim.Data.MySQL | |||
224 | 224 | ||
225 | public virtual bool Store(T row) | 225 | public virtual bool Store(T row) |
226 | { | 226 | { |
227 | // m_log.DebugFormat("[MYSQL GENERIC TABLE HANDLER]: Store(T row) invoked"); | ||
228 | |||
227 | using (MySqlCommand cmd = new MySqlCommand()) | 229 | using (MySqlCommand cmd = new MySqlCommand()) |
228 | { | 230 | { |
229 | string query = ""; | 231 | string query = ""; |
@@ -278,6 +280,10 @@ namespace OpenSim.Data.MySQL | |||
278 | 280 | ||
279 | public virtual bool Delete(string[] fields, string[] keys) | 281 | public virtual bool Delete(string[] fields, string[] keys) |
280 | { | 282 | { |
283 | // m_log.DebugFormat( | ||
284 | // "[MYSQL GENERIC TABLE HANDLER]: Delete(string[] fields, string[] keys) invoked with {0}:{1}", | ||
285 | // string.Join(",", fields), string.Join(",", keys)); | ||
286 | |||
281 | if (fields.Length != keys.Length) | 287 | if (fields.Length != keys.Length) |
282 | return false; | 288 | return false; |
283 | 289 | ||
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 0614879..a2d4ae4 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs | |||
@@ -30,11 +30,11 @@ using System.Collections; | |||
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Data; | 31 | using System.Data; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | 33 | using MySql.Data.MySqlClient; | |
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Data; | 36 | using OpenSim.Data; |
37 | using MySql.Data.MySqlClient; | 37 | using RegionFlags = OpenSim.Framework.RegionFlags; |
38 | 38 | ||
39 | namespace OpenSim.Data.MySQL | 39 | namespace OpenSim.Data.MySQL |
40 | { | 40 | { |
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 4d7c0c9..12c979a 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs | |||
@@ -747,95 +747,99 @@ namespace OpenSim.Data.MySQL | |||
747 | RegionLightShareData nWP = new RegionLightShareData(); | 747 | RegionLightShareData nWP = new RegionLightShareData(); |
748 | nWP.OnSave += StoreRegionWindlightSettings; | 748 | nWP.OnSave += StoreRegionWindlightSettings; |
749 | 749 | ||
750 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 750 | lock (m_dbLock) |
751 | { | 751 | { |
752 | dbcon.Open(); | 752 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
753 | |||
754 | string command = "select * from `regionwindlight` where region_id = ?regionID"; | ||
755 | |||
756 | using (MySqlCommand cmd = new MySqlCommand(command)) | ||
757 | { | 753 | { |
758 | cmd.Connection = dbcon; | 754 | dbcon.Open(); |
759 | 755 | ||
760 | cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); | 756 | string command = "select * from `regionwindlight` where region_id = ?regionID"; |
761 | 757 | ||
762 | IDataReader result = ExecuteReader(cmd); | 758 | using (MySqlCommand cmd = new MySqlCommand(command)) |
763 | if (!result.Read()) | ||
764 | { | ||
765 | //No result, so store our default windlight profile and return it | ||
766 | nWP.regionID = regionUUID; | ||
767 | // StoreRegionWindlightSettings(nWP); | ||
768 | return nWP; | ||
769 | } | ||
770 | else | ||
771 | { | 759 | { |
772 | nWP.regionID = DBGuid.FromDB(result["region_id"]); | 760 | cmd.Connection = dbcon; |
773 | nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); | 761 | |
774 | nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); | 762 | cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); |
775 | nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); | 763 | |
776 | nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); | 764 | IDataReader result = ExecuteReader(cmd); |
777 | nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); | 765 | if (!result.Read()) |
778 | nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); | 766 | { |
779 | nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); | 767 | //No result, so store our default windlight profile and return it |
780 | nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); | 768 | nWP.regionID = regionUUID; |
781 | nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); | 769 | // StoreRegionWindlightSettings(nWP); |
782 | nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); | 770 | return nWP; |
783 | nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); | 771 | } |
784 | nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); | 772 | else |
785 | nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); | 773 | { |
786 | nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); | 774 | nWP.regionID = DBGuid.FromDB(result["region_id"]); |
787 | nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); | 775 | nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); |
788 | nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); | 776 | nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); |
789 | nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); | 777 | nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); |
790 | UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); | 778 | nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); |
791 | nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); | 779 | nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); |
792 | nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); | 780 | nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); |
793 | nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); | 781 | nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); |
794 | nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); | 782 | nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); |
795 | nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); | 783 | nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); |
796 | nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); | 784 | nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); |
797 | nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); | 785 | nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); |
798 | nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); | 786 | nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); |
799 | nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); | 787 | nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); |
800 | nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); | 788 | nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); |
801 | nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); | 789 | nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); |
802 | nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); | 790 | nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); |
803 | nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); | 791 | nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); |
804 | nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); | 792 | UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); |
805 | nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); | 793 | nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); |
806 | nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); | 794 | nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); |
807 | nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); | 795 | nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); |
808 | nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); | 796 | nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); |
809 | nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); | 797 | nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); |
810 | nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); | 798 | nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); |
811 | nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); | 799 | nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); |
812 | nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); | 800 | nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); |
813 | nWP.eastAngle = Convert.ToSingle(result["east_angle"]); | 801 | nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); |
814 | nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); | 802 | nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); |
815 | nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); | 803 | nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); |
816 | nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); | 804 | nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); |
817 | nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); | 805 | nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); |
818 | nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); | 806 | nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); |
819 | nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); | 807 | nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); |
820 | nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); | 808 | nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); |
821 | nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); | 809 | nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); |
822 | nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); | 810 | nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); |
823 | nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); | 811 | nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); |
824 | nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); | 812 | nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); |
825 | nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); | 813 | nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); |
826 | nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); | 814 | nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); |
827 | nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); | 815 | nWP.eastAngle = Convert.ToSingle(result["east_angle"]); |
828 | nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); | 816 | nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); |
829 | nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); | 817 | nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); |
830 | nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); | 818 | nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); |
831 | nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); | 819 | nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); |
832 | nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); | 820 | nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); |
833 | nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); | 821 | nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); |
834 | nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); | 822 | nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); |
835 | nWP.valid = true; | 823 | nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); |
824 | nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); | ||
825 | nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); | ||
826 | nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); | ||
827 | nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); | ||
828 | nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); | ||
829 | nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); | ||
830 | nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); | ||
831 | nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); | ||
832 | nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); | ||
833 | nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); | ||
834 | nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); | ||
835 | nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); | ||
836 | nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); | ||
837 | nWP.valid = true; | ||
838 | } | ||
836 | } | 839 | } |
837 | } | 840 | } |
838 | } | 841 | } |
842 | |||
839 | return nWP; | 843 | return nWP; |
840 | } | 844 | } |
841 | 845 | ||
@@ -881,118 +885,124 @@ namespace OpenSim.Data.MySQL | |||
881 | 885 | ||
882 | public virtual void StoreRegionWindlightSettings(RegionLightShareData wl) | 886 | public virtual void StoreRegionWindlightSettings(RegionLightShareData wl) |
883 | { | 887 | { |
884 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 888 | lock (m_dbLock) |
885 | { | 889 | { |
886 | dbcon.Open(); | 890 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
887 | |||
888 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
889 | { | 891 | { |
890 | cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; | 892 | dbcon.Open(); |
891 | cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; | 893 | |
892 | cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; | 894 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
893 | cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; | 895 | { |
894 | cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; | 896 | cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; |
895 | cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; | 897 | cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; |
896 | cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; | 898 | cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; |
897 | cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; | 899 | cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; |
898 | cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; | 900 | cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; |
899 | cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; | 901 | cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; |
900 | cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; | 902 | cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; |
901 | cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; | 903 | cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; |
902 | cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; | 904 | cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; |
903 | cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; | 905 | cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; |
904 | cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; | 906 | cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; |
905 | cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; | 907 | cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; |
906 | cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; | 908 | cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; |
907 | cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; | 909 | cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; |
908 | cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; | 910 | cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; |
909 | cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; | 911 | cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; |
910 | cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; | 912 | cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; |
911 | cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; | 913 | cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; |
912 | cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; | 914 | cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; |
913 | cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; | 915 | cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; |
914 | cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; | 916 | cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; |
915 | 917 | cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; | |
916 | cmd.Parameters.AddWithValue("region_id", wl.regionID); | 918 | cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; |
917 | cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); | 919 | cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; |
918 | cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y); | 920 | cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; |
919 | cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z); | 921 | |
920 | cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent); | 922 | cmd.Parameters.AddWithValue("region_id", wl.regionID); |
921 | cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier); | 923 | cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); |
922 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X); | 924 | cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y); |
923 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y); | 925 | cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z); |
924 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z); | 926 | cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent); |
925 | cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale); | 927 | cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier); |
926 | cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset); | 928 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X); |
927 | cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove); | 929 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y); |
928 | cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow); | 930 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z); |
929 | cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier); | 931 | cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale); |
930 | cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X); | 932 | cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset); |
931 | cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y); | 933 | cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove); |
932 | cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X); | 934 | cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow); |
933 | cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y); | 935 | cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier); |
934 | cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture); | 936 | cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X); |
935 | cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X); | 937 | cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y); |
936 | cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y); | 938 | cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X); |
937 | cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z); | 939 | cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y); |
938 | cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W); | 940 | cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture); |
939 | cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon); | 941 | cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X); |
940 | cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X); | 942 | cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y); |
941 | cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y); | 943 | cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z); |
942 | cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z); | 944 | cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W); |
943 | cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W); | 945 | cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon); |
944 | cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity); | 946 | cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X); |
945 | cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier); | 947 | cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y); |
946 | cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier); | 948 | cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z); |
947 | cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude); | 949 | cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W); |
948 | cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X); | 950 | cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity); |
949 | cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y); | 951 | cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier); |
950 | cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z); | 952 | cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier); |
951 | cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W); | 953 | cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude); |
952 | cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition); | 954 | cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X); |
953 | cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X); | 955 | cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y); |
954 | cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y); | 956 | cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z); |
955 | cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z); | 957 | cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W); |
956 | cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W); | 958 | cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition); |
957 | cmd.Parameters.AddWithValue("east_angle", wl.eastAngle); | 959 | cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X); |
958 | cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus); | 960 | cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y); |
959 | cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize); | 961 | cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z); |
960 | cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma); | 962 | cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W); |
961 | cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness); | 963 | cmd.Parameters.AddWithValue("east_angle", wl.eastAngle); |
962 | cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X); | 964 | cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus); |
963 | cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y); | 965 | cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize); |
964 | cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z); | 966 | cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma); |
965 | cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W); | 967 | cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness); |
966 | cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X); | 968 | cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X); |
967 | cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y); | 969 | cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y); |
968 | cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z); | 970 | cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z); |
969 | cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage); | 971 | cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W); |
970 | cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale); | 972 | cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X); |
971 | cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X); | 973 | cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y); |
972 | cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y); | 974 | cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z); |
973 | cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z); | 975 | cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage); |
974 | cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX); | 976 | cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale); |
975 | cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock); | 977 | cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X); |
976 | cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); | 978 | cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y); |
977 | cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); | 979 | cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z); |
978 | cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); | 980 | cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX); |
979 | 981 | cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock); | |
980 | ExecuteNonQuery(cmd); | 982 | cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); |
983 | cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); | ||
984 | cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); | ||
985 | |||
986 | ExecuteNonQuery(cmd); | ||
987 | } | ||
981 | } | 988 | } |
982 | } | 989 | } |
983 | } | 990 | } |
984 | 991 | ||
985 | public virtual void RemoveRegionWindlightSettings(UUID regionID) | 992 | public virtual void RemoveRegionWindlightSettings(UUID regionID) |
986 | { | 993 | { |
987 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 994 | lock (m_dbLock) |
988 | { | 995 | { |
989 | dbcon.Open(); | 996 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
990 | |||
991 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
992 | { | 997 | { |
993 | cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID"; | 998 | dbcon.Open(); |
994 | cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); | 999 | |
995 | ExecuteNonQuery(cmd); | 1000 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
1001 | { | ||
1002 | cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID"; | ||
1003 | cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); | ||
1004 | ExecuteNonQuery(cmd); | ||
1005 | } | ||
996 | } | 1006 | } |
997 | } | 1007 | } |
998 | } | 1008 | } |
@@ -1000,26 +1010,29 @@ namespace OpenSim.Data.MySQL | |||
1000 | #region RegionEnvironmentSettings | 1010 | #region RegionEnvironmentSettings |
1001 | public string LoadRegionEnvironmentSettings(UUID regionUUID) | 1011 | public string LoadRegionEnvironmentSettings(UUID regionUUID) |
1002 | { | 1012 | { |
1003 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1013 | lock (m_dbLock) |
1004 | { | 1014 | { |
1005 | dbcon.Open(); | 1015 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1006 | |||
1007 | string command = "select * from `regionenvironment` where region_id = ?region_id"; | ||
1008 | |||
1009 | using (MySqlCommand cmd = new MySqlCommand(command)) | ||
1010 | { | 1016 | { |
1011 | cmd.Connection = dbcon; | 1017 | dbcon.Open(); |
1012 | 1018 | ||
1013 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | 1019 | string command = "select * from `regionenvironment` where region_id = ?region_id"; |
1014 | 1020 | ||
1015 | IDataReader result = ExecuteReader(cmd); | 1021 | using (MySqlCommand cmd = new MySqlCommand(command)) |
1016 | if (!result.Read()) | ||
1017 | { | ||
1018 | return String.Empty; | ||
1019 | } | ||
1020 | else | ||
1021 | { | 1022 | { |
1022 | return Convert.ToString(result["llsd_settings"]); | 1023 | cmd.Connection = dbcon; |
1024 | |||
1025 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | ||
1026 | |||
1027 | IDataReader result = ExecuteReader(cmd); | ||
1028 | if (!result.Read()) | ||
1029 | { | ||
1030 | return String.Empty; | ||
1031 | } | ||
1032 | else | ||
1033 | { | ||
1034 | return Convert.ToString(result["llsd_settings"]); | ||
1035 | } | ||
1023 | } | 1036 | } |
1024 | } | 1037 | } |
1025 | } | 1038 | } |
@@ -1027,33 +1040,39 @@ namespace OpenSim.Data.MySQL | |||
1027 | 1040 | ||
1028 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) | 1041 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) |
1029 | { | 1042 | { |
1030 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1043 | lock (m_dbLock) |
1031 | { | 1044 | { |
1032 | dbcon.Open(); | 1045 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1033 | |||
1034 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
1035 | { | 1046 | { |
1036 | cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)"; | 1047 | dbcon.Open(); |
1037 | 1048 | ||
1038 | cmd.Parameters.AddWithValue("region_id", regionUUID); | 1049 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
1039 | cmd.Parameters.AddWithValue("llsd_settings", settings); | 1050 | { |
1040 | 1051 | cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)"; | |
1041 | ExecuteNonQuery(cmd); | 1052 | |
1053 | cmd.Parameters.AddWithValue("region_id", regionUUID); | ||
1054 | cmd.Parameters.AddWithValue("llsd_settings", settings); | ||
1055 | |||
1056 | ExecuteNonQuery(cmd); | ||
1057 | } | ||
1042 | } | 1058 | } |
1043 | } | 1059 | } |
1044 | } | 1060 | } |
1045 | 1061 | ||
1046 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) | 1062 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) |
1047 | { | 1063 | { |
1048 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1064 | lock (m_dbLock) |
1049 | { | 1065 | { |
1050 | dbcon.Open(); | 1066 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1051 | |||
1052 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
1053 | { | 1067 | { |
1054 | cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id"; | 1068 | dbcon.Open(); |
1055 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | 1069 | |
1056 | ExecuteNonQuery(cmd); | 1070 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
1071 | { | ||
1072 | cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id"; | ||
1073 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | ||
1074 | ExecuteNonQuery(cmd); | ||
1075 | } | ||
1057 | } | 1076 | } |
1058 | } | 1077 | } |
1059 | } | 1078 | } |
diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index caf18a4..c74033e 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs | |||
@@ -26,9 +26,10 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.Data; | 30 | using System.Data; |
31 | using System.Linq; | ||
30 | using System.Reflection; | 32 | using System.Reflection; |
31 | using System.Collections.Generic; | ||
32 | using log4net; | 33 | using log4net; |
33 | using MySql.Data.MySqlClient; | 34 | using MySql.Data.MySqlClient; |
34 | using OpenMetaverse; | 35 | using OpenMetaverse; |
@@ -41,12 +42,12 @@ namespace OpenSim.Data.MySQL | |||
41 | /// </summary> | 42 | /// </summary> |
42 | public class MySQLXInventoryData : IXInventoryData | 43 | public class MySQLXInventoryData : IXInventoryData |
43 | { | 44 | { |
44 | private MySQLGenericTableHandler<XInventoryFolder> m_Folders; | 45 | private MySqlFolderHandler m_Folders; |
45 | private MySqlItemHandler m_Items; | 46 | private MySqlItemHandler m_Items; |
46 | 47 | ||
47 | public MySQLXInventoryData(string conn, string realm) | 48 | public MySQLXInventoryData(string conn, string realm) |
48 | { | 49 | { |
49 | m_Folders = new MySQLGenericTableHandler<XInventoryFolder>( | 50 | m_Folders = new MySqlFolderHandler( |
50 | conn, "inventoryfolders", "InventoryStore"); | 51 | conn, "inventoryfolders", "InventoryStore"); |
51 | m_Items = new MySqlItemHandler( | 52 | m_Items = new MySqlItemHandler( |
52 | conn, "inventoryitems", String.Empty); | 53 | conn, "inventoryitems", String.Empty); |
@@ -105,6 +106,11 @@ namespace OpenSim.Data.MySQL | |||
105 | return m_Items.MoveItem(id, newParent); | 106 | return m_Items.MoveItem(id, newParent); |
106 | } | 107 | } |
107 | 108 | ||
109 | public bool MoveFolder(string id, string newParent) | ||
110 | { | ||
111 | return m_Folders.MoveFolder(id, newParent); | ||
112 | } | ||
113 | |||
108 | public XInventoryItem[] GetActiveGestures(UUID principalID) | 114 | public XInventoryItem[] GetActiveGestures(UUID principalID) |
109 | { | 115 | { |
110 | return m_Items.GetActiveGestures(principalID); | 116 | return m_Items.GetActiveGestures(principalID); |
@@ -116,24 +122,71 @@ namespace OpenSim.Data.MySQL | |||
116 | } | 122 | } |
117 | } | 123 | } |
118 | 124 | ||
119 | public class MySqlItemHandler : MySQLGenericTableHandler<XInventoryItem> | 125 | public class MySqlItemHandler : MySqlInventoryHandler<XInventoryItem> |
120 | { | 126 | { |
127 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
128 | |||
121 | public MySqlItemHandler(string c, string t, string m) : | 129 | public MySqlItemHandler(string c, string t, string m) : |
122 | base(c, t, m) | 130 | base(c, t, m) |
123 | { | 131 | { |
124 | } | 132 | } |
125 | 133 | ||
134 | public override bool Delete(string field, string val) | ||
135 | { | ||
136 | XInventoryItem[] retrievedItems = Get(new string[] { field }, new string[] { val }); | ||
137 | if (retrievedItems.Length == 0) | ||
138 | return false; | ||
139 | |||
140 | if (!base.Delete(field, val)) | ||
141 | return false; | ||
142 | |||
143 | // Don't increment folder version here since Delete(string, string) calls Delete(string[], string[]) | ||
144 | // IncrementFolderVersion(retrievedItems[0].parentFolderID); | ||
145 | |||
146 | return true; | ||
147 | } | ||
148 | |||
149 | public override bool Delete(string[] fields, string[] vals) | ||
150 | { | ||
151 | XInventoryItem[] retrievedItems = Get(fields, vals); | ||
152 | if (retrievedItems.Length == 0) | ||
153 | return false; | ||
154 | |||
155 | if (!base.Delete(fields, vals)) | ||
156 | return false; | ||
157 | |||
158 | HashSet<UUID> deletedItemFolderUUIDs = new HashSet<UUID>(); | ||
159 | |||
160 | Array.ForEach<XInventoryItem>(retrievedItems, i => deletedItemFolderUUIDs.Add(i.parentFolderID)); | ||
161 | |||
162 | foreach (UUID deletedItemFolderUUID in deletedItemFolderUUIDs) | ||
163 | IncrementFolderVersion(deletedItemFolderUUID); | ||
164 | |||
165 | return true; | ||
166 | } | ||
167 | |||
126 | public bool MoveItem(string id, string newParent) | 168 | public bool MoveItem(string id, string newParent) |
127 | { | 169 | { |
170 | XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id }); | ||
171 | if (retrievedItems.Length == 0) | ||
172 | return false; | ||
173 | |||
174 | UUID oldParent = retrievedItems[0].parentFolderID; | ||
175 | |||
128 | using (MySqlCommand cmd = new MySqlCommand()) | 176 | using (MySqlCommand cmd = new MySqlCommand()) |
129 | { | 177 | { |
130 | |||
131 | cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm); | 178 | cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm); |
132 | cmd.Parameters.AddWithValue("?ParentFolderID", newParent); | 179 | cmd.Parameters.AddWithValue("?ParentFolderID", newParent); |
133 | cmd.Parameters.AddWithValue("?InventoryID", id); | 180 | cmd.Parameters.AddWithValue("?InventoryID", id); |
134 | 181 | ||
135 | return ExecuteNonQuery(cmd) == 0 ? false : true; | 182 | if (ExecuteNonQuery(cmd) == 0) |
183 | return false; | ||
136 | } | 184 | } |
185 | |||
186 | IncrementFolderVersion(oldParent); | ||
187 | IncrementFolderVersion(newParent); | ||
188 | |||
189 | return true; | ||
137 | } | 190 | } |
138 | 191 | ||
139 | public XInventoryItem[] GetActiveGestures(UUID principalID) | 192 | public XInventoryItem[] GetActiveGestures(UUID principalID) |
@@ -184,6 +237,73 @@ namespace OpenSim.Data.MySQL | |||
184 | if (!base.Store(item)) | 237 | if (!base.Store(item)) |
185 | return false; | 238 | return false; |
186 | 239 | ||
240 | IncrementFolderVersion(item.parentFolderID); | ||
241 | |||
242 | return true; | ||
243 | } | ||
244 | } | ||
245 | |||
246 | public class MySqlFolderHandler : MySqlInventoryHandler<XInventoryFolder> | ||
247 | { | ||
248 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
249 | |||
250 | public MySqlFolderHandler(string c, string t, string m) : | ||
251 | base(c, t, m) | ||
252 | { | ||
253 | } | ||
254 | |||
255 | public bool MoveFolder(string id, string newParentFolderID) | ||
256 | { | ||
257 | XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id }); | ||
258 | |||
259 | if (folders.Length == 0) | ||
260 | return false; | ||
261 | |||
262 | UUID oldParentFolderUUID = folders[0].parentFolderID; | ||
263 | |||
264 | using (MySqlCommand cmd = new MySqlCommand()) | ||
265 | { | ||
266 | cmd.CommandText | ||
267 | = String.Format( | ||
268 | "update {0} set parentFolderID = ?ParentFolderID where folderID = ?folderID", m_Realm); | ||
269 | cmd.Parameters.AddWithValue("?ParentFolderID", newParentFolderID); | ||
270 | cmd.Parameters.AddWithValue("?folderID", id); | ||
271 | |||
272 | if (ExecuteNonQuery(cmd) == 0) | ||
273 | return false; | ||
274 | } | ||
275 | |||
276 | IncrementFolderVersion(oldParentFolderUUID); | ||
277 | IncrementFolderVersion(newParentFolderID); | ||
278 | |||
279 | return true; | ||
280 | } | ||
281 | |||
282 | public override bool Store(XInventoryFolder folder) | ||
283 | { | ||
284 | if (!base.Store(folder)) | ||
285 | return false; | ||
286 | |||
287 | IncrementFolderVersion(folder.parentFolderID); | ||
288 | |||
289 | return true; | ||
290 | } | ||
291 | } | ||
292 | |||
293 | public class MySqlInventoryHandler<T> : MySQLGenericTableHandler<T> where T: class, new() | ||
294 | { | ||
295 | public MySqlInventoryHandler(string c, string t, string m) : base(c, t, m) {} | ||
296 | |||
297 | protected bool IncrementFolderVersion(UUID folderID) | ||
298 | { | ||
299 | return IncrementFolderVersion(folderID.ToString()); | ||
300 | } | ||
301 | |||
302 | protected bool IncrementFolderVersion(string folderID) | ||
303 | { | ||
304 | // m_log.DebugFormat("[MYSQL FOLDER HANDLER]: Incrementing version on folder {0}", folderID); | ||
305 | // Util.PrintCallStack(); | ||
306 | |||
187 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 307 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
188 | { | 308 | { |
189 | dbcon.Open(); | 309 | dbcon.Open(); |
@@ -193,7 +313,7 @@ namespace OpenSim.Data.MySQL | |||
193 | cmd.Connection = dbcon; | 313 | cmd.Connection = dbcon; |
194 | 314 | ||
195 | cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID"); | 315 | cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID"); |
196 | cmd.Parameters.AddWithValue("?folderID", item.parentFolderID.ToString()); | 316 | cmd.Parameters.AddWithValue("?folderID", folderID); |
197 | 317 | ||
198 | try | 318 | try |
199 | { | 319 | { |
@@ -205,9 +325,11 @@ namespace OpenSim.Data.MySQL | |||
205 | } | 325 | } |
206 | cmd.Dispose(); | 326 | cmd.Dispose(); |
207 | } | 327 | } |
328 | |||
208 | dbcon.Close(); | 329 | dbcon.Close(); |
209 | } | 330 | } |
331 | |||
210 | return true; | 332 | return true; |
211 | } | 333 | } |
212 | } | 334 | } |
213 | } | 335 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs index c28829c..ab3fe36 100644 --- a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs | |||
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices; | |||
61 | // You can specify all the values or you can default the Revision and Build Numbers | 61 | // You can specify all the values or you can default the Revision and Build Numbers |
62 | // by using the '*' as shown below: | 62 | // by using the '*' as shown below: |
63 | 63 | ||
64 | [assembly : AssemblyVersion("0.6.5.*")] | 64 | [assembly : AssemblyVersion("0.7.5.*")] |
65 | [assembly : AssemblyFileVersion("0.6.5.0")] | 65 | [assembly : AssemblyFileVersion("0.6.5.0")] |
diff --git a/OpenSim/Data/MySQL/Resources/GridUserStore.migrations b/OpenSim/Data/MySQL/Resources/GridUserStore.migrations index 32b85ee..d08e096 100644 --- a/OpenSim/Data/MySQL/Resources/GridUserStore.migrations +++ b/OpenSim/Data/MySQL/Resources/GridUserStore.migrations | |||
@@ -17,3 +17,8 @@ CREATE TABLE `GridUser` ( | |||
17 | ) ENGINE=InnoDB; | 17 | ) ENGINE=InnoDB; |
18 | 18 | ||
19 | COMMIT; | 19 | COMMIT; |
20 | |||
21 | :VERSION 2 # -------------------------- | ||
22 | BEGIN; | ||
23 | |||
24 | COMMIT; | ||
diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs index deb50cb..b4d701a 100644 --- a/OpenSim/Data/Null/NullRegionData.cs +++ b/OpenSim/Data/Null/NullRegionData.cs | |||
@@ -33,6 +33,7 @@ using OpenSim.Framework; | |||
33 | using OpenSim.Data; | 33 | using OpenSim.Data; |
34 | using System.Reflection; | 34 | using System.Reflection; |
35 | using log4net; | 35 | using log4net; |
36 | using RegionFlags = OpenSim.Framework.RegionFlags; | ||
36 | 37 | ||
37 | namespace OpenSim.Data.Null | 38 | namespace OpenSim.Data.Null |
38 | { | 39 | { |
diff --git a/OpenSim/Data/Null/Properties/AssemblyInfo.cs b/OpenSim/Data/Null/Properties/AssemblyInfo.cs index 4b64436..43b0bb3 100644 --- a/OpenSim/Data/Null/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/Null/Properties/AssemblyInfo.cs | |||
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices; | |||
61 | // You can specify all the values or you can default the Revision and Build Numbers | 61 | // You can specify all the values or you can default the Revision and Build Numbers |
62 | // by using the '*' as shown below: | 62 | // by using the '*' as shown below: |
63 | 63 | ||
64 | [assembly : AssemblyVersion("0.6.5.*")] | 64 | [assembly : AssemblyVersion("0.7.5.*")] |
65 | [assembly : AssemblyFileVersion("0.6.5.0")] | 65 | [assembly : AssemblyFileVersion("0.6.5.0")] |
diff --git a/OpenSim/Data/Properties/AssemblyInfo.cs b/OpenSim/Data/Properties/AssemblyInfo.cs index 6940d25..0da1a6b 100644 --- a/OpenSim/Data/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/Properties/AssemblyInfo.cs | |||
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices; | |||
61 | // You can specify all the values or you can default the Revision and Build Numbers | 61 | // You can specify all the values or you can default the Revision and Build Numbers |
62 | // by using the '*' as shown below: | 62 | // by using the '*' as shown below: |
63 | 63 | ||
64 | [assembly : AssemblyVersion("0.6.5.*")] | 64 | [assembly : AssemblyVersion("0.7.5.*")] |
65 | [assembly : AssemblyFileVersion("0.6.5.0")] | 65 | [assembly : AssemblyFileVersion("0.6.5.0")] |
diff --git a/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs b/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs index d45ab50..c9a8553 100644 --- a/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs | |||
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices; | |||
61 | // You can specify all the values or you can default the Revision and Build Numbers | 61 | // You can specify all the values or you can default the Revision and Build Numbers |
62 | // by using the '*' as shown below: | 62 | // by using the '*' as shown below: |
63 | 63 | ||
64 | [assembly : AssemblyVersion("0.6.5.*")] | 64 | [assembly : AssemblyVersion("0.7.5.*")] |
65 | [assembly : AssemblyFileVersion("0.6.5.0")] | 65 | [assembly : AssemblyFileVersion("0.6.5.0")] |
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 7f7059b..b94a58c 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs | |||
@@ -204,7 +204,8 @@ namespace OpenSim.Data.SQLite | |||
204 | /// <returns>True if exist, or false.</returns> | 204 | /// <returns>True if exist, or false.</returns> |
205 | override public bool ExistsAsset(UUID uuid) | 205 | override public bool ExistsAsset(UUID uuid) |
206 | { | 206 | { |
207 | lock (this) { | 207 | lock (this) |
208 | { | ||
208 | using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn)) | 209 | using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn)) |
209 | { | 210 | { |
210 | cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); | 211 | cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); |
@@ -355,12 +356,13 @@ namespace OpenSim.Data.SQLite | |||
355 | { | 356 | { |
356 | lock (this) | 357 | lock (this) |
357 | { | 358 | { |
358 | using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn)) | 359 | using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn)) |
359 | { | 360 | { |
360 | cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); | 361 | cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); |
361 | cmd.ExecuteNonQuery(); | 362 | cmd.ExecuteNonQuery(); |
362 | } | 363 | } |
363 | } | 364 | } |
365 | |||
364 | return true; | 366 | return true; |
365 | } | 367 | } |
366 | 368 | ||
diff --git a/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs b/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs index 5120453..0428c11 100644 --- a/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs +++ b/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs | |||
@@ -82,11 +82,14 @@ namespace OpenSim.Data.SQLite | |||
82 | { | 82 | { |
83 | AuthenticationData ret = new AuthenticationData(); | 83 | AuthenticationData ret = new AuthenticationData(); |
84 | ret.Data = new Dictionary<string, object>(); | 84 | ret.Data = new Dictionary<string, object>(); |
85 | IDataReader result; | ||
85 | 86 | ||
86 | SqliteCommand cmd = new SqliteCommand("select * from `" + m_Realm + "` where UUID = :PrincipalID"); | 87 | using (SqliteCommand cmd = new SqliteCommand("select * from `" + m_Realm + "` where UUID = :PrincipalID")) |
87 | cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); | 88 | { |
89 | cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); | ||
88 | 90 | ||
89 | IDataReader result = ExecuteReader(cmd, m_Connection); | 91 | result = ExecuteReader(cmd, m_Connection); |
92 | } | ||
90 | 93 | ||
91 | try | 94 | try |
92 | { | 95 | { |
@@ -121,10 +124,6 @@ namespace OpenSim.Data.SQLite | |||
121 | catch | 124 | catch |
122 | { | 125 | { |
123 | } | 126 | } |
124 | finally | ||
125 | { | ||
126 | //CloseCommand(cmd); | ||
127 | } | ||
128 | 127 | ||
129 | return null; | 128 | return null; |
130 | } | 129 | } |
@@ -140,84 +139,81 @@ namespace OpenSim.Data.SQLite | |||
140 | foreach (object o in data.Data.Values) | 139 | foreach (object o in data.Data.Values) |
141 | values[i++] = o.ToString(); | 140 | values[i++] = o.ToString(); |
142 | 141 | ||
143 | SqliteCommand cmd = new SqliteCommand(); | 142 | using (SqliteCommand cmd = new SqliteCommand()) |
144 | |||
145 | if (Get(data.PrincipalID) != null) | ||
146 | { | 143 | { |
144 | if (Get(data.PrincipalID) != null) | ||
145 | { | ||
147 | 146 | ||
148 | 147 | ||
149 | string update = "update `" + m_Realm + "` set "; | 148 | string update = "update `" + m_Realm + "` set "; |
150 | bool first = true; | 149 | bool first = true; |
151 | foreach (string field in fields) | 150 | foreach (string field in fields) |
152 | { | 151 | { |
153 | if (!first) | 152 | if (!first) |
154 | update += ", "; | 153 | update += ", "; |
155 | update += "`" + field + "` = :" + field; | 154 | update += "`" + field + "` = :" + field; |
156 | cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field])); | 155 | cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field])); |
157 | 156 | ||
158 | first = false; | 157 | first = false; |
159 | } | 158 | } |
160 | 159 | ||
161 | update += " where UUID = :UUID"; | 160 | update += " where UUID = :UUID"; |
162 | cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString())); | 161 | cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString())); |
163 | 162 | ||
164 | cmd.CommandText = update; | 163 | cmd.CommandText = update; |
165 | try | 164 | try |
166 | { | 165 | { |
167 | if (ExecuteNonQuery(cmd, m_Connection) < 1) | 166 | if (ExecuteNonQuery(cmd, m_Connection) < 1) |
167 | { | ||
168 | //CloseCommand(cmd); | ||
169 | return false; | ||
170 | } | ||
171 | } | ||
172 | catch (Exception e) | ||
168 | { | 173 | { |
174 | m_log.Error("[SQLITE]: Exception storing authentication data", e); | ||
169 | //CloseCommand(cmd); | 175 | //CloseCommand(cmd); |
170 | return false; | 176 | return false; |
171 | } | 177 | } |
172 | } | 178 | } |
173 | catch (Exception e) | 179 | else |
174 | { | 180 | { |
175 | m_log.Error("[SQLITE]: Exception storing authentication data", e); | 181 | string insert = "insert into `" + m_Realm + "` (`UUID`, `" + |
176 | //CloseCommand(cmd); | 182 | String.Join("`, `", fields) + |
177 | return false; | 183 | "`) values (:UUID, :" + String.Join(", :", fields) + ")"; |
178 | } | ||
179 | } | ||
180 | 184 | ||
181 | else | 185 | cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString())); |
182 | { | 186 | foreach (string field in fields) |
183 | string insert = "insert into `" + m_Realm + "` (`UUID`, `" + | 187 | cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field])); |
184 | String.Join("`, `", fields) + | ||
185 | "`) values (:UUID, :" + String.Join(", :", fields) + ")"; | ||
186 | |||
187 | cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString())); | ||
188 | foreach (string field in fields) | ||
189 | cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field])); | ||
190 | 188 | ||
191 | cmd.CommandText = insert; | 189 | cmd.CommandText = insert; |
192 | 190 | ||
193 | try | 191 | try |
194 | { | ||
195 | if (ExecuteNonQuery(cmd, m_Connection) < 1) | ||
196 | { | 192 | { |
197 | //CloseCommand(cmd); | 193 | if (ExecuteNonQuery(cmd, m_Connection) < 1) |
194 | { | ||
195 | return false; | ||
196 | } | ||
197 | } | ||
198 | catch (Exception e) | ||
199 | { | ||
200 | Console.WriteLine(e.ToString()); | ||
198 | return false; | 201 | return false; |
199 | } | 202 | } |
200 | } | 203 | } |
201 | catch (Exception e) | ||
202 | { | ||
203 | Console.WriteLine(e.ToString()); | ||
204 | //CloseCommand(cmd); | ||
205 | return false; | ||
206 | } | ||
207 | } | 204 | } |
208 | 205 | ||
209 | //CloseCommand(cmd); | ||
210 | |||
211 | return true; | 206 | return true; |
212 | } | 207 | } |
213 | 208 | ||
214 | public bool SetDataItem(UUID principalID, string item, string value) | 209 | public bool SetDataItem(UUID principalID, string item, string value) |
215 | { | 210 | { |
216 | SqliteCommand cmd = new SqliteCommand("update `" + m_Realm + | 211 | using (SqliteCommand cmd = new SqliteCommand("update `" + m_Realm + |
217 | "` set `" + item + "` = " + value + " where UUID = '" + principalID.ToString() + "'"); | 212 | "` set `" + item + "` = " + value + " where UUID = '" + principalID.ToString() + "'")) |
218 | 213 | { | |
219 | if (ExecuteNonQuery(cmd, m_Connection) > 0) | 214 | if (ExecuteNonQuery(cmd, m_Connection) > 0) |
220 | return true; | 215 | return true; |
216 | } | ||
221 | 217 | ||
222 | return false; | 218 | return false; |
223 | } | 219 | } |
@@ -227,16 +223,13 @@ namespace OpenSim.Data.SQLite | |||
227 | if (System.Environment.TickCount - m_LastExpire > 30000) | 223 | if (System.Environment.TickCount - m_LastExpire > 30000) |
228 | DoExpire(); | 224 | DoExpire(); |
229 | 225 | ||
230 | SqliteCommand cmd = new SqliteCommand("insert into tokens (UUID, token, validity) values ('" + principalID.ToString() + | 226 | using (SqliteCommand cmd = new SqliteCommand("insert into tokens (UUID, token, validity) values ('" + principalID.ToString() + |
231 | "', '" + token + "', datetime('now', 'localtime', '+" + lifetime.ToString() + " minutes'))"); | 227 | "', '" + token + "', datetime('now', 'localtime', '+" + lifetime.ToString() + " minutes'))")) |
232 | |||
233 | if (ExecuteNonQuery(cmd, m_Connection) > 0) | ||
234 | { | 228 | { |
235 | cmd.Dispose(); | 229 | if (ExecuteNonQuery(cmd, m_Connection) > 0) |
236 | return true; | 230 | return true; |
237 | } | 231 | } |
238 | 232 | ||
239 | cmd.Dispose(); | ||
240 | return false; | 233 | return false; |
241 | } | 234 | } |
242 | 235 | ||
@@ -245,28 +238,22 @@ namespace OpenSim.Data.SQLite | |||
245 | if (System.Environment.TickCount - m_LastExpire > 30000) | 238 | if (System.Environment.TickCount - m_LastExpire > 30000) |
246 | DoExpire(); | 239 | DoExpire(); |
247 | 240 | ||
248 | SqliteCommand cmd = new SqliteCommand("update tokens set validity = datetime('now', 'localtime', '+" + lifetime.ToString() + | 241 | using (SqliteCommand cmd = new SqliteCommand("update tokens set validity = datetime('now', 'localtime', '+" + lifetime.ToString() + |
249 | " minutes') where UUID = '" + principalID.ToString() + "' and token = '" + token + "' and validity > datetime('now', 'localtime')"); | 242 | " minutes') where UUID = '" + principalID.ToString() + "' and token = '" + token + "' and validity > datetime('now', 'localtime')")) |
250 | |||
251 | if (ExecuteNonQuery(cmd, m_Connection) > 0) | ||
252 | { | 243 | { |
253 | cmd.Dispose(); | 244 | if (ExecuteNonQuery(cmd, m_Connection) > 0) |
254 | return true; | 245 | return true; |
255 | } | 246 | } |
256 | 247 | ||
257 | cmd.Dispose(); | ||
258 | |||
259 | return false; | 248 | return false; |
260 | } | 249 | } |
261 | 250 | ||
262 | private void DoExpire() | 251 | private void DoExpire() |
263 | { | 252 | { |
264 | SqliteCommand cmd = new SqliteCommand("delete from tokens where validity < datetime('now', 'localtime')"); | 253 | using (SqliteCommand cmd = new SqliteCommand("delete from tokens where validity < datetime('now', 'localtime')")) |
265 | ExecuteNonQuery(cmd, m_Connection); | 254 | ExecuteNonQuery(cmd, m_Connection); |
266 | |||
267 | cmd.Dispose(); | ||
268 | 255 | ||
269 | m_LastExpire = System.Environment.TickCount; | 256 | m_LastExpire = System.Environment.TickCount; |
270 | } | 257 | } |
271 | } | 258 | } |
272 | } | 259 | } \ No newline at end of file |
diff --git a/OpenSim/Data/SQLite/SQLiteAvatarData.cs b/OpenSim/Data/SQLite/SQLiteAvatarData.cs index faf34da..c6d615b 100644 --- a/OpenSim/Data/SQLite/SQLiteAvatarData.cs +++ b/OpenSim/Data/SQLite/SQLiteAvatarData.cs | |||
@@ -56,23 +56,17 @@ namespace OpenSim.Data.SQLite | |||
56 | 56 | ||
57 | public bool Delete(UUID principalID, string name) | 57 | public bool Delete(UUID principalID, string name) |
58 | { | 58 | { |
59 | SqliteCommand cmd = new SqliteCommand(); | 59 | using (SqliteCommand cmd = new SqliteCommand()) |
60 | |||
61 | cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm); | ||
62 | cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); | ||
63 | cmd.Parameters.AddWithValue(":Name", name); | ||
64 | |||
65 | try | ||
66 | { | 60 | { |
61 | cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm); | ||
62 | cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); | ||
63 | cmd.Parameters.AddWithValue(":Name", name); | ||
64 | |||
67 | if (ExecuteNonQuery(cmd, m_Connection) > 0) | 65 | if (ExecuteNonQuery(cmd, m_Connection) > 0) |
68 | return true; | 66 | return true; |
69 | |||
70 | return false; | ||
71 | } | ||
72 | finally | ||
73 | { | ||
74 | //CloseCommand(cmd); | ||
75 | } | 67 | } |
68 | |||
69 | return false; | ||
76 | } | 70 | } |
77 | } | 71 | } |
78 | } | 72 | } \ No newline at end of file |
diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs index c042ba2..d51f2d4 100644 --- a/OpenSim/Data/SQLite/SQLiteEstateData.cs +++ b/OpenSim/Data/SQLite/SQLiteEstateData.cs | |||
@@ -104,12 +104,13 @@ namespace OpenSim.Data.SQLite | |||
104 | { | 104 | { |
105 | string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = :RegionID"; | 105 | string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = :RegionID"; |
106 | 106 | ||
107 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 107 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
108 | 108 | { | |
109 | cmd.CommandText = sql; | 109 | cmd.CommandText = sql; |
110 | cmd.Parameters.AddWithValue(":RegionID", regionID.ToString()); | 110 | cmd.Parameters.AddWithValue(":RegionID", regionID.ToString()); |
111 | 111 | ||
112 | return DoLoad(cmd, regionID, create); | 112 | return DoLoad(cmd, regionID, create); |
113 | } | ||
113 | } | 114 | } |
114 | 115 | ||
115 | private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID, bool create) | 116 | private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID, bool create) |
@@ -186,37 +187,39 @@ namespace OpenSim.Data.SQLite | |||
186 | { | 187 | { |
187 | List<string> names = new List<string>(FieldList); | 188 | List<string> names = new List<string>(FieldList); |
188 | 189 | ||
189 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | ||
190 | IDataReader r = null; | 190 | IDataReader r = null; |
191 | 191 | ||
192 | names.Remove("EstateID"); | 192 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
193 | { | ||
194 | names.Remove("EstateID"); | ||
193 | 195 | ||
194 | string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")"; | 196 | string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")"; |
195 | 197 | ||
196 | cmd.CommandText = sql; | 198 | cmd.CommandText = sql; |
197 | cmd.Parameters.Clear(); | 199 | cmd.Parameters.Clear(); |
198 | 200 | ||
199 | foreach (string name in FieldList) | 201 | foreach (string name in FieldList) |
200 | { | ||
201 | if (m_FieldMap[name].GetValue(es) is bool) | ||
202 | { | 202 | { |
203 | if ((bool)m_FieldMap[name].GetValue(es)) | 203 | if (m_FieldMap[name].GetValue(es) is bool) |
204 | cmd.Parameters.AddWithValue(":"+name, "1"); | 204 | { |
205 | if ((bool)m_FieldMap[name].GetValue(es)) | ||
206 | cmd.Parameters.AddWithValue(":"+name, "1"); | ||
207 | else | ||
208 | cmd.Parameters.AddWithValue(":"+name, "0"); | ||
209 | } | ||
205 | else | 210 | else |
206 | cmd.Parameters.AddWithValue(":"+name, "0"); | 211 | { |
207 | } | 212 | cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString()); |
208 | else | 213 | } |
209 | { | ||
210 | cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString()); | ||
211 | } | 214 | } |
212 | } | ||
213 | 215 | ||
214 | cmd.ExecuteNonQuery(); | 216 | cmd.ExecuteNonQuery(); |
215 | 217 | ||
216 | cmd.CommandText = "select LAST_INSERT_ROWID() as id"; | 218 | cmd.CommandText = "select LAST_INSERT_ROWID() as id"; |
217 | cmd.Parameters.Clear(); | 219 | cmd.Parameters.Clear(); |
218 | 220 | ||
219 | r = cmd.ExecuteReader(); | 221 | r = cmd.ExecuteReader(); |
222 | } | ||
220 | 223 | ||
221 | r.Read(); | 224 | r.Read(); |
222 | 225 | ||
@@ -239,26 +242,27 @@ namespace OpenSim.Data.SQLite | |||
239 | 242 | ||
240 | string sql = "update estate_settings set "+String.Join(", ", terms.ToArray())+" where EstateID = :EstateID"; | 243 | string sql = "update estate_settings set "+String.Join(", ", terms.ToArray())+" where EstateID = :EstateID"; |
241 | 244 | ||
242 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 245 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
243 | |||
244 | cmd.CommandText = sql; | ||
245 | |||
246 | foreach (string name in FieldList) | ||
247 | { | 246 | { |
248 | if (m_FieldMap[name].GetValue(es) is bool) | 247 | cmd.CommandText = sql; |
248 | |||
249 | foreach (string name in FieldList) | ||
249 | { | 250 | { |
250 | if ((bool)m_FieldMap[name].GetValue(es)) | 251 | if (m_FieldMap[name].GetValue(es) is bool) |
251 | cmd.Parameters.AddWithValue(":"+name, "1"); | 252 | { |
253 | if ((bool)m_FieldMap[name].GetValue(es)) | ||
254 | cmd.Parameters.AddWithValue(":"+name, "1"); | ||
255 | else | ||
256 | cmd.Parameters.AddWithValue(":"+name, "0"); | ||
257 | } | ||
252 | else | 258 | else |
253 | cmd.Parameters.AddWithValue(":"+name, "0"); | 259 | { |
254 | } | 260 | cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString()); |
255 | else | 261 | } |
256 | { | ||
257 | cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString()); | ||
258 | } | 262 | } |
259 | } | ||
260 | 263 | ||
261 | cmd.ExecuteNonQuery(); | 264 | cmd.ExecuteNonQuery(); |
265 | } | ||
262 | 266 | ||
263 | SaveBanList(es); | 267 | SaveBanList(es); |
264 | SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); | 268 | SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); |
@@ -270,12 +274,15 @@ namespace OpenSim.Data.SQLite | |||
270 | { | 274 | { |
271 | es.ClearBans(); | 275 | es.ClearBans(); |
272 | 276 | ||
273 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 277 | IDataReader r; |
274 | 278 | ||
275 | cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID"; | 279 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
276 | cmd.Parameters.AddWithValue(":EstateID", es.EstateID); | 280 | { |
281 | cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID"; | ||
282 | cmd.Parameters.AddWithValue(":EstateID", es.EstateID); | ||
277 | 283 | ||
278 | IDataReader r = cmd.ExecuteReader(); | 284 | r = cmd.ExecuteReader(); |
285 | } | ||
279 | 286 | ||
280 | while (r.Read()) | 287 | while (r.Read()) |
281 | { | 288 | { |
@@ -294,60 +301,64 @@ namespace OpenSim.Data.SQLite | |||
294 | 301 | ||
295 | private void SaveBanList(EstateSettings es) | 302 | private void SaveBanList(EstateSettings es) |
296 | { | 303 | { |
297 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 304 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
298 | |||
299 | cmd.CommandText = "delete from estateban where EstateID = :EstateID"; | ||
300 | cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); | ||
301 | |||
302 | cmd.ExecuteNonQuery(); | ||
303 | |||
304 | cmd.Parameters.Clear(); | ||
305 | |||
306 | cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( :EstateID, :bannedUUID, '', '', '' )"; | ||
307 | |||
308 | foreach (EstateBan b in es.EstateBans) | ||
309 | { | 305 | { |
306 | cmd.CommandText = "delete from estateban where EstateID = :EstateID"; | ||
310 | cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); | 307 | cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); |
311 | cmd.Parameters.AddWithValue(":bannedUUID", b.BannedUserID.ToString()); | ||
312 | 308 | ||
313 | cmd.ExecuteNonQuery(); | 309 | cmd.ExecuteNonQuery(); |
310 | |||
314 | cmd.Parameters.Clear(); | 311 | cmd.Parameters.Clear(); |
312 | |||
313 | cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( :EstateID, :bannedUUID, '', '', '' )"; | ||
314 | |||
315 | foreach (EstateBan b in es.EstateBans) | ||
316 | { | ||
317 | cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); | ||
318 | cmd.Parameters.AddWithValue(":bannedUUID", b.BannedUserID.ToString()); | ||
319 | |||
320 | cmd.ExecuteNonQuery(); | ||
321 | cmd.Parameters.Clear(); | ||
322 | } | ||
315 | } | 323 | } |
316 | } | 324 | } |
317 | 325 | ||
318 | void SaveUUIDList(uint EstateID, string table, UUID[] data) | 326 | void SaveUUIDList(uint EstateID, string table, UUID[] data) |
319 | { | 327 | { |
320 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 328 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
321 | |||
322 | cmd.CommandText = "delete from "+table+" where EstateID = :EstateID"; | ||
323 | cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString()); | ||
324 | |||
325 | cmd.ExecuteNonQuery(); | ||
326 | |||
327 | cmd.Parameters.Clear(); | ||
328 | |||
329 | cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( :EstateID, :uuid )"; | ||
330 | |||
331 | foreach (UUID uuid in data) | ||
332 | { | 329 | { |
330 | cmd.CommandText = "delete from "+table+" where EstateID = :EstateID"; | ||
333 | cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString()); | 331 | cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString()); |
334 | cmd.Parameters.AddWithValue(":uuid", uuid.ToString()); | ||
335 | 332 | ||
336 | cmd.ExecuteNonQuery(); | 333 | cmd.ExecuteNonQuery(); |
334 | |||
337 | cmd.Parameters.Clear(); | 335 | cmd.Parameters.Clear(); |
336 | |||
337 | cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( :EstateID, :uuid )"; | ||
338 | |||
339 | foreach (UUID uuid in data) | ||
340 | { | ||
341 | cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString()); | ||
342 | cmd.Parameters.AddWithValue(":uuid", uuid.ToString()); | ||
343 | |||
344 | cmd.ExecuteNonQuery(); | ||
345 | cmd.Parameters.Clear(); | ||
346 | } | ||
338 | } | 347 | } |
339 | } | 348 | } |
340 | 349 | ||
341 | UUID[] LoadUUIDList(uint EstateID, string table) | 350 | UUID[] LoadUUIDList(uint EstateID, string table) |
342 | { | 351 | { |
343 | List<UUID> uuids = new List<UUID>(); | 352 | List<UUID> uuids = new List<UUID>(); |
353 | IDataReader r; | ||
344 | 354 | ||
345 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 355 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
346 | 356 | { | |
347 | cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID"; | 357 | cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID"; |
348 | cmd.Parameters.AddWithValue(":EstateID", EstateID); | 358 | cmd.Parameters.AddWithValue(":EstateID", EstateID); |
349 | 359 | ||
350 | IDataReader r = cmd.ExecuteReader(); | 360 | r = cmd.ExecuteReader(); |
361 | } | ||
351 | 362 | ||
352 | while (r.Read()) | 363 | while (r.Read()) |
353 | { | 364 | { |
@@ -367,12 +378,13 @@ namespace OpenSim.Data.SQLite | |||
367 | { | 378 | { |
368 | string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_settings where estate_settings.EstateID = :EstateID"; | 379 | string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_settings where estate_settings.EstateID = :EstateID"; |
369 | 380 | ||
370 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 381 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
371 | 382 | { | |
372 | cmd.CommandText = sql; | 383 | cmd.CommandText = sql; |
373 | cmd.Parameters.AddWithValue(":EstateID", estateID.ToString()); | 384 | cmd.Parameters.AddWithValue(":EstateID", estateID.ToString()); |
374 | 385 | ||
375 | return DoLoad(cmd, UUID.Zero, false); | 386 | return DoLoad(cmd, UUID.Zero, false); |
387 | } | ||
376 | } | 388 | } |
377 | 389 | ||
378 | public List<EstateSettings> LoadEstateSettingsAll() | 390 | public List<EstateSettings> LoadEstateSettingsAll() |
@@ -391,13 +403,15 @@ namespace OpenSim.Data.SQLite | |||
391 | List<int> result = new List<int>(); | 403 | List<int> result = new List<int>(); |
392 | 404 | ||
393 | string sql = "select EstateID from estate_settings where estate_settings.EstateName = :EstateName"; | 405 | string sql = "select EstateID from estate_settings where estate_settings.EstateName = :EstateName"; |
406 | IDataReader r; | ||
394 | 407 | ||
395 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 408 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
396 | 409 | { | |
397 | cmd.CommandText = sql; | 410 | cmd.CommandText = sql; |
398 | cmd.Parameters.AddWithValue(":EstateName", search); | 411 | cmd.Parameters.AddWithValue(":EstateName", search); |
399 | 412 | ||
400 | IDataReader r = cmd.ExecuteReader(); | 413 | r = cmd.ExecuteReader(); |
414 | } | ||
401 | 415 | ||
402 | while (r.Read()) | 416 | while (r.Read()) |
403 | { | 417 | { |
@@ -413,12 +427,14 @@ namespace OpenSim.Data.SQLite | |||
413 | List<int> result = new List<int>(); | 427 | List<int> result = new List<int>(); |
414 | 428 | ||
415 | string sql = "select EstateID from estate_settings"; | 429 | string sql = "select EstateID from estate_settings"; |
430 | IDataReader r; | ||
416 | 431 | ||
417 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 432 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
418 | 433 | { | |
419 | cmd.CommandText = sql; | 434 | cmd.CommandText = sql; |
420 | 435 | ||
421 | IDataReader r = cmd.ExecuteReader(); | 436 | r = cmd.ExecuteReader(); |
437 | } | ||
422 | 438 | ||
423 | while (r.Read()) | 439 | while (r.Read()) |
424 | { | 440 | { |
@@ -434,13 +450,15 @@ namespace OpenSim.Data.SQLite | |||
434 | List<int> result = new List<int>(); | 450 | List<int> result = new List<int>(); |
435 | 451 | ||
436 | string sql = "select EstateID from estate_settings where estate_settings.EstateOwner = :EstateOwner"; | 452 | string sql = "select EstateID from estate_settings where estate_settings.EstateOwner = :EstateOwner"; |
453 | IDataReader r; | ||
437 | 454 | ||
438 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 455 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
439 | 456 | { | |
440 | cmd.CommandText = sql; | 457 | cmd.CommandText = sql; |
441 | cmd.Parameters.AddWithValue(":EstateOwner", ownerID); | 458 | cmd.Parameters.AddWithValue(":EstateOwner", ownerID); |
442 | 459 | ||
443 | IDataReader r = cmd.ExecuteReader(); | 460 | r = cmd.ExecuteReader(); |
461 | } | ||
444 | 462 | ||
445 | while (r.Read()) | 463 | while (r.Read()) |
446 | { | 464 | { |
diff --git a/OpenSim/Data/SQLite/SQLiteFramework.cs b/OpenSim/Data/SQLite/SQLiteFramework.cs index 1594717..35b9a2f 100644 --- a/OpenSim/Data/SQLite/SQLiteFramework.cs +++ b/OpenSim/Data/SQLite/SQLiteFramework.cs | |||
@@ -90,12 +90,5 @@ namespace OpenSim.Data.SQLite | |||
90 | return cmd.ExecuteReader(); | 90 | return cmd.ExecuteReader(); |
91 | } | 91 | } |
92 | } | 92 | } |
93 | |||
94 | protected void CloseCommand(SqliteCommand cmd) | ||
95 | { | ||
96 | cmd.Connection.Close(); | ||
97 | cmd.Connection.Dispose(); | ||
98 | cmd.Dispose(); | ||
99 | } | ||
100 | } | 93 | } |
101 | } | 94 | } \ No newline at end of file |
diff --git a/OpenSim/Data/SQLite/SQLiteFriendsData.cs b/OpenSim/Data/SQLite/SQLiteFriendsData.cs index 5f68977..cab85eb 100644 --- a/OpenSim/Data/SQLite/SQLiteFriendsData.cs +++ b/OpenSim/Data/SQLite/SQLiteFriendsData.cs | |||
@@ -53,13 +53,13 @@ namespace OpenSim.Data.SQLite | |||
53 | 53 | ||
54 | public FriendsData[] GetFriends(string userID) | 54 | public FriendsData[] GetFriends(string userID) |
55 | { | 55 | { |
56 | SqliteCommand cmd = new SqliteCommand(); | 56 | using (SqliteCommand cmd = new SqliteCommand()) |
57 | 57 | { | |
58 | cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm); | 58 | cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm); |
59 | cmd.Parameters.AddWithValue(":PrincipalID", userID.ToString()); | 59 | cmd.Parameters.AddWithValue(":PrincipalID", userID.ToString()); |
60 | |||
61 | return DoQuery(cmd); | ||
62 | 60 | ||
61 | return DoQuery(cmd); | ||
62 | } | ||
63 | } | 63 | } |
64 | 64 | ||
65 | public bool Delete(UUID principalID, string friend) | 65 | public bool Delete(UUID principalID, string friend) |
@@ -69,13 +69,14 @@ namespace OpenSim.Data.SQLite | |||
69 | 69 | ||
70 | public bool Delete(string principalID, string friend) | 70 | public bool Delete(string principalID, string friend) |
71 | { | 71 | { |
72 | SqliteCommand cmd = new SqliteCommand(); | 72 | using (SqliteCommand cmd = new SqliteCommand()) |
73 | 73 | { | |
74 | cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm); | 74 | cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm); |
75 | cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); | 75 | cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); |
76 | cmd.Parameters.AddWithValue(":Friend", friend); | 76 | cmd.Parameters.AddWithValue(":Friend", friend); |
77 | 77 | ||
78 | ExecuteNonQuery(cmd, m_Connection); | 78 | ExecuteNonQuery(cmd, m_Connection); |
79 | } | ||
79 | 80 | ||
80 | return true; | 81 | return true; |
81 | } | 82 | } |
diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs index 4f977a8..9fbeb10 100644 --- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs +++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs | |||
@@ -120,34 +120,35 @@ namespace OpenSim.Data.SQLite | |||
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | public T[] Get(string field, string key) | 123 | public virtual T[] Get(string field, string key) |
124 | { | 124 | { |
125 | return Get(new string[] { field }, new string[] { key }); | 125 | return Get(new string[] { field }, new string[] { key }); |
126 | } | 126 | } |
127 | 127 | ||
128 | public T[] Get(string[] fields, string[] keys) | 128 | public virtual T[] Get(string[] fields, string[] keys) |
129 | { | 129 | { |
130 | if (fields.Length != keys.Length) | 130 | if (fields.Length != keys.Length) |
131 | return new T[0]; | 131 | return new T[0]; |
132 | 132 | ||
133 | List<string> terms = new List<string>(); | 133 | List<string> terms = new List<string>(); |
134 | 134 | ||
135 | SqliteCommand cmd = new SqliteCommand(); | 135 | using (SqliteCommand cmd = new SqliteCommand()) |
136 | |||
137 | for (int i = 0 ; i < fields.Length ; i++) | ||
138 | { | 136 | { |
139 | cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i])); | 137 | for (int i = 0 ; i < fields.Length ; i++) |
140 | terms.Add("`" + fields[i] + "` = :" + fields[i]); | 138 | { |
141 | } | 139 | cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i])); |
140 | terms.Add("`" + fields[i] + "` = :" + fields[i]); | ||
141 | } | ||
142 | 142 | ||
143 | string where = String.Join(" and ", terms.ToArray()); | 143 | string where = String.Join(" and ", terms.ToArray()); |
144 | 144 | ||
145 | string query = String.Format("select * from {0} where {1}", | 145 | string query = String.Format("select * from {0} where {1}", |
146 | m_Realm, where); | 146 | m_Realm, where); |
147 | 147 | ||
148 | cmd.CommandText = query; | 148 | cmd.CommandText = query; |
149 | 149 | ||
150 | return DoQuery(cmd); | 150 | return DoQuery(cmd); |
151 | } | ||
151 | } | 152 | } |
152 | 153 | ||
153 | protected T[] DoQuery(SqliteCommand cmd) | 154 | protected T[] DoQuery(SqliteCommand cmd) |
@@ -212,52 +213,54 @@ namespace OpenSim.Data.SQLite | |||
212 | return result.ToArray(); | 213 | return result.ToArray(); |
213 | } | 214 | } |
214 | 215 | ||
215 | public T[] Get(string where) | 216 | public virtual T[] Get(string where) |
216 | { | 217 | { |
217 | SqliteCommand cmd = new SqliteCommand(); | 218 | using (SqliteCommand cmd = new SqliteCommand()) |
218 | 219 | { | |
219 | string query = String.Format("select * from {0} where {1}", | 220 | string query = String.Format("select * from {0} where {1}", |
220 | m_Realm, where); | 221 | m_Realm, where); |
221 | 222 | ||
222 | cmd.CommandText = query; | 223 | cmd.CommandText = query; |
223 | 224 | ||
224 | return DoQuery(cmd); | 225 | return DoQuery(cmd); |
226 | } | ||
225 | } | 227 | } |
226 | 228 | ||
227 | public bool Store(T row) | 229 | public virtual bool Store(T row) |
228 | { | 230 | { |
229 | SqliteCommand cmd = new SqliteCommand(); | 231 | using (SqliteCommand cmd = new SqliteCommand()) |
230 | |||
231 | string query = ""; | ||
232 | List<String> names = new List<String>(); | ||
233 | List<String> values = new List<String>(); | ||
234 | |||
235 | foreach (FieldInfo fi in m_Fields.Values) | ||
236 | { | 232 | { |
237 | names.Add(fi.Name); | 233 | string query = ""; |
238 | values.Add(":" + fi.Name); | 234 | List<String> names = new List<String>(); |
239 | cmd.Parameters.Add(new SqliteParameter(":" + fi.Name, fi.GetValue(row).ToString())); | 235 | List<String> values = new List<String>(); |
240 | } | ||
241 | 236 | ||
242 | if (m_DataField != null) | 237 | foreach (FieldInfo fi in m_Fields.Values) |
243 | { | 238 | { |
244 | Dictionary<string, string> data = | 239 | names.Add(fi.Name); |
245 | (Dictionary<string, string>)m_DataField.GetValue(row); | 240 | values.Add(":" + fi.Name); |
241 | cmd.Parameters.Add(new SqliteParameter(":" + fi.Name, fi.GetValue(row).ToString())); | ||
242 | } | ||
246 | 243 | ||
247 | foreach (KeyValuePair<string, string> kvp in data) | 244 | if (m_DataField != null) |
248 | { | 245 | { |
249 | names.Add(kvp.Key); | 246 | Dictionary<string, string> data = |
250 | values.Add(":" + kvp.Key); | 247 | (Dictionary<string, string>)m_DataField.GetValue(row); |
251 | cmd.Parameters.Add(new SqliteParameter(":" + kvp.Key, kvp.Value)); | 248 | |
249 | foreach (KeyValuePair<string, string> kvp in data) | ||
250 | { | ||
251 | names.Add(kvp.Key); | ||
252 | values.Add(":" + kvp.Key); | ||
253 | cmd.Parameters.Add(new SqliteParameter(":" + kvp.Key, kvp.Value)); | ||
254 | } | ||
252 | } | 255 | } |
253 | } | ||
254 | 256 | ||
255 | query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")"; | 257 | query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")"; |
256 | 258 | ||
257 | cmd.CommandText = query; | 259 | cmd.CommandText = query; |
258 | 260 | ||
259 | if (ExecuteNonQuery(cmd, m_Connection) > 0) | 261 | if (ExecuteNonQuery(cmd, m_Connection) > 0) |
260 | return true; | 262 | return true; |
263 | } | ||
261 | 264 | ||
262 | return false; | 265 | return false; |
263 | } | 266 | } |
@@ -267,28 +270,29 @@ namespace OpenSim.Data.SQLite | |||
267 | return Delete(new string[] { field }, new string[] { key }); | 270 | return Delete(new string[] { field }, new string[] { key }); |
268 | } | 271 | } |
269 | 272 | ||
270 | public bool Delete(string[] fields, string[] keys) | 273 | public virtual bool Delete(string[] fields, string[] keys) |
271 | { | 274 | { |
272 | if (fields.Length != keys.Length) | 275 | if (fields.Length != keys.Length) |
273 | return false; | 276 | return false; |
274 | 277 | ||
275 | List<string> terms = new List<string>(); | 278 | List<string> terms = new List<string>(); |
276 | 279 | ||
277 | SqliteCommand cmd = new SqliteCommand(); | 280 | using (SqliteCommand cmd = new SqliteCommand()) |
278 | |||
279 | for (int i = 0 ; i < fields.Length ; i++) | ||
280 | { | 281 | { |
281 | cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i])); | 282 | for (int i = 0 ; i < fields.Length ; i++) |
282 | terms.Add("`" + fields[i] + "` = :" + fields[i]); | 283 | { |
283 | } | 284 | cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i])); |
285 | terms.Add("`" + fields[i] + "` = :" + fields[i]); | ||
286 | } | ||
284 | 287 | ||
285 | string where = String.Join(" and ", terms.ToArray()); | 288 | string where = String.Join(" and ", terms.ToArray()); |
286 | 289 | ||
287 | string query = String.Format("delete from {0} where {1}", m_Realm, where); | 290 | string query = String.Format("delete from {0} where {1}", m_Realm, where); |
288 | 291 | ||
289 | cmd.CommandText = query; | 292 | cmd.CommandText = query; |
290 | 293 | ||
291 | return ExecuteNonQuery(cmd, m_Connection) > 0; | 294 | return ExecuteNonQuery(cmd, m_Connection) > 0; |
295 | } | ||
292 | } | 296 | } |
293 | } | 297 | } |
294 | } | 298 | } |
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs index 431709f..42cd59d 100644 --- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs +++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs | |||
@@ -1366,6 +1366,13 @@ namespace OpenSim.Data.SQLite | |||
1366 | createCol(land, "UserLookAtZ", typeof(Double)); | 1366 | createCol(land, "UserLookAtZ", typeof(Double)); |
1367 | createCol(land, "AuthbuyerID", typeof(String)); | 1367 | createCol(land, "AuthbuyerID", typeof(String)); |
1368 | createCol(land, "OtherCleanTime", typeof(Int32)); | 1368 | createCol(land, "OtherCleanTime", typeof(Int32)); |
1369 | createCol(land, "Dwell", typeof(Int32)); | ||
1370 | createCol(land, "MediaType", typeof(String)); | ||
1371 | createCol(land, "MediaDescription", typeof(String)); | ||
1372 | createCol(land, "MediaSize", typeof(String)); | ||
1373 | createCol(land, "MediaLoop", typeof(Boolean)); | ||
1374 | createCol(land, "ObscureMedia", typeof(Boolean)); | ||
1375 | createCol(land, "ObscureMusic", typeof(Boolean)); | ||
1369 | 1376 | ||
1370 | land.PrimaryKey = new DataColumn[] { land.Columns["UUID"] }; | 1377 | land.PrimaryKey = new DataColumn[] { land.Columns["UUID"] }; |
1371 | 1378 | ||
@@ -1781,9 +1788,16 @@ namespace OpenSim.Data.SQLite | |||
1781 | newData.PassHours = Convert.ToSingle(row["PassHours"]); | 1788 | newData.PassHours = Convert.ToSingle(row["PassHours"]); |
1782 | newData.PassPrice = Convert.ToInt32(row["PassPrice"]); | 1789 | newData.PassPrice = Convert.ToInt32(row["PassPrice"]); |
1783 | newData.SnapshotID = (UUID)(String)row["SnapshotUUID"]; | 1790 | newData.SnapshotID = (UUID)(String)row["SnapshotUUID"]; |
1791 | newData.Dwell = Convert.ToInt32(row["Dwell"]); | ||
1792 | newData.MediaType = (String)row["MediaType"]; | ||
1793 | newData.MediaDescription = (String)row["MediaDescription"]; | ||
1794 | newData.MediaWidth = Convert.ToInt32((((string)row["MediaSize"]).Split(','))[0]); | ||
1795 | newData.MediaHeight = Convert.ToInt32((((string)row["MediaSize"]).Split(','))[1]); | ||
1796 | newData.MediaLoop = Convert.ToBoolean(row["MediaLoop"]); | ||
1797 | newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]); | ||
1798 | newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]); | ||
1784 | try | 1799 | try |
1785 | { | 1800 | { |
1786 | |||
1787 | newData.UserLocation = | 1801 | newData.UserLocation = |
1788 | new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), | 1802 | new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), |
1789 | Convert.ToSingle(row["UserLocationZ"])); | 1803 | Convert.ToSingle(row["UserLocationZ"])); |
@@ -2195,12 +2209,13 @@ namespace OpenSim.Data.SQLite | |||
2195 | row["UserLookAtZ"] = land.UserLookAt.Z; | 2209 | row["UserLookAtZ"] = land.UserLookAt.Z; |
2196 | row["AuthbuyerID"] = land.AuthBuyerID.ToString(); | 2210 | row["AuthbuyerID"] = land.AuthBuyerID.ToString(); |
2197 | row["OtherCleanTime"] = land.OtherCleanTime; | 2211 | row["OtherCleanTime"] = land.OtherCleanTime; |
2212 | row["Dwell"] = land.Dwell; | ||
2198 | row["MediaType"] = land.MediaType; | 2213 | row["MediaType"] = land.MediaType; |
2199 | row["MediaDescription"] = land.MediaDescription; | 2214 | row["MediaDescription"] = land.MediaDescription; |
2200 | row["MediaSize"] = land.MediaWidth.ToString() + "," + land.MediaHeight.ToString(); | 2215 | row["MediaSize"] = String.Format("{0},{1}", land.MediaWidth, land.MediaHeight); |
2201 | row["MediaLoop"] = land.MediaLoop.ToString(); | 2216 | row["MediaLoop"] = land.MediaLoop; |
2202 | row["ObscureMusic"] = land.ObscureMusic.ToString(); | 2217 | row["ObscureMusic"] = land.ObscureMusic; |
2203 | row["ObscureMedia"] = land.ObscureMedia.ToString(); | 2218 | row["ObscureMedia"] = land.ObscureMedia; |
2204 | } | 2219 | } |
2205 | 2220 | ||
2206 | /// <summary> | 2221 | /// <summary> |
diff --git a/OpenSim/Data/SQLite/SQLiteUserAccountData.cs b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs index 4d580c0..91d62ce 100644 --- a/OpenSim/Data/SQLite/SQLiteUserAccountData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs | |||
@@ -66,20 +66,21 @@ namespace OpenSim.Data.SQLite | |||
66 | if (words.Length > 2) | 66 | if (words.Length > 2) |
67 | return new UserAccountData[0]; | 67 | return new UserAccountData[0]; |
68 | 68 | ||
69 | SqliteCommand cmd = new SqliteCommand(); | 69 | using (SqliteCommand cmd = new SqliteCommand()) |
70 | |||
71 | if (words.Length == 1) | ||
72 | { | ||
73 | cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')", | ||
74 | m_Realm, scopeID.ToString(), words[0]); | ||
75 | } | ||
76 | else | ||
77 | { | 70 | { |
78 | cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')", | 71 | if (words.Length == 1) |
79 | m_Realm, scopeID.ToString(), words[0], words[1]); | 72 | { |
80 | } | 73 | cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')", |
74 | m_Realm, scopeID.ToString(), words[0]); | ||
75 | } | ||
76 | else | ||
77 | { | ||
78 | cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')", | ||
79 | m_Realm, scopeID.ToString(), words[0], words[1]); | ||
80 | } | ||
81 | 81 | ||
82 | return DoQuery(cmd); | 82 | return DoQuery(cmd); |
83 | } | ||
83 | } | 84 | } |
84 | 85 | ||
85 | public UserAccountData[] GetUsersWhere(UUID scopeID, string where) | 86 | public UserAccountData[] GetUsersWhere(UUID scopeID, string where) |
diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs index 1f36986..2a0a8f6 100644 --- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs +++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs | |||
@@ -47,7 +47,7 @@ namespace OpenSim.Data.SQLite | |||
47 | { | 47 | { |
48 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 49 | ||
50 | private SQLiteGenericTableHandler<XInventoryFolder> m_Folders; | 50 | private SqliteFolderHandler m_Folders; |
51 | private SqliteItemHandler m_Items; | 51 | private SqliteItemHandler m_Items; |
52 | 52 | ||
53 | public SQLiteXInventoryData(string conn, string realm) | 53 | public SQLiteXInventoryData(string conn, string realm) |
@@ -55,7 +55,7 @@ namespace OpenSim.Data.SQLite | |||
55 | if (Util.IsWindows()) | 55 | if (Util.IsWindows()) |
56 | Util.LoadArchSpecificWindowsDll("sqlite3.dll"); | 56 | Util.LoadArchSpecificWindowsDll("sqlite3.dll"); |
57 | 57 | ||
58 | m_Folders = new SQLiteGenericTableHandler<XInventoryFolder>( | 58 | m_Folders = new SqliteFolderHandler( |
59 | conn, "inventoryfolders", "XInventoryStore"); | 59 | conn, "inventoryfolders", "XInventoryStore"); |
60 | m_Items = new SqliteItemHandler( | 60 | m_Items = new SqliteItemHandler( |
61 | conn, "inventoryitems", String.Empty); | 61 | conn, "inventoryitems", String.Empty); |
@@ -114,6 +114,11 @@ namespace OpenSim.Data.SQLite | |||
114 | return m_Items.MoveItem(id, newParent); | 114 | return m_Items.MoveItem(id, newParent); |
115 | } | 115 | } |
116 | 116 | ||
117 | public bool MoveFolder(string id, string newParent) | ||
118 | { | ||
119 | return m_Folders.MoveFolder(id, newParent); | ||
120 | } | ||
121 | |||
117 | public XInventoryItem[] GetActiveGestures(UUID principalID) | 122 | public XInventoryItem[] GetActiveGestures(UUID principalID) |
118 | { | 123 | { |
119 | return m_Items.GetActiveGestures(principalID); | 124 | return m_Items.GetActiveGestures(principalID); |
@@ -125,44 +130,106 @@ namespace OpenSim.Data.SQLite | |||
125 | } | 130 | } |
126 | } | 131 | } |
127 | 132 | ||
128 | public class SqliteItemHandler : SQLiteGenericTableHandler<XInventoryItem> | 133 | public class SqliteItemHandler : SqliteInventoryHandler<XInventoryItem> |
129 | { | 134 | { |
130 | public SqliteItemHandler(string c, string t, string m) : | 135 | public SqliteItemHandler(string c, string t, string m) : |
131 | base(c, t, m) | 136 | base(c, t, m) |
132 | { | 137 | { |
133 | } | 138 | } |
134 | 139 | ||
140 | public override bool Store(XInventoryItem item) | ||
141 | { | ||
142 | if (!base.Store(item)) | ||
143 | return false; | ||
144 | |||
145 | IncrementFolderVersion(item.parentFolderID); | ||
146 | |||
147 | return true; | ||
148 | } | ||
149 | |||
150 | public override bool Delete(string field, string val) | ||
151 | { | ||
152 | XInventoryItem[] retrievedItems = Get(new string[] { field }, new string[] { val }); | ||
153 | if (retrievedItems.Length == 0) | ||
154 | return false; | ||
155 | |||
156 | if (!base.Delete(field, val)) | ||
157 | return false; | ||
158 | |||
159 | // Don't increment folder version here since Delete(string, string) calls Delete(string[], string[]) | ||
160 | // IncrementFolderVersion(retrievedItems[0].parentFolderID); | ||
161 | |||
162 | return true; | ||
163 | } | ||
164 | |||
165 | public override bool Delete(string[] fields, string[] vals) | ||
166 | { | ||
167 | XInventoryItem[] retrievedItems = Get(fields, vals); | ||
168 | if (retrievedItems.Length == 0) | ||
169 | return false; | ||
170 | |||
171 | if (!base.Delete(fields, vals)) | ||
172 | return false; | ||
173 | |||
174 | HashSet<UUID> deletedItemFolderUUIDs = new HashSet<UUID>(); | ||
175 | |||
176 | Array.ForEach<XInventoryItem>(retrievedItems, i => deletedItemFolderUUIDs.Add(i.parentFolderID)); | ||
177 | |||
178 | foreach (UUID deletedItemFolderUUID in deletedItemFolderUUIDs) | ||
179 | IncrementFolderVersion(deletedItemFolderUUID); | ||
180 | |||
181 | return true; | ||
182 | } | ||
183 | |||
135 | public bool MoveItem(string id, string newParent) | 184 | public bool MoveItem(string id, string newParent) |
136 | { | 185 | { |
137 | SqliteCommand cmd = new SqliteCommand(); | 186 | XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id }); |
187 | if (retrievedItems.Length == 0) | ||
188 | return false; | ||
189 | |||
190 | UUID oldParent = retrievedItems[0].parentFolderID; | ||
191 | |||
192 | using (SqliteCommand cmd = new SqliteCommand()) | ||
193 | { | ||
194 | cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where inventoryID = :InventoryID", m_Realm); | ||
195 | cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParent)); | ||
196 | cmd.Parameters.Add(new SqliteParameter(":InventoryID", id)); | ||
138 | 197 | ||
139 | cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where inventoryID = :InventoryID", m_Realm); | 198 | if (ExecuteNonQuery(cmd, m_Connection) == 0) |
140 | cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParent)); | 199 | return false; |
141 | cmd.Parameters.Add(new SqliteParameter(":InventoryID", id)); | 200 | } |
201 | |||
202 | IncrementFolderVersion(oldParent); | ||
203 | IncrementFolderVersion(newParent); | ||
142 | 204 | ||
143 | return ExecuteNonQuery(cmd, m_Connection) == 0 ? false : true; | 205 | return true; |
144 | } | 206 | } |
145 | 207 | ||
146 | public XInventoryItem[] GetActiveGestures(UUID principalID) | 208 | public XInventoryItem[] GetActiveGestures(UUID principalID) |
147 | { | 209 | { |
148 | SqliteCommand cmd = new SqliteCommand(); | 210 | using (SqliteCommand cmd = new SqliteCommand()) |
149 | cmd.CommandText = String.Format("select * from inventoryitems where avatarId = :uuid and assetType = :type and flags = 1", m_Realm); | 211 | { |
212 | cmd.CommandText = String.Format("select * from inventoryitems where avatarId = :uuid and assetType = :type and flags = 1", m_Realm); | ||
150 | 213 | ||
151 | cmd.Parameters.Add(new SqliteParameter(":uuid", principalID.ToString())); | 214 | cmd.Parameters.Add(new SqliteParameter(":uuid", principalID.ToString())); |
152 | cmd.Parameters.Add(new SqliteParameter(":type", (int)AssetType.Gesture)); | 215 | cmd.Parameters.Add(new SqliteParameter(":type", (int)AssetType.Gesture)); |
153 | 216 | ||
154 | return DoQuery(cmd); | 217 | return DoQuery(cmd); |
218 | } | ||
155 | } | 219 | } |
156 | 220 | ||
157 | public int GetAssetPermissions(UUID principalID, UUID assetID) | 221 | public int GetAssetPermissions(UUID principalID, UUID assetID) |
158 | { | 222 | { |
159 | SqliteCommand cmd = new SqliteCommand(); | 223 | IDataReader reader; |
160 | 224 | ||
161 | cmd.CommandText = String.Format("select inventoryCurrentPermissions from inventoryitems where avatarID = :PrincipalID and assetID = :AssetID", m_Realm); | 225 | using (SqliteCommand cmd = new SqliteCommand()) |
162 | cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); | 226 | { |
163 | cmd.Parameters.Add(new SqliteParameter(":AssetID", assetID.ToString())); | 227 | cmd.CommandText = String.Format("select inventoryCurrentPermissions from inventoryitems where avatarID = :PrincipalID and assetID = :AssetID", m_Realm); |
228 | cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); | ||
229 | cmd.Parameters.Add(new SqliteParameter(":AssetID", assetID.ToString())); | ||
164 | 230 | ||
165 | IDataReader reader = ExecuteReader(cmd, m_Connection); | 231 | reader = ExecuteReader(cmd, m_Connection); |
232 | } | ||
166 | 233 | ||
167 | int perms = 0; | 234 | int perms = 0; |
168 | 235 | ||
@@ -177,4 +244,81 @@ namespace OpenSim.Data.SQLite | |||
177 | return perms; | 244 | return perms; |
178 | } | 245 | } |
179 | } | 246 | } |
180 | } | 247 | |
248 | public class SqliteFolderHandler : SqliteInventoryHandler<XInventoryFolder> | ||
249 | { | ||
250 | public SqliteFolderHandler(string c, string t, string m) : | ||
251 | base(c, t, m) | ||
252 | { | ||
253 | } | ||
254 | |||
255 | public override bool Store(XInventoryFolder folder) | ||
256 | { | ||
257 | if (!base.Store(folder)) | ||
258 | return false; | ||
259 | |||
260 | IncrementFolderVersion(folder.parentFolderID); | ||
261 | |||
262 | return true; | ||
263 | } | ||
264 | |||
265 | public bool MoveFolder(string id, string newParentFolderID) | ||
266 | { | ||
267 | XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id }); | ||
268 | |||
269 | if (folders.Length == 0) | ||
270 | return false; | ||
271 | |||
272 | UUID oldParentFolderUUID = folders[0].parentFolderID; | ||
273 | |||
274 | using (SqliteCommand cmd = new SqliteCommand()) | ||
275 | { | ||
276 | cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where folderID = :FolderID", m_Realm); | ||
277 | cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParentFolderID)); | ||
278 | cmd.Parameters.Add(new SqliteParameter(":FolderID", id)); | ||
279 | |||
280 | if (ExecuteNonQuery(cmd, m_Connection) == 0) | ||
281 | return false; | ||
282 | } | ||
283 | |||
284 | IncrementFolderVersion(oldParentFolderUUID); | ||
285 | IncrementFolderVersion(newParentFolderID); | ||
286 | |||
287 | return true; | ||
288 | } | ||
289 | |||
290 | } | ||
291 | |||
292 | public class SqliteInventoryHandler<T> : SQLiteGenericTableHandler<T> where T: class, new() | ||
293 | { | ||
294 | public SqliteInventoryHandler(string c, string t, string m) : base(c, t, m) {} | ||
295 | |||
296 | protected bool IncrementFolderVersion(UUID folderID) | ||
297 | { | ||
298 | return IncrementFolderVersion(folderID.ToString()); | ||
299 | } | ||
300 | |||
301 | protected bool IncrementFolderVersion(string folderID) | ||
302 | { | ||
303 | // m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID); | ||
304 | // Util.PrintCallStack(); | ||
305 | |||
306 | using (SqliteCommand cmd = new SqliteCommand()) | ||
307 | { | ||
308 | cmd.CommandText = "update inventoryfolders set version=version+1 where folderID = ?folderID"; | ||
309 | cmd.Parameters.Add(new SqliteParameter(":folderID", folderID)); | ||
310 | |||
311 | try | ||
312 | { | ||
313 | cmd.ExecuteNonQuery(); | ||
314 | } | ||
315 | catch (Exception) | ||
316 | { | ||
317 | return false; | ||
318 | } | ||
319 | } | ||
320 | |||
321 | return true; | ||
322 | } | ||
323 | } | ||
324 | } \ No newline at end of file | ||