Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim
commit
08d3650138
|
@ -95,16 +95,15 @@ namespace OpenSim.Client.VWoHTTP.ClientStack
|
||||||
|
|
||||||
ManagedImage tmp;
|
ManagedImage tmp;
|
||||||
Image imgData;
|
Image imgData;
|
||||||
|
byte[] jpegdata;
|
||||||
|
|
||||||
OpenJPEG.DecodeToImage(asset.Data, out tmp, out imgData);
|
OpenJPEG.DecodeToImage(asset.Data, out tmp, out imgData);
|
||||||
|
|
||||||
MemoryStream ms = new MemoryStream();
|
|
||||||
|
|
||||||
imgData.Save(ms, ImageFormat.Jpeg);
|
using (MemoryStream ms = new MemoryStream())
|
||||||
|
{
|
||||||
byte[] jpegdata = ms.GetBuffer();
|
imgData.Save(ms, ImageFormat.Jpeg);
|
||||||
|
jpegdata = ms.GetBuffer();
|
||||||
ms.Close();
|
}
|
||||||
|
|
||||||
resp.ContentType = "image/jpeg";
|
resp.ContentType = "image/jpeg";
|
||||||
resp.ContentLength = jpegdata.Length;
|
resp.ContentLength = jpegdata.Length;
|
||||||
|
|
|
@ -197,20 +197,11 @@ namespace OpenSim.Data.MSSQL
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
SqlConnection conn = realCommand.Connection;
|
SqlConnection conn = realCommand.Connection;
|
||||||
try
|
try { realCommand.Dispose(); }
|
||||||
{
|
|
||||||
realCommand.Dispose();
|
|
||||||
}
|
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
try
|
try { conn.Dispose(); }
|
||||||
{
|
finally { }
|
||||||
conn.Close();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
conn.Dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -348,8 +348,6 @@ namespace OpenSim.Data.MSSQL
|
||||||
//Delete the actual row
|
//Delete the actual row
|
||||||
DeleteOneFolder(folderID, connection);
|
DeleteOneFolder(folderID, connection);
|
||||||
DeleteItemsInFolder(folderID, connection);
|
DeleteItemsInFolder(folderID, connection);
|
||||||
|
|
||||||
connection.Close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -340,8 +340,6 @@ namespace OpenSim.Data.MSSQL
|
||||||
MSSQLMigration migration = new MSSQLMigration(connection, assem, migrationStore);
|
MSSQLMigration migration = new MSSQLMigration(connection, assem, migrationStore);
|
||||||
|
|
||||||
migration.Update();
|
migration.Update();
|
||||||
|
|
||||||
connection.Close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,9 +383,7 @@ namespace OpenSim.Data.MSSQL
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tables.Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -56,7 +56,6 @@ namespace OpenSim.Data.MSSQL
|
||||||
{
|
{
|
||||||
version = Convert.ToInt32(reader["version"]);
|
version = Convert.ToInt32(reader["version"]);
|
||||||
}
|
}
|
||||||
reader.Close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|
|
@ -131,25 +131,26 @@ namespace OpenSim.Data
|
||||||
m_log.InfoFormat("[MIGRATIONS] Upgrading {0} to latest revision.", _type);
|
m_log.InfoFormat("[MIGRATIONS] Upgrading {0} to latest revision.", _type);
|
||||||
m_log.Info("[MIGRATIONS] NOTE: this may take a while, don't interupt this process!");
|
m_log.Info("[MIGRATIONS] NOTE: this may take a while, don't interupt this process!");
|
||||||
|
|
||||||
DbCommand cmd = _conn.CreateCommand();
|
using (DbCommand cmd = _conn.CreateCommand())
|
||||||
foreach (KeyValuePair<int, string> kvp in migrations)
|
|
||||||
{
|
{
|
||||||
int newversion = kvp.Key;
|
foreach (KeyValuePair<int, string> kvp in migrations)
|
||||||
cmd.CommandText = kvp.Value;
|
{
|
||||||
// we need to up the command timeout to infinite as we might be doing long migrations.
|
int newversion = kvp.Key;
|
||||||
cmd.CommandTimeout = 0;
|
cmd.CommandText = kvp.Value;
|
||||||
cmd.ExecuteNonQuery();
|
// we need to up the command timeout to infinite as we might be doing long migrations.
|
||||||
|
cmd.CommandTimeout = 0;
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
if (version == 0)
|
if (version == 0)
|
||||||
{
|
{
|
||||||
InsertVersion(_type, newversion);
|
InsertVersion(_type, newversion);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UpdateVersion(_type, newversion);
|
||||||
|
}
|
||||||
|
version = newversion;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
UpdateVersion(_type, newversion);
|
|
||||||
}
|
|
||||||
version = newversion;
|
|
||||||
cmd.Dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,43 +190,45 @@ namespace OpenSim.Data
|
||||||
protected virtual int FindVersion(DbConnection conn, string type)
|
protected virtual int FindVersion(DbConnection conn, string type)
|
||||||
{
|
{
|
||||||
int version = 0;
|
int version = 0;
|
||||||
DbCommand cmd = conn.CreateCommand();
|
|
||||||
try
|
using (DbCommand cmd = conn.CreateCommand())
|
||||||
{
|
{
|
||||||
cmd.CommandText = "select version from migrations where name='" + type +"' order by version desc";
|
try
|
||||||
using (IDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
{
|
||||||
if (reader.Read())
|
cmd.CommandText = "select version from migrations where name='" + type + "' order by version desc";
|
||||||
|
using (IDataReader reader = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
version = Convert.ToInt32(reader["version"]);
|
if (reader.Read())
|
||||||
|
version = Convert.ToInt32(reader["version"]);
|
||||||
}
|
}
|
||||||
reader.Close();
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Something went wrong, so we're version 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
|
||||||
{
|
|
||||||
// Something went wrong, so we're version 0
|
|
||||||
}
|
|
||||||
cmd.Dispose();
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InsertVersion(string type, int version)
|
private void InsertVersion(string type, int version)
|
||||||
{
|
{
|
||||||
DbCommand cmd = _conn.CreateCommand();
|
using (DbCommand cmd = _conn.CreateCommand())
|
||||||
cmd.CommandText = "insert into migrations(name, version) values('" + type + "', " + version + ")";
|
{
|
||||||
m_log.InfoFormat("[MIGRATIONS]: Creating {0} at version {1}", type, version);
|
cmd.CommandText = "insert into migrations(name, version) values('" + type + "', " + version + ")";
|
||||||
cmd.ExecuteNonQuery();
|
m_log.InfoFormat("[MIGRATIONS]: Creating {0} at version {1}", type, version);
|
||||||
cmd.Dispose();
|
cmd.ExecuteNonQuery();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateVersion(string type, int version)
|
private void UpdateVersion(string type, int version)
|
||||||
{
|
{
|
||||||
DbCommand cmd = _conn.CreateCommand();
|
using (DbCommand cmd = _conn.CreateCommand())
|
||||||
cmd.CommandText = "update migrations set version=" + version + " where name='" + type + "'";
|
{
|
||||||
m_log.InfoFormat("[MIGRATIONS]: Updating {0} to version {1}", type, version);
|
cmd.CommandText = "update migrations set version=" + version + " where name='" + type + "'";
|
||||||
cmd.ExecuteNonQuery();
|
m_log.InfoFormat("[MIGRATIONS]: Updating {0} to version {1}", type, version);
|
||||||
cmd.Dispose();
|
cmd.ExecuteNonQuery();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private SortedList<int, string> GetAllMigrations()
|
// private SortedList<int, string> GetAllMigrations()
|
||||||
|
|
|
@ -142,46 +142,45 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
_dbConnection.CheckConnection();
|
_dbConnection.CheckConnection();
|
||||||
|
|
||||||
MySqlCommand cmd =
|
using (MySqlCommand cmd = new MySqlCommand(
|
||||||
new MySqlCommand(
|
"SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id",
|
||||||
"SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id",
|
_dbConnection.Connection))
|
||||||
_dbConnection.Connection);
|
{
|
||||||
cmd.Parameters.AddWithValue("?id", assetID.ToString());
|
cmd.Parameters.AddWithValue("?id", assetID.ToString());
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
|
||||||
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
|
||||||
{
|
{
|
||||||
if (dbReader.Read())
|
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||||
{
|
{
|
||||||
asset = new AssetBase();
|
if (dbReader.Read())
|
||||||
asset.Data = (byte[]) dbReader["data"];
|
|
||||||
asset.Description = (string) dbReader["description"];
|
|
||||||
asset.FullID = assetID;
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
asset.Local = (bool)dbReader["local"];
|
asset = new AssetBase();
|
||||||
|
asset.Data = (byte[])dbReader["data"];
|
||||||
|
asset.Description = (string)dbReader["description"];
|
||||||
|
asset.FullID = assetID;
|
||||||
|
|
||||||
|
string local = dbReader["local"].ToString();
|
||||||
|
if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
asset.Local = true;
|
||||||
|
else
|
||||||
|
asset.Local = false;
|
||||||
|
|
||||||
|
asset.Name = (string)dbReader["name"];
|
||||||
|
asset.Type = (sbyte)dbReader["assetType"];
|
||||||
|
asset.Temporary = Convert.ToBoolean(dbReader["temporary"]);
|
||||||
}
|
}
|
||||||
catch (InvalidCastException)
|
|
||||||
{
|
|
||||||
asset.Local = false;
|
|
||||||
}
|
|
||||||
asset.Name = (string) dbReader["name"];
|
|
||||||
asset.Type = (sbyte) dbReader["assetType"];
|
|
||||||
asset.Temporary = Convert.ToBoolean(dbReader["temporary"]);
|
|
||||||
}
|
}
|
||||||
dbReader.Close();
|
|
||||||
cmd.Dispose();
|
if (asset != null)
|
||||||
|
UpdateAccessTime(asset);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString()
|
||||||
|
+ Environment.NewLine + "Reconnecting", assetID);
|
||||||
|
_dbConnection.Reconnect();
|
||||||
}
|
}
|
||||||
if (asset != null)
|
|
||||||
UpdateAccessTime(asset);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat(
|
|
||||||
"[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString()
|
|
||||||
+ Environment.NewLine + "Reconnecting", assetID);
|
|
||||||
_dbConnection.Reconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return asset;
|
return asset;
|
||||||
|
@ -297,32 +296,27 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
_dbConnection.CheckConnection();
|
_dbConnection.CheckConnection();
|
||||||
|
|
||||||
MySqlCommand cmd =
|
using (MySqlCommand cmd = new MySqlCommand(
|
||||||
new MySqlCommand(
|
"SELECT id FROM assets WHERE id=?id",
|
||||||
"SELECT id FROM assets WHERE id=?id",
|
_dbConnection.Connection))
|
||||||
_dbConnection.Connection);
|
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("?id", uuid.ToString());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
cmd.Parameters.AddWithValue("?id", uuid.ToString());
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (dbReader.Read())
|
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||||
{
|
{
|
||||||
assetExists = true;
|
if (dbReader.Read())
|
||||||
|
assetExists = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbReader.Close();
|
|
||||||
cmd.Dispose();
|
|
||||||
}
|
}
|
||||||
}
|
catch (Exception e)
|
||||||
catch (Exception e)
|
{
|
||||||
{
|
m_log.ErrorFormat(
|
||||||
m_log.ErrorFormat(
|
"[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString()
|
||||||
"[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString()
|
+ Environment.NewLine + "Attempting reconnection", uuid);
|
||||||
+ Environment.NewLine + "Attempting reconnection", uuid);
|
_dbConnection.Reconnect();
|
||||||
_dbConnection.Reconnect();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,44 +55,38 @@ namespace OpenSim.Data.MySQL
|
||||||
AuthenticationData ret = new AuthenticationData();
|
AuthenticationData ret = new AuthenticationData();
|
||||||
ret.Data = new Dictionary<string, object>();
|
ret.Data = new Dictionary<string, object>();
|
||||||
|
|
||||||
MySqlCommand cmd = new MySqlCommand(
|
using (MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID"))
|
||||||
"select * from `"+m_Realm+"` where UUID = ?principalID"
|
|
||||||
);
|
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
|
|
||||||
|
|
||||||
IDataReader result = ExecuteReader(cmd);
|
|
||||||
|
|
||||||
if (result.Read())
|
|
||||||
{
|
{
|
||||||
ret.PrincipalID = principalID;
|
cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
|
||||||
|
|
||||||
if (m_ColumnNames == null)
|
using (IDataReader result = ExecuteReader(cmd))
|
||||||
{
|
{
|
||||||
m_ColumnNames = new List<string>();
|
if (result.Read())
|
||||||
|
{
|
||||||
|
ret.PrincipalID = principalID;
|
||||||
|
|
||||||
DataTable schemaTable = result.GetSchemaTable();
|
if (m_ColumnNames == null)
|
||||||
foreach (DataRow row in schemaTable.Rows)
|
{
|
||||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
m_ColumnNames = new List<string>();
|
||||||
|
|
||||||
|
DataTable schemaTable = result.GetSchemaTable();
|
||||||
|
foreach (DataRow row in schemaTable.Rows)
|
||||||
|
m_ColumnNames.Add(row["ColumnName"].ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string s in m_ColumnNames)
|
||||||
|
{
|
||||||
|
if (s == "UUID")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ret.Data[s] = result[s].ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (string s in m_ColumnNames)
|
|
||||||
{
|
|
||||||
if (s == "UUID")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ret.Data[s] = result[s].ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
result.Close();
|
|
||||||
CloseReaderCommand(cmd);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Close();
|
|
||||||
CloseReaderCommand(cmd);
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,21 +95,17 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
protected void GetWaitTimeout()
|
protected void GetWaitTimeout()
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect,
|
using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, m_connection))
|
||||||
m_connection);
|
|
||||||
|
|
||||||
using (MySqlDataReader dbReader =
|
|
||||||
cmd.ExecuteReader(CommandBehavior.SingleRow))
|
|
||||||
{
|
{
|
||||||
if (dbReader.Read())
|
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||||
{
|
{
|
||||||
m_waitTimeout
|
if (dbReader.Read())
|
||||||
= Convert.ToInt32(dbReader["@@wait_timeout"]) *
|
{
|
||||||
TimeSpan.TicksPerSecond + m_waitTimeoutLeeway;
|
m_waitTimeout
|
||||||
|
= Convert.ToInt32(dbReader["@@wait_timeout"]) *
|
||||||
|
TimeSpan.TicksPerSecond + m_waitTimeoutLeeway;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dbReader.Close();
|
|
||||||
cmd.Dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lastConnectionUse = DateTime.Now.Ticks;
|
m_lastConnectionUse = DateTime.Now.Ticks;
|
||||||
|
@ -147,53 +143,122 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
CheckConnection();
|
CheckConnection();
|
||||||
|
|
||||||
MySqlCommand cmd = m_connection.CreateCommand();
|
bool migration = true;
|
||||||
|
|
||||||
cmd.CommandText = sql;
|
using (MySqlCommand cmd = m_connection.CreateCommand())
|
||||||
cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
|
|
||||||
|
|
||||||
IDataReader r = cmd.ExecuteReader();
|
|
||||||
|
|
||||||
if (r.Read())
|
|
||||||
{
|
{
|
||||||
foreach (string name in FieldList)
|
cmd.CommandText = sql;
|
||||||
{
|
cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
|
||||||
if (m_FieldMap[name].GetValue(es) is bool)
|
|
||||||
{
|
|
||||||
int v = Convert.ToInt32(r[name]);
|
|
||||||
if (v != 0)
|
|
||||||
m_FieldMap[name].SetValue(es, true);
|
|
||||||
else
|
|
||||||
m_FieldMap[name].SetValue(es, false);
|
|
||||||
}
|
|
||||||
else if (m_FieldMap[name].GetValue(es) is UUID)
|
|
||||||
{
|
|
||||||
UUID uuid = UUID.Zero;
|
|
||||||
|
|
||||||
UUID.TryParse(r[name].ToString(), out uuid);
|
using (IDataReader r = cmd.ExecuteReader())
|
||||||
m_FieldMap[name].SetValue(es, uuid);
|
{
|
||||||
}
|
if (r.Read())
|
||||||
else
|
|
||||||
{
|
{
|
||||||
m_FieldMap[name].SetValue(es, r[name]);
|
migration = false;
|
||||||
|
|
||||||
|
foreach (string name in FieldList)
|
||||||
|
{
|
||||||
|
if (m_FieldMap[name].GetValue(es) is bool)
|
||||||
|
{
|
||||||
|
int v = Convert.ToInt32(r[name]);
|
||||||
|
if (v != 0)
|
||||||
|
m_FieldMap[name].SetValue(es, true);
|
||||||
|
else
|
||||||
|
m_FieldMap[name].SetValue(es, false);
|
||||||
|
}
|
||||||
|
else if (m_FieldMap[name].GetValue(es) is UUID)
|
||||||
|
{
|
||||||
|
UUID uuid = UUID.Zero;
|
||||||
|
|
||||||
|
UUID.TryParse(r[name].ToString(), out uuid);
|
||||||
|
m_FieldMap[name].SetValue(es, uuid);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_FieldMap[name].SetValue(es, r[name]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r.Close();
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (migration)
|
||||||
{
|
{
|
||||||
// Migration case
|
// Migration case
|
||||||
//
|
|
||||||
r.Close();
|
|
||||||
|
|
||||||
List<string> names = new List<string>(FieldList);
|
List<string> names = new List<string>(FieldList);
|
||||||
|
|
||||||
names.Remove("EstateID");
|
names.Remove("EstateID");
|
||||||
|
|
||||||
sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")";
|
sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")";
|
||||||
|
|
||||||
|
using (MySqlCommand cmd = m_connection.CreateCommand())
|
||||||
|
{
|
||||||
|
cmd.CommandText = sql;
|
||||||
|
cmd.Parameters.Clear();
|
||||||
|
|
||||||
|
foreach (string name in FieldList)
|
||||||
|
{
|
||||||
|
if (m_FieldMap[name].GetValue(es) is bool)
|
||||||
|
{
|
||||||
|
if ((bool)m_FieldMap[name].GetValue(es))
|
||||||
|
cmd.Parameters.AddWithValue("?" + name, "1");
|
||||||
|
else
|
||||||
|
cmd.Parameters.AddWithValue("?" + name, "0");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
cmd.CommandText = "select LAST_INSERT_ID() as id";
|
||||||
|
cmd.Parameters.Clear();
|
||||||
|
|
||||||
|
using (IDataReader r = cmd.ExecuteReader())
|
||||||
|
{
|
||||||
|
r.Read();
|
||||||
|
es.EstateID = Convert.ToUInt32(r["id"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)";
|
||||||
|
cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
|
||||||
|
|
||||||
|
// This will throw on dupe key
|
||||||
|
try { cmd.ExecuteNonQuery(); }
|
||||||
|
catch (Exception) { }
|
||||||
|
|
||||||
|
// Munge and transfer the ban list
|
||||||
|
cmd.Parameters.Clear();
|
||||||
|
cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID";
|
||||||
|
cmd.Parameters.AddWithValue("?UUID", regionID.ToString());
|
||||||
|
|
||||||
|
try { cmd.ExecuteNonQuery(); }
|
||||||
|
catch (Exception) { }
|
||||||
|
|
||||||
|
es.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadBanList(es);
|
||||||
|
|
||||||
|
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
|
||||||
|
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
|
||||||
|
es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups");
|
||||||
|
return es;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StoreEstateSettings(EstateSettings es)
|
||||||
|
{
|
||||||
|
string sql = "replace into estate_settings (" + String.Join(",", FieldList) + ") values ( ?" + String.Join(", ?", FieldList) + ")";
|
||||||
|
|
||||||
|
CheckConnection();
|
||||||
|
|
||||||
|
using (MySqlCommand cmd = m_connection.CreateCommand())
|
||||||
|
{
|
||||||
cmd.CommandText = sql;
|
cmd.CommandText = sql;
|
||||||
cmd.Parameters.Clear();
|
|
||||||
|
|
||||||
foreach (string name in FieldList)
|
foreach (string name in FieldList)
|
||||||
{
|
{
|
||||||
|
@ -211,83 +276,8 @@ namespace OpenSim.Data.MySQL
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
cmd.CommandText = "select LAST_INSERT_ID() as id";
|
|
||||||
cmd.Parameters.Clear();
|
|
||||||
|
|
||||||
r = cmd.ExecuteReader();
|
|
||||||
|
|
||||||
r.Read();
|
|
||||||
|
|
||||||
es.EstateID = Convert.ToUInt32(r["id"]);
|
|
||||||
|
|
||||||
r.Close();
|
|
||||||
|
|
||||||
cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)";
|
|
||||||
cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
|
|
||||||
|
|
||||||
// This will throw on dupe key
|
|
||||||
try
|
|
||||||
{
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Munge and transfer the ban list
|
|
||||||
//
|
|
||||||
cmd.Parameters.Clear();
|
|
||||||
cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID";
|
|
||||||
cmd.Parameters.AddWithValue("?UUID", regionID.ToString());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
es.Save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadBanList(es);
|
|
||||||
|
|
||||||
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
|
|
||||||
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
|
|
||||||
es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups");
|
|
||||||
return es;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StoreEstateSettings(EstateSettings es)
|
|
||||||
{
|
|
||||||
string sql = "replace into estate_settings (" + String.Join(",", FieldList) + ") values ( ?" + String.Join(", ?", FieldList) + ")";
|
|
||||||
|
|
||||||
CheckConnection();
|
|
||||||
|
|
||||||
MySqlCommand cmd = m_connection.CreateCommand();
|
|
||||||
|
|
||||||
cmd.CommandText = sql;
|
|
||||||
|
|
||||||
foreach (string name in FieldList)
|
|
||||||
{
|
|
||||||
if (m_FieldMap[name].GetValue(es) is bool)
|
|
||||||
{
|
|
||||||
if ((bool)m_FieldMap[name].GetValue(es))
|
|
||||||
cmd.Parameters.AddWithValue("?" + name, "1");
|
|
||||||
else
|
|
||||||
cmd.Parameters.AddWithValue("?" + name, "0");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
|
|
||||||
SaveBanList(es);
|
SaveBanList(es);
|
||||||
SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers);
|
SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers);
|
||||||
SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess);
|
SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess);
|
||||||
|
@ -300,50 +290,52 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
CheckConnection();
|
CheckConnection();
|
||||||
|
|
||||||
MySqlCommand cmd = m_connection.CreateCommand();
|
using (MySqlCommand cmd = m_connection.CreateCommand())
|
||||||
|
|
||||||
cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID";
|
|
||||||
cmd.Parameters.AddWithValue("?EstateID", es.EstateID);
|
|
||||||
|
|
||||||
IDataReader r = cmd.ExecuteReader();
|
|
||||||
|
|
||||||
while (r.Read())
|
|
||||||
{
|
{
|
||||||
EstateBan eb = new EstateBan();
|
cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID";
|
||||||
|
cmd.Parameters.AddWithValue("?EstateID", es.EstateID);
|
||||||
|
|
||||||
UUID uuid = new UUID();
|
using (IDataReader r = cmd.ExecuteReader())
|
||||||
UUID.TryParse(r["bannedUUID"].ToString(), out uuid);
|
{
|
||||||
|
while (r.Read())
|
||||||
|
{
|
||||||
|
EstateBan eb = new EstateBan();
|
||||||
|
|
||||||
eb.BannedUserID = uuid;
|
UUID uuid = new UUID();
|
||||||
eb.BannedHostAddress = "0.0.0.0";
|
UUID.TryParse(r["bannedUUID"].ToString(), out uuid);
|
||||||
eb.BannedHostIPMask = "0.0.0.0";
|
|
||||||
es.AddBan(eb);
|
eb.BannedUserID = uuid;
|
||||||
|
eb.BannedHostAddress = "0.0.0.0";
|
||||||
|
eb.BannedHostIPMask = "0.0.0.0";
|
||||||
|
es.AddBan(eb);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
r.Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveBanList(EstateSettings es)
|
private void SaveBanList(EstateSettings es)
|
||||||
{
|
{
|
||||||
CheckConnection();
|
CheckConnection();
|
||||||
|
|
||||||
MySqlCommand cmd = m_connection.CreateCommand();
|
using (MySqlCommand cmd = m_connection.CreateCommand())
|
||||||
|
|
||||||
cmd.CommandText = "delete from estateban where EstateID = ?EstateID";
|
|
||||||
cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
|
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
|
|
||||||
cmd.Parameters.Clear();
|
|
||||||
|
|
||||||
cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )";
|
|
||||||
|
|
||||||
foreach (EstateBan b in es.EstateBans)
|
|
||||||
{
|
{
|
||||||
|
cmd.CommandText = "delete from estateban where EstateID = ?EstateID";
|
||||||
cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
|
cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
|
||||||
cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString());
|
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
cmd.Parameters.Clear();
|
cmd.Parameters.Clear();
|
||||||
|
|
||||||
|
cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )";
|
||||||
|
|
||||||
|
foreach (EstateBan b in es.EstateBans)
|
||||||
|
{
|
||||||
|
cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString());
|
||||||
|
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
cmd.Parameters.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,24 +343,25 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
CheckConnection();
|
CheckConnection();
|
||||||
|
|
||||||
MySqlCommand cmd = m_connection.CreateCommand();
|
using (MySqlCommand cmd = m_connection.CreateCommand())
|
||||||
|
|
||||||
cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID";
|
|
||||||
cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString());
|
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
|
|
||||||
cmd.Parameters.Clear();
|
|
||||||
|
|
||||||
cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )";
|
|
||||||
|
|
||||||
foreach (UUID uuid in data)
|
|
||||||
{
|
{
|
||||||
|
cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID";
|
||||||
cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString());
|
cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString());
|
||||||
cmd.Parameters.AddWithValue("?uuid", uuid.ToString());
|
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
cmd.Parameters.Clear();
|
cmd.Parameters.Clear();
|
||||||
|
|
||||||
|
cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )";
|
||||||
|
|
||||||
|
foreach (UUID uuid in data)
|
||||||
|
{
|
||||||
|
cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?uuid", uuid.ToString());
|
||||||
|
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
cmd.Parameters.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,23 +371,24 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
CheckConnection();
|
CheckConnection();
|
||||||
|
|
||||||
MySqlCommand cmd = m_connection.CreateCommand();
|
using (MySqlCommand cmd = m_connection.CreateCommand())
|
||||||
|
|
||||||
cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID";
|
|
||||||
cmd.Parameters.AddWithValue("?EstateID", EstateID);
|
|
||||||
|
|
||||||
IDataReader r = cmd.ExecuteReader();
|
|
||||||
|
|
||||||
while (r.Read())
|
|
||||||
{
|
{
|
||||||
// EstateBan eb = new EstateBan();
|
cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID";
|
||||||
|
cmd.Parameters.AddWithValue("?EstateID", EstateID);
|
||||||
|
|
||||||
UUID uuid = new UUID();
|
using (IDataReader r = cmd.ExecuteReader())
|
||||||
UUID.TryParse(r["uuid"].ToString(), out uuid);
|
{
|
||||||
|
while (r.Read())
|
||||||
|
{
|
||||||
|
// EstateBan eb = new EstateBan();
|
||||||
|
|
||||||
uuids.Add(uuid);
|
UUID uuid = new UUID();
|
||||||
|
UUID.TryParse(r["uuid"].ToString(), out uuid);
|
||||||
|
|
||||||
|
uuids.Add(uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
r.Close();
|
|
||||||
|
|
||||||
return uuids.ToArray();
|
return uuids.ToArray();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,8 @@ namespace OpenSim.Data.MySQL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MySqlFramework
|
public class MySqlFramework
|
||||||
{
|
{
|
||||||
|
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
protected MySqlConnection m_Connection;
|
protected MySqlConnection m_Connection;
|
||||||
|
|
||||||
protected MySqlFramework(string connectionString)
|
protected MySqlFramework(string connectionString)
|
||||||
|
@ -70,12 +72,11 @@ namespace OpenSim.Data.MySQL
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Console.WriteLine(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
if (errorSeen)
|
if (errorSeen)
|
||||||
throw;
|
throw;
|
||||||
|
|
||||||
// This is "Server has gone away" and "Server lost"
|
// This is "Server has gone away" and "Server lost"
|
||||||
//
|
|
||||||
if (e.Number == 2006 || e.Number == 2013)
|
if (e.Number == 2006 || e.Number == 2013)
|
||||||
{
|
{
|
||||||
errorSeen = true;
|
errorSeen = true;
|
||||||
|
@ -94,7 +95,7 @@ Console.WriteLine(e.ToString());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.WriteLine(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,12 +113,5 @@ Console.WriteLine(e.ToString());
|
||||||
|
|
||||||
return cmd.ExecuteReader();
|
return cmd.ExecuteReader();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void CloseReaderCommand(MySqlCommand cmd)
|
|
||||||
{
|
|
||||||
cmd.Connection.Close();
|
|
||||||
cmd.Connection.Dispose();
|
|
||||||
cmd.Dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,29 +197,27 @@ namespace OpenSim.Data.MySQL
|
||||||
param["?xmax"] = xmax.ToString();
|
param["?xmax"] = xmax.ToString();
|
||||||
param["?ymax"] = ymax.ToString();
|
param["?ymax"] = ymax.ToString();
|
||||||
|
|
||||||
IDbCommand result =
|
using (IDbCommand result = dbm.Manager.Query(
|
||||||
dbm.Manager.Query(
|
|
||||||
"SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax",
|
"SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax",
|
||||||
param);
|
param))
|
||||||
IDataReader reader = result.ExecuteReader();
|
|
||||||
|
|
||||||
RegionProfileData row;
|
|
||||||
|
|
||||||
List<RegionProfileData> rows = new List<RegionProfileData>();
|
|
||||||
|
|
||||||
while ((row = dbm.Manager.readSimRow(reader)) != null)
|
|
||||||
{
|
{
|
||||||
rows.Add(row);
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
}
|
{
|
||||||
reader.Close();
|
RegionProfileData row;
|
||||||
result.Dispose();
|
|
||||||
|
|
||||||
return rows.ToArray();
|
List<RegionProfileData> rows = new List<RegionProfileData>();
|
||||||
|
|
||||||
|
while ((row = dbm.Manager.readSimRow(reader)) != null)
|
||||||
|
rows.Add(row);
|
||||||
|
|
||||||
|
return rows.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -243,29 +241,27 @@ namespace OpenSim.Data.MySQL
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||||
param["?name"] = namePrefix + "%";
|
param["?name"] = namePrefix + "%";
|
||||||
|
|
||||||
IDbCommand result =
|
using (IDbCommand result = dbm.Manager.Query(
|
||||||
dbm.Manager.Query(
|
"SELECT * FROM regions WHERE regionName LIKE ?name",
|
||||||
"SELECT * FROM regions WHERE regionName LIKE ?name",
|
param))
|
||||||
param);
|
|
||||||
IDataReader reader = result.ExecuteReader();
|
|
||||||
|
|
||||||
RegionProfileData row;
|
|
||||||
|
|
||||||
List<RegionProfileData> rows = new List<RegionProfileData>();
|
|
||||||
|
|
||||||
while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null)
|
|
||||||
{
|
{
|
||||||
rows.Add(row);
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
}
|
{
|
||||||
reader.Close();
|
RegionProfileData row;
|
||||||
result.Dispose();
|
|
||||||
|
|
||||||
return rows;
|
List<RegionProfileData> rows = new List<RegionProfileData>();
|
||||||
|
|
||||||
|
while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null)
|
||||||
|
rows.Add(row);
|
||||||
|
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -286,21 +282,21 @@ namespace OpenSim.Data.MySQL
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||||
param["?handle"] = handle.ToString();
|
param["?handle"] = handle.ToString();
|
||||||
|
|
||||||
IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param);
|
using (IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param))
|
||||||
IDataReader reader = result.ExecuteReader();
|
{
|
||||||
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
RegionProfileData row = dbm.Manager.readSimRow(reader);
|
{
|
||||||
reader.Close();
|
RegionProfileData row = dbm.Manager.readSimRow(reader);
|
||||||
result.Dispose();
|
return row;
|
||||||
|
}
|
||||||
return row;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -321,23 +317,24 @@ namespace OpenSim.Data.MySQL
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||||
param["?uuid"] = uuid.ToString();
|
param["?uuid"] = uuid.ToString();
|
||||||
|
|
||||||
IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param);
|
using (IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param))
|
||||||
IDataReader reader = result.ExecuteReader();
|
{
|
||||||
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
RegionProfileData row = dbm.Manager.readSimRow(reader);
|
{
|
||||||
reader.Close();
|
RegionProfileData row = dbm.Manager.readSimRow(reader);
|
||||||
result.Dispose();
|
return row;
|
||||||
|
}
|
||||||
return row;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
} finally
|
}
|
||||||
|
finally
|
||||||
{
|
{
|
||||||
dbm.Release();
|
dbm.Release();
|
||||||
}
|
}
|
||||||
|
@ -359,22 +356,21 @@ namespace OpenSim.Data.MySQL
|
||||||
// Add % because this is a like query.
|
// Add % because this is a like query.
|
||||||
param["?regionName"] = regionName + "%";
|
param["?regionName"] = regionName + "%";
|
||||||
// Order by statement will return shorter matches first. Only returns one record or no record.
|
// Order by statement will return shorter matches first. Only returns one record or no record.
|
||||||
IDbCommand result =
|
using (IDbCommand result = dbm.Manager.Query(
|
||||||
dbm.Manager.Query(
|
"SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1",
|
||||||
"SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1",
|
param))
|
||||||
param);
|
{
|
||||||
IDataReader reader = result.ExecuteReader();
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
|
{
|
||||||
RegionProfileData row = dbm.Manager.readSimRow(reader);
|
RegionProfileData row = dbm.Manager.readSimRow(reader);
|
||||||
reader.Close();
|
return row;
|
||||||
result.Dispose();
|
}
|
||||||
|
}
|
||||||
return row;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -382,6 +378,7 @@ namespace OpenSim.Data.MySQL
|
||||||
dbm.Release();
|
dbm.Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters");
|
m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -394,12 +391,12 @@ namespace OpenSim.Data.MySQL
|
||||||
override public DataResponse StoreProfile(RegionProfileData profile)
|
override public DataResponse StoreProfile(RegionProfileData profile)
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection();
|
MySQLSuperManager dbm = GetLockedConnection();
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
if (dbm.Manager.insertRegion(profile))
|
if (dbm.Manager.insertRegion(profile))
|
||||||
{
|
|
||||||
return DataResponse.RESPONSE_OK;
|
return DataResponse.RESPONSE_OK;
|
||||||
}
|
else
|
||||||
return DataResponse.RESPONSE_ERROR;
|
return DataResponse.RESPONSE_ERROR;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -417,14 +414,14 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection();
|
MySQLSuperManager dbm = GetLockedConnection();
|
||||||
|
|
||||||
|
try
|
||||||
try {
|
{
|
||||||
if (dbm.Manager.deleteRegion(uuid))
|
if (dbm.Manager.deleteRegion(uuid))
|
||||||
{
|
|
||||||
return DataResponse.RESPONSE_OK;
|
return DataResponse.RESPONSE_OK;
|
||||||
}
|
else
|
||||||
return DataResponse.RESPONSE_ERROR;
|
return DataResponse.RESPONSE_ERROR;
|
||||||
} finally
|
}
|
||||||
|
finally
|
||||||
{
|
{
|
||||||
dbm.Release();
|
dbm.Release();
|
||||||
}
|
}
|
||||||
|
@ -482,26 +479,26 @@ namespace OpenSim.Data.MySQL
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||||
param["?x"] = x.ToString();
|
param["?x"] = x.ToString();
|
||||||
param["?y"] = y.ToString();
|
param["?y"] = y.ToString();
|
||||||
IDbCommand result =
|
using (IDbCommand result = dbm.Manager.Query(
|
||||||
dbm.Manager.Query(
|
"SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y",
|
||||||
"SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y",
|
param))
|
||||||
param);
|
{
|
||||||
IDataReader reader = result.ExecuteReader();
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
|
{
|
||||||
ReservationData row = dbm.Manager.readReservationRow(reader);
|
ReservationData row = dbm.Manager.readReservationRow(reader);
|
||||||
reader.Close();
|
return row;
|
||||||
result.Dispose();
|
}
|
||||||
|
}
|
||||||
return row;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
} finally
|
}
|
||||||
|
finally
|
||||||
{
|
{
|
||||||
dbm.Release();
|
dbm.Release();
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,30 +135,30 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
database.CheckConnection();
|
database.CheckConnection();
|
||||||
|
|
||||||
MySqlCommand result =
|
using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid",
|
||||||
new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid",
|
database.Connection))
|
||||||
database.Connection);
|
|
||||||
result.Parameters.AddWithValue("?uuid", folderID.ToString());
|
|
||||||
MySqlDataReader reader = result.ExecuteReader();
|
|
||||||
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
{
|
||||||
// A null item (because something went wrong) breaks everything in the folder
|
result.Parameters.AddWithValue("?uuid", folderID.ToString());
|
||||||
InventoryItemBase item = readInventoryItem(reader);
|
|
||||||
if (item != null)
|
using (MySqlDataReader reader = result.ExecuteReader())
|
||||||
items.Add(item);
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
// A null item (because something went wrong) breaks everything in the folder
|
||||||
|
InventoryItemBase item = readInventoryItem(reader);
|
||||||
|
if (item != null)
|
||||||
|
items.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.Close();
|
|
||||||
result.Dispose();
|
|
||||||
|
|
||||||
return items;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
database.Reconnect();
|
database.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,29 +176,28 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
database.CheckConnection();
|
database.CheckConnection();
|
||||||
|
|
||||||
MySqlCommand result =
|
using (MySqlCommand result = new MySqlCommand(
|
||||||
new MySqlCommand(
|
"SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid",
|
||||||
"SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid",
|
database.Connection))
|
||||||
database.Connection);
|
{
|
||||||
result.Parameters.AddWithValue("?uuid", user.ToString());
|
result.Parameters.AddWithValue("?uuid", user.ToString());
|
||||||
result.Parameters.AddWithValue("?zero", UUID.Zero.ToString());
|
result.Parameters.AddWithValue("?zero", UUID.Zero.ToString());
|
||||||
MySqlDataReader reader = result.ExecuteReader();
|
|
||||||
|
|
||||||
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
|
using (MySqlDataReader reader = result.ExecuteReader())
|
||||||
while (reader.Read())
|
{
|
||||||
items.Add(readInventoryFolder(reader));
|
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
|
||||||
|
while (reader.Read())
|
||||||
|
items.Add(readInventoryFolder(reader));
|
||||||
|
|
||||||
|
return items;
|
||||||
reader.Close();
|
}
|
||||||
result.Dispose();
|
}
|
||||||
|
|
||||||
return items;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
database.Reconnect();
|
database.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,41 +216,38 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
database.CheckConnection();
|
database.CheckConnection();
|
||||||
|
|
||||||
MySqlCommand result =
|
using (MySqlCommand result = new MySqlCommand(
|
||||||
new MySqlCommand(
|
"SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid",
|
||||||
"SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid",
|
database.Connection))
|
||||||
database.Connection);
|
|
||||||
result.Parameters.AddWithValue("?uuid", user.ToString());
|
|
||||||
result.Parameters.AddWithValue("?zero", UUID.Zero.ToString());
|
|
||||||
|
|
||||||
MySqlDataReader reader = result.ExecuteReader();
|
|
||||||
|
|
||||||
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
|
|
||||||
while (reader.Read())
|
|
||||||
items.Add(readInventoryFolder(reader));
|
|
||||||
|
|
||||||
InventoryFolderBase rootFolder = null;
|
|
||||||
|
|
||||||
// There should only ever be one root folder for a user. However, if there's more
|
|
||||||
// than one we'll simply use the first one rather than failing. It would be even
|
|
||||||
// nicer to print some message to this effect, but this feels like it's too low a
|
|
||||||
// to put such a message out, and it's too minor right now to spare the time to
|
|
||||||
// suitably refactor.
|
|
||||||
if (items.Count > 0)
|
|
||||||
{
|
{
|
||||||
rootFolder = items[0];
|
result.Parameters.AddWithValue("?uuid", user.ToString());
|
||||||
|
result.Parameters.AddWithValue("?zero", UUID.Zero.ToString());
|
||||||
|
|
||||||
|
using (MySqlDataReader reader = result.ExecuteReader())
|
||||||
|
{
|
||||||
|
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
|
||||||
|
while (reader.Read())
|
||||||
|
items.Add(readInventoryFolder(reader));
|
||||||
|
|
||||||
|
InventoryFolderBase rootFolder = null;
|
||||||
|
|
||||||
|
// There should only ever be one root folder for a user. However, if there's more
|
||||||
|
// than one we'll simply use the first one rather than failing. It would be even
|
||||||
|
// nicer to print some message to this effect, but this feels like it's too low a
|
||||||
|
// to put such a message out, and it's too minor right now to spare the time to
|
||||||
|
// suitably refactor.
|
||||||
|
if (items.Count > 0)
|
||||||
|
rootFolder = items[0];
|
||||||
|
|
||||||
|
return rootFolder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.Close();
|
|
||||||
result.Dispose();
|
|
||||||
|
|
||||||
return rootFolder;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
database.Reconnect();
|
database.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -271,27 +267,26 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
database.CheckConnection();
|
database.CheckConnection();
|
||||||
|
|
||||||
MySqlCommand result =
|
using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid",
|
||||||
new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid",
|
database.Connection))
|
||||||
database.Connection);
|
{
|
||||||
result.Parameters.AddWithValue("?uuid", parentID.ToString());
|
result.Parameters.AddWithValue("?uuid", parentID.ToString());
|
||||||
MySqlDataReader reader = result.ExecuteReader();
|
using (MySqlDataReader reader = result.ExecuteReader())
|
||||||
|
{
|
||||||
|
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
|
||||||
|
|
||||||
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
|
while (reader.Read())
|
||||||
|
items.Add(readInventoryFolder(reader));
|
||||||
|
|
||||||
while (reader.Read())
|
return items;
|
||||||
items.Add(readInventoryFolder(reader));
|
}
|
||||||
|
}
|
||||||
reader.Close();
|
|
||||||
result.Dispose();
|
|
||||||
|
|
||||||
return items;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
database.Reconnect();
|
database.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -370,25 +365,25 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
database.CheckConnection();
|
database.CheckConnection();
|
||||||
|
|
||||||
MySqlCommand result =
|
using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection))
|
||||||
new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection);
|
{
|
||||||
result.Parameters.AddWithValue("?uuid", itemID.ToString());
|
result.Parameters.AddWithValue("?uuid", itemID.ToString());
|
||||||
MySqlDataReader reader = result.ExecuteReader();
|
|
||||||
|
|
||||||
InventoryItemBase item = null;
|
using (MySqlDataReader reader = result.ExecuteReader())
|
||||||
if (reader.Read())
|
{
|
||||||
item = readInventoryItem(reader);
|
InventoryItemBase item = null;
|
||||||
|
if (reader.Read())
|
||||||
|
item = readInventoryItem(reader);
|
||||||
|
|
||||||
reader.Close();
|
return item;
|
||||||
result.Dispose();
|
}
|
||||||
|
}
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
database.Reconnect();
|
database.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -413,7 +408,7 @@ namespace OpenSim.Data.MySQL
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -433,24 +428,25 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
database.CheckConnection();
|
database.CheckConnection();
|
||||||
|
|
||||||
MySqlCommand result =
|
using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection))
|
||||||
new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection);
|
{
|
||||||
result.Parameters.AddWithValue("?uuid", folderID.ToString());
|
result.Parameters.AddWithValue("?uuid", folderID.ToString());
|
||||||
MySqlDataReader reader = result.ExecuteReader();
|
|
||||||
|
|
||||||
InventoryFolderBase folder = null;
|
using (MySqlDataReader reader = result.ExecuteReader())
|
||||||
if (reader.Read())
|
{
|
||||||
folder = readInventoryFolder(reader);
|
InventoryFolderBase folder = null;
|
||||||
reader.Close();
|
if (reader.Read())
|
||||||
result.Dispose();
|
folder = readInventoryFolder(reader);
|
||||||
|
|
||||||
return folder;
|
return folder;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
database.Reconnect();
|
database.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -698,69 +694,73 @@ namespace OpenSim.Data.MySQL
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
|
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
|
||||||
Dictionary<UUID, List<InventoryFolderBase>> hashtable
|
Dictionary<UUID, List<InventoryFolderBase>> hashtable = new Dictionary<UUID, List<InventoryFolderBase>>(); ;
|
||||||
= new Dictionary<UUID, List<InventoryFolderBase>>(); ;
|
|
||||||
List<InventoryFolderBase> parentFolder = new List<InventoryFolderBase>();
|
List<InventoryFolderBase> parentFolder = new List<InventoryFolderBase>();
|
||||||
|
bool buildResultsFromHashTable = false;
|
||||||
|
|
||||||
lock (database)
|
lock (database)
|
||||||
{
|
{
|
||||||
MySqlCommand result;
|
|
||||||
MySqlDataReader reader;
|
|
||||||
bool buildResultsFromHashTable = false;
|
|
||||||
|
|
||||||
database.CheckConnection();
|
database.CheckConnection();
|
||||||
|
|
||||||
/* Fetch the parent folder from the database to determine the agent ID, and if
|
/* Fetch the parent folder from the database to determine the agent ID, and if
|
||||||
* we're querying the root of the inventory folder tree */
|
* we're querying the root of the inventory folder tree */
|
||||||
result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid",
|
using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection))
|
||||||
database.Connection);
|
{
|
||||||
result.Parameters.AddWithValue("?uuid", parentID.ToString());
|
result.Parameters.AddWithValue("?uuid", parentID.ToString());
|
||||||
reader = result.ExecuteReader();
|
|
||||||
while (reader.Read()) // Should be at most 1 result
|
using (MySqlDataReader reader = result.ExecuteReader())
|
||||||
parentFolder.Add(readInventoryFolder(reader));
|
{
|
||||||
reader.Close();
|
// Should be at most 1 result
|
||||||
result.Dispose();
|
while (reader.Read())
|
||||||
|
parentFolder.Add(readInventoryFolder(reader));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (parentFolder.Count >= 1) // No result means parent folder does not exist
|
if (parentFolder.Count >= 1) // No result means parent folder does not exist
|
||||||
{
|
{
|
||||||
if (parentFolder[0].ParentID == UUID.Zero) // We are querying the root folder
|
if (parentFolder[0].ParentID == UUID.Zero) // We are querying the root folder
|
||||||
{
|
{
|
||||||
/* Get all of the agent's folders from the database, put them in a list and return it */
|
/* Get all of the agent's folders from the database, put them in a list and return it */
|
||||||
result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid",
|
using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", database.Connection))
|
||||||
database.Connection);
|
|
||||||
result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString());
|
|
||||||
reader = result.ExecuteReader();
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
{
|
||||||
InventoryFolderBase curFolder = readInventoryFolder(reader);
|
result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString());
|
||||||
if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list
|
|
||||||
folders.Add(curFolder);
|
using (MySqlDataReader reader = result.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
InventoryFolderBase curFolder = readInventoryFolder(reader);
|
||||||
|
if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list
|
||||||
|
folders.Add(curFolder);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reader.Close();
|
|
||||||
result.Dispose();
|
|
||||||
} // if we are querying the root folder
|
} // if we are querying the root folder
|
||||||
else // else we are querying a subtree of the inventory folder tree
|
else // else we are querying a subtree of the inventory folder tree
|
||||||
{
|
{
|
||||||
/* Get all of the agent's folders from the database, put them all in a hash table
|
/* Get all of the agent's folders from the database, put them all in a hash table
|
||||||
* indexed by their parent ID */
|
* indexed by their parent ID */
|
||||||
result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid",
|
using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", database.Connection))
|
||||||
database.Connection);
|
|
||||||
result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString());
|
|
||||||
reader = result.ExecuteReader();
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
{
|
||||||
InventoryFolderBase curFolder = readInventoryFolder(reader);
|
result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString());
|
||||||
if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling
|
|
||||||
hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list
|
using (MySqlDataReader reader = result.ExecuteReader())
|
||||||
else // else current folder has no known (yet) siblings
|
|
||||||
{
|
{
|
||||||
List<InventoryFolderBase> siblingList = new List<InventoryFolderBase>();
|
while (reader.Read())
|
||||||
siblingList.Add(curFolder);
|
{
|
||||||
// Current folder has no known (yet) siblings
|
InventoryFolderBase curFolder = readInventoryFolder(reader);
|
||||||
hashtable.Add(curFolder.ParentID, siblingList);
|
if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling
|
||||||
|
hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list
|
||||||
|
else // else current folder has no known (yet) siblings
|
||||||
|
{
|
||||||
|
List<InventoryFolderBase> siblingList = new List<InventoryFolderBase>();
|
||||||
|
siblingList.Add(curFolder);
|
||||||
|
// Current folder has no known (yet) siblings
|
||||||
|
hashtable.Add(curFolder.ParentID, siblingList);
|
||||||
|
}
|
||||||
|
} // while more items to read from the database
|
||||||
}
|
}
|
||||||
} // while more items to read from the database
|
}
|
||||||
reader.Close();
|
|
||||||
result.Dispose();
|
|
||||||
|
|
||||||
// Set flag so we know we need to build the results from the hash table after
|
// Set flag so we know we need to build the results from the hash table after
|
||||||
// we unlock the database
|
// we unlock the database
|
||||||
|
@ -781,12 +781,13 @@ namespace OpenSim.Data.MySQL
|
||||||
folders.AddRange(hashtable[folders[i].ID]);
|
folders.AddRange(hashtable[folders[i].ID]);
|
||||||
}
|
}
|
||||||
} // lock (database)
|
} // lock (database)
|
||||||
|
|
||||||
return folders;
|
return folders;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
database.Reconnect();
|
database.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -801,19 +802,18 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
database.CheckConnection();
|
database.CheckConnection();
|
||||||
|
|
||||||
MySqlCommand cmd =
|
using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection))
|
||||||
new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection);
|
|
||||||
cmd.Parameters.AddWithValue("?uuid", folderID.ToString());
|
|
||||||
|
|
||||||
lock (database)
|
|
||||||
{
|
{
|
||||||
cmd.ExecuteNonQuery();
|
cmd.Parameters.AddWithValue("?uuid", folderID.ToString());
|
||||||
|
|
||||||
|
lock (database)
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
database.Reconnect();
|
database.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -827,13 +827,12 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
database.CheckConnection();
|
database.CheckConnection();
|
||||||
|
|
||||||
MySqlCommand cmd =
|
using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection))
|
||||||
new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection);
|
|
||||||
cmd.Parameters.AddWithValue("?uuid", folderID.ToString());
|
|
||||||
|
|
||||||
lock (database)
|
|
||||||
{
|
{
|
||||||
cmd.ExecuteNonQuery();
|
cmd.Parameters.AddWithValue("?uuid", folderID.ToString());
|
||||||
|
|
||||||
|
lock (database)
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
|
@ -865,40 +864,38 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
public List<InventoryItemBase> fetchActiveGestures(UUID avatarID)
|
public List<InventoryItemBase> fetchActiveGestures(UUID avatarID)
|
||||||
{
|
{
|
||||||
MySqlDataReader result = null;
|
|
||||||
MySqlCommand sqlCmd = null;
|
|
||||||
lock (database)
|
lock (database)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
database.CheckConnection();
|
database.CheckConnection();
|
||||||
sqlCmd = new MySqlCommand(
|
|
||||||
"SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1",
|
|
||||||
database.Connection);
|
|
||||||
sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString());
|
|
||||||
sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture);
|
|
||||||
result = sqlCmd.ExecuteReader();
|
|
||||||
|
|
||||||
List<InventoryItemBase> list = new List<InventoryItemBase>();
|
using (MySqlCommand sqlCmd = new MySqlCommand(
|
||||||
while (result.Read())
|
"SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1",
|
||||||
|
database.Connection))
|
||||||
{
|
{
|
||||||
InventoryItemBase item = readInventoryItem(result);
|
sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString());
|
||||||
if (item != null)
|
sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture);
|
||||||
list.Add(item);
|
|
||||||
|
using (MySqlDataReader result = sqlCmd.ExecuteReader())
|
||||||
|
{
|
||||||
|
List<InventoryItemBase> list = new List<InventoryItemBase>();
|
||||||
|
while (result.Read())
|
||||||
|
{
|
||||||
|
InventoryItemBase item = readInventoryItem(result);
|
||||||
|
if (item != null)
|
||||||
|
list.Add(item);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
database.Reconnect();
|
database.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (result != null) result.Close();
|
|
||||||
if (sqlCmd != null) sqlCmd.Dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,6 +268,8 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
public void RemoveObject(UUID obj, UUID regionUUID)
|
public void RemoveObject(UUID obj, UUID regionUUID)
|
||||||
{
|
{
|
||||||
|
List<UUID> uuids = new List<UUID>();
|
||||||
|
|
||||||
// Formerly, this used to check the region UUID.
|
// Formerly, this used to check the region UUID.
|
||||||
// That makes no sense, as we remove the contents of a prim
|
// That makes no sense, as we remove the contents of a prim
|
||||||
// unconditionally, but the prim dependent on the region ID.
|
// unconditionally, but the prim dependent on the region ID.
|
||||||
|
@ -278,43 +280,31 @@ namespace OpenSim.Data.MySQL
|
||||||
//
|
//
|
||||||
lock (m_Connection)
|
lock (m_Connection)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = m_Connection.CreateCommand();
|
using (MySqlCommand cmd = m_Connection.CreateCommand())
|
||||||
|
|
||||||
cmd.CommandText = "select UUID from prims where "+
|
|
||||||
"SceneGroupID= ?UUID";
|
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("UUID", obj.ToString());
|
|
||||||
|
|
||||||
List<UUID> uuids = new List<UUID>();
|
|
||||||
|
|
||||||
IDataReader reader = ExecuteReader(cmd);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
while (reader.Read())
|
cmd.CommandText = "select UUID from prims where SceneGroupID= ?UUID";
|
||||||
|
cmd.Parameters.AddWithValue("UUID", obj.ToString());
|
||||||
|
|
||||||
|
using (IDataReader reader = ExecuteReader(cmd))
|
||||||
{
|
{
|
||||||
uuids.Add(new UUID(reader["UUID"].ToString()));
|
while (reader.Read())
|
||||||
|
uuids.Add(new UUID(reader["UUID"].ToString()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
reader.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete the main prims
|
// delete the main prims
|
||||||
cmd.CommandText = "delete from prims where SceneGroupID= ?UUID";
|
cmd.CommandText = "delete from prims where SceneGroupID= ?UUID";
|
||||||
ExecuteNonQuery(cmd);
|
ExecuteNonQuery(cmd);
|
||||||
cmd.Dispose();
|
|
||||||
|
|
||||||
// there is no way this should be < 1 unless there is
|
|
||||||
// a very corrupt database, but in that case be extra
|
|
||||||
// safe anyway.
|
|
||||||
if (uuids.Count > 0)
|
|
||||||
{
|
|
||||||
RemoveShapes(uuids);
|
|
||||||
RemoveItems(uuids);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// there is no way this should be < 1 unless there is
|
||||||
|
// a very corrupt database, but in that case be extra
|
||||||
|
// safe anyway.
|
||||||
|
if (uuids.Count > 0)
|
||||||
|
{
|
||||||
|
RemoveShapes(uuids);
|
||||||
|
RemoveItems(uuids);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -326,19 +316,16 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
lock (m_Connection)
|
lock (m_Connection)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = m_Connection.CreateCommand();
|
using (MySqlCommand cmd = m_Connection.CreateCommand())
|
||||||
|
{
|
||||||
|
cmd.CommandText = "delete from primitems where PrimID = ?PrimID";
|
||||||
|
cmd.Parameters.AddWithValue("PrimID", uuid.ToString());
|
||||||
|
|
||||||
cmd.CommandText = "delete from primitems where " +
|
ExecuteNonQuery(cmd);
|
||||||
"PrimID = ?PrimID";
|
}
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("PrimID", uuid.ToString());
|
|
||||||
|
|
||||||
ExecuteNonQuery(cmd);
|
|
||||||
cmd.Dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove all persisted shapes for a list of prims
|
/// Remove all persisted shapes for a list of prims
|
||||||
/// The caller must acquire the necessrary synchronization locks
|
/// The caller must acquire the necessrary synchronization locks
|
||||||
|
@ -349,28 +336,27 @@ namespace OpenSim.Data.MySQL
|
||||||
lock (m_Connection)
|
lock (m_Connection)
|
||||||
{
|
{
|
||||||
string sql = "delete from primshapes where ";
|
string sql = "delete from primshapes where ";
|
||||||
MySqlCommand cmd = m_Connection.CreateCommand();
|
|
||||||
|
using (MySqlCommand cmd = m_Connection.CreateCommand())
|
||||||
for (int i = 0; i < uuids.Count; i++)
|
|
||||||
{
|
{
|
||||||
if ((i + 1) == uuids.Count)
|
for (int i = 0; i < uuids.Count; i++)
|
||||||
{// end of the list
|
|
||||||
sql += "(UUID = ?UUID" + i + ")";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
sql += "(UUID = ?UUID" + i + ") or ";
|
if ((i + 1) == uuids.Count)
|
||||||
|
{// end of the list
|
||||||
|
sql += "(UUID = ?UUID" + i + ")";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sql += "(UUID = ?UUID" + i + ") or ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
cmd.CommandText = sql;
|
||||||
cmd.CommandText = sql;
|
|
||||||
|
|
||||||
for (int i = 0; i < uuids.Count; i++)
|
for (int i = 0; i < uuids.Count; i++)
|
||||||
{
|
cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString());
|
||||||
cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
ExecuteNonQuery(cmd);
|
ExecuteNonQuery(cmd);
|
||||||
cmd.Dispose();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,28 +370,28 @@ namespace OpenSim.Data.MySQL
|
||||||
lock (m_Connection)
|
lock (m_Connection)
|
||||||
{
|
{
|
||||||
string sql = "delete from primitems where ";
|
string sql = "delete from primitems where ";
|
||||||
MySqlCommand cmd = m_Connection.CreateCommand();
|
|
||||||
|
using (MySqlCommand cmd = m_Connection.CreateCommand())
|
||||||
for (int i = 0; i < uuids.Count; i++)
|
|
||||||
{
|
{
|
||||||
if ((i + 1) == uuids.Count)
|
for (int i = 0; i < uuids.Count; i++)
|
||||||
{// end of the list
|
|
||||||
sql += "(PrimID = ?PrimID" + i + ")";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
sql += "(PrimID = ?PrimID" + i + ") or ";
|
if ((i + 1) == uuids.Count)
|
||||||
|
{
|
||||||
|
// end of the list
|
||||||
|
sql += "(PrimID = ?PrimID" + i + ")";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sql += "(PrimID = ?PrimID" + i + ") or ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
cmd.CommandText = sql;
|
||||||
cmd.CommandText = sql;
|
|
||||||
|
|
||||||
for (int i = 0; i < uuids.Count; i++)
|
for (int i = 0; i < uuids.Count; i++)
|
||||||
{
|
cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString());
|
||||||
cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
ExecuteNonQuery(cmd);
|
ExecuteNonQuery(cmd);
|
||||||
cmd.Dispose();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,77 +404,71 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
lock (m_Connection)
|
lock (m_Connection)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = m_Connection.CreateCommand();
|
using (MySqlCommand cmd = m_Connection.CreateCommand())
|
||||||
|
{
|
||||||
cmd.CommandText = "select *, " +
|
cmd.CommandText = "select *, " +
|
||||||
"case when prims.UUID = SceneGroupID " +
|
"case when prims.UUID = SceneGroupID " +
|
||||||
"then 0 else 1 end as sort from prims " +
|
"then 0 else 1 end as sort from prims " +
|
||||||
"left join primshapes on prims.UUID = primshapes.UUID "+
|
"left join primshapes on prims.UUID = primshapes.UUID " +
|
||||||
"where RegionUUID = ?RegionUUID " +
|
"where RegionUUID = ?RegionUUID " +
|
||||||
"order by SceneGroupID asc, sort asc, LinkNumber asc";
|
"order by SceneGroupID asc, sort asc, LinkNumber asc";
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString());
|
|
||||||
|
|
||||||
IDataReader reader = ExecuteReader(cmd);
|
cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString());
|
||||||
|
|
||||||
try
|
using (IDataReader reader = ExecuteReader(cmd))
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
{
|
||||||
SceneObjectPart prim = BuildPrim(reader);
|
while (reader.Read())
|
||||||
if (reader["Shape"] is DBNull)
|
|
||||||
prim.Shape = PrimitiveBaseShape.Default;
|
|
||||||
else
|
|
||||||
prim.Shape = BuildShape(reader);
|
|
||||||
|
|
||||||
prims[prim.UUID] = prim;
|
|
||||||
|
|
||||||
UUID groupID = new UUID(reader["SceneGroupID"].ToString());
|
|
||||||
|
|
||||||
if (groupID != lastGroupID) // New SOG
|
|
||||||
{
|
{
|
||||||
if (grp != null)
|
SceneObjectPart prim = BuildPrim(reader);
|
||||||
objects[grp.UUID] = grp;
|
if (reader["Shape"] is DBNull)
|
||||||
|
prim.Shape = PrimitiveBaseShape.Default;
|
||||||
|
else
|
||||||
|
prim.Shape = BuildShape(reader);
|
||||||
|
|
||||||
lastGroupID = groupID;
|
prims[prim.UUID] = prim;
|
||||||
|
|
||||||
// There sometimes exist OpenSim bugs that 'orphan groups' so that none of the prims are
|
UUID groupID = new UUID(reader["SceneGroupID"].ToString());
|
||||||
// recorded as the root prim (for which the UUID must equal the persisted group UUID). In
|
|
||||||
// this case, force the UUID to be the same as the group UUID so that at least these can be
|
if (groupID != lastGroupID) // New SOG
|
||||||
// deleted (we need to change the UUID so that any other prims in the linkset can also be
|
|
||||||
// deleted).
|
|
||||||
if (prim.UUID != groupID && groupID != UUID.Zero)
|
|
||||||
{
|
{
|
||||||
m_log.WarnFormat(
|
if (grp != null)
|
||||||
"[REGION DB]: Found root prim {0} {1} at {2} where group was actually {3}. Forcing UUID to group UUID",
|
objects[grp.UUID] = grp;
|
||||||
prim.Name, prim.UUID, prim.GroupPosition, groupID);
|
|
||||||
|
lastGroupID = groupID;
|
||||||
prim.UUID = groupID;
|
|
||||||
|
// There sometimes exist OpenSim bugs that 'orphan groups' so that none of the prims are
|
||||||
|
// recorded as the root prim (for which the UUID must equal the persisted group UUID). In
|
||||||
|
// this case, force the UUID to be the same as the group UUID so that at least these can be
|
||||||
|
// deleted (we need to change the UUID so that any other prims in the linkset can also be
|
||||||
|
// deleted).
|
||||||
|
if (prim.UUID != groupID && groupID != UUID.Zero)
|
||||||
|
{
|
||||||
|
m_log.WarnFormat(
|
||||||
|
"[REGION DB]: Found root prim {0} {1} at {2} where group was actually {3}. Forcing UUID to group UUID",
|
||||||
|
prim.Name, prim.UUID, prim.GroupPosition, groupID);
|
||||||
|
|
||||||
|
prim.UUID = groupID;
|
||||||
|
}
|
||||||
|
|
||||||
|
grp = new SceneObjectGroup(prim);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Black magic to preserve link numbers
|
||||||
|
//
|
||||||
|
int link = prim.LinkNum;
|
||||||
|
|
||||||
grp = new SceneObjectGroup(prim);
|
grp.AddPart(prim);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Black magic to preserve link numbers
|
|
||||||
//
|
|
||||||
int link = prim.LinkNum;
|
|
||||||
|
|
||||||
grp.AddPart(prim);
|
if (link != 0)
|
||||||
|
prim.LinkNum = link;
|
||||||
if (link != 0)
|
}
|
||||||
prim.LinkNum = link;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
reader.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (grp != null)
|
if (grp != null)
|
||||||
objects[grp.UUID] = grp;
|
objects[grp.UUID] = grp;
|
||||||
cmd.Dispose();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instead of attempting to LoadItems on every prim,
|
// Instead of attempting to LoadItems on every prim,
|
||||||
|
@ -498,34 +478,29 @@ namespace OpenSim.Data.MySQL
|
||||||
List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>();
|
List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>();
|
||||||
lock (m_Connection)
|
lock (m_Connection)
|
||||||
{
|
{
|
||||||
MySqlCommand itemCmd = m_Connection.CreateCommand();
|
using (MySqlCommand itemCmd = m_Connection.CreateCommand())
|
||||||
itemCmd.CommandText = "select distinct primID from primitems";
|
|
||||||
IDataReader itemReader = ExecuteReader(itemCmd);
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
while (itemReader.Read())
|
itemCmd.CommandText = "select distinct primID from primitems";
|
||||||
|
using (IDataReader itemReader = ExecuteReader(itemCmd))
|
||||||
{
|
{
|
||||||
if (!(itemReader["primID"] is DBNull))
|
while (itemReader.Read())
|
||||||
{
|
{
|
||||||
UUID primID = new UUID(itemReader["primID"].ToString());
|
if (!(itemReader["primID"] is DBNull))
|
||||||
if (prims.ContainsKey(primID))
|
|
||||||
{
|
{
|
||||||
primsWithInventory.Add(prims[primID]);
|
UUID primID = new UUID(itemReader["primID"].ToString());
|
||||||
|
if (prims.ContainsKey(primID))
|
||||||
|
{
|
||||||
|
primsWithInventory.Add(prims[primID]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
itemReader.Close();
|
|
||||||
}
|
|
||||||
itemCmd.Dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (SceneObjectPart prim in primsWithInventory)
|
foreach (SceneObjectPart prim in primsWithInventory)
|
||||||
{
|
|
||||||
LoadItems(prim);
|
LoadItems(prim);
|
||||||
}
|
|
||||||
m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count);
|
m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count);
|
||||||
return new List<SceneObjectGroup>(objects.Values);
|
return new List<SceneObjectGroup>(objects.Values);
|
||||||
}
|
}
|
||||||
|
@ -538,34 +513,25 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
lock (m_Connection)
|
lock (m_Connection)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = m_Connection.CreateCommand();
|
List<TaskInventoryItem> inventory = new List<TaskInventoryItem>();
|
||||||
|
|
||||||
cmd.CommandText = "select * from primitems where "+
|
using (MySqlCommand cmd = m_Connection.CreateCommand())
|
||||||
"PrimID = ?PrimID";
|
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString());
|
|
||||||
|
|
||||||
IDataReader reader = ExecuteReader(cmd);
|
|
||||||
List<TaskInventoryItem> inventory =
|
|
||||||
new List<TaskInventoryItem>();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
while (reader.Read())
|
cmd.CommandText = "select * from primitems where PrimID = ?PrimID";
|
||||||
{
|
cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString());
|
||||||
TaskInventoryItem item = BuildItem(reader);
|
|
||||||
|
|
||||||
item.ParentID = prim.UUID; // Values in database are
|
using (IDataReader reader = ExecuteReader(cmd))
|
||||||
// often wrong
|
{
|
||||||
inventory.Add(item);
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
TaskInventoryItem item = BuildItem(reader);
|
||||||
|
|
||||||
|
item.ParentID = prim.UUID; // Values in database are often wrong
|
||||||
|
inventory.Add(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
reader.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd.Dispose();
|
|
||||||
prim.Inventory.RestoreInventoryItems(inventory);
|
prim.Inventory.RestoreInventoryItems(inventory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -576,23 +542,21 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
lock (m_Connection)
|
lock (m_Connection)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = m_Connection.CreateCommand();
|
using (MySqlCommand cmd = m_Connection.CreateCommand())
|
||||||
|
{
|
||||||
|
cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID";
|
||||||
|
cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
|
||||||
|
|
||||||
cmd.CommandText = "delete from terrain where " +
|
ExecuteNonQuery(cmd);
|
||||||
"RegionUUID = ?RegionUUID";
|
|
||||||
cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
|
|
||||||
|
|
||||||
ExecuteNonQuery(cmd);
|
cmd.CommandText = "insert into terrain (RegionUUID, " +
|
||||||
|
|
||||||
cmd.CommandText = "insert into terrain (RegionUUID, " +
|
|
||||||
"Revision, Heightfield) values (?RegionUUID, " +
|
"Revision, Heightfield) values (?RegionUUID, " +
|
||||||
"1, ?Heightfield)";
|
"1, ?Heightfield)";
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("Heightfield",
|
cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter));
|
||||||
SerializeTerrain(ter));
|
|
||||||
|
ExecuteNonQuery(cmd);
|
||||||
ExecuteNonQuery(cmd);
|
}
|
||||||
cmd.Dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,42 +566,40 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
lock (m_Connection)
|
lock (m_Connection)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = m_Connection.CreateCommand();
|
using (MySqlCommand cmd = m_Connection.CreateCommand())
|
||||||
cmd.CommandText = "select RegionUUID, Revision, Heightfield " +
|
|
||||||
"from terrain where RegionUUID = ?RegionUUID "+
|
|
||||||
"order by Revision desc limit 1";
|
|
||||||
cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
|
|
||||||
|
|
||||||
IDataReader reader = ExecuteReader(cmd);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
while (reader.Read())
|
cmd.CommandText = "select RegionUUID, Revision, Heightfield " +
|
||||||
|
"from terrain where RegionUUID = ?RegionUUID " +
|
||||||
|
"order by Revision desc limit 1";
|
||||||
|
cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
|
||||||
|
|
||||||
|
using (IDataReader reader = ExecuteReader(cmd))
|
||||||
{
|
{
|
||||||
terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize];
|
while (reader.Read())
|
||||||
terrain.Initialize();
|
|
||||||
|
|
||||||
MemoryStream mstr = new MemoryStream((byte[]) reader["Heightfield"]);
|
|
||||||
int rev = 0;
|
|
||||||
|
|
||||||
BinaryReader br = new BinaryReader(mstr);
|
|
||||||
for (int x = 0; x < (int)Constants.RegionSize; x++)
|
|
||||||
{
|
{
|
||||||
for (int y = 0; y < (int)Constants.RegionSize; y++)
|
int rev = Convert.ToInt32(reader["Revision"]);
|
||||||
|
|
||||||
|
terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize];
|
||||||
|
terrain.Initialize();
|
||||||
|
|
||||||
|
using (MemoryStream mstr = new MemoryStream((byte[])reader["Heightfield"]))
|
||||||
{
|
{
|
||||||
terrain[x, y] = br.ReadDouble();
|
using (BinaryReader br = new BinaryReader(mstr))
|
||||||
|
{
|
||||||
|
for (int x = 0; x < (int)Constants.RegionSize; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < (int)Constants.RegionSize; y++)
|
||||||
|
{
|
||||||
|
terrain[x, y] = br.ReadDouble();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_log.InfoFormat("[REGION DB]: Loaded terrain revision r{0}", rev);
|
||||||
}
|
}
|
||||||
rev = Convert.ToInt32(reader["Revision"]);
|
|
||||||
}
|
}
|
||||||
m_log.InfoFormat("[REGION DB]: Loaded terrain " +
|
|
||||||
"revision r{0}", rev);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
reader.Close();
|
|
||||||
}
|
|
||||||
cmd.Dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return terrain;
|
return terrain;
|
||||||
|
@ -647,14 +609,13 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
lock (m_Connection)
|
lock (m_Connection)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = m_Connection.CreateCommand();
|
using (MySqlCommand cmd = m_Connection.CreateCommand())
|
||||||
|
{
|
||||||
|
cmd.CommandText = "delete from land where UUID = ?UUID";
|
||||||
|
cmd.Parameters.AddWithValue("UUID", globalID.ToString());
|
||||||
|
|
||||||
cmd.CommandText = "delete from land where UUID = ?UUID";
|
ExecuteNonQuery(cmd);
|
||||||
|
}
|
||||||
cmd.Parameters.AddWithValue("UUID", globalID.ToString());
|
|
||||||
|
|
||||||
ExecuteNonQuery(cmd);
|
|
||||||
cmd.Dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -662,9 +623,9 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
lock (m_Connection)
|
lock (m_Connection)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = m_Connection.CreateCommand();
|
using (MySqlCommand cmd = m_Connection.CreateCommand())
|
||||||
|
{
|
||||||
cmd.CommandText = "replace into land (UUID, RegionUUID, " +
|
cmd.CommandText = "replace into land (UUID, RegionUUID, " +
|
||||||
"LocalLandID, Bitmap, Name, Description, " +
|
"LocalLandID, Bitmap, Name, Description, " +
|
||||||
"OwnerUUID, IsGroupOwned, Area, AuctionID, " +
|
"OwnerUUID, IsGroupOwned, Area, AuctionID, " +
|
||||||
"Category, ClaimDate, ClaimPrice, GroupUUID, " +
|
"Category, ClaimDate, ClaimPrice, GroupUUID, " +
|
||||||
|
@ -685,28 +646,26 @@ namespace OpenSim.Data.MySQL
|
||||||
"?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " +
|
"?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " +
|
||||||
"?AuthbuyerID, ?OtherCleanTime, ?Dwell)";
|
"?AuthbuyerID, ?OtherCleanTime, ?Dwell)";
|
||||||
|
|
||||||
FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID);
|
FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID);
|
||||||
|
|
||||||
ExecuteNonQuery(cmd);
|
|
||||||
|
|
||||||
cmd.CommandText = "delete from landaccesslist where " +
|
|
||||||
"LandUUID = ?UUID";
|
|
||||||
|
|
||||||
ExecuteNonQuery(cmd);
|
|
||||||
|
|
||||||
cmd.Parameters.Clear();
|
|
||||||
cmd.CommandText = "insert into landaccesslist (LandUUID, " +
|
|
||||||
"AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " +
|
|
||||||
"?Flags)";
|
|
||||||
|
|
||||||
foreach (ParcelManager.ParcelAccessEntry entry in
|
|
||||||
parcel.LandData.ParcelAccessList)
|
|
||||||
{
|
|
||||||
FillLandAccessCommand(cmd, entry, parcel.LandData.GlobalID);
|
|
||||||
ExecuteNonQuery(cmd);
|
ExecuteNonQuery(cmd);
|
||||||
|
|
||||||
|
cmd.CommandText = "delete from landaccesslist where LandUUID = ?UUID";
|
||||||
|
|
||||||
|
ExecuteNonQuery(cmd);
|
||||||
|
|
||||||
cmd.Parameters.Clear();
|
cmd.Parameters.Clear();
|
||||||
|
cmd.CommandText = "insert into landaccesslist (LandUUID, " +
|
||||||
|
"AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " +
|
||||||
|
"?Flags)";
|
||||||
|
|
||||||
|
foreach (ParcelManager.ParcelAccessEntry entry in parcel.LandData.ParcelAccessList)
|
||||||
|
{
|
||||||
|
FillLandAccessCommand(cmd, entry, parcel.LandData.GlobalID);
|
||||||
|
ExecuteNonQuery(cmd);
|
||||||
|
cmd.Parameters.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cmd.Dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,35 +675,28 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
lock (m_Connection)
|
lock (m_Connection)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = m_Connection.CreateCommand();
|
using (MySqlCommand cmd = m_Connection.CreateCommand())
|
||||||
|
|
||||||
cmd.CommandText = "select * from regionsettings where " +
|
|
||||||
"regionUUID = ?RegionUUID";
|
|
||||||
cmd.Parameters.AddWithValue("regionUUID", regionUUID);
|
|
||||||
|
|
||||||
IDataReader reader = ExecuteReader(cmd);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
if (reader.Read())
|
cmd.CommandText = "select * from regionsettings where regionUUID = ?RegionUUID";
|
||||||
{
|
cmd.Parameters.AddWithValue("regionUUID", regionUUID);
|
||||||
rs = BuildRegionSettings(reader);
|
|
||||||
rs.OnSave += StoreRegionSettings;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rs = new RegionSettings();
|
|
||||||
rs.RegionUUID = regionUUID;
|
|
||||||
rs.OnSave += StoreRegionSettings;
|
|
||||||
|
|
||||||
StoreRegionSettings(rs);
|
using (IDataReader reader = ExecuteReader(cmd))
|
||||||
|
{
|
||||||
|
if (reader.Read())
|
||||||
|
{
|
||||||
|
rs = BuildRegionSettings(reader);
|
||||||
|
rs.OnSave += StoreRegionSettings;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rs = new RegionSettings();
|
||||||
|
rs.RegionUUID = regionUUID;
|
||||||
|
rs.OnSave += StoreRegionSettings;
|
||||||
|
|
||||||
|
StoreRegionSettings(rs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
reader.Close();
|
|
||||||
}
|
|
||||||
cmd.Dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rs;
|
return rs;
|
||||||
|
@ -754,9 +706,9 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
lock (m_Connection)
|
lock (m_Connection)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = m_Connection.CreateCommand();
|
using (MySqlCommand cmd = m_Connection.CreateCommand())
|
||||||
|
{
|
||||||
cmd.CommandText = "replace into regionsettings (regionUUID, " +
|
cmd.CommandText = "replace into regionsettings (regionUUID, " +
|
||||||
"block_terraform, block_fly, allow_damage, " +
|
"block_terraform, block_fly, allow_damage, " +
|
||||||
"restrict_pushing, allow_land_resell, " +
|
"restrict_pushing, allow_land_resell, " +
|
||||||
"allow_land_join_divide, block_show_in_search, " +
|
"allow_land_join_divide, block_show_in_search, " +
|
||||||
|
@ -766,8 +718,8 @@ namespace OpenSim.Data.MySQL
|
||||||
"terrain_texture_2, terrain_texture_3, " +
|
"terrain_texture_2, terrain_texture_3, " +
|
||||||
"terrain_texture_4, elevation_1_nw, " +
|
"terrain_texture_4, elevation_1_nw, " +
|
||||||
"elevation_2_nw, elevation_1_ne, " +
|
"elevation_2_nw, elevation_1_ne, " +
|
||||||
"elevation_2_ne, elevation_1_se, "+
|
"elevation_2_ne, elevation_1_se, " +
|
||||||
"elevation_2_se, elevation_1_sw, "+
|
"elevation_2_se, elevation_1_sw, " +
|
||||||
"elevation_2_sw, water_height, " +
|
"elevation_2_sw, water_height, " +
|
||||||
"terrain_raise_limit, terrain_lower_limit, " +
|
"terrain_raise_limit, terrain_lower_limit, " +
|
||||||
"use_estate_sun, fixed_sun, sun_position, " +
|
"use_estate_sun, fixed_sun, sun_position, " +
|
||||||
|
@ -789,11 +741,10 @@ namespace OpenSim.Data.MySQL
|
||||||
"?SunVectorX, ?SunVectorY, ?SunVectorZ, " +
|
"?SunVectorX, ?SunVectorY, ?SunVectorZ, " +
|
||||||
"?LoadedCreationDateTime, ?LoadedCreationID)";
|
"?LoadedCreationDateTime, ?LoadedCreationID)";
|
||||||
|
|
||||||
FillRegionSettingsCommand(cmd, rs);
|
FillRegionSettingsCommand(cmd, rs);
|
||||||
|
|
||||||
ExecuteNonQuery(cmd);
|
|
||||||
cmd.Dispose();
|
|
||||||
|
|
||||||
|
ExecuteNonQuery(cmd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -803,52 +754,38 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
lock (m_Connection)
|
lock (m_Connection)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = m_Connection.CreateCommand();
|
using (MySqlCommand cmd = m_Connection.CreateCommand())
|
||||||
|
|
||||||
cmd.CommandText = "select * from land where " +
|
|
||||||
"RegionUUID = ?RegionUUID";
|
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString());
|
|
||||||
|
|
||||||
IDataReader reader = ExecuteReader(cmd);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
while (reader.Read())
|
cmd.CommandText = "select * from land where RegionUUID = ?RegionUUID";
|
||||||
{
|
cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString());
|
||||||
LandData newLand = BuildLandData(reader);
|
|
||||||
landData.Add(newLand);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
reader.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (LandData land in landData)
|
using (IDataReader reader = ExecuteReader(cmd))
|
||||||
{
|
|
||||||
cmd.Parameters.Clear();
|
|
||||||
|
|
||||||
cmd.CommandText = "select * from landaccesslist " +
|
|
||||||
"where LandUUID = ?LandUUID";
|
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString());
|
|
||||||
|
|
||||||
reader = ExecuteReader(cmd);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
land.ParcelAccessList.Add(BuildLandAccessData(reader));
|
LandData newLand = BuildLandData(reader);
|
||||||
|
landData.Add(newLand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
}
|
||||||
|
|
||||||
|
using (MySqlCommand cmd = m_Connection.CreateCommand())
|
||||||
|
{
|
||||||
|
foreach (LandData land in landData)
|
||||||
{
|
{
|
||||||
reader.Close();
|
cmd.Parameters.Clear();
|
||||||
|
cmd.CommandText = "select * from landaccesslist where LandUUID = ?LandUUID";
|
||||||
|
cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString());
|
||||||
|
|
||||||
|
using (IDataReader reader = ExecuteReader(cmd))
|
||||||
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
land.ParcelAccessList.Add(BuildLandAccessData(reader));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmd.Dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return landData;
|
return landData;
|
||||||
|
|
|
@ -134,18 +134,16 @@ namespace OpenSim.Data.MySQL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void GetWaitTimeout()
|
protected void GetWaitTimeout()
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon);
|
using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon))
|
||||||
|
|
||||||
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
|
||||||
{
|
{
|
||||||
if (dbReader.Read())
|
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||||
{
|
{
|
||||||
m_waitTimeout
|
if (dbReader.Read())
|
||||||
= Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway;
|
{
|
||||||
|
m_waitTimeout
|
||||||
|
= Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dbReader.Close();
|
|
||||||
cmd.Dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lastConnectionUse = DateTime.Now.Ticks;
|
m_lastConnectionUse = DateTime.Now.Ticks;
|
||||||
|
@ -303,31 +301,31 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
CheckConnection();
|
CheckConnection();
|
||||||
|
|
||||||
MySqlCommand tablesCmd =
|
using (MySqlCommand tablesCmd = new MySqlCommand(
|
||||||
new MySqlCommand(
|
"SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname",
|
||||||
"SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname",
|
dbcon))
|
||||||
dbcon);
|
|
||||||
tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database);
|
|
||||||
|
|
||||||
using (MySqlDataReader tables = tablesCmd.ExecuteReader())
|
|
||||||
{
|
{
|
||||||
while (tables.Read())
|
tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database);
|
||||||
|
|
||||||
|
using (MySqlDataReader tables = tablesCmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
try
|
while (tables.Read())
|
||||||
{
|
{
|
||||||
string tableName = (string) tables["TABLE_NAME"];
|
try
|
||||||
string comment = (string) tables["TABLE_COMMENT"];
|
|
||||||
if (tableList.ContainsKey(tableName))
|
|
||||||
{
|
{
|
||||||
tableList[tableName] = comment;
|
string tableName = (string)tables["TABLE_NAME"];
|
||||||
|
string comment = (string)tables["TABLE_COMMENT"];
|
||||||
|
if (tableList.ContainsKey(tableName))
|
||||||
|
{
|
||||||
|
tableList[tableName] = comment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.Error(e.Message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.ToString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
tables.Close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -346,19 +344,19 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
CheckConnection(); // Not sure if this one is necessary
|
CheckConnection(); // Not sure if this one is necessary
|
||||||
|
|
||||||
MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand();
|
MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand();
|
||||||
dbcommand.CommandText = sql;
|
dbcommand.CommandText = sql;
|
||||||
foreach (KeyValuePair<string, object> param in parameters)
|
foreach (KeyValuePair<string, object> param in parameters)
|
||||||
{
|
{
|
||||||
dbcommand.Parameters.AddWithValue(param.Key, param.Value);
|
dbcommand.Parameters.AddWithValue(param.Key, param.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (IDbCommand) dbcommand;
|
return (IDbCommand)dbcommand;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// Return null if it fails.
|
// Return null if it fails.
|
||||||
m_log.Error("Failed during Query generation: " + e.ToString());
|
m_log.Error("Failed during Query generation: " + e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -694,8 +692,6 @@ namespace OpenSim.Data.MySQL
|
||||||
ret.Add(attachpoint, item);
|
ret.Add(attachpoint, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Close();
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,12 +56,13 @@ namespace OpenSim.Data.MySQL
|
||||||
if (scopeID != UUID.Zero)
|
if (scopeID != UUID.Zero)
|
||||||
command += " and ScopeID = ?scopeID";
|
command += " and ScopeID = ?scopeID";
|
||||||
|
|
||||||
MySqlCommand cmd = new MySqlCommand(command);
|
using (MySqlCommand cmd = new MySqlCommand(command))
|
||||||
|
{
|
||||||
|
cmd.Parameters.AddWithValue("?regionName", regionName);
|
||||||
|
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("?regionName", regionName);
|
return RunCommand(cmd);
|
||||||
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
}
|
||||||
|
|
||||||
return RunCommand(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RegionData Get(int posX, int posY, UUID scopeID)
|
public RegionData Get(int posX, int posY, UUID scopeID)
|
||||||
|
@ -70,17 +71,18 @@ namespace OpenSim.Data.MySQL
|
||||||
if (scopeID != UUID.Zero)
|
if (scopeID != UUID.Zero)
|
||||||
command += " and ScopeID = ?scopeID";
|
command += " and ScopeID = ?scopeID";
|
||||||
|
|
||||||
MySqlCommand cmd = new MySqlCommand(command);
|
using (MySqlCommand cmd = new MySqlCommand(command))
|
||||||
|
{
|
||||||
|
cmd.Parameters.AddWithValue("?posX", posX.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?posY", posY.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("?posX", posX.ToString());
|
List<RegionData> ret = RunCommand(cmd);
|
||||||
cmd.Parameters.AddWithValue("?posY", posY.ToString());
|
if (ret.Count == 0)
|
||||||
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
return null;
|
||||||
|
|
||||||
List<RegionData> ret = RunCommand(cmd);
|
return ret[0];
|
||||||
if (ret.Count == 0)
|
}
|
||||||
return null;
|
|
||||||
|
|
||||||
return ret[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RegionData Get(UUID regionID, UUID scopeID)
|
public RegionData Get(UUID regionID, UUID scopeID)
|
||||||
|
@ -89,16 +91,17 @@ namespace OpenSim.Data.MySQL
|
||||||
if (scopeID != UUID.Zero)
|
if (scopeID != UUID.Zero)
|
||||||
command += " and ScopeID = ?scopeID";
|
command += " and ScopeID = ?scopeID";
|
||||||
|
|
||||||
MySqlCommand cmd = new MySqlCommand(command);
|
using (MySqlCommand cmd = new MySqlCommand(command))
|
||||||
|
{
|
||||||
|
cmd.Parameters.AddWithValue("?regionID", regionID.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("?regionID", regionID.ToString());
|
List<RegionData> ret = RunCommand(cmd);
|
||||||
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
if (ret.Count == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
List<RegionData> ret = RunCommand(cmd);
|
return ret[0];
|
||||||
if (ret.Count == 0)
|
}
|
||||||
return null;
|
|
||||||
|
|
||||||
return ret[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID)
|
public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID)
|
||||||
|
@ -107,71 +110,70 @@ namespace OpenSim.Data.MySQL
|
||||||
if (scopeID != UUID.Zero)
|
if (scopeID != UUID.Zero)
|
||||||
command += " and ScopeID = ?scopeID";
|
command += " and ScopeID = ?scopeID";
|
||||||
|
|
||||||
MySqlCommand cmd = new MySqlCommand(command);
|
using (MySqlCommand cmd = new MySqlCommand(command))
|
||||||
|
{
|
||||||
|
cmd.Parameters.AddWithValue("?startX", startX.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?startY", startY.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?endX", endX.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?endY", endY.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("?startX", startX.ToString());
|
return RunCommand(cmd);
|
||||||
cmd.Parameters.AddWithValue("?startY", startY.ToString());
|
}
|
||||||
cmd.Parameters.AddWithValue("?endX", endX.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?endY", endY.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
|
||||||
|
|
||||||
return RunCommand(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RegionData> RunCommand(MySqlCommand cmd)
|
public List<RegionData> RunCommand(MySqlCommand cmd)
|
||||||
{
|
{
|
||||||
List<RegionData> retList = new List<RegionData>();
|
List<RegionData> retList = new List<RegionData>();
|
||||||
|
|
||||||
IDataReader result = ExecuteReader(cmd);
|
using (IDataReader result = ExecuteReader(cmd))
|
||||||
|
|
||||||
while (result.Read())
|
|
||||||
{
|
{
|
||||||
RegionData ret = new RegionData();
|
while (result.Read())
|
||||||
ret.Data = new Dictionary<string, object>();
|
|
||||||
|
|
||||||
UUID regionID;
|
|
||||||
UUID.TryParse(result["uuid"].ToString(), out regionID);
|
|
||||||
ret.RegionID = regionID;
|
|
||||||
UUID scope;
|
|
||||||
UUID.TryParse(result["ScopeID"].ToString(), out scope);
|
|
||||||
ret.ScopeID = scope;
|
|
||||||
ret.RegionName = result["regionName"].ToString();
|
|
||||||
ret.posX = Convert.ToInt32(result["locX"]);
|
|
||||||
ret.posY = Convert.ToInt32(result["locY"]);
|
|
||||||
ret.sizeX = Convert.ToInt32(result["sizeX"]);
|
|
||||||
ret.sizeY = Convert.ToInt32(result["sizeY"]);
|
|
||||||
|
|
||||||
if (m_ColumnNames == null)
|
|
||||||
{
|
{
|
||||||
m_ColumnNames = new List<string>();
|
RegionData ret = new RegionData();
|
||||||
|
ret.Data = new Dictionary<string, object>();
|
||||||
|
|
||||||
DataTable schemaTable = result.GetSchemaTable();
|
UUID regionID;
|
||||||
foreach (DataRow row in schemaTable.Rows)
|
UUID.TryParse(result["uuid"].ToString(), out regionID);
|
||||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
ret.RegionID = regionID;
|
||||||
|
UUID scope;
|
||||||
|
UUID.TryParse(result["ScopeID"].ToString(), out scope);
|
||||||
|
ret.ScopeID = scope;
|
||||||
|
ret.RegionName = result["regionName"].ToString();
|
||||||
|
ret.posX = Convert.ToInt32(result["locX"]);
|
||||||
|
ret.posY = Convert.ToInt32(result["locY"]);
|
||||||
|
ret.sizeX = Convert.ToInt32(result["sizeX"]);
|
||||||
|
ret.sizeY = Convert.ToInt32(result["sizeY"]);
|
||||||
|
|
||||||
|
if (m_ColumnNames == null)
|
||||||
|
{
|
||||||
|
m_ColumnNames = new List<string>();
|
||||||
|
|
||||||
|
DataTable schemaTable = result.GetSchemaTable();
|
||||||
|
foreach (DataRow row in schemaTable.Rows)
|
||||||
|
m_ColumnNames.Add(row["ColumnName"].ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string s in m_ColumnNames)
|
||||||
|
{
|
||||||
|
if (s == "uuid")
|
||||||
|
continue;
|
||||||
|
if (s == "ScopeID")
|
||||||
|
continue;
|
||||||
|
if (s == "regionName")
|
||||||
|
continue;
|
||||||
|
if (s == "locX")
|
||||||
|
continue;
|
||||||
|
if (s == "locY")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ret.Data[s] = result[s].ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
retList.Add(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (string s in m_ColumnNames)
|
|
||||||
{
|
|
||||||
if (s == "uuid")
|
|
||||||
continue;
|
|
||||||
if (s == "ScopeID")
|
|
||||||
continue;
|
|
||||||
if (s == "regionName")
|
|
||||||
continue;
|
|
||||||
if (s == "locX")
|
|
||||||
continue;
|
|
||||||
if (s == "locY")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ret.Data[s] = result[s].ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
retList.Add(ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Close();
|
|
||||||
CloseReaderCommand(cmd);
|
|
||||||
|
|
||||||
return retList;
|
return retList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,76 +200,72 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
string[] fields = new List<string>(data.Data.Keys).ToArray();
|
string[] fields = new List<string>(data.Data.Keys).ToArray();
|
||||||
|
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
using (MySqlCommand cmd = new MySqlCommand())
|
||||||
|
|
||||||
string update = "update `"+m_Realm+"` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY";
|
|
||||||
foreach (string field in fields)
|
|
||||||
{
|
{
|
||||||
update += ", ";
|
string update = "update `" + m_Realm + "` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY";
|
||||||
update += "`" + field + "` = ?"+field;
|
foreach (string field in fields)
|
||||||
|
{
|
||||||
|
update += ", ";
|
||||||
|
update += "`" + field + "` = ?" + field;
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("?"+field, data.Data[field]);
|
cmd.Parameters.AddWithValue("?" + field, data.Data[field]);
|
||||||
}
|
}
|
||||||
|
|
||||||
update += " where uuid = ?regionID";
|
update += " where uuid = ?regionID";
|
||||||
|
|
||||||
if (data.ScopeID != UUID.Zero)
|
if (data.ScopeID != UUID.Zero)
|
||||||
update += " and ScopeID = ?scopeID";
|
update += " and ScopeID = ?scopeID";
|
||||||
|
|
||||||
cmd.CommandText = update;
|
cmd.CommandText = update;
|
||||||
cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString());
|
cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString());
|
||||||
cmd.Parameters.AddWithValue("?regionName", data.RegionName);
|
cmd.Parameters.AddWithValue("?regionName", data.RegionName);
|
||||||
cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString());
|
cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString());
|
||||||
cmd.Parameters.AddWithValue("?posX", data.posX.ToString());
|
cmd.Parameters.AddWithValue("?posX", data.posX.ToString());
|
||||||
cmd.Parameters.AddWithValue("?posY", data.posY.ToString());
|
cmd.Parameters.AddWithValue("?posY", data.posY.ToString());
|
||||||
cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString());
|
cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString());
|
||||||
cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString());
|
cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString());
|
||||||
|
|
||||||
if (ExecuteNonQuery(cmd) < 1)
|
|
||||||
{
|
|
||||||
string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" +
|
|
||||||
String.Join("`, `", fields) +
|
|
||||||
"`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")";
|
|
||||||
|
|
||||||
cmd.CommandText = insert;
|
|
||||||
|
|
||||||
if (ExecuteNonQuery(cmd) < 1)
|
if (ExecuteNonQuery(cmd) < 1)
|
||||||
{
|
{
|
||||||
cmd.Dispose();
|
string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" +
|
||||||
return false;
|
String.Join("`, `", fields) +
|
||||||
|
"`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")";
|
||||||
|
|
||||||
|
cmd.CommandText = insert;
|
||||||
|
|
||||||
|
if (ExecuteNonQuery(cmd) < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Dispose();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SetDataItem(UUID regionID, string item, string value)
|
public bool SetDataItem(UUID regionID, string item, string value)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = new MySqlCommand("update `" + m_Realm +
|
using (MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + "` set `" + item + "` = ?" + item + " where uuid = ?UUID"))
|
||||||
"` set `" + item + "` = ?" + item + " where uuid = ?UUID");
|
{
|
||||||
|
cmd.Parameters.AddWithValue("?" + item, value);
|
||||||
|
cmd.Parameters.AddWithValue("?UUID", regionID.ToString());
|
||||||
|
|
||||||
|
if (ExecuteNonQuery(cmd) > 0)
|
||||||
cmd.Parameters.AddWithValue("?"+item, value);
|
return true;
|
||||||
cmd.Parameters.AddWithValue("?UUID", regionID.ToString());
|
}
|
||||||
|
|
||||||
if (ExecuteNonQuery(cmd) > 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Delete(UUID regionID)
|
public bool Delete(UUID regionID)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm +
|
using (MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm + "` where uuid = ?UUID"))
|
||||||
"` where uuid = ?UUID");
|
{
|
||||||
|
cmd.Parameters.AddWithValue("?UUID", regionID.ToString());
|
||||||
|
|
||||||
|
if (ExecuteNonQuery(cmd) > 0)
|
||||||
cmd.Parameters.AddWithValue("?UUID", regionID.ToString());
|
return true;
|
||||||
|
}
|
||||||
if (ExecuteNonQuery(cmd) > 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,48 +64,44 @@ namespace OpenSim.Data.MySQL
|
||||||
if (scopeID != UUID.Zero)
|
if (scopeID != UUID.Zero)
|
||||||
command += " and ScopeID = ?scopeID";
|
command += " and ScopeID = ?scopeID";
|
||||||
|
|
||||||
MySqlCommand cmd = new MySqlCommand(command);
|
using (MySqlCommand cmd = new MySqlCommand(command))
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
|
||||||
|
|
||||||
IDataReader result = ExecuteReader(cmd);
|
|
||||||
|
|
||||||
if (result.Read())
|
|
||||||
{
|
{
|
||||||
ret.PrincipalID = principalID;
|
cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
|
||||||
UUID scope;
|
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
||||||
UUID.TryParse(result["ScopeID"].ToString(), out scope);
|
|
||||||
ret.ScopeID = scope;
|
|
||||||
|
|
||||||
if (m_ColumnNames == null)
|
using (IDataReader result = ExecuteReader(cmd))
|
||||||
{
|
{
|
||||||
m_ColumnNames = new List<string>();
|
if (result.Read())
|
||||||
|
{
|
||||||
|
ret.PrincipalID = principalID;
|
||||||
|
UUID scope;
|
||||||
|
UUID.TryParse(result["ScopeID"].ToString(), out scope);
|
||||||
|
ret.ScopeID = scope;
|
||||||
|
|
||||||
DataTable schemaTable = result.GetSchemaTable();
|
if (m_ColumnNames == null)
|
||||||
foreach (DataRow row in schemaTable.Rows)
|
{
|
||||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
m_ColumnNames = new List<string>();
|
||||||
|
|
||||||
|
DataTable schemaTable = result.GetSchemaTable();
|
||||||
|
foreach (DataRow row in schemaTable.Rows)
|
||||||
|
m_ColumnNames.Add(row["ColumnName"].ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string s in m_ColumnNames)
|
||||||
|
{
|
||||||
|
if (s == "UUID")
|
||||||
|
continue;
|
||||||
|
if (s == "ScopeID")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ret.Data[s] = result[s].ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (string s in m_ColumnNames)
|
|
||||||
{
|
|
||||||
if (s == "UUID")
|
|
||||||
continue;
|
|
||||||
if (s == "ScopeID")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ret.Data[s] = result[s].ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
result.Close();
|
|
||||||
CloseReaderCommand(cmd);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Close();
|
|
||||||
CloseReaderCommand(cmd);
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,61 +114,60 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
string[] fields = new List<string>(data.Data.Keys).ToArray();
|
string[] fields = new List<string>(data.Data.Keys).ToArray();
|
||||||
|
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
using (MySqlCommand cmd = new MySqlCommand())
|
||||||
|
|
||||||
string update = "update `"+m_Realm+"` set ";
|
|
||||||
bool first = true;
|
|
||||||
foreach (string field in fields)
|
|
||||||
{
|
{
|
||||||
if (!first)
|
string update = "update `" + m_Realm + "` set ";
|
||||||
update += ", ";
|
bool first = true;
|
||||||
update += "`" + field + "` = ?"+field;
|
foreach (string field in fields)
|
||||||
|
{
|
||||||
|
if (!first)
|
||||||
|
update += ", ";
|
||||||
|
update += "`" + field + "` = ?" + field;
|
||||||
|
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("?"+field, data.Data[field]);
|
cmd.Parameters.AddWithValue("?" + field, data.Data[field]);
|
||||||
}
|
}
|
||||||
|
|
||||||
update += " where UUID = ?principalID";
|
update += " where UUID = ?principalID";
|
||||||
|
|
||||||
if (data.ScopeID != UUID.Zero)
|
if (data.ScopeID != UUID.Zero)
|
||||||
update += " and ScopeID = ?scopeID";
|
update += " and ScopeID = ?scopeID";
|
||||||
|
|
||||||
cmd.CommandText = update;
|
cmd.CommandText = update;
|
||||||
cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString());
|
cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString());
|
||||||
cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString());
|
cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString());
|
||||||
|
|
||||||
if (ExecuteNonQuery(cmd) < 1)
|
|
||||||
{
|
|
||||||
string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" +
|
|
||||||
String.Join("`, `", fields) +
|
|
||||||
"`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")";
|
|
||||||
|
|
||||||
cmd.CommandText = insert;
|
|
||||||
|
|
||||||
if (ExecuteNonQuery(cmd) < 1)
|
if (ExecuteNonQuery(cmd) < 1)
|
||||||
{
|
{
|
||||||
cmd.Dispose();
|
string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" +
|
||||||
return false;
|
String.Join("`, `", fields) +
|
||||||
|
"`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")";
|
||||||
|
|
||||||
|
cmd.CommandText = insert;
|
||||||
|
|
||||||
|
if (ExecuteNonQuery(cmd) < 1)
|
||||||
|
{
|
||||||
|
cmd.Dispose();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Dispose();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SetDataItem(UUID principalID, string item, string value)
|
public bool SetDataItem(UUID principalID, string item, string value)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = new MySqlCommand("update `" + m_Realm +
|
using (MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + "` set `" +
|
||||||
"` set `" + item + "` = ?" + item + " where UUID = ?UUID");
|
item + "` = ?" + item + " where UUID = ?UUID"))
|
||||||
|
{
|
||||||
|
cmd.Parameters.AddWithValue("?" + item, value);
|
||||||
|
cmd.Parameters.AddWithValue("?UUID", principalID.ToString());
|
||||||
|
|
||||||
|
if (ExecuteNonQuery(cmd) > 0)
|
||||||
cmd.Parameters.AddWithValue("?"+item, value);
|
return true;
|
||||||
cmd.Parameters.AddWithValue("?UUID", principalID.ToString());
|
}
|
||||||
|
|
||||||
if (ExecuteNonQuery(cmd) > 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,21 +181,20 @@ namespace OpenSim.Data.MySQL
|
||||||
param["?first"] = user;
|
param["?first"] = user;
|
||||||
param["?second"] = last;
|
param["?second"] = last;
|
||||||
|
|
||||||
IDbCommand result =
|
using (IDbCommand result = dbm.Manager.Query(
|
||||||
dbm.Manager.Query(
|
"SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param))
|
||||||
"SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param);
|
{
|
||||||
IDataReader reader = result.ExecuteReader();
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
|
{
|
||||||
UserProfileData row = dbm.Manager.readUserRow(reader);
|
UserProfileData row = dbm.Manager.readUserRow(reader);
|
||||||
|
return row;
|
||||||
reader.Dispose();
|
}
|
||||||
result.Dispose();
|
}
|
||||||
return row;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -220,28 +219,30 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IDbCommand adder =
|
using (IDbCommand adder = dbm.Manager.Query(
|
||||||
dbm.Manager.Query(
|
"INSERT INTO `" + m_userFriendsTableName + "` " +
|
||||||
"INSERT INTO `" + m_userFriendsTableName + "` " +
|
"(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
|
||||||
"(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
|
"VALUES " +
|
||||||
"VALUES " +
|
"(?ownerID,?friendID,?friendPerms,?datetimestamp)",
|
||||||
"(?ownerID,?friendID,?friendPerms,?datetimestamp)",
|
param))
|
||||||
param);
|
{
|
||||||
adder.ExecuteNonQuery();
|
adder.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
|
||||||
adder =
|
using (IDbCommand adder = dbm.Manager.Query(
|
||||||
dbm.Manager.Query(
|
"INSERT INTO `" + m_userFriendsTableName + "` " +
|
||||||
"INSERT INTO `" + m_userFriendsTableName + "` " +
|
"(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
|
||||||
"(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
|
"VALUES " +
|
||||||
"VALUES " +
|
"(?friendID,?ownerID,?friendPerms,?datetimestamp)",
|
||||||
"(?friendID,?ownerID,?friendPerms,?datetimestamp)",
|
param))
|
||||||
param);
|
{
|
||||||
adder.ExecuteNonQuery();
|
adder.ExecuteNonQuery();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -260,22 +261,24 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IDbCommand updater =
|
using (IDbCommand updater = dbm.Manager.Query(
|
||||||
dbm.Manager.Query(
|
|
||||||
"delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID",
|
"delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID",
|
||||||
param);
|
param))
|
||||||
updater.ExecuteNonQuery();
|
{
|
||||||
|
updater.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
|
||||||
updater =
|
using (IDbCommand updater = dbm.Manager.Query(
|
||||||
dbm.Manager.Query(
|
|
||||||
"delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID",
|
"delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID",
|
||||||
param);
|
param))
|
||||||
updater.ExecuteNonQuery();
|
{
|
||||||
|
updater.ExecuteNonQuery();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -295,18 +298,19 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IDbCommand updater =
|
using (IDbCommand updater = dbm.Manager.Query(
|
||||||
dbm.Manager.Query(
|
|
||||||
"update " + m_userFriendsTableName +
|
"update " + m_userFriendsTableName +
|
||||||
" SET friendPerms = ?friendPerms " +
|
" SET friendPerms = ?friendPerms " +
|
||||||
"where ownerID = ?ownerID and friendID = ?friendID",
|
"where ownerID = ?ownerID and friendID = ?friendID",
|
||||||
param);
|
param))
|
||||||
updater.ExecuteNonQuery();
|
{
|
||||||
|
updater.ExecuteNonQuery();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -327,34 +331,33 @@ namespace OpenSim.Data.MySQL
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Left Join userfriends to itself
|
//Left Join userfriends to itself
|
||||||
IDbCommand result =
|
using (IDbCommand result = dbm.Manager.Query(
|
||||||
dbm.Manager.Query(
|
"select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " +
|
||||||
"select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " +
|
m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" +
|
||||||
m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" +
|
" where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID",
|
||||||
" where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID",
|
param))
|
||||||
param);
|
|
||||||
IDataReader reader = result.ExecuteReader();
|
|
||||||
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
{
|
||||||
FriendListItem fli = new FriendListItem();
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
fli.FriendListOwner = new UUID((string) reader["ownerID"]);
|
{
|
||||||
fli.Friend = new UUID((string) reader["friendID"]);
|
while (reader.Read())
|
||||||
fli.FriendPerms = (uint) Convert.ToInt32(reader["friendPerms"]);
|
{
|
||||||
|
FriendListItem fli = new FriendListItem();
|
||||||
|
fli.FriendListOwner = new UUID((string)reader["ownerID"]);
|
||||||
|
fli.Friend = new UUID((string)reader["friendID"]);
|
||||||
|
fli.FriendPerms = (uint)Convert.ToInt32(reader["friendPerms"]);
|
||||||
|
|
||||||
// This is not a real column in the database table, it's a joined column from the opposite record
|
// This is not a real column in the database table, it's a joined column from the opposite record
|
||||||
fli.FriendListOwnerPerms = (uint) Convert.ToInt32(reader["ownerperms"]);
|
fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]);
|
||||||
|
|
||||||
Lfli.Add(fli);
|
Lfli.Add(fli);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.Dispose();
|
|
||||||
result.Dispose();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return Lfli;
|
return Lfli;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -376,29 +379,29 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||||
param["?uuid"] = uuid.ToString();
|
param["?uuid"] = uuid.ToString();
|
||||||
IDbCommand result =
|
|
||||||
dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName +
|
|
||||||
" where UUID = ?uuid", param);
|
|
||||||
|
|
||||||
IDataReader reader = result.ExecuteReader();
|
using (IDbCommand result = dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName +
|
||||||
while (reader.Read())
|
" where UUID = ?uuid", param))
|
||||||
{
|
{
|
||||||
FriendRegionInfo fri = new FriendRegionInfo();
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
fri.isOnline = (sbyte)reader["agentOnline"] != 0;
|
{
|
||||||
fri.regionHandle = (ulong)reader["currentHandle"];
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
FriendRegionInfo fri = new FriendRegionInfo();
|
||||||
|
fri.isOnline = (sbyte)reader["agentOnline"] != 0;
|
||||||
|
fri.regionHandle = (ulong)reader["currentHandle"];
|
||||||
|
|
||||||
infos[uuid] = fri;
|
infos[uuid] = fri;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.Dispose();
|
|
||||||
result.Dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e);
|
m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e);
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -427,28 +430,28 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IDbCommand result =
|
using (IDbCommand result = dbm.Manager.Query(
|
||||||
dbm.Manager.Query(
|
"SELECT UUID,username,lastname FROM " + m_usersTableName +
|
||||||
"SELECT UUID,username,lastname FROM " + m_usersTableName +
|
" WHERE username like ?first AND lastname like ?second LIMIT 100",
|
||||||
" WHERE username like ?first AND lastname like ?second LIMIT 100",
|
param))
|
||||||
param);
|
|
||||||
IDataReader reader = result.ExecuteReader();
|
|
||||||
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
{
|
||||||
AvatarPickerAvatar user = new AvatarPickerAvatar();
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
user.AvatarID = new UUID((string) reader["UUID"]);
|
{
|
||||||
user.firstName = (string) reader["username"];
|
while (reader.Read())
|
||||||
user.lastName = (string) reader["lastname"];
|
{
|
||||||
returnlist.Add(user);
|
AvatarPickerAvatar user = new AvatarPickerAvatar();
|
||||||
|
user.AvatarID = new UUID((string)reader["UUID"]);
|
||||||
|
user.firstName = (string)reader["username"];
|
||||||
|
user.lastName = (string)reader["lastname"];
|
||||||
|
returnlist.Add(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reader.Dispose();
|
|
||||||
result.Dispose();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return returnlist;
|
return returnlist;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -465,28 +468,28 @@ namespace OpenSim.Data.MySQL
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||||
param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%";
|
param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%";
|
||||||
|
|
||||||
IDbCommand result =
|
using (IDbCommand result = dbm.Manager.Query(
|
||||||
dbm.Manager.Query(
|
"SELECT UUID,username,lastname FROM " + m_usersTableName +
|
||||||
"SELECT UUID,username,lastname FROM " + m_usersTableName +
|
" WHERE username like ?first OR lastname like ?first LIMIT 100",
|
||||||
" WHERE username like ?first OR lastname like ?first LIMIT 100",
|
param))
|
||||||
param);
|
|
||||||
IDataReader reader = result.ExecuteReader();
|
|
||||||
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
{
|
||||||
AvatarPickerAvatar user = new AvatarPickerAvatar();
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
user.AvatarID = new UUID((string) reader["UUID"]);
|
{
|
||||||
user.firstName = (string) reader["username"];
|
while (reader.Read())
|
||||||
user.lastName = (string) reader["lastname"];
|
{
|
||||||
returnlist.Add(user);
|
AvatarPickerAvatar user = new AvatarPickerAvatar();
|
||||||
|
user.AvatarID = new UUID((string)reader["UUID"]);
|
||||||
|
user.firstName = (string)reader["username"];
|
||||||
|
user.lastName = (string)reader["lastname"];
|
||||||
|
returnlist.Add(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reader.Dispose();
|
|
||||||
result.Dispose();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return returnlist;
|
return returnlist;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -510,20 +513,19 @@ namespace OpenSim.Data.MySQL
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||||
param["?uuid"] = uuid.ToString();
|
param["?uuid"] = uuid.ToString();
|
||||||
|
|
||||||
IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param);
|
using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param))
|
||||||
IDataReader reader = result.ExecuteReader();
|
{
|
||||||
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
UserProfileData row = dbm.Manager.readUserRow(reader);
|
{
|
||||||
|
UserProfileData row = dbm.Manager.readUserRow(reader);
|
||||||
reader.Dispose();
|
return row;
|
||||||
result.Dispose();
|
}
|
||||||
|
}
|
||||||
return row;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -569,15 +571,15 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dbm.Manager.ExecuteParameterizedSql(
|
dbm.Manager.ExecuteParameterizedSql(
|
||||||
"update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " +
|
"update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " +
|
||||||
"where UUID = ?UUID",
|
"where UUID = ?UUID",
|
||||||
param);
|
param);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -600,21 +602,19 @@ namespace OpenSim.Data.MySQL
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||||
param["?uuid"] = uuid.ToString();
|
param["?uuid"] = uuid.ToString();
|
||||||
|
|
||||||
IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid",
|
using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param))
|
||||||
param);
|
{
|
||||||
IDataReader reader = result.ExecuteReader();
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
|
{
|
||||||
UserAgentData row = dbm.Manager.readAgentRow(reader);
|
UserAgentData row = dbm.Manager.readAgentRow(reader);
|
||||||
|
return row;
|
||||||
reader.Dispose();
|
}
|
||||||
result.Dispose();
|
}
|
||||||
|
|
||||||
return row;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -638,19 +638,20 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dbm.Manager.insertUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
|
dbm.Manager.insertUserRow(
|
||||||
user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y,
|
user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
|
||||||
user.HomeLocation.Z,
|
user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y,
|
||||||
user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created,
|
user.HomeLocation.Z,
|
||||||
user.LastLogin, user.UserInventoryURI, user.UserAssetURI,
|
user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created,
|
||||||
user.CanDoMask, user.WantDoMask,
|
user.LastLogin, user.UserInventoryURI, user.UserAssetURI,
|
||||||
user.AboutText, user.FirstLifeAboutText, user.Image,
|
user.CanDoMask, user.WantDoMask,
|
||||||
user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner);
|
user.AboutText, user.FirstLifeAboutText, user.Image,
|
||||||
|
user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -676,7 +677,7 @@ namespace OpenSim.Data.MySQL
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -693,14 +694,15 @@ namespace OpenSim.Data.MySQL
|
||||||
MySQLSuperManager dbm = GetLockedConnection("UpdateUserProfile");
|
MySQLSuperManager dbm = GetLockedConnection("UpdateUserProfile");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dbm.Manager.updateUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
|
dbm.Manager.updateUserRow(
|
||||||
user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y,
|
user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
|
||||||
user.HomeLocation.Z, user.HomeLookAt.X,
|
user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y,
|
||||||
user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin,
|
user.HomeLocation.Z, user.HomeLookAt.X,
|
||||||
user.UserInventoryURI,
|
user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin,
|
||||||
user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText,
|
user.UserInventoryURI,
|
||||||
user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey,
|
user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText,
|
||||||
user.UserFlags, user.GodLevel, user.CustomType, user.Partner);
|
user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey,
|
||||||
|
user.UserFlags, user.GodLevel, user.CustomType, user.Partner);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -748,29 +750,29 @@ namespace OpenSim.Data.MySQL
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||||
param["?owner"] = user.ToString();
|
param["?owner"] = user.ToString();
|
||||||
|
|
||||||
IDbCommand result = dbm.Manager.Query(
|
using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param))
|
||||||
"SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param);
|
|
||||||
IDataReader reader = result.ExecuteReader();
|
|
||||||
|
|
||||||
AvatarAppearance appearance = dbm.Manager.readAppearanceRow(reader);
|
|
||||||
|
|
||||||
reader.Dispose();
|
|
||||||
result.Dispose();
|
|
||||||
|
|
||||||
if (null == appearance)
|
|
||||||
{
|
{
|
||||||
m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString());
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
return null;
|
{
|
||||||
}
|
AvatarAppearance appearance = dbm.Manager.readAppearanceRow(reader);
|
||||||
|
|
||||||
appearance.SetAttachments(GetUserAttachments(user));
|
|
||||||
|
|
||||||
return appearance;
|
if (appearance == null)
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
appearance.SetAttachments(GetUserAttachments(user));
|
||||||
|
return appearance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -798,7 +800,7 @@ namespace OpenSim.Data.MySQL
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -833,20 +835,20 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IDbCommand result = dbm.Manager.Query(
|
using (IDbCommand result = dbm.Manager.Query(
|
||||||
"SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param);
|
"SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param))
|
||||||
IDataReader reader = result.ExecuteReader();
|
{
|
||||||
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
Hashtable ret = dbm.Manager.readAttachments(reader);
|
{
|
||||||
|
Hashtable ret = dbm.Manager.readAttachments(reader);
|
||||||
reader.Dispose();
|
return ret;
|
||||||
result.Dispose();
|
}
|
||||||
return ret;
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -905,7 +907,7 @@ namespace OpenSim.Data.MySQL
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
dbm.Manager.Reconnect();
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.Message, e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
|
@ -205,13 +205,10 @@ namespace OpenSim
|
||||||
Directory.CreateDirectory(m_crashDir);
|
Directory.CreateDirectory(m_crashDir);
|
||||||
}
|
}
|
||||||
string log = Util.GetUniqueFilename(ex.GetType() + ".txt");
|
string log = Util.GetUniqueFilename(ex.GetType() + ".txt");
|
||||||
StreamWriter m_crashLog =
|
using (StreamWriter m_crashLog = new StreamWriter(Path.Combine(m_crashDir, log)))
|
||||||
new StreamWriter(
|
{
|
||||||
Path.Combine(m_crashDir, log)
|
m_crashLog.WriteLine(msg);
|
||||||
);
|
}
|
||||||
|
|
||||||
m_crashLog.WriteLine(msg);
|
|
||||||
m_crashLog.Close();
|
|
||||||
|
|
||||||
File.Copy("OpenSim.ini", Path.Combine(m_crashDir, log + "_OpenSim.ini"), true);
|
File.Copy("OpenSim.ini", Path.Combine(m_crashDir, log + "_OpenSim.ini"), true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue