mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 08:55:56 +08:00
* Optimized usings
* Shortened type references * Removed redundant 'this' qualifier
This commit is contained in:
@@ -29,10 +29,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using libsecondlife;
|
||||
using Mono.Data.SqliteClient;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.LandManagement;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
@@ -55,6 +56,7 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
* Public Interface Functions
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
public void Initialise(string dbfile, string dbname)
|
||||
{
|
||||
string connectionString = "URI=file:" + dbfile + ",version=3";
|
||||
@@ -80,17 +82,18 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
// primDa.FillSchema(ds, SchemaType.Source, "PrimSchema");
|
||||
TestTables(conn);
|
||||
|
||||
lock(ds) {
|
||||
lock (ds)
|
||||
{
|
||||
ds.Tables.Add(createPrimTable());
|
||||
setupPrimCommands(primDa, conn);
|
||||
primDa.Fill(ds.Tables["prims"]);
|
||||
|
||||
|
||||
ds.Tables.Add(createShapeTable());
|
||||
setupShapeCommands(shapeDa, conn);
|
||||
|
||||
ds.Tables.Add(createTerrainTable());
|
||||
setupTerrainCommands(terrainDa, conn);
|
||||
|
||||
|
||||
// WORKAROUND: This is a work around for sqlite on
|
||||
// windows, which gets really unhappy with blob columns
|
||||
// that have no sample data in them. At some point we
|
||||
@@ -118,7 +121,8 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
|
||||
public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID)
|
||||
{
|
||||
lock (ds) {
|
||||
lock (ds)
|
||||
{
|
||||
foreach (SceneObjectPart prim in obj.Children.Values)
|
||||
{
|
||||
MainLog.Instance.Verbose("DATASTORE", "Adding obj: " + obj.UUID + " to region: " + regionUUID);
|
||||
@@ -136,11 +140,12 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
DataTable shapes = ds.Tables["primshapes"];
|
||||
|
||||
string selectExp = "SceneGroupID = '" + obj.ToString() + "'";
|
||||
lock (ds) {
|
||||
lock (ds)
|
||||
{
|
||||
DataRow[] primRows = prims.Select(selectExp);
|
||||
foreach (DataRow row in primRows)
|
||||
{
|
||||
LLUUID uuid = new LLUUID((string)row["UUID"]);
|
||||
LLUUID uuid = new LLUUID((string) row["UUID"]);
|
||||
DataRow shapeRow = shapes.Rows.Find(uuid);
|
||||
if (shapeRow != null)
|
||||
{
|
||||
@@ -149,7 +154,7 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
row.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Commit();
|
||||
}
|
||||
|
||||
@@ -165,16 +170,18 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
string byRegion = "RegionUUID = '" + regionUUID.ToString() + "'";
|
||||
string orderByParent = "ParentID ASC";
|
||||
|
||||
lock (ds) {
|
||||
lock (ds)
|
||||
{
|
||||
DataRow[] primsForRegion = prims.Select(byRegion, orderByParent);
|
||||
MainLog.Instance.Verbose("DATASTORE", "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID);
|
||||
|
||||
MainLog.Instance.Verbose("DATASTORE",
|
||||
"Loaded " + primsForRegion.Length + " prims for region: " + regionUUID);
|
||||
|
||||
foreach (DataRow primRow in primsForRegion)
|
||||
{
|
||||
try
|
||||
{
|
||||
string uuid = (string)primRow["UUID"];
|
||||
string objID = (string)primRow["SceneGroupID"];
|
||||
string uuid = (string) primRow["UUID"];
|
||||
string objID = (string) primRow["SceneGroupID"];
|
||||
if (uuid == objID) //is new SceneObjectGroup ?
|
||||
{
|
||||
SceneObjectGroup group = new SceneObjectGroup();
|
||||
@@ -186,12 +193,13 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
}
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Notice("No shape found for prim in storage, so setting default box shape");
|
||||
MainLog.Instance.Notice(
|
||||
"No shape found for prim in storage, so setting default box shape");
|
||||
prim.Shape = BoxShape.Default;
|
||||
}
|
||||
}
|
||||
group.AddPart(prim);
|
||||
group.RootPart = prim;
|
||||
|
||||
|
||||
createdObjects.Add(group.UUID, group);
|
||||
retvals.Add(group);
|
||||
}
|
||||
@@ -205,7 +213,8 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
}
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Notice("No shape found for prim in storage, so setting default box shape");
|
||||
MainLog.Instance.Notice(
|
||||
"No shape found for prim in storage, so setting default box shape");
|
||||
prim.Shape = BoxShape.Default;
|
||||
}
|
||||
createdObjects[new LLUUID(objID)].AddPart(prim);
|
||||
@@ -228,46 +237,48 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
|
||||
public void StoreTerrain(double[,] ter, LLUUID regionID)
|
||||
{
|
||||
int revision = OpenSim.Framework.Util.UnixTimeSinceEpoch();
|
||||
int revision = Util.UnixTimeSinceEpoch();
|
||||
|
||||
MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString());
|
||||
|
||||
DataTable terrain = ds.Tables["terrain"];
|
||||
lock (ds) {
|
||||
lock (ds)
|
||||
{
|
||||
DataRow newrow = terrain.NewRow();
|
||||
fillTerrainRow(newrow, regionID, revision, ter);
|
||||
terrain.Rows.Add(newrow);
|
||||
|
||||
|
||||
Commit();
|
||||
}
|
||||
}
|
||||
|
||||
public double[,] LoadTerrain(LLUUID regionID)
|
||||
{
|
||||
double[,] terret = new double[256, 256];
|
||||
double[,] terret = new double[256,256];
|
||||
terret.Initialize();
|
||||
|
||||
DataTable terrain = ds.Tables["terrain"];
|
||||
|
||||
lock (ds) {
|
||||
DataRow[] rows = terrain.Select("RegionUUID = '" + regionID.ToString() + "'","Revision DESC");
|
||||
|
||||
|
||||
lock (ds)
|
||||
{
|
||||
DataRow[] rows = terrain.Select("RegionUUID = '" + regionID.ToString() + "'", "Revision DESC");
|
||||
|
||||
int rev = 0;
|
||||
|
||||
if (rows.Length > 0)
|
||||
{
|
||||
DataRow row = rows[0];
|
||||
|
||||
byte[] heightmap = (byte[])row["Heightfield"];
|
||||
|
||||
byte[] heightmap = (byte[]) row["Heightfield"];
|
||||
for (int x = 0; x < 256; x++)
|
||||
{
|
||||
for (int y = 0; y < 256; y++)
|
||||
{
|
||||
terret[x, y] = BitConverter.ToDouble(heightmap, ((x * 256) + y) * 8);
|
||||
terret[x, y] = BitConverter.ToDouble(heightmap, ((x*256) + y)*8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rev = (int)row["Revision"];
|
||||
rev = (int) row["Revision"];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -275,7 +286,7 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
MainLog.Instance.Verbose("DATASTORE", "Loaded terrain revision r" + rev.ToString());
|
||||
}
|
||||
|
||||
@@ -284,12 +295,10 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
|
||||
public void RemoveLandObject(uint id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void StoreParcel(Land parcel)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public List<Land> LoadLandObjects()
|
||||
@@ -299,7 +308,8 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
lock (ds) {
|
||||
lock (ds)
|
||||
{
|
||||
primDa.Update(ds, "prims");
|
||||
shapeDa.Update(ds, "primshapes");
|
||||
terrainDa.Update(ds, "terrain");
|
||||
@@ -320,7 +330,7 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
private void createCol(DataTable dt, string name, System.Type type)
|
||||
private void createCol(DataTable dt, string name, Type type)
|
||||
{
|
||||
DataColumn col = new DataColumn(name, type);
|
||||
dt.Columns.Add(col);
|
||||
@@ -330,9 +340,9 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
{
|
||||
DataTable terrain = new DataTable("terrain");
|
||||
|
||||
createCol(terrain, "RegionUUID", typeof(System.String));
|
||||
createCol(terrain, "Revision", typeof(System.Int32));
|
||||
createCol(terrain, "Heightfield", typeof(System.Byte[]));
|
||||
createCol(terrain, "RegionUUID", typeof (String));
|
||||
createCol(terrain, "Revision", typeof (Int32));
|
||||
createCol(terrain, "Heightfield", typeof (Byte[]));
|
||||
|
||||
return terrain;
|
||||
}
|
||||
@@ -341,52 +351,52 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
{
|
||||
DataTable prims = new DataTable("prims");
|
||||
|
||||
createCol(prims, "UUID", typeof(System.String));
|
||||
createCol(prims, "RegionUUID", typeof(System.String));
|
||||
createCol(prims, "ParentID", typeof(System.Int32));
|
||||
createCol(prims, "CreationDate", typeof(System.Int32));
|
||||
createCol(prims, "Name", typeof(System.String));
|
||||
createCol(prims, "SceneGroupID", typeof(System.String));
|
||||
createCol(prims, "UUID", typeof (String));
|
||||
createCol(prims, "RegionUUID", typeof (String));
|
||||
createCol(prims, "ParentID", typeof (Int32));
|
||||
createCol(prims, "CreationDate", typeof (Int32));
|
||||
createCol(prims, "Name", typeof (String));
|
||||
createCol(prims, "SceneGroupID", typeof (String));
|
||||
// various text fields
|
||||
createCol(prims, "Text", typeof(System.String));
|
||||
createCol(prims, "Description", typeof(System.String));
|
||||
createCol(prims, "SitName", typeof(System.String));
|
||||
createCol(prims, "TouchName", typeof(System.String));
|
||||
createCol(prims, "Text", typeof (String));
|
||||
createCol(prims, "Description", typeof (String));
|
||||
createCol(prims, "SitName", typeof (String));
|
||||
createCol(prims, "TouchName", typeof (String));
|
||||
// permissions
|
||||
createCol(prims, "ObjectFlags", typeof(System.Int32));
|
||||
createCol(prims, "CreatorID", typeof(System.String));
|
||||
createCol(prims, "OwnerID", typeof(System.String));
|
||||
createCol(prims, "GroupID", typeof(System.String));
|
||||
createCol(prims, "LastOwnerID", typeof(System.String));
|
||||
createCol(prims, "OwnerMask", typeof(System.Int32));
|
||||
createCol(prims, "NextOwnerMask", typeof(System.Int32));
|
||||
createCol(prims, "GroupMask", typeof(System.Int32));
|
||||
createCol(prims, "EveryoneMask", typeof(System.Int32));
|
||||
createCol(prims, "BaseMask", typeof(System.Int32));
|
||||
createCol(prims, "ObjectFlags", typeof (Int32));
|
||||
createCol(prims, "CreatorID", typeof (String));
|
||||
createCol(prims, "OwnerID", typeof (String));
|
||||
createCol(prims, "GroupID", typeof (String));
|
||||
createCol(prims, "LastOwnerID", typeof (String));
|
||||
createCol(prims, "OwnerMask", typeof (Int32));
|
||||
createCol(prims, "NextOwnerMask", typeof (Int32));
|
||||
createCol(prims, "GroupMask", typeof (Int32));
|
||||
createCol(prims, "EveryoneMask", typeof (Int32));
|
||||
createCol(prims, "BaseMask", typeof (Int32));
|
||||
// vectors
|
||||
createCol(prims, "PositionX", typeof(System.Double));
|
||||
createCol(prims, "PositionY", typeof(System.Double));
|
||||
createCol(prims, "PositionZ", typeof(System.Double));
|
||||
createCol(prims, "GroupPositionX", typeof(System.Double));
|
||||
createCol(prims, "GroupPositionY", typeof(System.Double));
|
||||
createCol(prims, "GroupPositionZ", typeof(System.Double));
|
||||
createCol(prims, "VelocityX", typeof(System.Double));
|
||||
createCol(prims, "VelocityY", typeof(System.Double));
|
||||
createCol(prims, "VelocityZ", typeof(System.Double));
|
||||
createCol(prims, "AngularVelocityX", typeof(System.Double));
|
||||
createCol(prims, "AngularVelocityY", typeof(System.Double));
|
||||
createCol(prims, "AngularVelocityZ", typeof(System.Double));
|
||||
createCol(prims, "AccelerationX", typeof(System.Double));
|
||||
createCol(prims, "AccelerationY", typeof(System.Double));
|
||||
createCol(prims, "AccelerationZ", typeof(System.Double));
|
||||
createCol(prims, "PositionX", typeof (Double));
|
||||
createCol(prims, "PositionY", typeof (Double));
|
||||
createCol(prims, "PositionZ", typeof (Double));
|
||||
createCol(prims, "GroupPositionX", typeof (Double));
|
||||
createCol(prims, "GroupPositionY", typeof (Double));
|
||||
createCol(prims, "GroupPositionZ", typeof (Double));
|
||||
createCol(prims, "VelocityX", typeof (Double));
|
||||
createCol(prims, "VelocityY", typeof (Double));
|
||||
createCol(prims, "VelocityZ", typeof (Double));
|
||||
createCol(prims, "AngularVelocityX", typeof (Double));
|
||||
createCol(prims, "AngularVelocityY", typeof (Double));
|
||||
createCol(prims, "AngularVelocityZ", typeof (Double));
|
||||
createCol(prims, "AccelerationX", typeof (Double));
|
||||
createCol(prims, "AccelerationY", typeof (Double));
|
||||
createCol(prims, "AccelerationZ", typeof (Double));
|
||||
// quaternions
|
||||
createCol(prims, "RotationX", typeof(System.Double));
|
||||
createCol(prims, "RotationY", typeof(System.Double));
|
||||
createCol(prims, "RotationZ", typeof(System.Double));
|
||||
createCol(prims, "RotationW", typeof(System.Double));
|
||||
createCol(prims, "RotationX", typeof (Double));
|
||||
createCol(prims, "RotationY", typeof (Double));
|
||||
createCol(prims, "RotationZ", typeof (Double));
|
||||
createCol(prims, "RotationW", typeof (Double));
|
||||
|
||||
// Add in contraints
|
||||
prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] };
|
||||
prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]};
|
||||
|
||||
return prims;
|
||||
}
|
||||
@@ -394,40 +404,40 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
private DataTable createShapeTable()
|
||||
{
|
||||
DataTable shapes = new DataTable("primshapes");
|
||||
createCol(shapes, "UUID", typeof(System.String));
|
||||
createCol(shapes, "UUID", typeof (String));
|
||||
// shape is an enum
|
||||
createCol(shapes, "Shape", typeof(System.Int32));
|
||||
createCol(shapes, "Shape", typeof (Int32));
|
||||
// vectors
|
||||
createCol(shapes, "ScaleX", typeof(System.Double));
|
||||
createCol(shapes, "ScaleY", typeof(System.Double));
|
||||
createCol(shapes, "ScaleZ", typeof(System.Double));
|
||||
createCol(shapes, "ScaleX", typeof (Double));
|
||||
createCol(shapes, "ScaleY", typeof (Double));
|
||||
createCol(shapes, "ScaleZ", typeof (Double));
|
||||
// paths
|
||||
createCol(shapes, "PCode", typeof(System.Int32));
|
||||
createCol(shapes, "PathBegin", typeof(System.Int32));
|
||||
createCol(shapes, "PathEnd", typeof(System.Int32));
|
||||
createCol(shapes, "PathScaleX", typeof(System.Int32));
|
||||
createCol(shapes, "PathScaleY", typeof(System.Int32));
|
||||
createCol(shapes, "PathShearX", typeof(System.Int32));
|
||||
createCol(shapes, "PathShearY", typeof(System.Int32));
|
||||
createCol(shapes, "PathSkew", typeof(System.Int32));
|
||||
createCol(shapes, "PathCurve", typeof(System.Int32));
|
||||
createCol(shapes, "PathRadiusOffset", typeof(System.Int32));
|
||||
createCol(shapes, "PathRevolutions", typeof(System.Int32));
|
||||
createCol(shapes, "PathTaperX", typeof(System.Int32));
|
||||
createCol(shapes, "PathTaperY", typeof(System.Int32));
|
||||
createCol(shapes, "PathTwist", typeof(System.Int32));
|
||||
createCol(shapes, "PathTwistBegin", typeof(System.Int32));
|
||||
createCol(shapes, "PCode", typeof (Int32));
|
||||
createCol(shapes, "PathBegin", typeof (Int32));
|
||||
createCol(shapes, "PathEnd", typeof (Int32));
|
||||
createCol(shapes, "PathScaleX", typeof (Int32));
|
||||
createCol(shapes, "PathScaleY", typeof (Int32));
|
||||
createCol(shapes, "PathShearX", typeof (Int32));
|
||||
createCol(shapes, "PathShearY", typeof (Int32));
|
||||
createCol(shapes, "PathSkew", typeof (Int32));
|
||||
createCol(shapes, "PathCurve", typeof (Int32));
|
||||
createCol(shapes, "PathRadiusOffset", typeof (Int32));
|
||||
createCol(shapes, "PathRevolutions", typeof (Int32));
|
||||
createCol(shapes, "PathTaperX", typeof (Int32));
|
||||
createCol(shapes, "PathTaperY", typeof (Int32));
|
||||
createCol(shapes, "PathTwist", typeof (Int32));
|
||||
createCol(shapes, "PathTwistBegin", typeof (Int32));
|
||||
// profile
|
||||
createCol(shapes, "ProfileBegin", typeof(System.Int32));
|
||||
createCol(shapes, "ProfileEnd", typeof(System.Int32));
|
||||
createCol(shapes, "ProfileCurve", typeof(System.Int32));
|
||||
createCol(shapes, "ProfileHollow", typeof(System.Int32));
|
||||
createCol(shapes, "ProfileBegin", typeof (Int32));
|
||||
createCol(shapes, "ProfileEnd", typeof (Int32));
|
||||
createCol(shapes, "ProfileCurve", typeof (Int32));
|
||||
createCol(shapes, "ProfileHollow", typeof (Int32));
|
||||
// text TODO: this isn't right, but I'm not sure the right
|
||||
// way to specify this as a blob atm
|
||||
createCol(shapes, "Texture", typeof(System.Byte[]));
|
||||
createCol(shapes, "ExtraParams", typeof(System.Byte[]));
|
||||
createCol(shapes, "Texture", typeof (Byte[]));
|
||||
createCol(shapes, "ExtraParams", typeof (Byte[]));
|
||||
|
||||
shapes.PrimaryKey = new DataColumn[] { shapes.Columns["UUID"] };
|
||||
shapes.PrimaryKey = new DataColumn[] {shapes.Columns["UUID"]};
|
||||
|
||||
return shapes;
|
||||
}
|
||||
@@ -446,23 +456,23 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
// interesting has to be done to actually get these values
|
||||
// back out. Not enough time to figure it out yet.
|
||||
SceneObjectPart prim = new SceneObjectPart();
|
||||
prim.UUID = new LLUUID((String)row["UUID"]);
|
||||
prim.UUID = new LLUUID((String) row["UUID"]);
|
||||
// explicit conversion of integers is required, which sort
|
||||
// of sucks. No idea if there is a shortcut here or not.
|
||||
prim.ParentID = Convert.ToUInt32(row["ParentID"]);
|
||||
prim.CreationDate = Convert.ToInt32(row["CreationDate"]);
|
||||
prim.Name = (String)row["Name"];
|
||||
prim.Name = (String) row["Name"];
|
||||
// various text fields
|
||||
prim.Text = (String)row["Text"];
|
||||
prim.Description = (String)row["Description"];
|
||||
prim.SitName = (String)row["SitName"];
|
||||
prim.TouchName = (String)row["TouchName"];
|
||||
prim.Text = (String) row["Text"];
|
||||
prim.Description = (String) row["Description"];
|
||||
prim.SitName = (String) row["SitName"];
|
||||
prim.TouchName = (String) row["TouchName"];
|
||||
// permissions
|
||||
prim.ObjectFlags = Convert.ToUInt32(row["ObjectFlags"]);
|
||||
prim.CreatorID = new LLUUID((String)row["CreatorID"]);
|
||||
prim.OwnerID = new LLUUID((String)row["OwnerID"]);
|
||||
prim.GroupID = new LLUUID((String)row["GroupID"]);
|
||||
prim.LastOwnerID = new LLUUID((String)row["LastOwnerID"]);
|
||||
prim.CreatorID = new LLUUID((String) row["CreatorID"]);
|
||||
prim.OwnerID = new LLUUID((String) row["OwnerID"]);
|
||||
prim.GroupID = new LLUUID((String) row["GroupID"]);
|
||||
prim.LastOwnerID = new LLUUID((String) row["LastOwnerID"]);
|
||||
prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]);
|
||||
prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]);
|
||||
prim.GroupMask = Convert.ToUInt32(row["GroupMask"]);
|
||||
@@ -510,8 +520,8 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
row["RegionUUID"] = regionUUID;
|
||||
row["Revision"] = rev;
|
||||
|
||||
System.IO.MemoryStream str = new System.IO.MemoryStream(65536 * sizeof(double));
|
||||
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(str);
|
||||
MemoryStream str = new MemoryStream(65536*sizeof (double));
|
||||
BinaryWriter bw = new BinaryWriter(str);
|
||||
|
||||
// TODO: COMPATIBILITY - Add byte-order conversions
|
||||
for (int x = 0; x < 256; x++)
|
||||
@@ -599,8 +609,8 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]);
|
||||
// text TODO: this isn't right] = but I'm not sure the right
|
||||
// way to specify this as a blob atm
|
||||
s.TextureEntry = (byte[])row["Texture"];
|
||||
s.ExtraParams = (byte[])row["ExtraParams"];
|
||||
s.TextureEntry = (byte[]) row["Texture"];
|
||||
s.ExtraParams = (byte[]) row["ExtraParams"];
|
||||
// System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
|
||||
// string texture = encoding.GetString((Byte[])row["Texture"]);
|
||||
// if (!texture.StartsWith("<"))
|
||||
@@ -751,7 +761,8 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
foreach (DataColumn col in dt.Columns)
|
||||
{
|
||||
if (subsql.Length > 0)
|
||||
{ // a map function would rock so much here
|
||||
{
|
||||
// a map function would rock so much here
|
||||
subsql += ", ";
|
||||
}
|
||||
subsql += col.ColumnName + "= :" + col.ColumnName;
|
||||
@@ -778,7 +789,8 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
foreach (DataColumn col in dt.Columns)
|
||||
{
|
||||
if (subsql.Length > 0)
|
||||
{ // a map function would rock so much here
|
||||
{
|
||||
// a map function would rock so much here
|
||||
subsql += ",\n";
|
||||
}
|
||||
subsql += col.ColumnName + " " + sqliteType(col.DataType);
|
||||
@@ -812,7 +824,7 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
/// for us.
|
||||
///</summary>
|
||||
///<returns>a built sqlite parameter</returns>
|
||||
private SqliteParameter createSqliteParameter(string name, System.Type type)
|
||||
private SqliteParameter createSqliteParameter(string name, Type type)
|
||||
{
|
||||
SqliteParameter param = new SqliteParameter();
|
||||
param.ParameterName = ":" + name;
|
||||
@@ -831,7 +843,7 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
da.UpdateCommand.Connection = conn;
|
||||
|
||||
SqliteCommand delete = new SqliteCommand("delete from prims where UUID = :UUID");
|
||||
delete.Parameters.Add(createSqliteParameter("UUID", typeof(System.String)));
|
||||
delete.Parameters.Add(createSqliteParameter("UUID", typeof (String)));
|
||||
delete.Connection = conn;
|
||||
da.DeleteCommand = delete;
|
||||
}
|
||||
@@ -851,7 +863,7 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
da.UpdateCommand.Connection = conn;
|
||||
|
||||
SqliteCommand delete = new SqliteCommand("delete from primshapes where UUID = :UUID");
|
||||
delete.Parameters.Add(createSqliteParameter("UUID", typeof(System.String)));
|
||||
delete.Parameters.Add(createSqliteParameter("UUID", typeof (String)));
|
||||
delete.Connection = conn;
|
||||
da.DeleteCommand = delete;
|
||||
}
|
||||
@@ -871,8 +883,9 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
{
|
||||
pcmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (SqliteSyntaxException) {
|
||||
MainLog.Instance.Warn("SQLITE","Primitives Table Already Exists");
|
||||
catch (SqliteSyntaxException)
|
||||
{
|
||||
MainLog.Instance.Warn("SQLITE", "Primitives Table Already Exists");
|
||||
}
|
||||
|
||||
try
|
||||
@@ -912,7 +925,7 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
sDa.Fill(tmpDS, "primshapes");
|
||||
tDa.Fill(tmpDS, "terrain");
|
||||
}
|
||||
catch (Mono.Data.SqliteClient.SqliteSyntaxException)
|
||||
catch (SqliteSyntaxException)
|
||||
{
|
||||
MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating");
|
||||
InitDB(conn);
|
||||
@@ -957,27 +970,27 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
|
||||
private DbType dbtypeFromType(Type type)
|
||||
{
|
||||
if (type == typeof(System.String))
|
||||
if (type == typeof (String))
|
||||
{
|
||||
return DbType.String;
|
||||
}
|
||||
else if (type == typeof(System.Int32))
|
||||
else if (type == typeof (Int32))
|
||||
{
|
||||
return DbType.Int32;
|
||||
}
|
||||
else if (type == typeof(System.Double))
|
||||
else if (type == typeof (Double))
|
||||
{
|
||||
return DbType.Double;
|
||||
}
|
||||
else if (type == typeof(System.Byte))
|
||||
else if (type == typeof (Byte))
|
||||
{
|
||||
return DbType.Byte;
|
||||
}
|
||||
else if (type == typeof(System.Double))
|
||||
else if (type == typeof (Double))
|
||||
{
|
||||
return DbType.Double;
|
||||
}
|
||||
else if (type == typeof(System.Byte[]))
|
||||
else if (type == typeof (Byte[]))
|
||||
{
|
||||
return DbType.Binary;
|
||||
}
|
||||
@@ -991,19 +1004,19 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
// slightly differently.
|
||||
private string sqliteType(Type type)
|
||||
{
|
||||
if (type == typeof(System.String))
|
||||
if (type == typeof (String))
|
||||
{
|
||||
return "varchar(255)";
|
||||
}
|
||||
else if (type == typeof(System.Int32))
|
||||
else if (type == typeof (Int32))
|
||||
{
|
||||
return "integer";
|
||||
}
|
||||
else if (type == typeof(System.Double))
|
||||
else if (type == typeof (Double))
|
||||
{
|
||||
return "float";
|
||||
}
|
||||
else if (type == typeof(System.Byte[]))
|
||||
else if (type == typeof (Byte[]))
|
||||
{
|
||||
return "blob";
|
||||
}
|
||||
@@ -1013,4 +1026,4 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user