diff options
author | lbsa71 | 2007-12-27 21:41:48 +0000 |
---|---|---|
committer | lbsa71 | 2007-12-27 21:41:48 +0000 |
commit | efd90b56b761219af6425b1c7a2cdd3b6ffb4de2 (patch) | |
tree | bf5b897e1e3c13211e3e2fc61d30508b94c928c0 /OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs | |
parent | * removed always true if (diff) | |
download | opensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.zip opensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.gz opensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.bz2 opensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.xz |
* Optimized usings
* shortened references
* Removed redundant 'this'
* Normalized EOF
Diffstat (limited to 'OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs')
-rw-r--r-- | OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs | 309 |
1 files changed, 160 insertions, 149 deletions
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs index 60aeb83..5818583 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs | |||
@@ -33,8 +33,8 @@ using System.Data.SqlClient; | |||
33 | using System.IO; | 33 | using System.IO; |
34 | using libsecondlife; | 34 | using libsecondlife; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Data; | ||
37 | using OpenSim.Framework.Console; | 36 | using OpenSim.Framework.Console; |
37 | using OpenSim.Framework.Data; | ||
38 | using OpenSim.Region.Environment.Interfaces; | 38 | using OpenSim.Region.Environment.Interfaces; |
39 | using OpenSim.Region.Environment.LandManagement; | 39 | using OpenSim.Region.Environment.LandManagement; |
40 | using OpenSim.Region.Environment.Scenes; | 40 | using OpenSim.Region.Environment.Scenes; |
@@ -62,7 +62,9 @@ namespace OpenSim.DataStore.MSSQL | |||
62 | string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id"); | 62 | string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id"); |
63 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); | 63 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); |
64 | 64 | ||
65 | string connectionString = "Data Source=" + settingDataSource + ";Initial Catalog=" + settingInitialCatalog + ";Persist Security Info=" + settingPersistSecurityInfo + ";User ID=" + settingUserId + ";Password=" + settingPassword + ";"; | 65 | string connectionString = "Data Source=" + settingDataSource + ";Initial Catalog=" + settingInitialCatalog + |
66 | ";Persist Security Info=" + settingPersistSecurityInfo + ";User ID=" + | ||
67 | settingUserId + ";Password=" + settingPassword + ";"; | ||
66 | 68 | ||
67 | ds = new DataSet(); | 69 | ds = new DataSet(); |
68 | 70 | ||
@@ -85,11 +87,12 @@ namespace OpenSim.DataStore.MSSQL | |||
85 | // primDa.FillSchema(ds, SchemaType.Source, "PrimSchema"); | 87 | // primDa.FillSchema(ds, SchemaType.Source, "PrimSchema"); |
86 | TestTables(conn); | 88 | TestTables(conn); |
87 | 89 | ||
88 | lock(ds) { | 90 | lock (ds) |
91 | { | ||
89 | ds.Tables.Add(createPrimTable()); | 92 | ds.Tables.Add(createPrimTable()); |
90 | setupPrimCommands(primDa, conn); | 93 | setupPrimCommands(primDa, conn); |
91 | primDa.Fill(ds.Tables["prims"]); | 94 | primDa.Fill(ds.Tables["prims"]); |
92 | 95 | ||
93 | ds.Tables.Add(createShapeTable()); | 96 | ds.Tables.Add(createShapeTable()); |
94 | setupShapeCommands(shapeDa, conn); | 97 | setupShapeCommands(shapeDa, conn); |
95 | 98 | ||
@@ -122,7 +125,8 @@ namespace OpenSim.DataStore.MSSQL | |||
122 | 125 | ||
123 | public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) | 126 | public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) |
124 | { | 127 | { |
125 | lock (ds) { | 128 | lock (ds) |
129 | { | ||
126 | foreach (SceneObjectPart prim in obj.Children.Values) | 130 | foreach (SceneObjectPart prim in obj.Children.Values) |
127 | { | 131 | { |
128 | MainLog.Instance.Verbose("DATASTORE", "Adding obj: " + obj.UUID + " to region: " + regionUUID); | 132 | MainLog.Instance.Verbose("DATASTORE", "Adding obj: " + obj.UUID + " to region: " + regionUUID); |
@@ -140,11 +144,12 @@ namespace OpenSim.DataStore.MSSQL | |||
140 | DataTable shapes = ds.Tables["primshapes"]; | 144 | DataTable shapes = ds.Tables["primshapes"]; |
141 | 145 | ||
142 | string selectExp = "SceneGroupID = '" + obj.ToString() + "'"; | 146 | string selectExp = "SceneGroupID = '" + obj.ToString() + "'"; |
143 | lock (ds) { | 147 | lock (ds) |
148 | { | ||
144 | DataRow[] primRows = prims.Select(selectExp); | 149 | DataRow[] primRows = prims.Select(selectExp); |
145 | foreach (DataRow row in primRows) | 150 | foreach (DataRow row in primRows) |
146 | { | 151 | { |
147 | LLUUID uuid = new LLUUID((string)row["UUID"]); | 152 | LLUUID uuid = new LLUUID((string) row["UUID"]); |
148 | DataRow shapeRow = shapes.Rows.Find(uuid); | 153 | DataRow shapeRow = shapes.Rows.Find(uuid); |
149 | if (shapeRow != null) | 154 | if (shapeRow != null) |
150 | { | 155 | { |
@@ -153,7 +158,7 @@ namespace OpenSim.DataStore.MSSQL | |||
153 | row.Delete(); | 158 | row.Delete(); |
154 | } | 159 | } |
155 | } | 160 | } |
156 | 161 | ||
157 | Commit(); | 162 | Commit(); |
158 | } | 163 | } |
159 | 164 | ||
@@ -169,16 +174,18 @@ namespace OpenSim.DataStore.MSSQL | |||
169 | string byRegion = "RegionUUID = '" + regionUUID.ToString() + "'"; | 174 | string byRegion = "RegionUUID = '" + regionUUID.ToString() + "'"; |
170 | string orderByParent = "ParentID ASC"; | 175 | string orderByParent = "ParentID ASC"; |
171 | 176 | ||
172 | lock (ds) { | 177 | lock (ds) |
178 | { | ||
173 | DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); | 179 | DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); |
174 | MainLog.Instance.Verbose("DATASTORE", "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); | 180 | MainLog.Instance.Verbose("DATASTORE", |
175 | 181 | "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); | |
182 | |||
176 | foreach (DataRow primRow in primsForRegion) | 183 | foreach (DataRow primRow in primsForRegion) |
177 | { | 184 | { |
178 | try | 185 | try |
179 | { | 186 | { |
180 | string uuid = (string)primRow["UUID"]; | 187 | string uuid = (string) primRow["UUID"]; |
181 | string objID = (string)primRow["SceneGroupID"]; | 188 | string objID = (string) primRow["SceneGroupID"]; |
182 | if (uuid == objID) //is new SceneObjectGroup ? | 189 | if (uuid == objID) //is new SceneObjectGroup ? |
183 | { | 190 | { |
184 | SceneObjectGroup group = new SceneObjectGroup(); | 191 | SceneObjectGroup group = new SceneObjectGroup(); |
@@ -190,12 +197,13 @@ namespace OpenSim.DataStore.MSSQL | |||
190 | } | 197 | } |
191 | else | 198 | else |
192 | { | 199 | { |
193 | MainLog.Instance.Notice("No shape found for prim in storage, so setting default box shape"); | 200 | MainLog.Instance.Notice( |
201 | "No shape found for prim in storage, so setting default box shape"); | ||
194 | prim.Shape = BoxShape.Default; | 202 | prim.Shape = BoxShape.Default; |
195 | } | 203 | } |
196 | group.AddPart(prim); | 204 | group.AddPart(prim); |
197 | group.RootPart = prim; | 205 | group.RootPart = prim; |
198 | 206 | ||
199 | createdObjects.Add(group.UUID, group); | 207 | createdObjects.Add(group.UUID, group); |
200 | retvals.Add(group); | 208 | retvals.Add(group); |
201 | } | 209 | } |
@@ -209,7 +217,8 @@ namespace OpenSim.DataStore.MSSQL | |||
209 | } | 217 | } |
210 | else | 218 | else |
211 | { | 219 | { |
212 | MainLog.Instance.Notice("No shape found for prim in storage, so setting default box shape"); | 220 | MainLog.Instance.Notice( |
221 | "No shape found for prim in storage, so setting default box shape"); | ||
213 | prim.Shape = BoxShape.Default; | 222 | prim.Shape = BoxShape.Default; |
214 | } | 223 | } |
215 | createdObjects[new LLUUID(objID)].AddPart(prim); | 224 | createdObjects[new LLUUID(objID)].AddPart(prim); |
@@ -249,7 +258,7 @@ namespace OpenSim.DataStore.MSSQL | |||
249 | 258 | ||
250 | public double[,] LoadTerrain(LLUUID regionID) | 259 | public double[,] LoadTerrain(LLUUID regionID) |
251 | { | 260 | { |
252 | double[,] terret = new double[256, 256]; | 261 | double[,] terret = new double[256,256]; |
253 | terret.Initialize(); | 262 | terret.Initialize(); |
254 | 263 | ||
255 | DataTable terrain = ds.Tables["terrain"]; | 264 | DataTable terrain = ds.Tables["terrain"]; |
@@ -264,16 +273,16 @@ namespace OpenSim.DataStore.MSSQL | |||
264 | { | 273 | { |
265 | DataRow row = rows[0]; | 274 | DataRow row = rows[0]; |
266 | 275 | ||
267 | byte[] heightmap = (byte[])row["Heightfield"]; | 276 | byte[] heightmap = (byte[]) row["Heightfield"]; |
268 | for (int x = 0; x < 256; x++) | 277 | for (int x = 0; x < 256; x++) |
269 | { | 278 | { |
270 | for (int y = 0; y < 256; y++) | 279 | for (int y = 0; y < 256; y++) |
271 | { | 280 | { |
272 | terret[x, y] = BitConverter.ToDouble(heightmap, ((x * 256) + y) * 8); | 281 | terret[x, y] = BitConverter.ToDouble(heightmap, ((x*256) + y)*8); |
273 | } | 282 | } |
274 | } | 283 | } |
275 | 284 | ||
276 | rev = (int)row["Revision"]; | 285 | rev = (int) row["Revision"]; |
277 | } | 286 | } |
278 | else | 287 | else |
279 | { | 288 | { |
@@ -290,22 +299,21 @@ namespace OpenSim.DataStore.MSSQL | |||
290 | 299 | ||
291 | public void RemoveLandObject(LLUUID globalID) | 300 | public void RemoveLandObject(LLUUID globalID) |
292 | { | 301 | { |
293 | |||
294 | } | 302 | } |
295 | 303 | ||
296 | public void StoreLandObject(Land parcel, LLUUID regionUUID) | 304 | public void StoreLandObject(Land parcel, LLUUID regionUUID) |
297 | { | 305 | { |
298 | |||
299 | } | 306 | } |
300 | 307 | ||
301 | public List<Framework.LandData> LoadLandObjects(LLUUID regionUUID) | 308 | public List<LandData> LoadLandObjects(LLUUID regionUUID) |
302 | { | 309 | { |
303 | return new List<LandData>(); | 310 | return new List<LandData>(); |
304 | } | 311 | } |
305 | 312 | ||
306 | public void Commit() | 313 | public void Commit() |
307 | { | 314 | { |
308 | lock (ds) { | 315 | lock (ds) |
316 | { | ||
309 | primDa.Update(ds, "prims"); | 317 | primDa.Update(ds, "prims"); |
310 | shapeDa.Update(ds, "primshapes"); | 318 | shapeDa.Update(ds, "primshapes"); |
311 | terrainDa.Update(ds, "terrain"); | 319 | terrainDa.Update(ds, "terrain"); |
@@ -326,7 +334,7 @@ namespace OpenSim.DataStore.MSSQL | |||
326 | * | 334 | * |
327 | **********************************************************************/ | 335 | **********************************************************************/ |
328 | 336 | ||
329 | private void createCol(DataTable dt, string name, System.Type type) | 337 | private void createCol(DataTable dt, string name, Type type) |
330 | { | 338 | { |
331 | DataColumn col = new DataColumn(name, type); | 339 | DataColumn col = new DataColumn(name, type); |
332 | dt.Columns.Add(col); | 340 | dt.Columns.Add(col); |
@@ -336,9 +344,9 @@ namespace OpenSim.DataStore.MSSQL | |||
336 | { | 344 | { |
337 | DataTable terrain = new DataTable("terrain"); | 345 | DataTable terrain = new DataTable("terrain"); |
338 | 346 | ||
339 | createCol(terrain, "RegionUUID", typeof(String)); | 347 | createCol(terrain, "RegionUUID", typeof (String)); |
340 | createCol(terrain, "Revision", typeof(Int32)); | 348 | createCol(terrain, "Revision", typeof (Int32)); |
341 | createCol(terrain, "Heightfield", typeof(Byte[])); | 349 | createCol(terrain, "Heightfield", typeof (Byte[])); |
342 | 350 | ||
343 | return terrain; | 351 | return terrain; |
344 | } | 352 | } |
@@ -347,62 +355,62 @@ namespace OpenSim.DataStore.MSSQL | |||
347 | { | 355 | { |
348 | DataTable prims = new DataTable("prims"); | 356 | DataTable prims = new DataTable("prims"); |
349 | 357 | ||
350 | createCol(prims, "UUID", typeof(System.String)); | 358 | createCol(prims, "UUID", typeof (String)); |
351 | createCol(prims, "RegionUUID", typeof(System.String)); | 359 | createCol(prims, "RegionUUID", typeof (String)); |
352 | createCol(prims, "ParentID", typeof(System.Int32)); | 360 | createCol(prims, "ParentID", typeof (Int32)); |
353 | createCol(prims, "CreationDate", typeof(System.Int32)); | 361 | createCol(prims, "CreationDate", typeof (Int32)); |
354 | createCol(prims, "Name", typeof(System.String)); | 362 | createCol(prims, "Name", typeof (String)); |
355 | createCol(prims, "SceneGroupID", typeof(System.String)); | 363 | createCol(prims, "SceneGroupID", typeof (String)); |
356 | // various text fields | 364 | // various text fields |
357 | createCol(prims, "Text", typeof(System.String)); | 365 | createCol(prims, "Text", typeof (String)); |
358 | createCol(prims, "Description", typeof(System.String)); | 366 | createCol(prims, "Description", typeof (String)); |
359 | createCol(prims, "SitName", typeof(System.String)); | 367 | createCol(prims, "SitName", typeof (String)); |
360 | createCol(prims, "TouchName", typeof(System.String)); | 368 | createCol(prims, "TouchName", typeof (String)); |
361 | // permissions | 369 | // permissions |
362 | createCol(prims, "ObjectFlags", typeof(System.Int32)); | 370 | createCol(prims, "ObjectFlags", typeof (Int32)); |
363 | createCol(prims, "CreatorID", typeof(System.String)); | 371 | createCol(prims, "CreatorID", typeof (String)); |
364 | createCol(prims, "OwnerID", typeof(System.String)); | 372 | createCol(prims, "OwnerID", typeof (String)); |
365 | createCol(prims, "GroupID", typeof(System.String)); | 373 | createCol(prims, "GroupID", typeof (String)); |
366 | createCol(prims, "LastOwnerID", typeof(System.String)); | 374 | createCol(prims, "LastOwnerID", typeof (String)); |
367 | createCol(prims, "OwnerMask", typeof(System.Int32)); | 375 | createCol(prims, "OwnerMask", typeof (Int32)); |
368 | createCol(prims, "NextOwnerMask", typeof(System.Int32)); | 376 | createCol(prims, "NextOwnerMask", typeof (Int32)); |
369 | createCol(prims, "GroupMask", typeof(System.Int32)); | 377 | createCol(prims, "GroupMask", typeof (Int32)); |
370 | createCol(prims, "EveryoneMask", typeof(System.Int32)); | 378 | createCol(prims, "EveryoneMask", typeof (Int32)); |
371 | createCol(prims, "BaseMask", typeof(System.Int32)); | 379 | createCol(prims, "BaseMask", typeof (Int32)); |
372 | // vectors | 380 | // vectors |
373 | createCol(prims, "PositionX", typeof(System.Double)); | 381 | createCol(prims, "PositionX", typeof (Double)); |
374 | createCol(prims, "PositionY", typeof(System.Double)); | 382 | createCol(prims, "PositionY", typeof (Double)); |
375 | createCol(prims, "PositionZ", typeof(System.Double)); | 383 | createCol(prims, "PositionZ", typeof (Double)); |
376 | createCol(prims, "GroupPositionX", typeof(System.Double)); | 384 | createCol(prims, "GroupPositionX", typeof (Double)); |
377 | createCol(prims, "GroupPositionY", typeof(System.Double)); | 385 | createCol(prims, "GroupPositionY", typeof (Double)); |
378 | createCol(prims, "GroupPositionZ", typeof(System.Double)); | 386 | createCol(prims, "GroupPositionZ", typeof (Double)); |
379 | createCol(prims, "VelocityX", typeof(System.Double)); | 387 | createCol(prims, "VelocityX", typeof (Double)); |
380 | createCol(prims, "VelocityY", typeof(System.Double)); | 388 | createCol(prims, "VelocityY", typeof (Double)); |
381 | createCol(prims, "VelocityZ", typeof(System.Double)); | 389 | createCol(prims, "VelocityZ", typeof (Double)); |
382 | createCol(prims, "AngularVelocityX", typeof(System.Double)); | 390 | createCol(prims, "AngularVelocityX", typeof (Double)); |
383 | createCol(prims, "AngularVelocityY", typeof(System.Double)); | 391 | createCol(prims, "AngularVelocityY", typeof (Double)); |
384 | createCol(prims, "AngularVelocityZ", typeof(System.Double)); | 392 | createCol(prims, "AngularVelocityZ", typeof (Double)); |
385 | createCol(prims, "AccelerationX", typeof(System.Double)); | 393 | createCol(prims, "AccelerationX", typeof (Double)); |
386 | createCol(prims, "AccelerationY", typeof(System.Double)); | 394 | createCol(prims, "AccelerationY", typeof (Double)); |
387 | createCol(prims, "AccelerationZ", typeof(System.Double)); | 395 | createCol(prims, "AccelerationZ", typeof (Double)); |
388 | // quaternions | 396 | // quaternions |
389 | createCol(prims, "RotationX", typeof(System.Double)); | 397 | createCol(prims, "RotationX", typeof (Double)); |
390 | createCol(prims, "RotationY", typeof(System.Double)); | 398 | createCol(prims, "RotationY", typeof (Double)); |
391 | createCol(prims, "RotationZ", typeof(System.Double)); | 399 | createCol(prims, "RotationZ", typeof (Double)); |
392 | createCol(prims, "RotationW", typeof(System.Double)); | 400 | createCol(prims, "RotationW", typeof (Double)); |
393 | 401 | ||
394 | // sit target | 402 | // sit target |
395 | createCol(prims, "SitTargetOffsetX", typeof(System.Double)); | 403 | createCol(prims, "SitTargetOffsetX", typeof (Double)); |
396 | createCol(prims, "SitTargetOffsetY", typeof(System.Double)); | 404 | createCol(prims, "SitTargetOffsetY", typeof (Double)); |
397 | createCol(prims, "SitTargetOffsetZ", typeof(System.Double)); | 405 | createCol(prims, "SitTargetOffsetZ", typeof (Double)); |
398 | 406 | ||
399 | createCol(prims, "SitTargetOrientW", typeof(System.Double)); | 407 | createCol(prims, "SitTargetOrientW", typeof (Double)); |
400 | createCol(prims, "SitTargetOrientX", typeof(System.Double)); | 408 | createCol(prims, "SitTargetOrientX", typeof (Double)); |
401 | createCol(prims, "SitTargetOrientY", typeof(System.Double)); | 409 | createCol(prims, "SitTargetOrientY", typeof (Double)); |
402 | createCol(prims, "SitTargetOrientZ", typeof(System.Double)); | 410 | createCol(prims, "SitTargetOrientZ", typeof (Double)); |
403 | 411 | ||
404 | // Add in contraints | 412 | // Add in contraints |
405 | prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] }; | 413 | prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; |
406 | 414 | ||
407 | return prims; | 415 | return prims; |
408 | } | 416 | } |
@@ -410,40 +418,40 @@ namespace OpenSim.DataStore.MSSQL | |||
410 | private DataTable createShapeTable() | 418 | private DataTable createShapeTable() |
411 | { | 419 | { |
412 | DataTable shapes = new DataTable("primshapes"); | 420 | DataTable shapes = new DataTable("primshapes"); |
413 | createCol(shapes, "UUID", typeof(System.String)); | 421 | createCol(shapes, "UUID", typeof (String)); |
414 | // shape is an enum | 422 | // shape is an enum |
415 | createCol(shapes, "Shape", typeof(System.Int32)); | 423 | createCol(shapes, "Shape", typeof (Int32)); |
416 | // vectors | 424 | // vectors |
417 | createCol(shapes, "ScaleX", typeof(System.Double)); | 425 | createCol(shapes, "ScaleX", typeof (Double)); |
418 | createCol(shapes, "ScaleY", typeof(System.Double)); | 426 | createCol(shapes, "ScaleY", typeof (Double)); |
419 | createCol(shapes, "ScaleZ", typeof(System.Double)); | 427 | createCol(shapes, "ScaleZ", typeof (Double)); |
420 | // paths | 428 | // paths |
421 | createCol(shapes, "PCode", typeof(System.Int32)); | 429 | createCol(shapes, "PCode", typeof (Int32)); |
422 | createCol(shapes, "PathBegin", typeof(System.Int32)); | 430 | createCol(shapes, "PathBegin", typeof (Int32)); |
423 | createCol(shapes, "PathEnd", typeof(System.Int32)); | 431 | createCol(shapes, "PathEnd", typeof (Int32)); |
424 | createCol(shapes, "PathScaleX", typeof(System.Int32)); | 432 | createCol(shapes, "PathScaleX", typeof (Int32)); |
425 | createCol(shapes, "PathScaleY", typeof(System.Int32)); | 433 | createCol(shapes, "PathScaleY", typeof (Int32)); |
426 | createCol(shapes, "PathShearX", typeof(System.Int32)); | 434 | createCol(shapes, "PathShearX", typeof (Int32)); |
427 | createCol(shapes, "PathShearY", typeof(System.Int32)); | 435 | createCol(shapes, "PathShearY", typeof (Int32)); |
428 | createCol(shapes, "PathSkew", typeof(System.Int32)); | 436 | createCol(shapes, "PathSkew", typeof (Int32)); |
429 | createCol(shapes, "PathCurve", typeof(System.Int32)); | 437 | createCol(shapes, "PathCurve", typeof (Int32)); |
430 | createCol(shapes, "PathRadiusOffset", typeof(System.Int32)); | 438 | createCol(shapes, "PathRadiusOffset", typeof (Int32)); |
431 | createCol(shapes, "PathRevolutions", typeof(System.Int32)); | 439 | createCol(shapes, "PathRevolutions", typeof (Int32)); |
432 | createCol(shapes, "PathTaperX", typeof(System.Int32)); | 440 | createCol(shapes, "PathTaperX", typeof (Int32)); |
433 | createCol(shapes, "PathTaperY", typeof(System.Int32)); | 441 | createCol(shapes, "PathTaperY", typeof (Int32)); |
434 | createCol(shapes, "PathTwist", typeof(System.Int32)); | 442 | createCol(shapes, "PathTwist", typeof (Int32)); |
435 | createCol(shapes, "PathTwistBegin", typeof(System.Int32)); | 443 | createCol(shapes, "PathTwistBegin", typeof (Int32)); |
436 | // profile | 444 | // profile |
437 | createCol(shapes, "ProfileBegin", typeof(System.Int32)); | 445 | createCol(shapes, "ProfileBegin", typeof (Int32)); |
438 | createCol(shapes, "ProfileEnd", typeof(System.Int32)); | 446 | createCol(shapes, "ProfileEnd", typeof (Int32)); |
439 | createCol(shapes, "ProfileCurve", typeof(System.Int32)); | 447 | createCol(shapes, "ProfileCurve", typeof (Int32)); |
440 | createCol(shapes, "ProfileHollow", typeof(System.Int32)); | 448 | createCol(shapes, "ProfileHollow", typeof (Int32)); |
441 | // text TODO: this isn't right, but I'm not sure the right | 449 | // text TODO: this isn't right, but I'm not sure the right |
442 | // way to specify this as a blob atm | 450 | // way to specify this as a blob atm |
443 | createCol(shapes, "Texture", typeof(System.Byte[])); | 451 | createCol(shapes, "Texture", typeof (Byte[])); |
444 | createCol(shapes, "ExtraParams", typeof(System.Byte[])); | 452 | createCol(shapes, "ExtraParams", typeof (Byte[])); |
445 | 453 | ||
446 | shapes.PrimaryKey = new DataColumn[] { shapes.Columns["UUID"] }; | 454 | shapes.PrimaryKey = new DataColumn[] {shapes.Columns["UUID"]}; |
447 | 455 | ||
448 | return shapes; | 456 | return shapes; |
449 | } | 457 | } |
@@ -462,23 +470,23 @@ namespace OpenSim.DataStore.MSSQL | |||
462 | // interesting has to be done to actually get these values | 470 | // interesting has to be done to actually get these values |
463 | // back out. Not enough time to figure it out yet. | 471 | // back out. Not enough time to figure it out yet. |
464 | SceneObjectPart prim = new SceneObjectPart(); | 472 | SceneObjectPart prim = new SceneObjectPart(); |
465 | prim.UUID = new LLUUID((String)row["UUID"]); | 473 | prim.UUID = new LLUUID((String) row["UUID"]); |
466 | // explicit conversion of integers is required, which sort | 474 | // explicit conversion of integers is required, which sort |
467 | // of sucks. No idea if there is a shortcut here or not. | 475 | // of sucks. No idea if there is a shortcut here or not. |
468 | prim.ParentID = Convert.ToUInt32(row["ParentID"]); | 476 | prim.ParentID = Convert.ToUInt32(row["ParentID"]); |
469 | prim.CreationDate = Convert.ToInt32(row["CreationDate"]); | 477 | prim.CreationDate = Convert.ToInt32(row["CreationDate"]); |
470 | prim.Name = (String)row["Name"]; | 478 | prim.Name = (String) row["Name"]; |
471 | // various text fields | 479 | // various text fields |
472 | prim.Text = (String)row["Text"]; | 480 | prim.Text = (String) row["Text"]; |
473 | prim.Description = (String)row["Description"]; | 481 | prim.Description = (String) row["Description"]; |
474 | prim.SitName = (String)row["SitName"]; | 482 | prim.SitName = (String) row["SitName"]; |
475 | prim.TouchName = (String)row["TouchName"]; | 483 | prim.TouchName = (String) row["TouchName"]; |
476 | // permissions | 484 | // permissions |
477 | prim.ObjectFlags = Convert.ToUInt32(row["ObjectFlags"]); | 485 | prim.ObjectFlags = Convert.ToUInt32(row["ObjectFlags"]); |
478 | prim.CreatorID = new LLUUID((String)row["CreatorID"]); | 486 | prim.CreatorID = new LLUUID((String) row["CreatorID"]); |
479 | prim.OwnerID = new LLUUID((String)row["OwnerID"]); | 487 | prim.OwnerID = new LLUUID((String) row["OwnerID"]); |
480 | prim.GroupID = new LLUUID((String)row["GroupID"]); | 488 | prim.GroupID = new LLUUID((String) row["GroupID"]); |
481 | prim.LastOwnerID = new LLUUID((String)row["LastOwnerID"]); | 489 | prim.LastOwnerID = new LLUUID((String) row["LastOwnerID"]); |
482 | prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]); | 490 | prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]); |
483 | prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]); | 491 | prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]); |
484 | prim.GroupMask = Convert.ToUInt32(row["GroupMask"]); | 492 | prim.GroupMask = Convert.ToUInt32(row["GroupMask"]); |
@@ -521,15 +529,19 @@ namespace OpenSim.DataStore.MSSQL | |||
521 | try | 529 | try |
522 | { | 530 | { |
523 | prim.SetSitTargetLL(new LLVector3( | 531 | prim.SetSitTargetLL(new LLVector3( |
524 | Convert.ToSingle(row["SitTargetOffsetX"]), | 532 | Convert.ToSingle(row["SitTargetOffsetX"]), |
525 | Convert.ToSingle(row["SitTargetOffsetY"]), | 533 | Convert.ToSingle(row["SitTargetOffsetY"]), |
526 | Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion( | 534 | Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion( |
527 | Convert.ToSingle(row["SitTargetOrientX"]), | 535 | Convert.ToSingle( |
528 | Convert.ToSingle(row["SitTargetOrientY"]), | 536 | row["SitTargetOrientX"]), |
529 | Convert.ToSingle(row["SitTargetOrientZ"]), | 537 | Convert.ToSingle( |
530 | Convert.ToSingle(row["SitTargetOrientW"]))); | 538 | row["SitTargetOrientY"]), |
539 | Convert.ToSingle( | ||
540 | row["SitTargetOrientZ"]), | ||
541 | Convert.ToSingle( | ||
542 | row["SitTargetOrientW"]))); | ||
531 | } | 543 | } |
532 | catch (System.InvalidCastException) | 544 | catch (InvalidCastException) |
533 | { | 545 | { |
534 | // Database table was created before we got here and now has null values :P | 546 | // Database table was created before we got here and now has null values :P |
535 | } | 547 | } |
@@ -598,11 +610,10 @@ namespace OpenSim.DataStore.MSSQL | |||
598 | row["SitTargetOrientY"] = sitTargetOrient.Y; | 610 | row["SitTargetOrientY"] = sitTargetOrient.Y; |
599 | row["SitTargetOrientZ"] = sitTargetOrient.Z; | 611 | row["SitTargetOrientZ"] = sitTargetOrient.Z; |
600 | } | 612 | } |
601 | catch (System.Exception) | 613 | catch (Exception) |
602 | { | 614 | { |
603 | // TODO: Add Sit Target Rows! | 615 | // TODO: Add Sit Target Rows! |
604 | } | 616 | } |
605 | |||
606 | } | 617 | } |
607 | 618 | ||
608 | private PrimitiveBaseShape buildShape(DataRow row) | 619 | private PrimitiveBaseShape buildShape(DataRow row) |
@@ -634,14 +645,14 @@ namespace OpenSim.DataStore.MSSQL | |||
634 | s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]); | 645 | s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]); |
635 | s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]); | 646 | s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]); |
636 | s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); | 647 | s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); |
637 | 648 | ||
638 | // text TODO: this isn't right] = but I'm not sure the right | 649 | // text TODO: this isn't right] = but I'm not sure the right |
639 | // way to specify this as a blob atm | 650 | // way to specify this as a blob atm |
640 | byte[] textureEntry = (byte[])row["Texture"]; | 651 | byte[] textureEntry = (byte[]) row["Texture"]; |
641 | s.TextureEntry = textureEntry; | 652 | s.TextureEntry = textureEntry; |
642 | |||
643 | 653 | ||
644 | s.ExtraParams = (byte[])row["ExtraParams"]; | 654 | |
655 | s.ExtraParams = (byte[]) row["ExtraParams"]; | ||
645 | // System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); | 656 | // System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); |
646 | // string texture = encoding.GetString((Byte[])row["Texture"]); | 657 | // string texture = encoding.GetString((Byte[])row["Texture"]); |
647 | // if (!texture.StartsWith("<")) | 658 | // if (!texture.StartsWith("<")) |
@@ -774,7 +785,7 @@ namespace OpenSim.DataStore.MSSQL | |||
774 | sql += ") values (@"; | 785 | sql += ") values (@"; |
775 | sql += String.Join(", @", cols); | 786 | sql += String.Join(", @", cols); |
776 | sql += ")"; | 787 | sql += ")"; |
777 | SqlCommand cmd = new SqlCommand(sql); | 788 | SqlCommand cmd = new SqlCommand(sql); |
778 | // this provides the binding for all our parameters, so | 789 | // this provides the binding for all our parameters, so |
779 | // much less code than it used to be | 790 | // much less code than it used to be |
780 | foreach (DataColumn col in dt.Columns) | 791 | foreach (DataColumn col in dt.Columns) |
@@ -791,14 +802,15 @@ namespace OpenSim.DataStore.MSSQL | |||
791 | foreach (DataColumn col in dt.Columns) | 802 | foreach (DataColumn col in dt.Columns) |
792 | { | 803 | { |
793 | if (subsql.Length > 0) | 804 | if (subsql.Length > 0) |
794 | { // a map function would rock so much here | 805 | { |
806 | // a map function would rock so much here | ||
795 | subsql += ", "; | 807 | subsql += ", "; |
796 | } | 808 | } |
797 | subsql += col.ColumnName + "= @" + col.ColumnName; | 809 | subsql += col.ColumnName + "= @" + col.ColumnName; |
798 | } | 810 | } |
799 | sql += subsql; | 811 | sql += subsql; |
800 | sql += " where " + pk; | 812 | sql += " where " + pk; |
801 | SqlCommand cmd = new SqlCommand(sql); | 813 | SqlCommand cmd = new SqlCommand(sql); |
802 | // this provides the binding for all our parameters, so | 814 | // this provides the binding for all our parameters, so |
803 | // much less code than it used to be | 815 | // much less code than it used to be |
804 | 816 | ||
@@ -817,7 +829,8 @@ namespace OpenSim.DataStore.MSSQL | |||
817 | foreach (DataColumn col in dt.Columns) | 829 | foreach (DataColumn col in dt.Columns) |
818 | { | 830 | { |
819 | if (subsql.Length > 0) | 831 | if (subsql.Length > 0) |
820 | { // a map function would rock so much here | 832 | { |
833 | // a map function would rock so much here | ||
821 | subsql += ",\n"; | 834 | subsql += ",\n"; |
822 | } | 835 | } |
823 | subsql += col.ColumnName + " " + SqlType(col.DataType); | 836 | subsql += col.ColumnName + " " + SqlType(col.DataType); |
@@ -828,7 +841,7 @@ namespace OpenSim.DataStore.MSSQL | |||
828 | } | 841 | } |
829 | sql += subsql; | 842 | sql += subsql; |
830 | sql += ")"; | 843 | sql += ")"; |
831 | 844 | ||
832 | return sql; | 845 | return sql; |
833 | } | 846 | } |
834 | 847 | ||
@@ -837,7 +850,7 @@ namespace OpenSim.DataStore.MSSQL | |||
837 | row["RegionUUID"] = regionUUID; | 850 | row["RegionUUID"] = regionUUID; |
838 | row["Revision"] = rev; | 851 | row["Revision"] = rev; |
839 | 852 | ||
840 | MemoryStream str = new MemoryStream(65536 * sizeof(double)); | 853 | MemoryStream str = new MemoryStream(65536*sizeof (double)); |
841 | BinaryWriter bw = new BinaryWriter(str); | 854 | BinaryWriter bw = new BinaryWriter(str); |
842 | 855 | ||
843 | // TODO: COMPATIBILITY - Add byte-order conversions | 856 | // TODO: COMPATIBILITY - Add byte-order conversions |
@@ -868,7 +881,7 @@ namespace OpenSim.DataStore.MSSQL | |||
868 | /// for us. | 881 | /// for us. |
869 | ///</summary> | 882 | ///</summary> |
870 | ///<returns>a built Sql parameter</returns> | 883 | ///<returns>a built Sql parameter</returns> |
871 | private SqlParameter createSqlParameter(string name, System.Type type) | 884 | private SqlParameter createSqlParameter(string name, Type type) |
872 | { | 885 | { |
873 | SqlParameter param = new SqlParameter(); | 886 | SqlParameter param = new SqlParameter(); |
874 | param.ParameterName = "@" + name; | 887 | param.ParameterName = "@" + name; |
@@ -887,7 +900,7 @@ namespace OpenSim.DataStore.MSSQL | |||
887 | da.UpdateCommand.Connection = conn; | 900 | da.UpdateCommand.Connection = conn; |
888 | 901 | ||
889 | SqlCommand delete = new SqlCommand("delete from prims where UUID = @UUID"); | 902 | SqlCommand delete = new SqlCommand("delete from prims where UUID = @UUID"); |
890 | delete.Parameters.Add(createSqlParameter("UUID", typeof(System.String))); | 903 | delete.Parameters.Add(createSqlParameter("UUID", typeof (String))); |
891 | delete.Connection = conn; | 904 | delete.Connection = conn; |
892 | da.DeleteCommand = delete; | 905 | da.DeleteCommand = delete; |
893 | } | 906 | } |
@@ -901,7 +914,7 @@ namespace OpenSim.DataStore.MSSQL | |||
901 | da.UpdateCommand.Connection = conn; | 914 | da.UpdateCommand.Connection = conn; |
902 | 915 | ||
903 | SqlCommand delete = new SqlCommand("delete from primshapes where UUID = @UUID"); | 916 | SqlCommand delete = new SqlCommand("delete from primshapes where UUID = @UUID"); |
904 | delete.Parameters.Add(createSqlParameter("UUID", typeof(System.String))); | 917 | delete.Parameters.Add(createSqlParameter("UUID", typeof (String))); |
905 | delete.Connection = conn; | 918 | delete.Connection = conn; |
906 | da.DeleteCommand = delete; | 919 | da.DeleteCommand = delete; |
907 | } | 920 | } |
@@ -957,14 +970,13 @@ namespace OpenSim.DataStore.MSSQL | |||
957 | 970 | ||
958 | private bool TestTables(SqlConnection conn) | 971 | private bool TestTables(SqlConnection conn) |
959 | { | 972 | { |
960 | |||
961 | SqlCommand primSelectCmd = new SqlCommand(primSelect, conn); | 973 | SqlCommand primSelectCmd = new SqlCommand(primSelect, conn); |
962 | SqlDataAdapter pDa = new SqlDataAdapter(primSelectCmd); | 974 | SqlDataAdapter pDa = new SqlDataAdapter(primSelectCmd); |
963 | SqlCommand shapeSelectCmd = new SqlCommand(shapeSelect, conn); | 975 | SqlCommand shapeSelectCmd = new SqlCommand(shapeSelect, conn); |
964 | SqlDataAdapter sDa = new SqlDataAdapter(shapeSelectCmd); | 976 | SqlDataAdapter sDa = new SqlDataAdapter(shapeSelectCmd); |
965 | SqlCommand terrainSelectCmd = new SqlCommand(terrainSelect, conn); | 977 | SqlCommand terrainSelectCmd = new SqlCommand(terrainSelect, conn); |
966 | SqlDataAdapter tDa = new SqlDataAdapter(terrainSelectCmd); | 978 | SqlDataAdapter tDa = new SqlDataAdapter(terrainSelectCmd); |
967 | 979 | ||
968 | DataSet tmpDS = new DataSet(); | 980 | DataSet tmpDS = new DataSet(); |
969 | try | 981 | try |
970 | { | 982 | { |
@@ -978,7 +990,7 @@ namespace OpenSim.DataStore.MSSQL | |||
978 | InitDB(conn); | 990 | InitDB(conn); |
979 | } | 991 | } |
980 | 992 | ||
981 | try | 993 | try |
982 | { | 994 | { |
983 | if (tmpDS.Tables == null || tmpDS.Tables.Count == 0) | 995 | if (tmpDS.Tables == null || tmpDS.Tables.Count == 0) |
984 | { | 996 | { |
@@ -986,11 +998,10 @@ namespace OpenSim.DataStore.MSSQL | |||
986 | sDa.Fill(tmpDS, "primshapes"); | 998 | sDa.Fill(tmpDS, "primshapes"); |
987 | tDa.Fill(tmpDS, "terrain"); | 999 | tDa.Fill(tmpDS, "terrain"); |
988 | } | 1000 | } |
989 | |||
990 | } | 1001 | } |
991 | catch (SqlException e) | 1002 | catch (SqlException e) |
992 | { | 1003 | { |
993 | MainLog.Instance.Verbose("DATASTORE", e.ToString()); | 1004 | MainLog.Instance.Verbose("DATASTORE", e.ToString()); |
994 | } | 1005 | } |
995 | 1006 | ||
996 | foreach (DataColumn col in createPrimTable().Columns) | 1007 | foreach (DataColumn col in createPrimTable().Columns) |
@@ -1028,19 +1039,19 @@ namespace OpenSim.DataStore.MSSQL | |||
1028 | 1039 | ||
1029 | private DbType dbtypeFromType(Type type) | 1040 | private DbType dbtypeFromType(Type type) |
1030 | { | 1041 | { |
1031 | if (type == typeof(System.String)) | 1042 | if (type == typeof (String)) |
1032 | { | 1043 | { |
1033 | return DbType.String; | 1044 | return DbType.String; |
1034 | } | 1045 | } |
1035 | else if (type == typeof(System.Int32)) | 1046 | else if (type == typeof (Int32)) |
1036 | { | 1047 | { |
1037 | return DbType.Int32; | 1048 | return DbType.Int32; |
1038 | } | 1049 | } |
1039 | else if (type == typeof(System.Double)) | 1050 | else if (type == typeof (Double)) |
1040 | { | 1051 | { |
1041 | return DbType.Double; | 1052 | return DbType.Double; |
1042 | } | 1053 | } |
1043 | else if (type == typeof(System.Byte[])) | 1054 | else if (type == typeof (Byte[])) |
1044 | { | 1055 | { |
1045 | return DbType.Binary; | 1056 | return DbType.Binary; |
1046 | } | 1057 | } |
@@ -1054,19 +1065,19 @@ namespace OpenSim.DataStore.MSSQL | |||
1054 | // slightly differently. | 1065 | // slightly differently. |
1055 | private string SqlType(Type type) | 1066 | private string SqlType(Type type) |
1056 | { | 1067 | { |
1057 | if (type == typeof(System.String)) | 1068 | if (type == typeof (String)) |
1058 | { | 1069 | { |
1059 | return "varchar(255)"; | 1070 | return "varchar(255)"; |
1060 | } | 1071 | } |
1061 | else if (type == typeof(System.Int32)) | 1072 | else if (type == typeof (Int32)) |
1062 | { | 1073 | { |
1063 | return "integer"; | 1074 | return "integer"; |
1064 | } | 1075 | } |
1065 | else if (type == typeof(System.Double)) | 1076 | else if (type == typeof (Double)) |
1066 | { | 1077 | { |
1067 | return "float"; | 1078 | return "float"; |
1068 | } | 1079 | } |
1069 | else if (type == typeof(System.Byte[])) | 1080 | else if (type == typeof (Byte[])) |
1070 | { | 1081 | { |
1071 | return "image"; | 1082 | return "image"; |
1072 | } | 1083 | } |