changes on sqlite estatedata
parent
f89afd2aa8
commit
016886b3c6
|
@ -186,13 +186,10 @@ namespace OpenSim.Data.SQLite
|
||||||
private void DoCreate(EstateSettings es)
|
private void DoCreate(EstateSettings es)
|
||||||
{
|
{
|
||||||
List<string> names = new List<string>(FieldList);
|
List<string> names = new List<string>(FieldList);
|
||||||
|
names.Remove("EstateID");
|
||||||
IDataReader r = null;
|
|
||||||
|
|
||||||
using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
||||||
{
|
{
|
||||||
names.Remove("EstateID");
|
|
||||||
|
|
||||||
string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")";
|
string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")";
|
||||||
|
|
||||||
cmd.CommandText = sql;
|
cmd.CommandText = sql;
|
||||||
|
@ -217,17 +214,12 @@ namespace OpenSim.Data.SQLite
|
||||||
|
|
||||||
cmd.CommandText = "select LAST_INSERT_ROWID() as id";
|
cmd.CommandText = "select LAST_INSERT_ROWID() as id";
|
||||||
cmd.Parameters.Clear();
|
cmd.Parameters.Clear();
|
||||||
|
using(IDataReader r = cmd.ExecuteReader())
|
||||||
r = cmd.ExecuteReader();
|
{
|
||||||
|
r.Read();
|
||||||
|
es.EstateID = Convert.ToUInt32(r["id"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Read();
|
|
||||||
|
|
||||||
es.EstateID = Convert.ToUInt32(r["id"]);
|
|
||||||
|
|
||||||
r.Close();
|
|
||||||
|
|
||||||
es.Save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StoreEstateSettings(EstateSettings es)
|
public void StoreEstateSettings(EstateSettings es)
|
||||||
|
@ -240,11 +232,10 @@ namespace OpenSim.Data.SQLite
|
||||||
foreach (string f in fields)
|
foreach (string f in fields)
|
||||||
terms.Add(f+" = :"+f);
|
terms.Add(f+" = :"+f);
|
||||||
|
|
||||||
string sql = "update estate_settings set "+String.Join(", ", terms.ToArray())+" where EstateID = :EstateID";
|
|
||||||
|
|
||||||
using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
||||||
{
|
{
|
||||||
cmd.CommandText = sql;
|
cmd.CommandText = "update estate_settings set " + String.Join(", ", terms.ToArray()) + " where EstateID = :EstateID"; ;
|
||||||
|
cmd.Parameters.AddWithValue(":EstateID", es.EstateID);
|
||||||
|
|
||||||
foreach (string name in FieldList)
|
foreach (string name in FieldList)
|
||||||
{
|
{
|
||||||
|
@ -472,34 +463,35 @@ namespace OpenSim.Data.SQLite
|
||||||
|
|
||||||
public bool LinkRegion(UUID regionID, int estateID)
|
public bool LinkRegion(UUID regionID, int estateID)
|
||||||
{
|
{
|
||||||
SqliteTransaction transaction = m_connection.BeginTransaction();
|
using(SqliteTransaction transaction = m_connection.BeginTransaction())
|
||||||
|
|
||||||
// Delete any existing estate mapping for this region.
|
|
||||||
using(SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
|
||||||
{
|
{
|
||||||
cmd.CommandText = "delete from estate_map where RegionID = :RegionID";
|
// Delete any existing estate mapping for this region.
|
||||||
cmd.Transaction = transaction;
|
using(SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
||||||
cmd.Parameters.AddWithValue(":RegionID", regionID.ToString());
|
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
|
|
||||||
using(SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
|
||||||
{
|
|
||||||
cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)";
|
|
||||||
cmd.Transaction = transaction;
|
|
||||||
cmd.Parameters.AddWithValue(":RegionID", regionID.ToString());
|
|
||||||
cmd.Parameters.AddWithValue(":EstateID", estateID.ToString());
|
|
||||||
|
|
||||||
if (cmd.ExecuteNonQuery() == 0)
|
|
||||||
{
|
{
|
||||||
transaction.Rollback();
|
cmd.CommandText = "delete from estate_map where RegionID = :RegionID";
|
||||||
return false;
|
cmd.Transaction = transaction;
|
||||||
|
cmd.Parameters.AddWithValue(":RegionID", regionID.ToString());
|
||||||
|
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
using(SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
|
||||||
{
|
{
|
||||||
transaction.Commit();
|
cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)";
|
||||||
return true;
|
cmd.Transaction = transaction;
|
||||||
|
cmd.Parameters.AddWithValue(":RegionID", regionID.ToString());
|
||||||
|
cmd.Parameters.AddWithValue(":EstateID", estateID.ToString());
|
||||||
|
|
||||||
|
if (cmd.ExecuteNonQuery() == 0)
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
transaction.Commit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue