aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MSSQL/MSSQLRegionData.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLRegionData.cs1201
1 files changed, 573 insertions, 628 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLRegionData.cs b/OpenSim/Data/MSSQL/MSSQLRegionData.cs
index 179b48a..e710d1c 100644
--- a/OpenSim/Data/MSSQL/MSSQLRegionData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLRegionData.cs
@@ -54,19 +54,7 @@ namespace OpenSim.Data.MSSQL
54 /// The database manager 54 /// The database manager
55 /// </summary> 55 /// </summary>
56 private MSSQLManager _Database; 56 private MSSQLManager _Database;
57 57
58 /// <summary>
59 /// Const for the prim store..
60 /// </summary>
61 private const string _PrimSelect = "SELECT * FROM PRIMS WHERE RegionUUID = @RegionUUID"; //" AND UUID IN (@UUID)"; //SceneGroupID LIKE @SceneGroupID OR
62 private const string _ShapeSelect = "SELECT * FROM PRIMSHAPES WHERE UUID in (SELECT UUID FROM PRIMS WHERE RegionUUID = @RegionUUID)"; // AND UUID IN (@UUID))"; //(SceneGroupID LIKE @SceneGroupID OR
63 private const string _ItemsSelect = "SELECT * FROM PRIMITEMS WHERE primID in (SELECT UUID FROM PRIMS WHERE RegionUUID = @RegionUUID)"; // AND UUID IN (@UUID))"; //(SceneGroupID LIKE @SceneGroupID OR
64
65 private DataSet _PrimsDataSet;
66 private SqlDataAdapter _PrimDataAdapter;
67 private SqlDataAdapter _ShapeDataAdapter;
68 private SqlDataAdapter _ItemsDataAdapter;
69
70 /// <summary> 58 /// <summary>
71 /// Initialises the region datastore 59 /// Initialises the region datastore
72 /// </summary> 60 /// </summary>
@@ -75,7 +63,6 @@ namespace OpenSim.Data.MSSQL
75 { 63 {
76 if (!string.IsNullOrEmpty(connectionString)) 64 if (!string.IsNullOrEmpty(connectionString))
77 { 65 {
78 //Add MSSQLManager (dont know if we need it)
79 _Database = new MSSQLManager(connectionString); 66 _Database = new MSSQLManager(connectionString);
80 } 67 }
81 else 68 else
@@ -93,60 +80,6 @@ namespace OpenSim.Data.MSSQL
93 //Migration settings 80 //Migration settings
94 _Database.CheckMigration(_migrationStore); 81 _Database.CheckMigration(_migrationStore);
95 82
96 using (SqlConnection connection = _Database.DatabaseConnection())
97 {
98 //Create Dataset. Not filled!!!
99 _PrimsDataSet = new DataSet("primsdata");
100
101 using (SqlCommand primSelectCmd = new SqlCommand(_PrimSelect, connection))
102 {
103 primSelectCmd.Parameters.AddWithValue("@RegionUUID", "");
104 _PrimDataAdapter = new SqlDataAdapter(primSelectCmd);
105
106 DataTable primDataTable = new DataTable("prims");
107 _PrimDataAdapter.Fill(primDataTable);
108 primDataTable.PrimaryKey = new DataColumn[] { primDataTable.Columns["UUID"] };
109 _PrimsDataSet.Tables.Add(primDataTable);
110
111 SetupCommands(_PrimDataAdapter);
112
113 primDataTable.Clear();
114 }
115
116 using (SqlCommand shapeSelectCmd = new SqlCommand(_ShapeSelect, connection))
117 {
118 shapeSelectCmd.Parameters.AddWithValue("@RegionUUID", "");
119 _ShapeDataAdapter = new SqlDataAdapter(shapeSelectCmd);
120
121 DataTable shapeDataTable = new DataTable("primshapes");
122 _ShapeDataAdapter.Fill(shapeDataTable);
123 shapeDataTable.PrimaryKey = new DataColumn[] { shapeDataTable.Columns["UUID"] };
124 _PrimsDataSet.Tables.Add(shapeDataTable);
125
126 SetupCommands(_ShapeDataAdapter);
127
128 shapeDataTable.Clear();
129 }
130
131 using (SqlCommand itemSelectCmd = new SqlCommand(_ItemsSelect, connection))
132 {
133 itemSelectCmd.Parameters.AddWithValue("@RegionUUID", "");
134 _ItemsDataAdapter = new SqlDataAdapter(itemSelectCmd);
135
136 DataTable itemsDataTable = new DataTable("primitems");
137 _ItemsDataAdapter.Fill(itemsDataTable);
138 itemsDataTable.PrimaryKey = new DataColumn[] { itemsDataTable.Columns["itemID"] };
139 _PrimsDataSet.Tables.Add(itemsDataTable);
140
141 SetupCommands(_ItemsDataAdapter);
142
143 itemsDataTable.Clear();
144 }
145
146 connection.Close();
147 }
148
149 //After this we have a empty fully configured DataSet.
150 } 83 }
151 84
152 /// <summary> 85 /// <summary>
@@ -154,6 +87,8 @@ namespace OpenSim.Data.MSSQL
154 /// </summary> 87 /// </summary>
155 public void Dispose() { } 88 public void Dispose() { }
156 89
90 #region SceneObjectGroup region for loading and Store of the scene.
91
157 /// <summary> 92 /// <summary>
158 /// Loads the objects present in the region. 93 /// Loads the objects present in the region.
159 /// </summary> 94 /// </summary>
@@ -161,152 +96,117 @@ namespace OpenSim.Data.MSSQL
161 /// <returns></returns> 96 /// <returns></returns>
162 public List<SceneObjectGroup> LoadObjects(UUID regionUUID) 97 public List<SceneObjectGroup> LoadObjects(UUID regionUUID)
163 { 98 {
164 Dictionary<UUID, SceneObjectGroup> createdObjects = new Dictionary<UUID, SceneObjectGroup>(); 99 UUID lastGroupID = UUID.Zero;
165 100
166 //Retrieve all values of current region 101 List<SceneObjectPart> sceneObjectParts = new List<SceneObjectPart>();
167 RetrievePrimsDataForRegion(regionUUID, UUID.Zero, ""); 102 List<SceneObjectGroup> sceneObjectGroups = new List<SceneObjectGroup>();
103 SceneObjectGroup grp = null;
168 104
169 List<SceneObjectGroup> retvals = new List<SceneObjectGroup>();
170 105
171 DataTable prims = _PrimsDataSet.Tables["prims"]; 106 string query = "SELECT *, " +
172 DataTable shapes = _PrimsDataSet.Tables["primshapes"]; 107 "sort = CASE WHEN prims.UUID = prims.SceneGroupID THEN 0 ELSE 1 END " +
108 "FROM prims " +
109 "LEFT JOIN primshapes ON prims.UUID = primshapes.UUID " +
110 "WHERE RegionUUID = @RegionUUID " +
111 "ORDER BY SceneGroupID asc, sort asc, LinkNumber asc";
173 112
174 lock (_PrimsDataSet) 113 using (AutoClosingSqlCommand command = _Database.Query(query))
175 { 114 {
176 DataRow[] primsForRegion = prims.Select("", "ParentID ASC"); //.Select(byRegion, orderByParent); 115 command.Parameters.Add(_Database.CreateParameter("@regionUUID", regionUUID));
177
178 _Log.Info("[REGION DB]: " + "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID);
179 116
180 foreach (DataRow primRow in primsForRegion) 117 using (SqlDataReader reader = command.ExecuteReader())
181 { 118 {
182 try 119 while (reader.Read())
183 { 120 {
184 string uuid = (string)primRow["UUID"]; 121 SceneObjectPart sceneObjectPart = BuildPrim(reader);
185 string objID = (string)primRow["SceneGroupID"]; 122 if (reader["Shape"] is DBNull)
123 sceneObjectPart.Shape = PrimitiveBaseShape.Default;
124 else
125 sceneObjectPart.Shape = BuildShape(reader);
186 126
187 SceneObjectPart prim = buildPrim(primRow); 127 sceneObjectPart.FolderID = sceneObjectPart.UUID; // A relic from when we
128 // we thought prims contained
129 // folder objects. In
130 // reality, prim == folder
131 sceneObjectParts.Add(sceneObjectPart);
188 132
189 if (uuid == objID) //is new SceneObjectGroup ? 133 UUID groupID = new UUID(reader["SceneGroupID"].ToString());
134
135 if (groupID != lastGroupID) // New SOG
190 { 136 {
191 SceneObjectGroup group = new SceneObjectGroup(); 137 if (grp != null)
138 sceneObjectGroups.Add(grp);
192 139
193 DataRow shapeRow = shapes.Rows.Find(prim.UUID.ToString()); 140 lastGroupID = groupID;
194 if (shapeRow != null)
195 {
196 prim.Shape = buildShape(shapeRow);
197 }
198 else
199 {
200 _Log.Info(
201 "No shape found for prim in storage, so setting default box shape");
202 prim.Shape = PrimitiveBaseShape.Default;
203 }
204
205 group.SetRootPart(prim);
206 141
207 createdObjects.Add(group.UUID, group); 142 grp = new SceneObjectGroup(sceneObjectPart);
208 retvals.Add(group);
209 } 143 }
210 else 144 else
211 { 145 {
212 DataRow shapeRow = shapes.Rows.Find(prim.UUID.ToString()); 146 // Black magic to preserve link numbers
213 if (shapeRow != null) 147 // Why is this needed, fix this in AddPart method.
214 { 148 int link = sceneObjectPart.LinkNum;
215 prim.Shape = buildShape(shapeRow); 149
216 } 150 grp.AddPart(sceneObjectPart);
217 else 151
218 { 152 if (link != 0)
219 _Log.Info( 153 sceneObjectPart.LinkNum = link;
220 "No shape found for prim in storage, so setting default box shape");
221 prim.Shape = PrimitiveBaseShape.Default;
222 }
223 createdObjects[new UUID(objID)].AddPart(prim);
224 } 154 }
155 }
156 }
157 }
158
159 if (grp != null)
160 sceneObjectGroups.Add(grp);
161
162 //Load the inventory off all sceneobjects within the region
163 LoadItems(sceneObjectParts);
225 164
226 LoadItems(prim); 165 _Log.DebugFormat("[DATABASE] Loaded {0} objects using {1} prims", sceneObjectGroups.Count, sceneObjectParts.Count);
166
167 return sceneObjectGroups;
168
169 }
170
171 /// <summary>
172 /// Load in the prim's persisted inventory.
173 /// </summary>
174 /// <param name="allPrims">all prims on a region</param>
175 private void LoadItems(List<SceneObjectPart> allPrims)
176 {
177 using (AutoClosingSqlCommand command = _Database.Query("SELECT * FROM primitems WHERE PrimID = @PrimID"))
178 {
179 bool createParamOnce = true;
180
181 foreach (SceneObjectPart objectPart in allPrims)
182 {
183 if (createParamOnce)
184 {
185 command.Parameters.Add(_Database.CreateParameter("@PrimID", objectPart.UUID));
186 createParamOnce = false;
227 } 187 }
228 catch (Exception e) 188 else
229 { 189 {
230 _Log.Error("[REGION DB]: Failed create prim object, exception and data follows"); 190 command.Parameters["@PrimID"].Value = objectPart.UUID.ToString();
231 _Log.Info("[REGION DB]: " + e.Message); 191 }
232 foreach (DataColumn col in prims.Columns) 192
193 List<TaskInventoryItem> inventory = new List<TaskInventoryItem>();
194
195 using (SqlDataReader reader = command.ExecuteReader())
196 {
197 while (reader.Read())
233 { 198 {
234 _Log.Info("[REGION DB]: Col: " + col.ColumnName + " => " + primRow[col]); 199 TaskInventoryItem item = BuildItem(reader);
200
201 item.ParentID = objectPart.UUID; // Values in database are
202 // often wrong
203 inventory.Add(item);
235 } 204 }
236 } 205 }
237 }
238 206
239 _PrimsDataSet.Tables["prims"].Clear(); 207 objectPart.Inventory.RestoreInventoryItems(inventory);
240 _PrimsDataSet.Tables["primshapes"].Clear(); 208 }
241 _PrimsDataSet.Tables["primitems"].Clear();
242 } 209 }
243 return retvals;
244
245 #region Experimental
246
247 //
248 // //Get all prims
249 // string sql = "select * from prims where RegionUUID = @RegionUUID";
250 //
251 // using (AutoClosingSqlCommand cmdPrims = _Database.Query(sql))
252 // {
253 // cmdPrims.Parameters.AddWithValue("@RegionUUID", regionUUID.ToString());
254 // using (SqlDataReader readerPrims = cmdPrims.ExecuteReader())
255 // {
256 // while (readerPrims.Read())
257 // {
258 // string uuid = (string)readerPrims["UUID"];
259 // string objID = (string)readerPrims["SceneGroupID"];
260 // SceneObjectPart prim = buildPrim(readerPrims);
261 //
262 // //Setting default shape, will change shape ltr
263 // prim.Shape = PrimitiveBaseShape.Default;
264 //
265 // //Load inventory items of prim
266 // //LoadItems(prim);
267 //
268 // if (uuid == objID)
269 // {
270 // SceneObjectGroup group = new SceneObjectGroup();
271 //
272 // group.AddPart(prim);
273 // group.RootPart = prim;
274 //
275 // createdObjects.Add(group.UUID, group);
276 // retvals.Add(group);
277 // }
278 // else
279 // {
280 // createdObjects[new UUID(objID)].AddPart(prim);
281 // }
282 // }
283 // }
284 // }
285 // m_log.Info("[REGION DB]: Loaded " + retvals.Count + " prim objects for region: " + regionUUID);
286 //
287 // //Find all shapes related with prims
288 // sql = "select * from primshapes";
289 // using (AutoClosingSqlCommand cmdShapes = _Database.Query(sql))
290 // {
291 // using (SqlDataReader readerShapes = cmdShapes.ExecuteReader())
292 // {
293 // while (readerShapes.Read())
294 // {
295 // UUID UUID = new UUID((string) readerShapes["UUID"]);
296 //
297 // foreach (SceneObjectGroup objectGroup in createdObjects.Values)
298 // {
299 // if (objectGroup.Children.ContainsKey(UUID))
300 // {
301 // objectGroup.Children[UUID].Shape = buildShape(readerShapes);
302 // }
303 // }
304 // }
305 // }
306 // }
307 // return retvals;
308
309 #endregion
310 } 210 }
311 211
312 /// <summary> 212 /// <summary>
@@ -316,55 +216,184 @@ namespace OpenSim.Data.MSSQL
316 /// <param name="regionUUID"></param> 216 /// <param name="regionUUID"></param>
317 public void StoreObject(SceneObjectGroup obj, UUID regionUUID) 217 public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
318 { 218 {
319 //Retrieve all values of current region, and current scene/or prims 219 _Log.InfoFormat("[REGION DB]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Children.Count);
320 //Build primID's, we use IN so I can select all prims from objgroup
321 string primID = "";
322 220
323 lock (_Database) 221 using (SqlConnection conn = _Database.DatabaseConnection())
324 { 222 {
325 RetrievePrimsDataForRegion(regionUUID, obj.UUID, primID); 223 SqlTransaction transaction = conn.BeginTransaction();
326 224
327 _Log.InfoFormat("[REGION DB]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Children.Count); 225 try
328
329 DataTable prims = _PrimsDataSet.Tables["prims"];
330 DataTable shapes = _PrimsDataSet.Tables["primshapes"];
331
332 foreach (SceneObjectPart prim in obj.Children.Values)
333 { 226 {
334 if ((prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Temporary) == 0 227 foreach (SceneObjectPart sceneObjectPart in obj.Children.Values)
335 && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) == 0)
336 { 228 {
337 229 //Update prim
338 DataRow primRow = prims.Rows.Find(prim.UUID.ToString()); 230 using (SqlCommand sqlCommand = conn.CreateCommand())
339 if (primRow == null)
340 {
341 primRow = prims.NewRow();
342 fillPrimRow(primRow, prim, obj.UUID, regionUUID);
343 prims.Rows.Add(primRow);
344 }
345 else
346 { 231 {
347 fillPrimRow(primRow, prim, obj.UUID, regionUUID); 232 sqlCommand.Transaction = transaction;
233 try
234 {
235 StoreSceneObjectPrim(sceneObjectPart, sqlCommand, obj.UUID, regionUUID);
236 }
237 catch (SqlException sqlEx)
238 {
239 _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrim SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber);
240 throw;
241 }
348 } 242 }
349 243
350 DataRow shapeRow = shapes.Rows.Find(prim.UUID.ToString()); 244 //Update primshapes
351 if (shapeRow == null) 245 using (SqlCommand sqlCommand = conn.CreateCommand())
352 { 246 {
353 shapeRow = shapes.NewRow(); 247 sqlCommand.Transaction = transaction;
354 fillShapeRow(shapeRow, prim); 248 try
355 shapes.Rows.Add(shapeRow); 249 {
356 } 250 StoreSceneObjectPrimShapes(sceneObjectPart, sqlCommand, obj.UUID, regionUUID);
357 else 251 }
358 { 252 catch (SqlException sqlEx)
359 fillShapeRow(shapeRow, prim); 253 {
254 _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrimShapes SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber);
255 throw;
256 }
360 } 257 }
361 } 258 }
362 259
260 transaction.Commit();
363 } 261 }
262 catch (Exception ex)
263 {
264 _Log.ErrorFormat("[REGION DB]: Store SceneObjectGroup error: {0}, Rolling back...", ex.Message);
265 try
266 {
267 transaction.Rollback();
268 }
269 catch (Exception ex2)
270 {
271 //Show error
272 _Log.InfoFormat("[REGION DB]: Rollback of SceneObjectGroup store transaction failed with error: {0}", ex2.Message);
364 273
365 //Save changes 274 }
366 CommitDataSet(); 275 }
367 } 276 }
277
278 }
279
280 /// <summary>
281 /// Stores the prim of the sceneobjectpart.
282 /// </summary>
283 /// <param name="sceneObjectPart">The sceneobjectpart or prim.</param>
284 /// <param name="sqlCommand">The SQL command with the transaction.</param>
285 /// <param name="sceneGroupID">The scenegroup UUID.</param>
286 /// <param name="regionUUID">The region UUID.</param>
287 private void StoreSceneObjectPrim(SceneObjectPart sceneObjectPart, SqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID)
288 {
289 //Big query to update or insert a new prim.
290 //Note for SQL Server 2008 this could be simplified
291 string queryPrims = @"
292IF EXISTS (SELECT UUID FROM prims WHERE UUID = @UUID)
293 BEGIN
294 UPDATE prims SET
295 CreationDate = @CreationDate, Name = @Name, Text = @Text, Description = @Description, SitName = @SitName,
296 TouchName = @TouchName, ObjectFlags = @ObjectFlags, OwnerMask = @OwnerMask, NextOwnerMask = @NextOwnerMask, GroupMask = @GroupMask,
297 EveryoneMask = @EveryoneMask, BaseMask = @BaseMask, PositionX = @PositionX, PositionY = @PositionY, PositionZ = @PositionZ,
298 GroupPositionX = @GroupPositionX, GroupPositionY = @GroupPositionY, GroupPositionZ = @GroupPositionZ, VelocityX = @VelocityX,
299 VelocityY = @VelocityY, VelocityZ = @VelocityZ, AngularVelocityX = @AngularVelocityX, AngularVelocityY = @AngularVelocityY,
300 AngularVelocityZ = @AngularVelocityZ, AccelerationX = @AccelerationX, AccelerationY = @AccelerationY,
301 AccelerationZ = @AccelerationZ, RotationX = @RotationX, RotationY = @RotationY, RotationZ = @RotationZ, RotationW = @RotationW,
302 SitTargetOffsetX = @SitTargetOffsetX, SitTargetOffsetY = @SitTargetOffsetY, SitTargetOffsetZ = @SitTargetOffsetZ,
303 SitTargetOrientW = @SitTargetOrientW, SitTargetOrientX = @SitTargetOrientX, SitTargetOrientY = @SitTargetOrientY,
304 SitTargetOrientZ = @SitTargetOrientZ, RegionUUID = @RegionUUID, CreatorID = @CreatorID, OwnerID = @OwnerID, GroupID = @GroupID,
305 LastOwnerID = @LastOwnerID, SceneGroupID = @SceneGroupID, PayPrice = @PayPrice, PayButton1 = @PayButton1, PayButton2 = @PayButton2,
306 PayButton3 = @PayButton3, PayButton4 = @PayButton4, LoopedSound = @LoopedSound, LoopedSoundGain = @LoopedSoundGain,
307 TextureAnimation = @TextureAnimation, OmegaX = @OmegaX, OmegaY = @OmegaY, OmegaZ = @OmegaZ, CameraEyeOffsetX = @CameraEyeOffsetX,
308 CameraEyeOffsetY = @CameraEyeOffsetY, CameraEyeOffsetZ = @CameraEyeOffsetZ, CameraAtOffsetX = @CameraAtOffsetX,
309 CameraAtOffsetY = @CameraAtOffsetY, CameraAtOffsetZ = @CameraAtOffsetZ, ForceMouselook = @ForceMouselook,
310 ScriptAccessPin = @ScriptAccessPin, AllowedDrop = @AllowedDrop, DieAtEdge = @DieAtEdge, SalePrice = @SalePrice,
311 SaleType = @SaleType, ColorR = @ColorR, ColorG = @ColorG, ColorB = @ColorB, ColorA = @ColorA, ParticleSystem = @ParticleSystem,
312 ClickAction = @ClickAction, Material = @Material, CollisionSound = @CollisionSound, CollisionSoundVolume = @CollisionSoundVolume,
313 LinkNumber = @LinkNumber
314 WHERE UUID = @UUID
315 END
316ELSE
317 BEGIN
318 INSERT INTO
319 prims (
320 UUID, CreationDate, Name, Text, Description, SitName, TouchName, ObjectFlags, OwnerMask, NextOwnerMask, GroupMask,
321 EveryoneMask, BaseMask, PositionX, PositionY, PositionZ, GroupPositionX, GroupPositionY, GroupPositionZ, VelocityX,
322 VelocityY, VelocityZ, AngularVelocityX, AngularVelocityY, AngularVelocityZ, AccelerationX, AccelerationY, AccelerationZ,
323 RotationX, RotationY, RotationZ, RotationW, SitTargetOffsetX, SitTargetOffsetY, SitTargetOffsetZ, SitTargetOrientW,
324 SitTargetOrientX, SitTargetOrientY, SitTargetOrientZ, RegionUUID, CreatorID, OwnerID, GroupID, LastOwnerID, SceneGroupID,
325 PayPrice, PayButton1, PayButton2, PayButton3, PayButton4, LoopedSound, LoopedSoundGain, TextureAnimation, OmegaX,
326 OmegaY, OmegaZ, CameraEyeOffsetX, CameraEyeOffsetY, CameraEyeOffsetZ, CameraAtOffsetX, CameraAtOffsetY, CameraAtOffsetZ,
327 ForceMouselook, ScriptAccessPin, AllowedDrop, DieAtEdge, SalePrice, SaleType, ColorR, ColorG, ColorB, ColorA,
328 ParticleSystem, ClickAction, Material, CollisionSound, CollisionSoundVolume, LinkNumber
329 ) VALUES (
330 @UUID, @CreationDate, @Name, @Text, @Description, @SitName, @TouchName, @ObjectFlags, @OwnerMask, @NextOwnerMask, @GroupMask,
331 @EveryoneMask, @BaseMask, @PositionX, @PositionY, @PositionZ, @GroupPositionX, @GroupPositionY, @GroupPositionZ, @VelocityX,
332 @VelocityY, @VelocityZ, @AngularVelocityX, @AngularVelocityY, @AngularVelocityZ, @AccelerationX, @AccelerationY, @AccelerationZ,
333 @RotationX, @RotationY, @RotationZ, @RotationW, @SitTargetOffsetX, @SitTargetOffsetY, @SitTargetOffsetZ, @SitTargetOrientW,
334 @SitTargetOrientX, @SitTargetOrientY, @SitTargetOrientZ, @RegionUUID, @CreatorID, @OwnerID, @GroupID, @LastOwnerID, @SceneGroupID,
335 @PayPrice, @PayButton1, @PayButton2, @PayButton3, @PayButton4, @LoopedSound, @LoopedSoundGain, @TextureAnimation, @OmegaX,
336 @OmegaY, @OmegaZ, @CameraEyeOffsetX, @CameraEyeOffsetY, @CameraEyeOffsetZ, @CameraAtOffsetX, @CameraAtOffsetY, @CameraAtOffsetZ,
337 @ForceMouselook, @ScriptAccessPin, @AllowedDrop, @DieAtEdge, @SalePrice, @SaleType, @ColorR, @ColorG, @ColorB, @ColorA,
338 @ParticleSystem, @ClickAction, @Material, @CollisionSound, @CollisionSoundVolume, @LinkNumber
339 )
340 END";
341
342 //Set commandtext.
343 sqlCommand.CommandText = queryPrims;
344 //Add parameters
345 sqlCommand.Parameters.AddRange(CreatePrimParameters(sceneObjectPart, sceneGroupID, regionUUID));
346
347 //Execute the query. If it fails then error is trapped in calling function
348 sqlCommand.ExecuteNonQuery();
349 }
350
351 /// <summary>
352 /// Stores the scene object prim shapes.
353 /// </summary>
354 /// <param name="sceneObjectPart">The sceneobjectpart containing prim shape.</param>
355 /// <param name="sqlCommand">The SQL command with the transaction.</param>
356 /// <param name="sceneGroupID">The scenegroup UUID.</param>
357 /// <param name="regionUUID">The region UUID.</param>
358 private void StoreSceneObjectPrimShapes(SceneObjectPart sceneObjectPart, SqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID)
359 {
360 //Big query to or insert or update primshapes
361 //Note for SQL Server 2008 this can be simplified
362 string queryPrimShapes = @"
363IF EXISTS (SELECT UUID FROM primshapes WHERE UUID = @UUID)
364 BEGIN
365 UPDATE primshapes SET
366 Shape = @Shape, ScaleX = @ScaleX, ScaleY = @ScaleY, ScaleZ = @ScaleZ, PCode = @PCode, PathBegin = @PathBegin,
367 PathEnd = @PathEnd, PathScaleX = @PathScaleX, PathScaleY = @PathScaleY, PathShearX = @PathShearX, PathShearY = @PathShearY,
368 PathSkew = @PathSkew, PathCurve = @PathCurve, PathRadiusOffset = @PathRadiusOffset, PathRevolutions = @PathRevolutions,
369 PathTaperX = @PathTaperX, PathTaperY = @PathTaperY, PathTwist = @PathTwist, PathTwistBegin = @PathTwistBegin,
370 ProfileBegin = @ProfileBegin, ProfileEnd = @ProfileEnd, ProfileCurve = @ProfileCurve, ProfileHollow = @ProfileHollow,
371 Texture = @Texture, ExtraParams = @ExtraParams, State = @State
372 WHERE UUID = @UUID
373 END
374ELSE
375 BEGIN
376 INSERT INTO
377 primshapes (
378 UUID, Shape, ScaleX, ScaleY, ScaleZ, PCode, PathBegin, PathEnd, PathScaleX, PathScaleY, PathShearX, PathShearY,
379 PathSkew, PathCurve, PathRadiusOffset, PathRevolutions, PathTaperX, PathTaperY, PathTwist, PathTwistBegin, ProfileBegin,
380 ProfileEnd, ProfileCurve, ProfileHollow, Texture, ExtraParams, State
381 ) VALUES (
382 @UUID, @Shape, @ScaleX, @ScaleY, @ScaleZ, @PCode, @PathBegin, @PathEnd, @PathScaleX, @PathScaleY, @PathShearX, @PathShearY,
383 @PathSkew, @PathCurve, @PathRadiusOffset, @PathRevolutions, @PathTaperX, @PathTaperY, @PathTwist, @PathTwistBegin, @ProfileBegin,
384 @ProfileEnd, @ProfileCurve, @ProfileHollow, @Texture, @ExtraParams, @State
385 )
386 END";
387
388 //Set commandtext.
389 sqlCommand.CommandText = queryPrimShapes;
390
391 //Add parameters
392 sqlCommand.Parameters.AddRange(CreatePrimShapeParameters(sceneObjectPart, sceneGroupID, regionUUID));
393
394 //Execute the query. If it fails then error is trapped in calling function
395 sqlCommand.ExecuteNonQuery();
396
368 } 397 }
369 398
370 /// <summary> 399 /// <summary>
@@ -405,7 +434,7 @@ namespace OpenSim.Data.MSSQL
405 /// <param name="items"></param> 434 /// <param name="items"></param>
406 public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) 435 public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items)
407 { 436 {
408 //_Log.InfoFormat("[REGION DB]: Persisting Prim Inventory with prim ID {0}", primID); 437 //_Log.InfoFormat("[REGION DB: Persisting Prim Inventory with prim ID {0}", primID);
409 438
410 //Statement from MySQL section! 439 //Statement from MySQL section!
411 // For now, we're just going to crudely remove all the previous inventory items 440 // For now, we're just going to crudely remove all the previous inventory items
@@ -420,13 +449,17 @@ namespace OpenSim.Data.MSSQL
420 } 449 }
421 450
422 string sql = 451 string sql =
423 "INSERT INTO [primitems] ([itemID],[primID],[assetID],[parentFolderID],[invType],[assetType],[name],[description],[creationDate],[creatorID],[ownerID],[lastOwnerID],[groupID],[nextPermissions],[currentPermissions],[basePermissions],[everyonePermissions],[groupPermissions],[flags]) VALUES (@itemID,@primID,@assetID,@parentFolderID,@invType,@assetType,@name,@description,@creationDate,@creatorID,@ownerID,@lastOwnerID,@groupID,@nextPermissions,@currentPermissions,@basePermissions,@everyonePermissions,@groupPermissions,@flags)"; 452 @"INSERT INTO primitems (
453 itemID,primID,assetID,parentFolderID,invType,assetType,name,description,creationDate,creatorID,ownerID,lastOwnerID,groupID,
454 nextPermissions,currentPermissions,basePermissions,everyonePermissions,groupPermissions,flags)
455 VALUES (@itemID,@primID,@assetID,@parentFolderID,@invType,@assetType,@name,@description,@creationDate,@creatorID,@ownerID,
456 @lastOwnerID,@groupID,@nextPermissions,@currentPermissions,@basePermissions,@everyonePermissions,@groupPermissions,@flags)";
424 457
425 using (AutoClosingSqlCommand cmd = _Database.Query(sql)) 458 using (AutoClosingSqlCommand cmd = _Database.Query(sql))
426 { 459 {
427 foreach (TaskInventoryItem taskItem in items) 460 foreach (TaskInventoryItem taskItem in items)
428 { 461 {
429 cmd.Parameters.AddRange(CreatePrimInventoryParameters(taskItem)); 462 cmd.Parameters.AddRange(CreatePrimInventoryParameters(taskItem));
430 cmd.ExecuteNonQuery(); 463 cmd.ExecuteNonQuery();
431 464
432 cmd.Parameters.Clear(); 465 cmd.Parameters.Clear();
@@ -434,6 +467,8 @@ namespace OpenSim.Data.MSSQL
434 } 467 }
435 } 468 }
436 469
470 #endregion
471
437 /// <summary> 472 /// <summary>
438 /// Loads the terrain map. 473 /// Loads the terrain map.
439 /// </summary> 474 /// </summary>
@@ -529,7 +564,7 @@ namespace OpenSim.Data.MSSQL
529 { 564 {
530 while (readerLandData.Read()) 565 while (readerLandData.Read())
531 { 566 {
532 landDataForRegion.Add(buildLandData(readerLandData)); 567 landDataForRegion.Add(BuildLandData(readerLandData));
533 } 568 }
534 } 569 }
535 } 570 }
@@ -545,7 +580,7 @@ namespace OpenSim.Data.MSSQL
545 { 580 {
546 while (readerAccessList.Read()) 581 while (readerAccessList.Read())
547 { 582 {
548 landData.ParcelAccessList.Add(buildLandAccessData(readerAccessList)); 583 landData.ParcelAccessList.Add(BuildLandAccessData(readerAccessList));
549 } 584 }
550 } 585 }
551 } 586 }
@@ -586,7 +621,7 @@ VALUES
586 { 621 {
587 foreach (ParcelManager.ParcelAccessEntry parcelAccessEntry in parcel.landData.ParcelAccessList) 622 foreach (ParcelManager.ParcelAccessEntry parcelAccessEntry in parcel.landData.ParcelAccessList)
588 { 623 {
589 cmd.Parameters.AddRange(CreateLandAccessParameters(parcelAccessEntry, parcel.regionUUID)); 624 cmd.Parameters.AddRange(CreateLandAccessParameters(parcelAccessEntry, parcel.regionUUID));
590 625
591 cmd.ExecuteNonQuery(); 626 cmd.ExecuteNonQuery();
592 cmd.Parameters.Clear(); 627 cmd.Parameters.Clear();
@@ -629,7 +664,7 @@ VALUES
629 { 664 {
630 if (reader.Read()) 665 if (reader.Read())
631 { 666 {
632 regionSettings = buildRegionSettings(reader); 667 regionSettings = BuildRegionSettings(reader);
633 regionSettings.OnSave += StoreRegionSettings; 668 regionSettings.OnSave += StoreRegionSettings;
634 669
635 return regionSettings; 670 return regionSettings;
@@ -698,37 +733,6 @@ VALUES
698 #region Private Methods 733 #region Private Methods
699 734
700 /// <summary> 735 /// <summary>
701 /// Load in a prim's persisted inventory.
702 /// </summary>
703 /// <param name="prim">The prim</param>
704 private void LoadItems(SceneObjectPart prim)
705 {
706 DataTable dbItems = _PrimsDataSet.Tables["primitems"];
707
708 String sql = String.Format("primID = '{0}'", prim.UUID);
709 DataRow[] dbItemRows = dbItems.Select(sql);
710
711 IList<TaskInventoryItem> inventory = new List<TaskInventoryItem>();
712
713 foreach (DataRow row in dbItemRows)
714 {
715 TaskInventoryItem item = buildItem(row);
716 inventory.Add(item);
717
718 //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID);
719 }
720
721 prim.Inventory.RestoreInventoryItems(inventory);
722
723 // XXX A nasty little hack to recover the folder id for the prim (which is currently stored in
724 // every item). This data should really be stored in the prim table itself.
725 if (dbItemRows.Length > 0)
726 {
727 prim.FolderID = inventory[0].ParentID;
728 }
729 }
730
731 /// <summary>
732 /// Serializes the terrain data for storage in DB. 736 /// Serializes the terrain data for storage in DB.
733 /// </summary> 737 /// </summary>
734 /// <param name="val">terrain data</param> 738 /// <param name="val">terrain data</param>
@@ -773,7 +777,7 @@ VALUES
773 777
774 using (AutoClosingSqlCommand cmd = _Database.Query(sql)) 778 using (AutoClosingSqlCommand cmd = _Database.Query(sql))
775 { 779 {
776 cmd.Parameters.AddRange(CreateRegionSettingParameters(regionSettings)); 780 cmd.Parameters.AddRange(CreateRegionSettingParameters(regionSettings));
777 cmd.ExecuteNonQuery(); 781 cmd.ExecuteNonQuery();
778 } 782 }
779 } 783 }
@@ -785,7 +789,7 @@ VALUES
785 /// </summary> 789 /// </summary>
786 /// <param name="row">datarecord with regionsettings.</param> 790 /// <param name="row">datarecord with regionsettings.</param>
787 /// <returns></returns> 791 /// <returns></returns>
788 private static RegionSettings buildRegionSettings(IDataRecord row) 792 private static RegionSettings BuildRegionSettings(IDataRecord row)
789 { 793 {
790 //TODO change this is some more generic code so we doesnt have to change it every time a new field is added? 794 //TODO change this is some more generic code so we doesnt have to change it every time a new field is added?
791 RegionSettings newSettings = new RegionSettings(); 795 RegionSettings newSettings = new RegionSettings();
@@ -838,7 +842,7 @@ VALUES
838 /// </summary> 842 /// </summary>
839 /// <param name="row">datarecord with land data</param> 843 /// <param name="row">datarecord with land data</param>
840 /// <returns></returns> 844 /// <returns></returns>
841 private static LandData buildLandData(IDataRecord row) 845 private static LandData BuildLandData(IDataRecord row)
842 { 846 {
843 LandData newData = new LandData(); 847 LandData newData = new LandData();
844 848
@@ -909,7 +913,7 @@ VALUES
909 /// </summary> 913 /// </summary>
910 /// <param name="row">datarecord with landaccess data</param> 914 /// <param name="row">datarecord with landaccess data</param>
911 /// <returns></returns> 915 /// <returns></returns>
912 private static ParcelManager.ParcelAccessEntry buildLandAccessData(IDataRecord row) 916 private static ParcelManager.ParcelAccessEntry BuildLandAccessData(IDataRecord row)
913 { 917 {
914 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); 918 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
915 entry.AgentID = new UUID((string)row["AccessUUID"]); 919 entry.AgentID = new UUID((string)row["AccessUUID"]);
@@ -923,13 +927,14 @@ VALUES
923 /// </summary> 927 /// </summary>
924 /// <param name="primRow">datarecord</param> 928 /// <param name="primRow">datarecord</param>
925 /// <returns></returns> 929 /// <returns></returns>
926 private static SceneObjectPart buildPrim(DataRow primRow) 930 private static SceneObjectPart BuildPrim(IDataRecord primRow)
927 { 931 {
928 SceneObjectPart prim = new SceneObjectPart(); 932 SceneObjectPart prim = new SceneObjectPart();
929 933
930 prim.UUID = new UUID((String)primRow["UUID"]); 934 prim.UUID = new UUID((String)primRow["UUID"]);
931 // explicit conversion of integers is required, which sort 935 // explicit conversion of integers is required, which sort
932 // of sucks. No idea if there is a shortcut here or not. 936 // of sucks. No idea if there is a shortcut here or not.
937 //prim.ParentID = (uint)Convert.ToInt32(primRow["ParentID"]);
933 prim.CreationDate = Convert.ToInt32(primRow["CreationDate"]); 938 prim.CreationDate = Convert.ToInt32(primRow["CreationDate"]);
934 prim.Name = (String)primRow["Name"]; 939 prim.Name = (String)primRow["Name"];
935 // various text fields 940 // various text fields
@@ -1006,9 +1011,9 @@ VALUES
1006 prim.SoundGain = Convert.ToSingle(primRow["LoopedSoundGain"]); 1011 prim.SoundGain = Convert.ToSingle(primRow["LoopedSoundGain"]);
1007 prim.SoundFlags = 1; // If it's persisted at all, it's looped 1012 prim.SoundFlags = 1; // If it's persisted at all, it's looped
1008 1013
1009 if (!primRow.IsNull("TextureAnimation") && primRow["TextureAnimation"] != DBNull.Value) 1014 if (!(primRow["TextureAnimation"] is DBNull))
1010 prim.TextureAnimation = (Byte[])primRow["TextureAnimation"]; 1015 prim.TextureAnimation = (Byte[])primRow["TextureAnimation"];
1011 if (!primRow.IsNull("ParticleSystem")) 1016 if (!(primRow["ParticleSystem"] is DBNull))
1012 prim.ParticleSystem = (Byte[])primRow["ParticleSystem"]; 1017 prim.ParticleSystem = (Byte[])primRow["ParticleSystem"];
1013 1018
1014 prim.RotationalVelocity = new Vector3( 1019 prim.RotationalVelocity = new Vector3(
@@ -1044,97 +1049,100 @@ VALUES
1044 1049
1045 prim.Material = Convert.ToByte(primRow["Material"]); 1050 prim.Material = Convert.ToByte(primRow["Material"]);
1046 1051
1047 if (!primRow.IsNull("ClickAction")) 1052 if (!(primRow["ClickAction"] is DBNull))
1048 prim.ClickAction = Convert.ToByte(primRow["ClickAction"]); 1053 prim.ClickAction = Convert.ToByte(primRow["ClickAction"]);
1049 1054
1050 prim.CollisionSound = new UUID(primRow["CollisionSound"].ToString()); 1055 prim.CollisionSound = new UUID(primRow["CollisionSound"].ToString());
1051 prim.CollisionSoundVolume = Convert.ToSingle(primRow["CollisionSoundVolume"]); 1056 prim.CollisionSoundVolume = Convert.ToSingle(primRow["CollisionSoundVolume"]);
1052 1057
1058 prim.LinkNum = Convert.ToInt32(primRow["LinkNumber"]);
1059
1053 return prim; 1060 return prim;
1054 } 1061 }
1055 1062
1056 /// <summary> 1063 /// <summary>
1057 /// Builds the prim shape from a datarecord. 1064 /// Builds the prim shape from a datarecord.
1058 /// </summary> 1065 /// </summary>
1059 /// <param name="row">The row.</param> 1066 /// <param name="shapeRow">The row.</param>
1060 /// <returns></returns> 1067 /// <returns></returns>
1061 private static PrimitiveBaseShape buildShape(DataRow row) 1068 private static PrimitiveBaseShape BuildShape(IDataRecord shapeRow)
1062 { 1069 {
1063 PrimitiveBaseShape s = new PrimitiveBaseShape(); 1070 PrimitiveBaseShape baseShape = new PrimitiveBaseShape();
1064 s.Scale = new Vector3( 1071
1065 Convert.ToSingle(row["ScaleX"]), 1072 baseShape.Scale = new Vector3(
1066 Convert.ToSingle(row["ScaleY"]), 1073 Convert.ToSingle(shapeRow["ScaleX"]),
1067 Convert.ToSingle(row["ScaleZ"])); 1074 Convert.ToSingle(shapeRow["ScaleY"]),
1075 Convert.ToSingle(shapeRow["ScaleZ"]));
1068 1076
1069 // paths 1077 // paths
1070 s.PCode = Convert.ToByte(row["PCode"]); 1078 baseShape.PCode = Convert.ToByte(shapeRow["PCode"]);
1071 s.PathBegin = Convert.ToUInt16(row["PathBegin"]); 1079 baseShape.PathBegin = Convert.ToUInt16(shapeRow["PathBegin"]);
1072 s.PathEnd = Convert.ToUInt16(row["PathEnd"]); 1080 baseShape.PathEnd = Convert.ToUInt16(shapeRow["PathEnd"]);
1073 s.PathScaleX = Convert.ToByte(row["PathScaleX"]); 1081 baseShape.PathScaleX = Convert.ToByte(shapeRow["PathScaleX"]);
1074 s.PathScaleY = Convert.ToByte(row["PathScaleY"]); 1082 baseShape.PathScaleY = Convert.ToByte(shapeRow["PathScaleY"]);
1075 s.PathShearX = Convert.ToByte(row["PathShearX"]); 1083 baseShape.PathShearX = Convert.ToByte(shapeRow["PathShearX"]);
1076 s.PathShearY = Convert.ToByte(row["PathShearY"]); 1084 baseShape.PathShearY = Convert.ToByte(shapeRow["PathShearY"]);
1077 s.PathSkew = Convert.ToSByte(row["PathSkew"]); 1085 baseShape.PathSkew = Convert.ToSByte(shapeRow["PathSkew"]);
1078 s.PathCurve = Convert.ToByte(row["PathCurve"]); 1086 baseShape.PathCurve = Convert.ToByte(shapeRow["PathCurve"]);
1079 s.PathRadiusOffset = Convert.ToSByte(row["PathRadiusOffset"]); 1087 baseShape.PathRadiusOffset = Convert.ToSByte(shapeRow["PathRadiusOffset"]);
1080 s.PathRevolutions = Convert.ToByte(row["PathRevolutions"]); 1088 baseShape.PathRevolutions = Convert.ToByte(shapeRow["PathRevolutions"]);
1081 s.PathTaperX = Convert.ToSByte(row["PathTaperX"]); 1089 baseShape.PathTaperX = Convert.ToSByte(shapeRow["PathTaperX"]);
1082 s.PathTaperY = Convert.ToSByte(row["PathTaperY"]); 1090 baseShape.PathTaperY = Convert.ToSByte(shapeRow["PathTaperY"]);
1083 s.PathTwist = Convert.ToSByte(row["PathTwist"]); 1091 baseShape.PathTwist = Convert.ToSByte(shapeRow["PathTwist"]);
1084 s.PathTwistBegin = Convert.ToSByte(row["PathTwistBegin"]); 1092 baseShape.PathTwistBegin = Convert.ToSByte(shapeRow["PathTwistBegin"]);
1085 // profile 1093 // profile
1086 s.ProfileBegin = Convert.ToUInt16(row["ProfileBegin"]); 1094 baseShape.ProfileBegin = Convert.ToUInt16(shapeRow["ProfileBegin"]);
1087 s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]); 1095 baseShape.ProfileEnd = Convert.ToUInt16(shapeRow["ProfileEnd"]);
1088 s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]); 1096 baseShape.ProfileCurve = Convert.ToByte(shapeRow["ProfileCurve"]);
1089 s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); 1097 baseShape.ProfileHollow = Convert.ToUInt16(shapeRow["ProfileHollow"]);
1090 1098
1091 byte[] textureEntry = (byte[])row["Texture"]; 1099 byte[] textureEntry = (byte[])shapeRow["Texture"];
1092 s.TextureEntry = textureEntry; 1100 baseShape.TextureEntry = textureEntry;
1093 1101
1094 s.ExtraParams = (byte[])row["ExtraParams"]; 1102 baseShape.ExtraParams = (byte[])shapeRow["ExtraParams"];
1095 1103
1096 try 1104 try
1097 { 1105 {
1098 s.State = Convert.ToByte(row["State"]); 1106 baseShape.State = Convert.ToByte(shapeRow["State"]);
1099 } 1107 }
1100 catch (InvalidCastException) 1108 catch (InvalidCastException)
1101 { 1109 {
1102 } 1110 }
1103 1111
1104 return s; 1112 return baseShape;
1105 } 1113 }
1106 1114
1107 /// <summary> 1115 /// <summary>
1108 /// Build a prim inventory item from the persisted data. 1116 /// Build a prim inventory item from the persisted data.
1109 /// </summary> 1117 /// </summary>
1110 /// <param name="row"></param> 1118 /// <param name="inventoryRow"></param>
1111 /// <returns></returns> 1119 /// <returns></returns>
1112 private static TaskInventoryItem buildItem(DataRow row) 1120 private static TaskInventoryItem BuildItem(IDataRecord inventoryRow)
1113 { 1121 {
1114 TaskInventoryItem taskItem = new TaskInventoryItem(); 1122 TaskInventoryItem taskItem = new TaskInventoryItem();
1115 1123
1116 taskItem.ItemID = new UUID((String)row["itemID"]); 1124 taskItem.ItemID = new UUID((String)inventoryRow["itemID"]);
1117 taskItem.ParentPartID = new UUID((String)row["primID"]); 1125 taskItem.ParentPartID = new UUID((String)inventoryRow["primID"]);
1118 taskItem.AssetID = new UUID((String)row["assetID"]); 1126 taskItem.AssetID = new UUID((String)inventoryRow["assetID"]);
1119 taskItem.ParentID = new UUID((String)row["parentFolderID"]); 1127 taskItem.ParentID = new UUID((String)inventoryRow["parentFolderID"]);
1120 1128
1121 taskItem.InvType = Convert.ToInt32(row["invType"]); 1129 taskItem.InvType = Convert.ToInt32(inventoryRow["invType"]);
1122 taskItem.Type = Convert.ToInt32(row["assetType"]); 1130 taskItem.Type = Convert.ToInt32(inventoryRow["assetType"]);
1123 1131
1124 taskItem.Name = (String)row["name"]; 1132 taskItem.Name = (String)inventoryRow["name"];
1125 taskItem.Description = (String)row["description"]; 1133 taskItem.Description = (String)inventoryRow["description"];
1126 taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); 1134 taskItem.CreationDate = Convert.ToUInt32(inventoryRow["creationDate"]);
1127 taskItem.CreatorID = new UUID((String)row["creatorID"]); 1135 taskItem.CreatorID = new UUID((String)inventoryRow["creatorID"]);
1128 taskItem.OwnerID = new UUID((String)row["ownerID"]); 1136 taskItem.OwnerID = new UUID((String)inventoryRow["ownerID"]);
1129 taskItem.LastOwnerID = new UUID((String)row["lastOwnerID"]); 1137 taskItem.LastOwnerID = new UUID((String)inventoryRow["lastOwnerID"]);
1130 taskItem.GroupID = new UUID((String)row["groupID"]); 1138 taskItem.GroupID = new UUID((String)inventoryRow["groupID"]);
1131 1139
1132 taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]); 1140 taskItem.NextPermissions = Convert.ToUInt32(inventoryRow["nextPermissions"]);
1133 taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]); 1141 taskItem.CurrentPermissions = Convert.ToUInt32(inventoryRow["currentPermissions"]);
1134 taskItem.BasePermissions = Convert.ToUInt32(row["basePermissions"]); 1142 taskItem.BasePermissions = Convert.ToUInt32(inventoryRow["basePermissions"]);
1135 taskItem.EveryonePermissions = Convert.ToUInt32(row["everyonePermissions"]); 1143 taskItem.EveryonePermissions = Convert.ToUInt32(inventoryRow["everyonePermissions"]);
1136 taskItem.GroupPermissions = Convert.ToUInt32(row["groupPermissions"]); 1144 taskItem.GroupPermissions = Convert.ToUInt32(inventoryRow["groupPermissions"]);
1137 taskItem.Flags = Convert.ToUInt32(row["flags"]); 1145 taskItem.Flags = Convert.ToUInt32(inventoryRow["flags"]);
1138 1146
1139 return taskItem; 1147 return taskItem;
1140 } 1148 }
@@ -1149,31 +1157,30 @@ VALUES
1149 /// <returns></returns> 1157 /// <returns></returns>
1150 private SqlParameter[] CreatePrimInventoryParameters(TaskInventoryItem taskItem) 1158 private SqlParameter[] CreatePrimInventoryParameters(TaskInventoryItem taskItem)
1151 { 1159 {
1152 SqlParameter[] parameters = new SqlParameter[19]; 1160 List<SqlParameter> parameters = new List<SqlParameter>();
1153 1161
1154 parameters[0] = _Database.CreateParameter("itemID", taskItem.ItemID); 1162 parameters.Add(_Database.CreateParameter("itemID", taskItem.ItemID));
1155 parameters[1] = _Database.CreateParameter("primID", taskItem.ParentPartID); 1163 parameters.Add(_Database.CreateParameter("primID", taskItem.ParentPartID));
1156 parameters[2] = _Database.CreateParameter("assetID", taskItem.AssetID); 1164 parameters.Add(_Database.CreateParameter("assetID", taskItem.AssetID));
1157 parameters[3] = _Database.CreateParameter("parentFolderID", taskItem.ParentID); 1165 parameters.Add(_Database.CreateParameter("parentFolderID", taskItem.ParentID));
1158 1166 parameters.Add(_Database.CreateParameter("invType", taskItem.InvType));
1159 parameters[4] = _Database.CreateParameter("invType", taskItem.InvType); 1167 parameters.Add(_Database.CreateParameter("assetType", taskItem.Type));
1160 parameters[5] = _Database.CreateParameter("assetType", taskItem.Type); 1168
1161 1169 parameters.Add(_Database.CreateParameter("name", taskItem.Name));
1162 parameters[6] = _Database.CreateParameter("name", taskItem.Name); 1170 parameters.Add(_Database.CreateParameter("description", taskItem.Description));
1163 parameters[7] = _Database.CreateParameter("description", taskItem.Description); 1171 parameters.Add(_Database.CreateParameter("creationDate", taskItem.CreationDate));
1164 parameters[8] = _Database.CreateParameter("creationDate", taskItem.CreationDate); 1172 parameters.Add(_Database.CreateParameter("creatorID", taskItem.CreatorID));
1165 parameters[9] = _Database.CreateParameter("creatorID", taskItem.CreatorID); 1173 parameters.Add(_Database.CreateParameter("ownerID", taskItem.OwnerID));
1166 parameters[10] = _Database.CreateParameter("ownerID", taskItem.OwnerID); 1174 parameters.Add(_Database.CreateParameter("lastOwnerID", taskItem.LastOwnerID));
1167 parameters[11] = _Database.CreateParameter("lastOwnerID", taskItem.LastOwnerID); 1175 parameters.Add(_Database.CreateParameter("groupID", taskItem.GroupID));
1168 parameters[12] = _Database.CreateParameter("groupID", taskItem.GroupID); 1176 parameters.Add(_Database.CreateParameter("nextPermissions", taskItem.NextPermissions));
1169 parameters[13] = _Database.CreateParameter("nextPermissions", taskItem.NextPermissions); 1177 parameters.Add(_Database.CreateParameter("currentPermissions", taskItem.CurrentPermissions));
1170 parameters[14] = _Database.CreateParameter("currentPermissions", taskItem.CurrentPermissions); 1178 parameters.Add(_Database.CreateParameter("basePermissions", taskItem.BasePermissions));
1171 parameters[15] = _Database.CreateParameter("basePermissions", taskItem.BasePermissions); 1179 parameters.Add(_Database.CreateParameter("everyonePermissions", taskItem.EveryonePermissions));
1172 parameters[16] = _Database.CreateParameter("everyonePermissions", taskItem.EveryonePermissions); 1180 parameters.Add(_Database.CreateParameter("groupPermissions", taskItem.GroupPermissions));
1173 parameters[17] = _Database.CreateParameter("groupPermissions", taskItem.GroupPermissions); 1181 parameters.Add(_Database.CreateParameter("flags", taskItem.Flags));
1174 parameters[18] = _Database.CreateParameter("flags", taskItem.Flags); 1182
1175 1183 return parameters.ToArray();
1176 return parameters;
1177 } 1184 }
1178 1185
1179 /// <summary> 1186 /// <summary>
@@ -1183,47 +1190,47 @@ VALUES
1183 /// <returns></returns> 1190 /// <returns></returns>
1184 private SqlParameter[] CreateRegionSettingParameters(RegionSettings settings) 1191 private SqlParameter[] CreateRegionSettingParameters(RegionSettings settings)
1185 { 1192 {
1186 SqlParameter[] parameters = new SqlParameter[37]; 1193 List<SqlParameter> parameters = new List<SqlParameter>();
1187 1194
1188 parameters[0] = _Database.CreateParameter("regionUUID", settings.RegionUUID); 1195 parameters.Add(_Database.CreateParameter("regionUUID", settings.RegionUUID));
1189 parameters[1] = _Database.CreateParameter("block_terraform", settings.BlockTerraform); 1196 parameters.Add(_Database.CreateParameter("block_terraform", settings.BlockTerraform));
1190 parameters[2] = _Database.CreateParameter("block_fly", settings.BlockFly); 1197 parameters.Add(_Database.CreateParameter("block_fly", settings.BlockFly));
1191 parameters[3] = _Database.CreateParameter("allow_damage", settings.AllowDamage); 1198 parameters.Add(_Database.CreateParameter("allow_damage", settings.AllowDamage));
1192 parameters[4] = _Database.CreateParameter("restrict_pushing", settings.RestrictPushing); 1199 parameters.Add(_Database.CreateParameter("restrict_pushing", settings.RestrictPushing));
1193 parameters[5] = _Database.CreateParameter("allow_land_resell", settings.AllowLandResell); 1200 parameters.Add(_Database.CreateParameter("allow_land_resell", settings.AllowLandResell));
1194 parameters[6] = _Database.CreateParameter("allow_land_join_divide", settings.AllowLandJoinDivide); 1201 parameters.Add(_Database.CreateParameter("allow_land_join_divide", settings.AllowLandJoinDivide));
1195 parameters[7] = _Database.CreateParameter("block_show_in_search", settings.BlockShowInSearch); 1202 parameters.Add(_Database.CreateParameter("block_show_in_search", settings.BlockShowInSearch));
1196 parameters[8] = _Database.CreateParameter("agent_limit", settings.AgentLimit); 1203 parameters.Add(_Database.CreateParameter("agent_limit", settings.AgentLimit));
1197 parameters[9] = _Database.CreateParameter("object_bonus", settings.ObjectBonus); 1204 parameters.Add(_Database.CreateParameter("object_bonus", settings.ObjectBonus));
1198 parameters[10] = _Database.CreateParameter("maturity", settings.Maturity); 1205 parameters.Add(_Database.CreateParameter("maturity", settings.Maturity));
1199 parameters[11] = _Database.CreateParameter("disable_scripts", settings.DisableScripts); 1206 parameters.Add(_Database.CreateParameter("disable_scripts", settings.DisableScripts));
1200 parameters[12] = _Database.CreateParameter("disable_collisions", settings.DisableCollisions); 1207 parameters.Add(_Database.CreateParameter("disable_collisions", settings.DisableCollisions));
1201 parameters[13] = _Database.CreateParameter("disable_physics", settings.DisablePhysics); 1208 parameters.Add(_Database.CreateParameter("disable_physics", settings.DisablePhysics));
1202 parameters[14] = _Database.CreateParameter("terrain_texture_1", settings.TerrainTexture1); 1209 parameters.Add(_Database.CreateParameter("terrain_texture_1", settings.TerrainTexture1));
1203 parameters[15] = _Database.CreateParameter("terrain_texture_2", settings.TerrainTexture2); 1210 parameters.Add(_Database.CreateParameter("terrain_texture_2", settings.TerrainTexture2));
1204 parameters[16] = _Database.CreateParameter("terrain_texture_3", settings.TerrainTexture3); 1211 parameters.Add(_Database.CreateParameter("terrain_texture_3", settings.TerrainTexture3));
1205 parameters[17] = _Database.CreateParameter("terrain_texture_4", settings.TerrainTexture4); 1212 parameters.Add(_Database.CreateParameter("terrain_texture_4", settings.TerrainTexture4));
1206 parameters[18] = _Database.CreateParameter("elevation_1_nw", settings.Elevation1NW); 1213 parameters.Add(_Database.CreateParameter("elevation_1_nw", settings.Elevation1NW));
1207 parameters[19] = _Database.CreateParameter("elevation_2_nw", settings.Elevation2NW); 1214 parameters.Add(_Database.CreateParameter("elevation_2_nw", settings.Elevation2NW));
1208 parameters[20] = _Database.CreateParameter("elevation_1_ne", settings.Elevation1NE); 1215 parameters.Add(_Database.CreateParameter("elevation_1_ne", settings.Elevation1NE));
1209 parameters[21] = _Database.CreateParameter("elevation_2_ne", settings.Elevation2NE); 1216 parameters.Add(_Database.CreateParameter("elevation_2_ne", settings.Elevation2NE));
1210 parameters[22] = _Database.CreateParameter("elevation_1_se", settings.Elevation1SE); 1217 parameters.Add(_Database.CreateParameter("elevation_1_se", settings.Elevation1SE));
1211 parameters[23] = _Database.CreateParameter("elevation_2_se", settings.Elevation2SE); 1218 parameters.Add(_Database.CreateParameter("elevation_2_se", settings.Elevation2SE));
1212 parameters[24] = _Database.CreateParameter("elevation_1_sw", settings.Elevation1SW); 1219 parameters.Add(_Database.CreateParameter("elevation_1_sw", settings.Elevation1SW));
1213 parameters[25] = _Database.CreateParameter("elevation_2_sw", settings.Elevation2SW); 1220 parameters.Add(_Database.CreateParameter("elevation_2_sw", settings.Elevation2SW));
1214 parameters[26] = _Database.CreateParameter("water_height", settings.WaterHeight); 1221 parameters.Add(_Database.CreateParameter("water_height", settings.WaterHeight));
1215 parameters[27] = _Database.CreateParameter("terrain_raise_limit", settings.TerrainRaiseLimit); 1222 parameters.Add(_Database.CreateParameter("terrain_raise_limit", settings.TerrainRaiseLimit));
1216 parameters[28] = _Database.CreateParameter("terrain_lower_limit", settings.TerrainLowerLimit); 1223 parameters.Add(_Database.CreateParameter("terrain_lower_limit", settings.TerrainLowerLimit));
1217 parameters[29] = _Database.CreateParameter("use_estate_sun", settings.UseEstateSun); 1224 parameters.Add(_Database.CreateParameter("use_estate_sun", settings.UseEstateSun));
1218 parameters[30] = _Database.CreateParameter("sandbox", settings.Sandbox); 1225 parameters.Add(_Database.CreateParameter("sandbox", settings.Sandbox));
1219 parameters[31] = _Database.CreateParameter("fixed_sun", settings.FixedSun); 1226 parameters.Add(_Database.CreateParameter("fixed_sun", settings.FixedSun));
1220 parameters[32] = _Database.CreateParameter("sun_position", settings.SunPosition); 1227 parameters.Add(_Database.CreateParameter("sun_position", settings.SunPosition));
1221 parameters[33] = _Database.CreateParameter("sunvectorx", settings.SunVector.X); 1228 parameters.Add(_Database.CreateParameter("sunvectorx", settings.SunVector.X));
1222 parameters[34] = _Database.CreateParameter("sunvectory", settings.SunVector.Y); 1229 parameters.Add(_Database.CreateParameter("sunvectory", settings.SunVector.Y));
1223 parameters[35] = _Database.CreateParameter("sunvectorz", settings.SunVector.Z); 1230 parameters.Add(_Database.CreateParameter("sunvectorz", settings.SunVector.Z));
1224 parameters[36] = _Database.CreateParameter("covenant", settings.Covenant); 1231 parameters.Add(_Database.CreateParameter("covenant", settings.Covenant));
1225 1232
1226 return parameters; 1233 return parameters.ToArray();
1227 } 1234 }
1228 1235
1229 /// <summary> 1236 /// <summary>
@@ -1234,47 +1241,47 @@ VALUES
1234 /// <returns></returns> 1241 /// <returns></returns>
1235 private SqlParameter[] CreateLandParameters(LandData land, UUID regionUUID) 1242 private SqlParameter[] CreateLandParameters(LandData land, UUID regionUUID)
1236 { 1243 {
1237 SqlParameter[] parameters = new SqlParameter[34]; 1244 List<SqlParameter> parameters = new List<SqlParameter>();
1238 1245
1239 parameters[0] = _Database.CreateParameter("UUID", land.GlobalID); 1246 parameters.Add(_Database.CreateParameter("UUID", land.GlobalID));
1240 parameters[1] = _Database.CreateParameter("RegionUUID", regionUUID); 1247 parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID));
1241 parameters[2] = _Database.CreateParameter("LocalLandID", land.LocalID); 1248 parameters.Add(_Database.CreateParameter("LocalLandID", land.LocalID));
1242 1249
1243 // Bitmap is a byte[512] 1250 // Bitmap is a byte[512]
1244 parameters[3] = _Database.CreateParameter("Bitmap", land.Bitmap); 1251 parameters.Add(_Database.CreateParameter("Bitmap", land.Bitmap));
1245 1252
1246 parameters[4] = _Database.CreateParameter("Name", land.Name); 1253 parameters.Add(_Database.CreateParameter("Name", land.Name));
1247 parameters[5] = _Database.CreateParameter("Description", land.Description); 1254 parameters.Add(_Database.CreateParameter("Description", land.Description));
1248 parameters[6] = _Database.CreateParameter("OwnerUUID", land.OwnerID); 1255 parameters.Add(_Database.CreateParameter("OwnerUUID", land.OwnerID));
1249 parameters[7] = _Database.CreateParameter("IsGroupOwned", land.IsGroupOwned); 1256 parameters.Add(_Database.CreateParameter("IsGroupOwned", land.IsGroupOwned));
1250 parameters[8] = _Database.CreateParameter("Area", land.Area); 1257 parameters.Add(_Database.CreateParameter("Area", land.Area));
1251 parameters[9] = _Database.CreateParameter("AuctionID", land.AuctionID); //Unemplemented 1258 parameters.Add(_Database.CreateParameter("AuctionID", land.AuctionID)); //Unemplemented
1252 parameters[10] = _Database.CreateParameter("Category", (int)land.Category); //Enum libsecondlife.Parcel.ParcelCategory 1259 parameters.Add(_Database.CreateParameter("Category", (int)land.Category)); //Enum libsecondlife.Parcel.ParcelCategory
1253 parameters[11] = _Database.CreateParameter("ClaimDate", land.ClaimDate); 1260 parameters.Add(_Database.CreateParameter("ClaimDate", land.ClaimDate));
1254 parameters[12] = _Database.CreateParameter("ClaimPrice", land.ClaimPrice); 1261 parameters.Add(_Database.CreateParameter("ClaimPrice", land.ClaimPrice));
1255 parameters[13] = _Database.CreateParameter("GroupUUID", land.GroupID); 1262 parameters.Add(_Database.CreateParameter("GroupUUID", land.GroupID));
1256 parameters[14] = _Database.CreateParameter("SalePrice", land.SalePrice); 1263 parameters.Add(_Database.CreateParameter("SalePrice", land.SalePrice));
1257 parameters[15] = _Database.CreateParameter("LandStatus", (int)land.Status); //Enum. libsecondlife.Parcel.ParcelStatus 1264 parameters.Add(_Database.CreateParameter("LandStatus", (int)land.Status)); //Enum. libsecondlife.Parcel.ParcelStatus
1258 parameters[16] = _Database.CreateParameter("LandFlags", land.Flags); 1265 parameters.Add(_Database.CreateParameter("LandFlags", land.Flags));
1259 parameters[17] = _Database.CreateParameter("LandingType", land.LandingType); 1266 parameters.Add(_Database.CreateParameter("LandingType", land.LandingType));
1260 parameters[18] = _Database.CreateParameter("MediaAutoScale", land.MediaAutoScale); 1267 parameters.Add(_Database.CreateParameter("MediaAutoScale", land.MediaAutoScale));
1261 parameters[19] = _Database.CreateParameter("MediaTextureUUID", land.MediaID); 1268 parameters.Add(_Database.CreateParameter("MediaTextureUUID", land.MediaID));
1262 parameters[20] = _Database.CreateParameter("MediaURL", land.MediaURL); 1269 parameters.Add(_Database.CreateParameter("MediaURL", land.MediaURL));
1263 parameters[21] = _Database.CreateParameter("MusicURL", land.MusicURL); 1270 parameters.Add(_Database.CreateParameter("MusicURL", land.MusicURL));
1264 parameters[22] = _Database.CreateParameter("PassHours", land.PassHours); 1271 parameters.Add(_Database.CreateParameter("PassHours", land.PassHours));
1265 parameters[23] = _Database.CreateParameter("PassPrice", land.PassPrice); 1272 parameters.Add(_Database.CreateParameter("PassPrice", land.PassPrice));
1266 parameters[24] = _Database.CreateParameter("SnapshotUUID", land.SnapshotID); 1273 parameters.Add(_Database.CreateParameter("SnapshotUUID", land.SnapshotID));
1267 parameters[25] = _Database.CreateParameter("UserLocationX", land.UserLocation.X); 1274 parameters.Add(_Database.CreateParameter("UserLocationX", land.UserLocation.X));
1268 parameters[26] = _Database.CreateParameter("UserLocationY", land.UserLocation.Y); 1275 parameters.Add(_Database.CreateParameter("UserLocationY", land.UserLocation.Y));
1269 parameters[27] = _Database.CreateParameter("UserLocationZ", land.UserLocation.Z); 1276 parameters.Add(_Database.CreateParameter("UserLocationZ", land.UserLocation.Z));
1270 parameters[28] = _Database.CreateParameter("UserLookAtX", land.UserLookAt.X); 1277 parameters.Add(_Database.CreateParameter("UserLookAtX", land.UserLookAt.X));
1271 parameters[29] = _Database.CreateParameter("UserLookAtY", land.UserLookAt.Y); 1278 parameters.Add(_Database.CreateParameter("UserLookAtY", land.UserLookAt.Y));
1272 parameters[30] = _Database.CreateParameter("UserLookAtZ", land.UserLookAt.Z); 1279 parameters.Add(_Database.CreateParameter("UserLookAtZ", land.UserLookAt.Z));
1273 parameters[31] = _Database.CreateParameter("AuthBuyerID", land.AuthBuyerID); 1280 parameters.Add(_Database.CreateParameter("AuthBuyerID", land.AuthBuyerID));
1274 parameters[32] = _Database.CreateParameter("OtherCleanTime", land.OtherCleanTime); 1281 parameters.Add(_Database.CreateParameter("OtherCleanTime", land.OtherCleanTime));
1275 parameters[33] = _Database.CreateParameter("Dwell", land.Dwell); 1282 parameters.Add(_Database.CreateParameter("Dwell", land.Dwell));
1276 1283
1277 return parameters; 1284 return parameters.ToArray();
1278 } 1285 }
1279 1286
1280 /// <summary> 1287 /// <summary>
@@ -1285,264 +1292,202 @@ VALUES
1285 /// <returns></returns> 1292 /// <returns></returns>
1286 private SqlParameter[] CreateLandAccessParameters(ParcelManager.ParcelAccessEntry parcelAccessEntry, UUID parcelID) 1293 private SqlParameter[] CreateLandAccessParameters(ParcelManager.ParcelAccessEntry parcelAccessEntry, UUID parcelID)
1287 { 1294 {
1288 SqlParameter[] parameters = new SqlParameter[3]; 1295 List<SqlParameter> parameters = new List<SqlParameter>();
1289 1296
1290 parameters[0] = _Database.CreateParameter("LandUUID", parcelID); 1297 parameters.Add(_Database.CreateParameter("LandUUID", parcelID));
1291 parameters[1] = _Database.CreateParameter("AccessUUID", parcelAccessEntry.AgentID); 1298 parameters.Add(_Database.CreateParameter("AccessUUID", parcelAccessEntry.AgentID));
1292 parameters[2] = _Database.CreateParameter("Flags", parcelAccessEntry.Flags); 1299 parameters.Add(_Database.CreateParameter("Flags", parcelAccessEntry.Flags));
1293 1300
1294 return parameters; 1301 return parameters.ToArray();
1295 } 1302 }
1296 1303
1297 /// <summary> 1304 /// <summary>
1298 /// <summary> 1305 /// Creates the prim parameters for storing in DB.
1299 /// Fills/Updates the prim datarow.
1300 /// </summary> 1306 /// </summary>
1301 /// <param name="row">datarow.</param> 1307 /// <param name="prim">Basic data of SceneObjectpart prim.</param>
1302 /// <param name="prim">prim data.</param> 1308 /// <param name="sceneGroupID">The scenegroup ID.</param>
1303 /// <param name="sceneGroupID">scenegroup ID.</param> 1309 /// <param name="regionUUID">The region ID.</param>
1304 /// <param name="regionUUID">regionUUID.</param> 1310 /// <returns></returns>
1305 private static void fillPrimRow(DataRow row, SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) 1311 private SqlParameter[] CreatePrimParameters(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID)
1306 { 1312 {
1307 row["UUID"] = prim.UUID.ToString(); 1313 List<SqlParameter> parameters = new List<SqlParameter>();
1308 row["RegionUUID"] = regionUUID.ToString(); 1314
1309 row["CreationDate"] = prim.CreationDate; 1315 parameters.Add(_Database.CreateParameter("UUID", prim.UUID));
1310 row["Name"] = prim.Name; 1316 parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID));
1311 row["SceneGroupID"] = sceneGroupID.ToString(); 1317 //parameters.Add(_Database.CreateParameter("ParentID", (int)prim.ParentID));
1318 parameters.Add(_Database.CreateParameter("CreationDate", prim.CreationDate));
1319 parameters.Add(_Database.CreateParameter("Name", prim.Name));
1320 parameters.Add(_Database.CreateParameter("SceneGroupID", sceneGroupID));
1312 // the UUID of the root part for this SceneObjectGroup 1321 // the UUID of the root part for this SceneObjectGroup
1313 // various text fields 1322 // various text fields
1314 row["Text"] = prim.Text; 1323 parameters.Add(_Database.CreateParameter("Text", prim.Text));
1315 row["ColorR"] = prim.Color.R; 1324 parameters.Add(_Database.CreateParameter("ColorR", prim.Color.R));
1316 row["ColorG"] = prim.Color.G; 1325 parameters.Add(_Database.CreateParameter("ColorG", prim.Color.G));
1317 row["ColorB"] = prim.Color.B; 1326 parameters.Add(_Database.CreateParameter("ColorB", prim.Color.B));
1318 row["ColorA"] = prim.Color.A; 1327 parameters.Add(_Database.CreateParameter("ColorA", prim.Color.A));
1319 row["Description"] = prim.Description; 1328 parameters.Add(_Database.CreateParameter("Description", prim.Description));
1320 row["SitName"] = prim.SitName; 1329 parameters.Add(_Database.CreateParameter("SitName", prim.SitName));
1321 row["TouchName"] = prim.TouchName; 1330 parameters.Add(_Database.CreateParameter("TouchName", prim.TouchName));
1322 // permissions 1331 // permissions
1323 row["ObjectFlags"] = prim.ObjectFlags; 1332 parameters.Add(_Database.CreateParameter("ObjectFlags", prim.ObjectFlags));
1324 row["CreatorID"] = prim.CreatorID.ToString(); 1333 parameters.Add(_Database.CreateParameter("CreatorID", prim.CreatorID));
1325 row["OwnerID"] = prim.OwnerID.ToString(); 1334 parameters.Add(_Database.CreateParameter("OwnerID", prim.OwnerID));
1326 row["GroupID"] = prim.GroupID.ToString(); 1335 parameters.Add(_Database.CreateParameter("GroupID", prim.GroupID));
1327 row["LastOwnerID"] = prim.LastOwnerID.ToString(); 1336 parameters.Add(_Database.CreateParameter("LastOwnerID", prim.LastOwnerID));
1328 row["OwnerMask"] = prim.OwnerMask; 1337 parameters.Add(_Database.CreateParameter("OwnerMask", prim.OwnerMask));
1329 row["NextOwnerMask"] = prim.NextOwnerMask; 1338 parameters.Add(_Database.CreateParameter("NextOwnerMask", prim.NextOwnerMask));
1330 row["GroupMask"] = prim.GroupMask; 1339 parameters.Add(_Database.CreateParameter("GroupMask", prim.GroupMask));
1331 row["EveryoneMask"] = prim.EveryoneMask; 1340 parameters.Add(_Database.CreateParameter("EveryoneMask", prim.EveryoneMask));
1332 row["BaseMask"] = prim.BaseMask; 1341 parameters.Add(_Database.CreateParameter("BaseMask", prim.BaseMask));
1333 // vectors 1342 // vectors
1334 row["PositionX"] = prim.OffsetPosition.X; 1343 parameters.Add(_Database.CreateParameter("PositionX", prim.OffsetPosition.X));
1335 row["PositionY"] = prim.OffsetPosition.Y; 1344 parameters.Add(_Database.CreateParameter("PositionY", prim.OffsetPosition.Y));
1336 row["PositionZ"] = prim.OffsetPosition.Z; 1345 parameters.Add(_Database.CreateParameter("PositionZ", prim.OffsetPosition.Z));
1337 row["GroupPositionX"] = prim.GroupPosition.X; 1346 parameters.Add(_Database.CreateParameter("GroupPositionX", prim.GroupPosition.X));
1338 row["GroupPositionY"] = prim.GroupPosition.Y; 1347 parameters.Add(_Database.CreateParameter("GroupPositionY", prim.GroupPosition.Y));
1339 row["GroupPositionZ"] = prim.GroupPosition.Z; 1348 parameters.Add(_Database.CreateParameter("GroupPositionZ", prim.GroupPosition.Z));
1340 row["VelocityX"] = prim.Velocity.X; 1349 parameters.Add(_Database.CreateParameter("VelocityX", prim.Velocity.X));
1341 row["VelocityY"] = prim.Velocity.Y; 1350 parameters.Add(_Database.CreateParameter("VelocityY", prim.Velocity.Y));
1342 row["VelocityZ"] = prim.Velocity.Z; 1351 parameters.Add(_Database.CreateParameter("VelocityZ", prim.Velocity.Z));
1343 row["AngularVelocityX"] = prim.AngularVelocity.X; 1352 parameters.Add(_Database.CreateParameter("AngularVelocityX", prim.AngularVelocity.X));
1344 row["AngularVelocityY"] = prim.AngularVelocity.Y; 1353 parameters.Add(_Database.CreateParameter("AngularVelocityY", prim.AngularVelocity.Y));
1345 row["AngularVelocityZ"] = prim.AngularVelocity.Z; 1354 parameters.Add(_Database.CreateParameter("AngularVelocityZ", prim.AngularVelocity.Z));
1346 row["AccelerationX"] = prim.Acceleration.X; 1355 parameters.Add(_Database.CreateParameter("AccelerationX", prim.Acceleration.X));
1347 row["AccelerationY"] = prim.Acceleration.Y; 1356 parameters.Add(_Database.CreateParameter("AccelerationY", prim.Acceleration.Y));
1348 row["AccelerationZ"] = prim.Acceleration.Z; 1357 parameters.Add(_Database.CreateParameter("AccelerationZ", prim.Acceleration.Z));
1349 // quaternions 1358 // quaternions
1350 row["RotationX"] = prim.RotationOffset.X; 1359 parameters.Add(_Database.CreateParameter("RotationX", prim.RotationOffset.X));
1351 row["RotationY"] = prim.RotationOffset.Y; 1360 parameters.Add(_Database.CreateParameter("RotationY", prim.RotationOffset.Y));
1352 row["RotationZ"] = prim.RotationOffset.Z; 1361 parameters.Add(_Database.CreateParameter("RotationZ", prim.RotationOffset.Z));
1353 row["RotationW"] = prim.RotationOffset.W; 1362 parameters.Add(_Database.CreateParameter("RotationW", prim.RotationOffset.W));
1354 1363
1355 // Sit target 1364 // Sit target
1356 Vector3 sitTargetPos = prim.SitTargetPositionLL; 1365 Vector3 sitTargetPos = prim.SitTargetPositionLL;
1357 row["SitTargetOffsetX"] = sitTargetPos.X; 1366 parameters.Add(_Database.CreateParameter("SitTargetOffsetX", sitTargetPos.X));
1358 row["SitTargetOffsetY"] = sitTargetPos.Y; 1367 parameters.Add(_Database.CreateParameter("SitTargetOffsetY", sitTargetPos.Y));
1359 row["SitTargetOffsetZ"] = sitTargetPos.Z; 1368 parameters.Add(_Database.CreateParameter("SitTargetOffsetZ", sitTargetPos.Z));
1360 1369
1361 Quaternion sitTargetOrient = prim.SitTargetOrientationLL; 1370 Quaternion sitTargetOrient = prim.SitTargetOrientationLL;
1362 row["SitTargetOrientW"] = sitTargetOrient.W; 1371 parameters.Add(_Database.CreateParameter("SitTargetOrientW", sitTargetOrient.W));
1363 row["SitTargetOrientX"] = sitTargetOrient.X; 1372 parameters.Add(_Database.CreateParameter("SitTargetOrientX", sitTargetOrient.X));
1364 row["SitTargetOrientY"] = sitTargetOrient.Y; 1373 parameters.Add(_Database.CreateParameter("SitTargetOrientY", sitTargetOrient.Y));
1365 row["SitTargetOrientZ"] = sitTargetOrient.Z; 1374 parameters.Add(_Database.CreateParameter("SitTargetOrientZ", sitTargetOrient.Z));
1366 1375
1367 row["PayPrice"] = prim.PayPrice[0]; 1376 parameters.Add(_Database.CreateParameter("PayPrice", prim.PayPrice[0]));
1368 row["PayButton1"] = prim.PayPrice[1]; 1377 parameters.Add(_Database.CreateParameter("PayButton1", prim.PayPrice[1]));
1369 row["PayButton2"] = prim.PayPrice[2]; 1378 parameters.Add(_Database.CreateParameter("PayButton2", prim.PayPrice[2]));
1370 row["PayButton3"] = prim.PayPrice[3]; 1379 parameters.Add(_Database.CreateParameter("PayButton3", prim.PayPrice[3]));
1371 row["PayButton4"] = prim.PayPrice[4]; 1380 parameters.Add(_Database.CreateParameter("PayButton4", prim.PayPrice[4]));
1372 1381
1373 if ((prim.SoundFlags & 1) != 0) // Looped 1382 if ((prim.SoundFlags & 1) != 0) // Looped
1374 { 1383 {
1375 row["LoopedSound"] = prim.Sound.ToString(); 1384 parameters.Add(_Database.CreateParameter("LoopedSound", prim.Sound));
1376 row["LoopedSoundGain"] = prim.SoundGain; 1385 parameters.Add(_Database.CreateParameter("LoopedSoundGain", prim.SoundGain));
1377 } 1386 }
1378 else 1387 else
1379 { 1388 {
1380 row["LoopedSound"] = UUID.Zero; 1389 parameters.Add(_Database.CreateParameter("LoopedSound", UUID.Zero));
1381 row["LoopedSoundGain"] = 0.0f; 1390 parameters.Add(_Database.CreateParameter("LoopedSoundGain", 0.0f));
1382 } 1391 }
1383 1392
1384 row["TextureAnimation"] = prim.TextureAnimation; 1393 parameters.Add(_Database.CreateParameter("TextureAnimation", prim.TextureAnimation));
1385 row["ParticleSystem"] = prim.ParticleSystem; 1394 parameters.Add(_Database.CreateParameter("ParticleSystem", prim.ParticleSystem));
1386 1395
1387 row["OmegaX"] = prim.RotationalVelocity.X; 1396 parameters.Add(_Database.CreateParameter("OmegaX", prim.RotationalVelocity.X));
1388 row["OmegaY"] = prim.RotationalVelocity.Y; 1397 parameters.Add(_Database.CreateParameter("OmegaY", prim.RotationalVelocity.Y));
1389 row["OmegaZ"] = prim.RotationalVelocity.Z; 1398 parameters.Add(_Database.CreateParameter("OmegaZ", prim.RotationalVelocity.Z));
1390 1399
1391 row["CameraEyeOffsetX"] = prim.GetCameraEyeOffset().X; 1400 parameters.Add(_Database.CreateParameter("CameraEyeOffsetX", prim.GetCameraEyeOffset().X));
1392 row["CameraEyeOffsetY"] = prim.GetCameraEyeOffset().Y; 1401 parameters.Add(_Database.CreateParameter("CameraEyeOffsetY", prim.GetCameraEyeOffset().Y));
1393 row["CameraEyeOffsetZ"] = prim.GetCameraEyeOffset().Z; 1402 parameters.Add(_Database.CreateParameter("CameraEyeOffsetZ", prim.GetCameraEyeOffset().Z));
1394 1403
1395 row["CameraAtOffsetX"] = prim.GetCameraAtOffset().X; 1404 parameters.Add(_Database.CreateParameter("CameraAtOffsetX", prim.GetCameraAtOffset().X));
1396 row["CameraAtOffsetY"] = prim.GetCameraAtOffset().Y; 1405 parameters.Add(_Database.CreateParameter("CameraAtOffsetY", prim.GetCameraAtOffset().Y));
1397 row["CameraAtOffsetZ"] = prim.GetCameraAtOffset().Z; 1406 parameters.Add(_Database.CreateParameter("CameraAtOffsetZ", prim.GetCameraAtOffset().Z));
1398 1407
1399 if (prim.GetForceMouselook()) 1408 if (prim.GetForceMouselook())
1400 row["ForceMouselook"] = 1; 1409 parameters.Add(_Database.CreateParameter("ForceMouselook", 1));
1401 else 1410 else
1402 row["ForceMouselook"] = 0; 1411 parameters.Add(_Database.CreateParameter("ForceMouselook", 0));
1403 1412
1404 row["ScriptAccessPin"] = prim.ScriptAccessPin; 1413 parameters.Add(_Database.CreateParameter("ScriptAccessPin", prim.ScriptAccessPin));
1405 1414
1406 if (prim.AllowedDrop) 1415 if (prim.AllowedDrop)
1407 row["AllowedDrop"] = 1; 1416 parameters.Add(_Database.CreateParameter("AllowedDrop", 1));
1408 else 1417 else
1409 row["AllowedDrop"] = 0; 1418 parameters.Add(_Database.CreateParameter("AllowedDrop", 0));
1410 1419
1411 if (prim.DIE_AT_EDGE) 1420 if (prim.DIE_AT_EDGE)
1412 row["DieAtEdge"] = 1; 1421 parameters.Add(_Database.CreateParameter("DieAtEdge", 1));
1413 else 1422 else
1414 row["DieAtEdge"] = 0; 1423 parameters.Add(_Database.CreateParameter("DieAtEdge", 0));
1415 1424
1416 row["SalePrice"] = prim.SalePrice; 1425 parameters.Add(_Database.CreateParameter("SalePrice", prim.SalePrice));
1417 row["SaleType"] = Convert.ToInt16(prim.ObjectSaleType); 1426 parameters.Add(_Database.CreateParameter("SaleType", prim.ObjectSaleType));
1418 1427
1419 byte clickAction = prim.ClickAction; 1428 byte clickAction = prim.ClickAction;
1420 row["ClickAction"] = clickAction; 1429 parameters.Add(_Database.CreateParameter("ClickAction", clickAction));
1430
1431 parameters.Add(_Database.CreateParameter("Material", prim.Material));
1421 1432
1422 row["Material"] = prim.Material; 1433 parameters.Add(_Database.CreateParameter("CollisionSound", prim.CollisionSound));
1434 parameters.Add(_Database.CreateParameter("CollisionSoundVolume", prim.CollisionSoundVolume));
1435 parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum));
1423 1436
1424 row["CollisionSound"] = prim.CollisionSound.ToString(); 1437 return parameters.ToArray();
1425 row["CollisionSoundVolume"] = prim.CollisionSoundVolume;
1426 } 1438 }
1427 1439
1428 /// <summary> 1440 /// <summary>
1429 /// Fills/Updates the shape datarow. 1441 /// Creates the primshape parameters for stroing in DB.
1430 /// </summary> 1442 /// </summary>
1431 /// <param name="row">datarow to fill/update.</param> 1443 /// <param name="prim">Basic data of SceneObjectpart prim.</param>
1432 /// <param name="prim">prim shape data.</param> 1444 /// <param name="sceneGroupID">The scene group ID.</param>
1433 private static void fillShapeRow(DataRow row, SceneObjectPart prim) 1445 /// <param name="regionUUID">The region UUID.</param>
1446 /// <returns></returns>
1447 private SqlParameter[] CreatePrimShapeParameters(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID)
1434 { 1448 {
1449 List<SqlParameter> parameters = new List<SqlParameter>();
1450
1435 PrimitiveBaseShape s = prim.Shape; 1451 PrimitiveBaseShape s = prim.Shape;
1436 row["UUID"] = prim.UUID.ToString(); 1452 parameters.Add(_Database.CreateParameter("UUID", prim.UUID));
1437 // shape is an enum 1453 // shape is an enum
1438 row["Shape"] = 0; 1454 parameters.Add(_Database.CreateParameter("Shape", 0));
1439 // vectors 1455 // vectors
1440 row["ScaleX"] = s.Scale.X; 1456 parameters.Add(_Database.CreateParameter("ScaleX", s.Scale.X));
1441 row["ScaleY"] = s.Scale.Y; 1457 parameters.Add(_Database.CreateParameter("ScaleY", s.Scale.Y));
1442 row["ScaleZ"] = s.Scale.Z; 1458 parameters.Add(_Database.CreateParameter("ScaleZ", s.Scale.Z));
1443 // paths 1459 // paths
1444 row["PCode"] = s.PCode; 1460 parameters.Add(_Database.CreateParameter("PCode", s.PCode));
1445 row["PathBegin"] = s.PathBegin; 1461 parameters.Add(_Database.CreateParameter("PathBegin", s.PathBegin));
1446 row["PathEnd"] = s.PathEnd; 1462 parameters.Add(_Database.CreateParameter("PathEnd", s.PathEnd));
1447 row["PathScaleX"] = s.PathScaleX; 1463 parameters.Add(_Database.CreateParameter("PathScaleX", s.PathScaleX));
1448 row["PathScaleY"] = s.PathScaleY; 1464 parameters.Add(_Database.CreateParameter("PathScaleY", s.PathScaleY));
1449 row["PathShearX"] = s.PathShearX; 1465 parameters.Add(_Database.CreateParameter("PathShearX", s.PathShearX));
1450 row["PathShearY"] = s.PathShearY; 1466 parameters.Add(_Database.CreateParameter("PathShearY", s.PathShearY));
1451 row["PathSkew"] = s.PathSkew; 1467 parameters.Add(_Database.CreateParameter("PathSkew", s.PathSkew));
1452 row["PathCurve"] = s.PathCurve; 1468 parameters.Add(_Database.CreateParameter("PathCurve", s.PathCurve));
1453 row["PathRadiusOffset"] = s.PathRadiusOffset; 1469 parameters.Add(_Database.CreateParameter("PathRadiusOffset", s.PathRadiusOffset));
1454 row["PathRevolutions"] = s.PathRevolutions; 1470 parameters.Add(_Database.CreateParameter("PathRevolutions", s.PathRevolutions));
1455 row["PathTaperX"] = s.PathTaperX; 1471 parameters.Add(_Database.CreateParameter("PathTaperX", s.PathTaperX));
1456 row["PathTaperY"] = s.PathTaperY; 1472 parameters.Add(_Database.CreateParameter("PathTaperY", s.PathTaperY));
1457 row["PathTwist"] = s.PathTwist; 1473 parameters.Add(_Database.CreateParameter("PathTwist", s.PathTwist));
1458 row["PathTwistBegin"] = s.PathTwistBegin; 1474 parameters.Add(_Database.CreateParameter("PathTwistBegin", s.PathTwistBegin));
1459 // profile 1475 // profile
1460 row["ProfileBegin"] = s.ProfileBegin; 1476 parameters.Add(_Database.CreateParameter("ProfileBegin", s.ProfileBegin));
1461 row["ProfileEnd"] = s.ProfileEnd; 1477 parameters.Add(_Database.CreateParameter("ProfileEnd", s.ProfileEnd));
1462 row["ProfileCurve"] = s.ProfileCurve; 1478 parameters.Add(_Database.CreateParameter("ProfileCurve", s.ProfileCurve));
1463 row["ProfileHollow"] = s.ProfileHollow; 1479 parameters.Add(_Database.CreateParameter("ProfileHollow", s.ProfileHollow));
1464 row["Texture"] = s.TextureEntry; 1480 parameters.Add(_Database.CreateParameter("Texture", s.TextureEntry));
1465 row["ExtraParams"] = s.ExtraParams; 1481 parameters.Add(_Database.CreateParameter("ExtraParams", s.ExtraParams));
1466 row["State"] = s.State; 1482 parameters.Add(_Database.CreateParameter("State", s.State));
1483
1484 return parameters.ToArray();
1467 } 1485 }
1468 1486
1469 #endregion 1487
1470 1488
1471 /// <summary> 1489 #endregion
1472 /// Retrieves the prims data for region.
1473 /// </summary>
1474 /// <param name="regionUUID">The region UUID.</param>
1475 /// <param name="sceneGroupID">The scene group ID.</param>
1476 /// <param name="primID">The prim ID.</param>
1477 private void RetrievePrimsDataForRegion(UUID regionUUID, UUID sceneGroupID, string primID)
1478 {
1479 using (SqlConnection connection = _Database.DatabaseConnection())
1480 {
1481 _PrimDataAdapter.SelectCommand.Connection = connection;
1482 _PrimDataAdapter.SelectCommand.Parameters["@RegionUUID"].Value = regionUUID.ToString();
1483 _PrimDataAdapter.Fill(_PrimsDataSet, "prims");
1484
1485 _Log.Debug("Prim row count: " + _PrimsDataSet.Tables["prims"].Rows.Count);
1486
1487 _ShapeDataAdapter.SelectCommand.Connection = connection;
1488 _ShapeDataAdapter.SelectCommand.Parameters["@RegionUUID"].Value = regionUUID.ToString();
1489 _ShapeDataAdapter.Fill(_PrimsDataSet, "primshapes");
1490
1491 _ItemsDataAdapter.SelectCommand.Connection = connection;
1492 _ItemsDataAdapter.SelectCommand.Parameters["@RegionUUID"].Value = regionUUID.ToString();
1493 _ItemsDataAdapter.Fill(_PrimsDataSet, "primitems");
1494 }
1495 }
1496
1497 /// <summary>
1498 /// Commits the dataset.
1499 /// </summary>
1500 private void CommitDataSet()
1501 {
1502 try
1503 {
1504 using (SqlConnection connection = _Database.DatabaseConnection())
1505 {
1506 _PrimDataAdapter.InsertCommand.Connection = connection;
1507 _PrimDataAdapter.UpdateCommand.Connection = connection;
1508 _PrimDataAdapter.DeleteCommand.Connection = connection;
1509
1510 _ShapeDataAdapter.InsertCommand.Connection = connection;
1511 _ShapeDataAdapter.UpdateCommand.Connection = connection;
1512 _ShapeDataAdapter.DeleteCommand.Connection = connection;
1513
1514 _ItemsDataAdapter.InsertCommand.Connection = connection;
1515 _ItemsDataAdapter.UpdateCommand.Connection = connection;
1516 _ItemsDataAdapter.DeleteCommand.Connection = connection;
1517
1518 _PrimDataAdapter.Update(_PrimsDataSet.Tables["prims"]);
1519 _ShapeDataAdapter.Update(_PrimsDataSet.Tables["primshapes"]);
1520 _ItemsDataAdapter.Update(_PrimsDataSet.Tables["primitems"]);
1521 }
1522 }
1523 finally
1524 {
1525 _PrimsDataSet.AcceptChanges();
1526
1527 _PrimsDataSet.Tables["prims"].Clear();
1528 _PrimsDataSet.Tables["primshapes"].Clear();
1529 _PrimsDataSet.Tables["primitems"].Clear();
1530
1531 }
1532 }
1533
1534 /// <summary>
1535 /// Create commands for a dataadapter.
1536 /// </summary>
1537 /// <param name="dataAdapter">The data adapter.</param>
1538 private static void SetupCommands(SqlDataAdapter dataAdapter)
1539 {
1540 SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);
1541 1490
1542 dataAdapter.InsertCommand = commandBuilder.GetInsertCommand(true);
1543 dataAdapter.UpdateCommand = commandBuilder.GetUpdateCommand(true);
1544 dataAdapter.DeleteCommand = commandBuilder.GetDeleteCommand(true);
1545 }
1546 #endregion 1491 #endregion
1547 } 1492 }
1548} 1493}