Merge branch 'master' into careminster
commit
c8f3bb56ff
|
@ -43,10 +43,13 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private MySQLManager _dbConnection;
|
private string m_connectionString;
|
||||||
|
private object m_dbLock = new object();
|
||||||
|
|
||||||
#region IPlugin Members
|
#region IPlugin Members
|
||||||
|
|
||||||
|
public override string Version { get { return "1.0.0.0"; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>Initialises Asset interface</para>
|
/// <para>Initialises Asset interface</para>
|
||||||
/// <para>
|
/// <para>
|
||||||
|
@ -58,62 +61,28 @@ namespace OpenSim.Data.MySQL
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="connect">connect string</param>
|
/// <param name="connect">connect string</param>
|
||||||
override public void Initialise(string connect)
|
public override void Initialise(string connect)
|
||||||
{
|
{
|
||||||
// TODO: This will let you pass in the connect string in
|
m_connectionString = connect;
|
||||||
// the config, though someone will need to write that.
|
|
||||||
if (connect == String.Empty)
|
|
||||||
{
|
|
||||||
// This is old seperate config file
|
|
||||||
m_log.Warn("no connect string, using old mysql_connection.ini instead");
|
|
||||||
Initialise();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_dbConnection = new MySQLManager(connect);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This actually does the roll forward assembly stuff
|
// This actually does the roll forward assembly stuff
|
||||||
Assembly assem = GetType().Assembly;
|
Assembly assem = GetType().Assembly;
|
||||||
Migration m = new Migration(_dbConnection.Connection, assem, "AssetStore");
|
|
||||||
|
|
||||||
m.Update();
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
Migration m = new Migration(dbcon, assem, "AssetStore");
|
||||||
|
m.Update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// <para>Initialises Asset interface</para>
|
|
||||||
/// <para>
|
|
||||||
/// <list type="bullet">
|
|
||||||
/// <item>Loads and initialises the MySQL storage plugin</item>
|
|
||||||
/// <item>uses the obsolete mysql_connection.ini</item>
|
|
||||||
/// </list>
|
|
||||||
/// </para>
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>DEPRECATED and shouldn't be used</remarks>
|
|
||||||
public override void Initialise()
|
public override void Initialise()
|
||||||
{
|
{
|
||||||
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
|
throw new NotImplementedException();
|
||||||
string hostname = GridDataMySqlFile.ParseFileReadValue("hostname");
|
|
||||||
string database = GridDataMySqlFile.ParseFileReadValue("database");
|
|
||||||
string username = GridDataMySqlFile.ParseFileReadValue("username");
|
|
||||||
string password = GridDataMySqlFile.ParseFileReadValue("password");
|
|
||||||
string pooling = GridDataMySqlFile.ParseFileReadValue("pooling");
|
|
||||||
string port = GridDataMySqlFile.ParseFileReadValue("port");
|
|
||||||
|
|
||||||
_dbConnection = new MySQLManager(hostname, database, username, password, pooling, port);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose() { }
|
public override void Dispose() { }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Database provider version
|
|
||||||
/// </summary>
|
|
||||||
override public string Version
|
|
||||||
{
|
|
||||||
get { return _dbConnection.getVersion(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The name of this DB provider
|
/// The name of this DB provider
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -135,46 +104,43 @@ namespace OpenSim.Data.MySQL
|
||||||
override public AssetBase GetAsset(UUID assetID)
|
override public AssetBase GetAsset(UUID assetID)
|
||||||
{
|
{
|
||||||
AssetBase asset = null;
|
AssetBase asset = null;
|
||||||
lock (_dbConnection)
|
lock (m_dbLock)
|
||||||
{
|
{
|
||||||
_dbConnection.CheckConnection();
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
|
||||||
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);
|
dbcon))
|
||||||
cmd.Parameters.AddWithValue("?id", assetID.ToString());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
|
||||||
{
|
{
|
||||||
if (dbReader.Read())
|
cmd.Parameters.AddWithValue("?id", assetID.ToString());
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"]);
|
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||||
asset.Data = (byte[]) dbReader["data"];
|
{
|
||||||
asset.Description = (string) dbReader["description"];
|
if (dbReader.Read())
|
||||||
|
{
|
||||||
|
asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"]);
|
||||||
|
asset.Data = (byte[])dbReader["data"];
|
||||||
|
asset.Description = (string)dbReader["description"];
|
||||||
|
|
||||||
string local = dbReader["local"].ToString();
|
string local = dbReader["local"].ToString();
|
||||||
if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase))
|
if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase))
|
||||||
asset.Local = true;
|
asset.Local = true;
|
||||||
else
|
else
|
||||||
asset.Local = false;
|
asset.Local = false;
|
||||||
|
|
||||||
asset.Temporary = Convert.ToBoolean(dbReader["temporary"]);
|
asset.Temporary = Convert.ToBoolean(dbReader["temporary"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.Error("[ASSETS DB]: MySql failure fetching asset " + assetID + ": " + e.Message);
|
||||||
}
|
}
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return asset;
|
return asset;
|
||||||
|
@ -187,55 +153,57 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks>
|
/// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks>
|
||||||
override public void StoreAsset(AssetBase asset)
|
override public void StoreAsset(AssetBase asset)
|
||||||
{
|
{
|
||||||
lock (_dbConnection)
|
lock (m_dbLock)
|
||||||
{
|
{
|
||||||
_dbConnection.CheckConnection();
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
|
||||||
MySqlCommand cmd =
|
MySqlCommand cmd =
|
||||||
new MySqlCommand(
|
new MySqlCommand(
|
||||||
"replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" +
|
"replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" +
|
||||||
"VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)",
|
"VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)",
|
||||||
_dbConnection.Connection);
|
dbcon);
|
||||||
|
|
||||||
string assetName = asset.Name;
|
string assetName = asset.Name;
|
||||||
if (asset.Name.Length > 64)
|
if (asset.Name.Length > 64)
|
||||||
{
|
|
||||||
assetName = asset.Name.Substring(0, 64);
|
|
||||||
m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add");
|
|
||||||
}
|
|
||||||
|
|
||||||
string assetDescription = asset.Description;
|
|
||||||
if (asset.Description.Length > 64)
|
|
||||||
{
|
|
||||||
assetDescription = asset.Description.Substring(0, 64);
|
|
||||||
m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add");
|
|
||||||
}
|
|
||||||
|
|
||||||
// need to ensure we dispose
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (cmd)
|
|
||||||
{
|
{
|
||||||
// create unix epoch time
|
assetName = asset.Name.Substring(0, 64);
|
||||||
int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
|
m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add");
|
||||||
cmd.Parameters.AddWithValue("?id", asset.ID);
|
}
|
||||||
cmd.Parameters.AddWithValue("?name", assetName);
|
|
||||||
cmd.Parameters.AddWithValue("?description", assetDescription);
|
string assetDescription = asset.Description;
|
||||||
cmd.Parameters.AddWithValue("?assetType", asset.Type);
|
if (asset.Description.Length > 64)
|
||||||
cmd.Parameters.AddWithValue("?local", asset.Local);
|
{
|
||||||
cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
|
assetDescription = asset.Description.Substring(0, 64);
|
||||||
cmd.Parameters.AddWithValue("?create_time", now);
|
m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add");
|
||||||
cmd.Parameters.AddWithValue("?access_time", now);
|
}
|
||||||
cmd.Parameters.AddWithValue("?data", asset.Data);
|
|
||||||
cmd.ExecuteNonQuery();
|
// need to ensure we dispose
|
||||||
cmd.Dispose();
|
try
|
||||||
|
{
|
||||||
|
using (cmd)
|
||||||
|
{
|
||||||
|
// create unix epoch time
|
||||||
|
int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
|
||||||
|
cmd.Parameters.AddWithValue("?id", asset.ID);
|
||||||
|
cmd.Parameters.AddWithValue("?name", assetName);
|
||||||
|
cmd.Parameters.AddWithValue("?description", assetDescription);
|
||||||
|
cmd.Parameters.AddWithValue("?assetType", asset.Type);
|
||||||
|
cmd.Parameters.AddWithValue("?local", asset.Local);
|
||||||
|
cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
|
||||||
|
cmd.Parameters.AddWithValue("?create_time", now);
|
||||||
|
cmd.Parameters.AddWithValue("?access_time", now);
|
||||||
|
cmd.Parameters.AddWithValue("?data", asset.Data);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
cmd.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
|
||||||
|
asset.FullID, asset.Name, e.Message);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Attempting reconnect. Error: {2}",
|
|
||||||
asset.FullID, asset.Name, e.Message);
|
|
||||||
_dbConnection.Reconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,34 +213,35 @@ namespace OpenSim.Data.MySQL
|
||||||
// Writing to the database every time Get() is called on an asset is killing us. Seriously. -jph
|
// Writing to the database every time Get() is called on an asset is killing us. Seriously. -jph
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lock (_dbConnection)
|
lock (m_dbLock)
|
||||||
{
|
{
|
||||||
_dbConnection.CheckConnection();
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
|
|
||||||
MySqlCommand cmd =
|
|
||||||
new MySqlCommand("update assets set access_time=?access_time where id=?id",
|
|
||||||
_dbConnection.Connection);
|
|
||||||
|
|
||||||
// need to ensure we dispose
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
using (cmd)
|
dbcon.Open();
|
||||||
|
MySqlCommand cmd =
|
||||||
|
new MySqlCommand("update assets set access_time=?access_time where id=?id",
|
||||||
|
dbcon);
|
||||||
|
|
||||||
|
// need to ensure we dispose
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// create unix epoch time
|
using (cmd)
|
||||||
int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
|
{
|
||||||
cmd.Parameters.AddWithValue("?id", asset.ID);
|
// create unix epoch time
|
||||||
cmd.Parameters.AddWithValue("?access_time", now);
|
int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
|
||||||
cmd.ExecuteNonQuery();
|
cmd.Parameters.AddWithValue("?id", asset.ID);
|
||||||
cmd.Dispose();
|
cmd.Parameters.AddWithValue("?access_time", now);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
cmd.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[ASSETS DB]: " +
|
||||||
|
"MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString()
|
||||||
|
+ Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat(
|
|
||||||
"[ASSETS DB]: " +
|
|
||||||
"MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString()
|
|
||||||
+ Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name);
|
|
||||||
_dbConnection.Reconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,37 +256,30 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
bool assetExists = false;
|
bool assetExists = false;
|
||||||
|
|
||||||
lock (_dbConnection)
|
lock (m_dbLock)
|
||||||
{
|
{
|
||||||
_dbConnection.CheckConnection();
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
|
|
||||||
MySqlCommand cmd =
|
|
||||||
new MySqlCommand(
|
|
||||||
"SELECT id FROM assets WHERE id=?id",
|
|
||||||
_dbConnection.Connection);
|
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("?id", uuid.ToString());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
dbcon.Open();
|
||||||
|
using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM assets WHERE id=?id", dbcon))
|
||||||
{
|
{
|
||||||
if (dbReader.Read())
|
cmd.Parameters.AddWithValue("?id", uuid.ToString());
|
||||||
{
|
|
||||||
assetExists = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbReader.Close();
|
try
|
||||||
cmd.Dispose();
|
{
|
||||||
|
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||||
|
{
|
||||||
|
if (dbReader.Read())
|
||||||
|
assetExists = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString(), uuid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat(
|
|
||||||
"[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString()
|
|
||||||
+ Environment.NewLine + "Attempting reconnection", uuid);
|
|
||||||
_dbConnection.Reconnect();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return assetExists;
|
return assetExists;
|
||||||
|
@ -335,38 +297,39 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
List<AssetMetadata> retList = new List<AssetMetadata>(count);
|
List<AssetMetadata> retList = new List<AssetMetadata>(count);
|
||||||
|
|
||||||
lock (_dbConnection)
|
lock (m_dbLock)
|
||||||
{
|
{
|
||||||
_dbConnection.CheckConnection();
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
|
|
||||||
MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id FROM assets LIMIT ?start, ?count", _dbConnection.Connection);
|
|
||||||
cmd.Parameters.AddWithValue("?start", start);
|
|
||||||
cmd.Parameters.AddWithValue("?count", count);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
using (MySqlDataReader dbReader = cmd.ExecuteReader())
|
dbcon.Open();
|
||||||
|
MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id FROM assets LIMIT ?start, ?count", dbcon);
|
||||||
|
cmd.Parameters.AddWithValue("?start", start);
|
||||||
|
cmd.Parameters.AddWithValue("?count", count);
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
while (dbReader.Read())
|
using (MySqlDataReader dbReader = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
AssetMetadata metadata = new AssetMetadata();
|
while (dbReader.Read())
|
||||||
metadata.Name = (string) dbReader["name"];
|
{
|
||||||
metadata.Description = (string) dbReader["description"];
|
AssetMetadata metadata = new AssetMetadata();
|
||||||
metadata.Type = (sbyte) dbReader["assetType"];
|
metadata.Name = (string)dbReader["name"];
|
||||||
metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct.
|
metadata.Description = (string)dbReader["description"];
|
||||||
metadata.FullID = new UUID((string) dbReader["id"]);
|
metadata.Type = (sbyte)dbReader["assetType"];
|
||||||
|
metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct.
|
||||||
|
metadata.FullID = new UUID((string)dbReader["id"]);
|
||||||
|
|
||||||
// Current SHA1s are not stored/computed.
|
// Current SHA1s are not stored/computed.
|
||||||
metadata.SHA1 = new byte[] {};
|
metadata.SHA1 = new byte[] { };
|
||||||
|
|
||||||
retList.Add(metadata);
|
retList.Add(metadata);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (Exception e)
|
||||||
catch (Exception e)
|
{
|
||||||
{
|
m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString());
|
||||||
m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString() + Environment.NewLine + "Attempting reconnection");
|
}
|
||||||
_dbConnection.Reconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,7 +337,5 @@ namespace OpenSim.Data.MySQL
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,16 +38,22 @@ namespace OpenSim.Data.MySQL
|
||||||
public class MySqlAuthenticationData : MySqlFramework, IAuthenticationData
|
public class MySqlAuthenticationData : MySqlFramework, IAuthenticationData
|
||||||
{
|
{
|
||||||
private string m_Realm;
|
private string m_Realm;
|
||||||
private List<string> m_ColumnNames = null;
|
private List<string> m_ColumnNames;
|
||||||
private int m_LastExpire = 0;
|
private int m_LastExpire;
|
||||||
|
// private string m_connectionString;
|
||||||
|
|
||||||
public MySqlAuthenticationData(string connectionString, string realm)
|
public MySqlAuthenticationData(string connectionString, string realm)
|
||||||
: base(connectionString)
|
: base(connectionString)
|
||||||
{
|
{
|
||||||
m_Realm = realm;
|
m_Realm = realm;
|
||||||
|
m_connectionString = connectionString;
|
||||||
|
|
||||||
Migration m = new Migration(m_Connection, GetType().Assembly, "AuthStore");
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
m.Update();
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore");
|
||||||
|
m.Update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthenticationData Get(UUID principalID)
|
public AuthenticationData Get(UUID principalID)
|
||||||
|
@ -55,45 +61,42 @@ 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 (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
"select * from `"+m_Realm+"` where UUID = ?principalID"
|
|
||||||
);
|
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
|
|
||||||
|
|
||||||
IDataReader result = ExecuteReader(cmd);
|
|
||||||
|
|
||||||
if (result.Read())
|
|
||||||
{
|
{
|
||||||
ret.PrincipalID = principalID;
|
dbcon.Open();
|
||||||
|
MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID", dbcon);
|
||||||
|
cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
|
||||||
|
|
||||||
if (m_ColumnNames == null)
|
IDataReader result = cmd.ExecuteReader();
|
||||||
|
|
||||||
|
if (result.Read())
|
||||||
{
|
{
|
||||||
m_ColumnNames = new List<string>();
|
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;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
foreach (string s in m_ColumnNames)
|
|
||||||
{
|
{
|
||||||
if (s == "UUID")
|
return null;
|
||||||
continue;
|
|
||||||
|
|
||||||
ret.Data[s] = result[s].ToString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Close();
|
|
||||||
CloseReaderCommand(cmd);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Close();
|
|
||||||
CloseReaderCommand(cmd);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Store(AuthenticationData data)
|
public bool Store(AuthenticationData data)
|
||||||
|
|
|
@ -44,7 +44,6 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
private const string m_waitTimeoutSelect = "select @@wait_timeout";
|
private const string m_waitTimeoutSelect = "select @@wait_timeout";
|
||||||
|
|
||||||
private MySqlConnection m_connection;
|
|
||||||
private string m_connectionString;
|
private string m_connectionString;
|
||||||
private long m_waitTimeout;
|
private long m_waitTimeout;
|
||||||
private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond;
|
private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond;
|
||||||
|
@ -67,24 +66,26 @@ namespace OpenSim.Data.MySQL
|
||||||
m_log.Debug("Exception: password not found in connection string\n" + e.ToString());
|
m_log.Debug("Exception: password not found in connection string\n" + e.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_connection = new MySqlConnection(m_connectionString);
|
|
||||||
m_connection.Open();
|
|
||||||
|
|
||||||
GetWaitTimeout();
|
GetWaitTimeout();
|
||||||
|
|
||||||
Assembly assem = GetType().Assembly;
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
Migration m = new Migration(m_connection, assem, "EstateStore");
|
|
||||||
m.Update();
|
|
||||||
|
|
||||||
Type t = typeof(EstateSettings);
|
|
||||||
m_Fields = t.GetFields(BindingFlags.NonPublic |
|
|
||||||
BindingFlags.Instance |
|
|
||||||
BindingFlags.DeclaredOnly);
|
|
||||||
|
|
||||||
foreach (FieldInfo f in m_Fields)
|
|
||||||
{
|
{
|
||||||
if (f.Name.Substring(0, 2) == "m_")
|
dbcon.Open();
|
||||||
m_FieldMap[f.Name.Substring(2)] = f;
|
|
||||||
|
Assembly assem = GetType().Assembly;
|
||||||
|
Migration m = new Migration(dbcon, assem, "EstateStore");
|
||||||
|
m.Update();
|
||||||
|
|
||||||
|
Type t = typeof(EstateSettings);
|
||||||
|
m_Fields = t.GetFields(BindingFlags.NonPublic |
|
||||||
|
BindingFlags.Instance |
|
||||||
|
BindingFlags.DeclaredOnly);
|
||||||
|
|
||||||
|
foreach (FieldInfo f in m_Fields)
|
||||||
|
{
|
||||||
|
if (f.Name.Substring(0, 2) == "m_")
|
||||||
|
m_FieldMap[f.Name.Substring(2)] = f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,47 +96,29 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
protected void GetWaitTimeout()
|
protected void GetWaitTimeout()
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect,
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
m_connection);
|
|
||||||
|
|
||||||
using (MySqlDataReader dbReader =
|
|
||||||
cmd.ExecuteReader(CommandBehavior.SingleRow))
|
|
||||||
{
|
{
|
||||||
if (dbReader.Read())
|
dbcon.Open();
|
||||||
|
|
||||||
|
using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon))
|
||||||
{
|
{
|
||||||
m_waitTimeout
|
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||||
= Convert.ToInt32(dbReader["@@wait_timeout"]) *
|
{
|
||||||
TimeSpan.TicksPerSecond + m_waitTimeoutLeeway;
|
if (dbReader.Read())
|
||||||
|
{
|
||||||
|
m_waitTimeout
|
||||||
|
= Convert.ToInt32(dbReader["@@wait_timeout"]) *
|
||||||
|
TimeSpan.TicksPerSecond + m_waitTimeoutLeeway;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dbReader.Close();
|
m_lastConnectionUse = DateTime.Now.Ticks;
|
||||||
cmd.Dispose();
|
|
||||||
|
m_log.DebugFormat(
|
||||||
|
"[REGION DB]: Connection wait timeout {0} seconds",
|
||||||
|
m_waitTimeout / TimeSpan.TicksPerSecond);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lastConnectionUse = DateTime.Now.Ticks;
|
|
||||||
|
|
||||||
m_log.DebugFormat(
|
|
||||||
"[REGION DB]: Connection wait timeout {0} seconds",
|
|
||||||
m_waitTimeout / TimeSpan.TicksPerSecond);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void CheckConnection()
|
|
||||||
{
|
|
||||||
long timeNow = DateTime.Now.Ticks;
|
|
||||||
if (timeNow - m_lastConnectionUse > m_waitTimeout ||
|
|
||||||
m_connection.State != ConnectionState.Open)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting");
|
|
||||||
|
|
||||||
lock (m_connection)
|
|
||||||
{
|
|
||||||
m_connection.Close();
|
|
||||||
m_connection = new MySqlConnection(m_connectionString);
|
|
||||||
m_connection.Open();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_lastConnectionUse = timeNow;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EstateSettings LoadEstateSettings(UUID regionID)
|
public EstateSettings LoadEstateSettings(UUID regionID)
|
||||||
|
@ -143,114 +126,111 @@ namespace OpenSim.Data.MySQL
|
||||||
EstateSettings es = new EstateSettings();
|
EstateSettings es = new EstateSettings();
|
||||||
es.OnSave += StoreEstateSettings;
|
es.OnSave += StoreEstateSettings;
|
||||||
|
|
||||||
string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID";
|
string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) +
|
||||||
|
" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID";
|
||||||
|
|
||||||
CheckConnection();
|
bool migration = true;
|
||||||
|
|
||||||
MySqlCommand cmd = m_connection.CreateCommand();
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
|
|
||||||
cmd.CommandText = sql;
|
|
||||||
cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
|
|
||||||
|
|
||||||
IDataReader r = cmd.ExecuteReader();
|
|
||||||
|
|
||||||
if (r.Read())
|
|
||||||
{
|
{
|
||||||
foreach (string name in FieldList)
|
dbcon.Open();
|
||||||
|
|
||||||
|
using (MySqlCommand cmd = dbcon.CreateCommand())
|
||||||
{
|
{
|
||||||
if (m_FieldMap[name].GetValue(es) is bool)
|
cmd.CommandText = sql;
|
||||||
|
cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
|
||||||
|
|
||||||
|
using (IDataReader r = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
int v = Convert.ToInt32(r[name]);
|
if (r.Read())
|
||||||
if (v != 0)
|
{
|
||||||
m_FieldMap[name].SetValue(es, true);
|
migration = false;
|
||||||
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);
|
foreach (string name in FieldList)
|
||||||
m_FieldMap[name].SetValue(es, uuid);
|
{
|
||||||
}
|
if (m_FieldMap[name].GetValue(es) is bool)
|
||||||
else
|
{
|
||||||
{
|
int v = Convert.ToInt32(r[name]);
|
||||||
m_FieldMap[name].SetValue(es, r[name]);
|
if (v != 0)
|
||||||
}
|
m_FieldMap[name].SetValue(es, true);
|
||||||
}
|
else
|
||||||
r.Close();
|
m_FieldMap[name].SetValue(es, false);
|
||||||
}
|
}
|
||||||
else
|
else if (m_FieldMap[name].GetValue(es) is UUID)
|
||||||
{
|
{
|
||||||
// Migration case
|
UUID uuid = UUID.Zero;
|
||||||
//
|
|
||||||
r.Close();
|
|
||||||
|
|
||||||
List<string> names = new List<string>(FieldList);
|
UUID.TryParse(r[name].ToString(), out uuid);
|
||||||
|
m_FieldMap[name].SetValue(es, uuid);
|
||||||
names.Remove("EstateID");
|
}
|
||||||
|
else
|
||||||
sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")";
|
{
|
||||||
|
m_FieldMap[name].SetValue(es, r[name]);
|
||||||
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();
|
if (migration)
|
||||||
|
|
||||||
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();
|
// Migration case
|
||||||
}
|
List<string> names = new List<string>(FieldList);
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Munge and transfer the ban list
|
names.Remove("EstateID");
|
||||||
//
|
|
||||||
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
|
sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")";
|
||||||
{
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
es.Save();
|
using (MySqlCommand cmd = dbcon.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);
|
LoadBanList(es);
|
||||||
|
@ -265,29 +245,33 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
string sql = "replace into estate_settings (" + String.Join(",", FieldList) + ") values ( ?" + String.Join(", ?", FieldList) + ")";
|
string sql = "replace into estate_settings (" + String.Join(",", FieldList) + ") values ( ?" + String.Join(", ?", FieldList) + ")";
|
||||||
|
|
||||||
CheckConnection();
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
|
|
||||||
MySqlCommand cmd = m_connection.CreateCommand();
|
|
||||||
|
|
||||||
cmd.CommandText = sql;
|
|
||||||
|
|
||||||
foreach (string name in FieldList)
|
|
||||||
{
|
{
|
||||||
if (m_FieldMap[name].GetValue(es) is bool)
|
dbcon.Open();
|
||||||
|
|
||||||
|
using (MySqlCommand cmd = dbcon.CreateCommand())
|
||||||
{
|
{
|
||||||
if ((bool)m_FieldMap[name].GetValue(es))
|
cmd.CommandText = sql;
|
||||||
cmd.Parameters.AddWithValue("?" + name, "1");
|
|
||||||
else
|
foreach (string name in FieldList)
|
||||||
cmd.Parameters.AddWithValue("?" + name, "0");
|
{
|
||||||
}
|
if (m_FieldMap[name].GetValue(es) is bool)
|
||||||
else
|
{
|
||||||
{
|
if ((bool)m_FieldMap[name].GetValue(es))
|
||||||
cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString());
|
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.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);
|
||||||
|
@ -298,77 +282,89 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
es.ClearBans();
|
es.ClearBans();
|
||||||
|
|
||||||
CheckConnection();
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
|
|
||||||
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();
|
dbcon.Open();
|
||||||
|
|
||||||
UUID uuid = new UUID();
|
using (MySqlCommand cmd = dbcon.CreateCommand())
|
||||||
UUID.TryParse(r["bannedUUID"].ToString(), out uuid);
|
{
|
||||||
|
cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID";
|
||||||
|
cmd.Parameters.AddWithValue("?EstateID", es.EstateID);
|
||||||
|
|
||||||
eb.BannedUserID = uuid;
|
using (IDataReader r = cmd.ExecuteReader())
|
||||||
eb.BannedHostAddress = "0.0.0.0";
|
{
|
||||||
eb.BannedHostIPMask = "0.0.0.0";
|
while (r.Read())
|
||||||
es.AddBan(eb);
|
{
|
||||||
|
EstateBan eb = new EstateBan();
|
||||||
|
|
||||||
|
UUID uuid = new UUID();
|
||||||
|
UUID.TryParse(r["bannedUUID"].ToString(), out uuid);
|
||||||
|
|
||||||
|
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();
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
|
|
||||||
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.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
|
dbcon.Open();
|
||||||
cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString());
|
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
using (MySqlCommand cmd = dbcon.CreateCommand())
|
||||||
cmd.Parameters.Clear();
|
{
|
||||||
|
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.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString());
|
||||||
|
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
cmd.Parameters.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveUUIDList(uint EstateID, string table, UUID[] data)
|
void SaveUUIDList(uint EstateID, string table, UUID[] data)
|
||||||
{
|
{
|
||||||
CheckConnection();
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
|
|
||||||
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.Parameters.AddWithValue("?EstateID", EstateID.ToString());
|
dbcon.Open();
|
||||||
cmd.Parameters.AddWithValue("?uuid", uuid.ToString());
|
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
using (MySqlCommand cmd = dbcon.CreateCommand())
|
||||||
cmd.Parameters.Clear();
|
{
|
||||||
|
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.Parameters.AddWithValue("?EstateID", EstateID.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?uuid", uuid.ToString());
|
||||||
|
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
cmd.Parameters.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,25 +372,29 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
List<UUID> uuids = new List<UUID>();
|
List<UUID> uuids = new List<UUID>();
|
||||||
|
|
||||||
CheckConnection();
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
|
|
||||||
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();
|
dbcon.Open();
|
||||||
|
|
||||||
UUID uuid = new UUID();
|
using (MySqlCommand cmd = dbcon.CreateCommand())
|
||||||
UUID.TryParse(r["uuid"].ToString(), out uuid);
|
{
|
||||||
|
cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID";
|
||||||
|
cmd.Parameters.AddWithValue("?EstateID", EstateID);
|
||||||
|
|
||||||
uuids.Add(uuid);
|
using (IDataReader r = cmd.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (r.Read())
|
||||||
|
{
|
||||||
|
// EstateBan eb = new EstateBan();
|
||||||
|
|
||||||
|
UUID uuid = new UUID();
|
||||||
|
UUID.TryParse(r["uuid"].ToString(), out uuid);
|
||||||
|
|
||||||
|
uuids.Add(uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
r.Close();
|
|
||||||
|
|
||||||
return uuids.ToArray();
|
return uuids.ToArray();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,12 +40,16 @@ namespace OpenSim.Data.MySQL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MySqlFramework
|
public class MySqlFramework
|
||||||
{
|
{
|
||||||
protected MySqlConnection m_Connection;
|
private static readonly log4net.ILog m_log =
|
||||||
|
log4net.LogManager.GetLogger(
|
||||||
|
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
protected string m_connectionString;
|
||||||
|
protected object m_dbLock = new object();
|
||||||
|
|
||||||
protected MySqlFramework(string connectionString)
|
protected MySqlFramework(string connectionString)
|
||||||
{
|
{
|
||||||
m_Connection = new MySqlConnection(connectionString);
|
m_connectionString = connectionString;
|
||||||
m_Connection.Open();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
|
@ -55,64 +59,24 @@ namespace OpenSim.Data.MySQL
|
||||||
//
|
//
|
||||||
protected int ExecuteNonQuery(MySqlCommand cmd)
|
protected int ExecuteNonQuery(MySqlCommand cmd)
|
||||||
{
|
{
|
||||||
lock (m_Connection)
|
lock (m_dbLock)
|
||||||
{
|
{
|
||||||
cmd.Connection = m_Connection;
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
|
|
||||||
bool errorSeen = false;
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
cmd.Connection = dbcon;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return cmd.ExecuteNonQuery();
|
return cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
|
||||||
{
|
|
||||||
if (errorSeen)
|
|
||||||
throw;
|
|
||||||
|
|
||||||
// This is "Server has gone away" and "Server lost"
|
|
||||||
//
|
|
||||||
if (e.Number == 2006 || e.Number == 2013)
|
|
||||||
{
|
|
||||||
errorSeen = true;
|
|
||||||
|
|
||||||
m_Connection.Close();
|
|
||||||
MySqlConnection newConnection =
|
|
||||||
(MySqlConnection)((ICloneable)m_Connection).Clone();
|
|
||||||
m_Connection.Dispose();
|
|
||||||
m_Connection = newConnection;
|
|
||||||
m_Connection.Open();
|
|
||||||
|
|
||||||
cmd.Connection = m_Connection;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
m_log.Error(e.Message, e);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IDataReader ExecuteReader(MySqlCommand cmd)
|
|
||||||
{
|
|
||||||
MySqlConnection newConnection =
|
|
||||||
(MySqlConnection)((ICloneable)m_Connection).Clone();
|
|
||||||
newConnection.Open();
|
|
||||||
|
|
||||||
cmd.Connection = newConnection;
|
|
||||||
return cmd.ExecuteReader();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void CloseReaderCommand(MySqlCommand cmd)
|
|
||||||
{
|
|
||||||
cmd.Connection.Close();
|
|
||||||
cmd.Connection.Dispose();
|
|
||||||
cmd.Dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,12 +54,16 @@ namespace OpenSim.Data.MySQL
|
||||||
string realm, string storeName) : base(connectionString)
|
string realm, string storeName) : base(connectionString)
|
||||||
{
|
{
|
||||||
m_Realm = realm;
|
m_Realm = realm;
|
||||||
|
m_connectionString = connectionString;
|
||||||
|
|
||||||
if (storeName != String.Empty)
|
if (storeName != String.Empty)
|
||||||
{
|
{
|
||||||
Assembly assem = GetType().Assembly;
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
|
{
|
||||||
Migration m = new Migration(m_Connection, assem, storeName);
|
dbcon.Open();
|
||||||
m.Update();
|
Migration m = new Migration(dbcon, GetType().Assembly, storeName);
|
||||||
|
m.Update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Type t = typeof(T);
|
Type t = typeof(T);
|
||||||
|
@ -107,147 +111,160 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
List<string> terms = new List<string>();
|
List<string> terms = new List<string>();
|
||||||
|
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
using (MySqlCommand cmd = new MySqlCommand())
|
||||||
|
|
||||||
for (int i = 0 ; i < fields.Length ; i++)
|
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue(fields[i], keys[i]);
|
for (int i = 0 ; i < fields.Length ; i++)
|
||||||
terms.Add("`" + fields[i] + "` = ?" + fields[i]);
|
{
|
||||||
|
cmd.Parameters.AddWithValue(fields[i], keys[i]);
|
||||||
|
terms.Add("`" + fields[i] + "` = ?" + fields[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
string where = String.Join(" and ", terms.ToArray());
|
||||||
|
|
||||||
|
string query = String.Format("select * from {0} where {1}",
|
||||||
|
m_Realm, where);
|
||||||
|
|
||||||
|
cmd.CommandText = query;
|
||||||
|
|
||||||
|
return DoQuery(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
string where = String.Join(" and ", terms.ToArray());
|
|
||||||
|
|
||||||
string query = String.Format("select * from {0} where {1}",
|
|
||||||
m_Realm, where);
|
|
||||||
|
|
||||||
cmd.CommandText = query;
|
|
||||||
|
|
||||||
return DoQuery(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected T[] DoQuery(MySqlCommand cmd)
|
protected T[] DoQuery(MySqlCommand cmd)
|
||||||
{
|
{
|
||||||
IDataReader reader = ExecuteReader(cmd);
|
|
||||||
if (reader == null)
|
|
||||||
return new T[0];
|
|
||||||
|
|
||||||
CheckColumnNames(reader);
|
|
||||||
|
|
||||||
List<T> result = new List<T>();
|
List<T> result = new List<T>();
|
||||||
|
|
||||||
while (reader.Read())
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
{
|
{
|
||||||
T row = new T();
|
dbcon.Open();
|
||||||
|
cmd.Connection = dbcon;
|
||||||
|
|
||||||
foreach (string name in m_Fields.Keys)
|
using (IDataReader reader = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
if (m_Fields[name].GetValue(row) is bool)
|
if (reader == null)
|
||||||
{
|
return new T[0];
|
||||||
int v = Convert.ToInt32(reader[name]);
|
|
||||||
m_Fields[name].SetValue(row, v != 0 ? true : false);
|
|
||||||
}
|
|
||||||
else if (m_Fields[name].GetValue(row) is UUID)
|
|
||||||
{
|
|
||||||
UUID uuid = UUID.Zero;
|
|
||||||
|
|
||||||
UUID.TryParse(reader[name].ToString(), out uuid);
|
CheckColumnNames(reader);
|
||||||
m_Fields[name].SetValue(row, uuid);
|
|
||||||
}
|
while (reader.Read())
|
||||||
else if (m_Fields[name].GetValue(row) is int)
|
|
||||||
{
|
{
|
||||||
int v = Convert.ToInt32(reader[name]);
|
T row = new T();
|
||||||
m_Fields[name].SetValue(row, v);
|
|
||||||
}
|
foreach (string name in m_Fields.Keys)
|
||||||
else
|
{
|
||||||
{
|
if (m_Fields[name].GetValue(row) is bool)
|
||||||
m_Fields[name].SetValue(row, reader[name]);
|
{
|
||||||
}
|
int v = Convert.ToInt32(reader[name]);
|
||||||
}
|
m_Fields[name].SetValue(row, v != 0 ? true : false);
|
||||||
|
}
|
||||||
|
else if (m_Fields[name].GetValue(row) is UUID)
|
||||||
|
{
|
||||||
|
UUID uuid = UUID.Zero;
|
||||||
|
|
||||||
|
UUID.TryParse(reader[name].ToString(), out uuid);
|
||||||
|
m_Fields[name].SetValue(row, uuid);
|
||||||
|
}
|
||||||
|
else if (m_Fields[name].GetValue(row) is int)
|
||||||
|
{
|
||||||
|
int v = Convert.ToInt32(reader[name]);
|
||||||
|
m_Fields[name].SetValue(row, v);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_Fields[name].SetValue(row, reader[name]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_DataField != null)
|
if (m_DataField != null)
|
||||||
{
|
{
|
||||||
Dictionary<string, string> data =
|
Dictionary<string, string> data =
|
||||||
new Dictionary<string, string>();
|
new Dictionary<string, string>();
|
||||||
|
|
||||||
foreach (string col in m_ColumnNames)
|
foreach (string col in m_ColumnNames)
|
||||||
{
|
{
|
||||||
data[col] = reader[col].ToString();
|
data[col] = reader[col].ToString();
|
||||||
if (data[col] == null)
|
if (data[col] == null)
|
||||||
data[col] = String.Empty;
|
data[col] = String.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_DataField.SetValue(row, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.Add(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_DataField.SetValue(row, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Add(row);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseReaderCommand(cmd);
|
|
||||||
|
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public T[] Get(string where)
|
public T[] Get(string where)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
using (MySqlCommand cmd = new MySqlCommand())
|
||||||
|
{
|
||||||
string query = String.Format("select * from {0} where {1}",
|
|
||||||
m_Realm, where);
|
string query = String.Format("select * from {0} where {1}",
|
||||||
|
m_Realm, where);
|
||||||
cmd.CommandText = query;
|
|
||||||
|
cmd.CommandText = query;
|
||||||
return DoQuery(cmd);
|
|
||||||
|
return DoQuery(cmd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Store(T row)
|
public bool Store(T row)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
using (MySqlCommand cmd = new MySqlCommand())
|
||||||
|
|
||||||
string query = "";
|
|
||||||
List<String> names = new List<String>();
|
|
||||||
List<String> values = new List<String>();
|
|
||||||
|
|
||||||
foreach (FieldInfo fi in m_Fields.Values)
|
|
||||||
{
|
{
|
||||||
names.Add(fi.Name);
|
|
||||||
values.Add("?" + fi.Name);
|
|
||||||
cmd.Parameters.AddWithValue(fi.Name, fi.GetValue(row).ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_DataField != null)
|
string query = "";
|
||||||
{
|
List<String> names = new List<String>();
|
||||||
Dictionary<string, string> data =
|
List<String> values = new List<String>();
|
||||||
|
|
||||||
|
foreach (FieldInfo fi in m_Fields.Values)
|
||||||
|
{
|
||||||
|
names.Add(fi.Name);
|
||||||
|
values.Add("?" + fi.Name);
|
||||||
|
cmd.Parameters.AddWithValue(fi.Name, fi.GetValue(row).ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_DataField != null)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> data =
|
||||||
(Dictionary<string, string>)m_DataField.GetValue(row);
|
(Dictionary<string, string>)m_DataField.GetValue(row);
|
||||||
|
|
||||||
foreach (KeyValuePair<string, string> kvp in data)
|
foreach (KeyValuePair<string, string> kvp in data)
|
||||||
{
|
{
|
||||||
names.Add(kvp.Key);
|
names.Add(kvp.Key);
|
||||||
values.Add("?" + kvp.Key);
|
values.Add("?" + kvp.Key);
|
||||||
cmd.Parameters.AddWithValue("?" + kvp.Key, kvp.Value);
|
cmd.Parameters.AddWithValue("?" + kvp.Key, kvp.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")";
|
||||||
|
|
||||||
|
cmd.CommandText = query;
|
||||||
|
|
||||||
|
if (ExecuteNonQuery(cmd) > 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")";
|
|
||||||
|
|
||||||
cmd.CommandText = query;
|
|
||||||
|
|
||||||
if (ExecuteNonQuery(cmd) > 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Delete(string field, string val)
|
public bool Delete(string field, string val)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
using (MySqlCommand cmd = new MySqlCommand())
|
||||||
|
{
|
||||||
|
|
||||||
cmd.CommandText = String.Format("delete from {0} where `{1}` = ?{1}", m_Realm, field);
|
cmd.CommandText = String.Format("delete from {0} where `{1}` = ?{1}", m_Realm, field);
|
||||||
cmd.Parameters.AddWithValue(field, val);
|
cmd.Parameters.AddWithValue(field, val);
|
||||||
|
|
||||||
if (ExecuteNonQuery(cmd) > 0)
|
if (ExecuteNonQuery(cmd) > 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ using System.Data;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
|
||||||
|
@ -43,49 +44,9 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
/// <summary>
|
private MySQLManager m_database;
|
||||||
/// MySQL Database Manager
|
private object m_dbLock = new object();
|
||||||
/// </summary>
|
private string m_connectionString;
|
||||||
private MySQLManager database;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Better DB manager. Swap-in replacement too.
|
|
||||||
/// </summary>
|
|
||||||
public Dictionary<int, MySQLSuperManager> m_dbconnections = new Dictionary<int, MySQLSuperManager>();
|
|
||||||
|
|
||||||
public int m_maxConnections = 10;
|
|
||||||
public int m_lastConnect;
|
|
||||||
|
|
||||||
public MySQLSuperManager GetLockedConnection()
|
|
||||||
{
|
|
||||||
int lockedCons = 0;
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
m_lastConnect++;
|
|
||||||
|
|
||||||
// Overflow protection
|
|
||||||
if (m_lastConnect == int.MaxValue)
|
|
||||||
m_lastConnect = 0;
|
|
||||||
|
|
||||||
MySQLSuperManager x = m_dbconnections[m_lastConnect % m_maxConnections];
|
|
||||||
if (!x.Locked)
|
|
||||||
{
|
|
||||||
x.GetLock();
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
lockedCons++;
|
|
||||||
if (lockedCons > m_maxConnections)
|
|
||||||
{
|
|
||||||
lockedCons = 0;
|
|
||||||
Thread.Sleep(1000); // Wait some time before searching them again.
|
|
||||||
m_log.Debug(
|
|
||||||
"WARNING: All threads are in use. Probable cause: Something didnt release a mutex properly, or high volume of requests inbound.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override public void Initialise()
|
override public void Initialise()
|
||||||
{
|
{
|
||||||
|
@ -106,49 +67,17 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <param name="connect">connect string.</param>
|
/// <param name="connect">connect string.</param>
|
||||||
override public void Initialise(string connect)
|
override public void Initialise(string connect)
|
||||||
{
|
{
|
||||||
if (connect != String.Empty)
|
m_connectionString = connect;
|
||||||
{
|
m_database = new MySQLManager(connect);
|
||||||
database = new MySQLManager(connect);
|
|
||||||
|
|
||||||
m_log.Info("Creating " + m_maxConnections + " DB connections...");
|
|
||||||
for (int i = 0; i < m_maxConnections; i++)
|
|
||||||
{
|
|
||||||
m_log.Info("Connecting to DB... [" + i + "]");
|
|
||||||
MySQLSuperManager msm = new MySQLSuperManager();
|
|
||||||
msm.Manager = new MySQLManager(connect);
|
|
||||||
m_dbconnections.Add(i, msm);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.xml and we'll use that instead");
|
|
||||||
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
|
|
||||||
string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
|
|
||||||
string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
|
|
||||||
string settingUsername = GridDataMySqlFile.ParseFileReadValue("username");
|
|
||||||
string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
|
|
||||||
string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
|
|
||||||
string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
|
|
||||||
|
|
||||||
database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword,
|
|
||||||
settingPooling, settingPort);
|
|
||||||
|
|
||||||
m_log.Info("Creating " + m_maxConnections + " DB connections...");
|
|
||||||
for (int i = 0; i < m_maxConnections; i++)
|
|
||||||
{
|
|
||||||
m_log.Info("Connecting to DB... [" + i + "]");
|
|
||||||
MySQLSuperManager msm = new MySQLSuperManager();
|
|
||||||
msm.Manager = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword,
|
|
||||||
settingPooling, settingPort);
|
|
||||||
m_dbconnections.Add(i, msm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This actually does the roll forward assembly stuff
|
// This actually does the roll forward assembly stuff
|
||||||
Assembly assem = GetType().Assembly;
|
Assembly assem = GetType().Assembly;
|
||||||
Migration m = new Migration(database.Connection, assem, "GridStore");
|
|
||||||
m.Update();
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
|
{
|
||||||
|
Migration m = new Migration(dbcon, assem, "GridStore");
|
||||||
|
m.Update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -156,7 +85,6 @@ namespace OpenSim.Data.MySQL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
override public void Dispose()
|
override public void Dispose()
|
||||||
{
|
{
|
||||||
database.Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -187,8 +115,6 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <returns>Array of sim profiles</returns>
|
/// <returns>Array of sim profiles</returns>
|
||||||
override public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax)
|
override public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax)
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||||
|
@ -197,35 +123,33 @@ namespace OpenSim.Data.MySQL
|
||||||
param["?xmax"] = xmax.ToString();
|
param["?xmax"] = xmax.ToString();
|
||||||
param["?ymax"] = ymax.ToString();
|
param["?ymax"] = ymax.ToString();
|
||||||
|
|
||||||
IDbCommand result =
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
dbm.Manager.Query(
|
|
||||||
"SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax",
|
|
||||||
param);
|
|
||||||
IDataReader reader = result.ExecuteReader();
|
|
||||||
|
|
||||||
RegionProfileData row;
|
|
||||||
|
|
||||||
List<RegionProfileData> rows = new List<RegionProfileData>();
|
|
||||||
|
|
||||||
while ((row = dbm.Manager.readSimRow(reader)) != null)
|
|
||||||
{
|
{
|
||||||
rows.Add(row);
|
dbcon.Open();
|
||||||
}
|
|
||||||
reader.Close();
|
|
||||||
result.Dispose();
|
|
||||||
|
|
||||||
return rows.ToArray();
|
using (IDbCommand result = m_database.Query(dbcon,
|
||||||
|
"SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax",
|
||||||
|
param))
|
||||||
|
{
|
||||||
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
|
{
|
||||||
|
RegionProfileData row;
|
||||||
|
|
||||||
|
List<RegionProfileData> rows = new List<RegionProfileData>();
|
||||||
|
|
||||||
|
while ((row = m_database.readSimRow(reader)) != null)
|
||||||
|
rows.Add(row);
|
||||||
|
|
||||||
|
return rows.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -236,42 +160,38 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <returns>A list of sim profiles</returns>
|
/// <returns>A list of sim profiles</returns>
|
||||||
override public List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum)
|
override public List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum)
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
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 (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
dbm.Manager.Query(
|
|
||||||
"SELECT * FROM regions WHERE regionName LIKE ?name",
|
|
||||||
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);
|
dbcon.Open();
|
||||||
}
|
|
||||||
reader.Close();
|
|
||||||
result.Dispose();
|
|
||||||
|
|
||||||
return rows;
|
using (IDbCommand result = m_database.Query(dbcon,
|
||||||
|
"SELECT * FROM regions WHERE regionName LIKE ?name",
|
||||||
|
param))
|
||||||
|
{
|
||||||
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
|
{
|
||||||
|
RegionProfileData row;
|
||||||
|
|
||||||
|
List<RegionProfileData> rows = new List<RegionProfileData>();
|
||||||
|
|
||||||
|
while (rows.Count < maxNum && (row = m_database.readSimRow(reader)) != null)
|
||||||
|
rows.Add(row);
|
||||||
|
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -281,32 +201,30 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <returns>Sim profile</returns>
|
/// <returns>Sim profile</returns>
|
||||||
override public RegionProfileData GetProfileByHandle(ulong handle)
|
override public RegionProfileData GetProfileByHandle(ulong handle)
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection();
|
|
||||||
|
|
||||||
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 (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
IDataReader reader = result.ExecuteReader();
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
|
||||||
RegionProfileData row = dbm.Manager.readSimRow(reader);
|
using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM regions WHERE regionHandle = ?handle", param))
|
||||||
reader.Close();
|
{
|
||||||
result.Dispose();
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
|
{
|
||||||
return row;
|
RegionProfileData row = m_database.readSimRow(reader);
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -316,30 +234,29 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <returns>The sim profile</returns>
|
/// <returns>The sim profile</returns>
|
||||||
override public RegionProfileData GetProfileByUUID(UUID uuid)
|
override public RegionProfileData GetProfileByUUID(UUID uuid)
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection();
|
|
||||||
|
|
||||||
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 (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
IDataReader reader = result.ExecuteReader();
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
|
||||||
RegionProfileData row = dbm.Manager.readSimRow(reader);
|
using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM regions WHERE uuid = ?uuid", param))
|
||||||
reader.Close();
|
{
|
||||||
result.Dispose();
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
|
{
|
||||||
return row;
|
RegionProfileData row = m_database.readSimRow(reader);
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return null;
|
return null;
|
||||||
} finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,37 +268,36 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
if (regionName.Length > 2)
|
if (regionName.Length > 2)
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||||
// 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.
|
|
||||||
IDbCommand result =
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
dbm.Manager.Query(
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
|
||||||
|
// Order by statement will return shorter matches first. Only returns one record or no record.
|
||||||
|
using (IDbCommand result = m_database.Query(dbcon,
|
||||||
"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);
|
{
|
||||||
reader.Close();
|
RegionProfileData row = m_database.readSimRow(reader);
|
||||||
result.Dispose();
|
return row;
|
||||||
|
}
|
||||||
return row;
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -393,17 +309,16 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <returns>Successful?</returns>
|
/// <returns>Successful?</returns>
|
||||||
override public DataResponse StoreProfile(RegionProfileData profile)
|
override public DataResponse StoreProfile(RegionProfileData profile)
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection();
|
try
|
||||||
try {
|
|
||||||
if (dbm.Manager.insertRegion(profile))
|
|
||||||
{
|
|
||||||
return DataResponse.RESPONSE_OK;
|
|
||||||
}
|
|
||||||
return DataResponse.RESPONSE_ERROR;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
{
|
||||||
dbm.Release();
|
if (m_database.insertRegion(profile))
|
||||||
|
return DataResponse.RESPONSE_OK;
|
||||||
|
else
|
||||||
|
return DataResponse.RESPONSE_ERROR;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return DataResponse.RESPONSE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,18 +330,16 @@ namespace OpenSim.Data.MySQL
|
||||||
//public DataResponse DeleteProfile(RegionProfileData profile)
|
//public DataResponse DeleteProfile(RegionProfileData profile)
|
||||||
override public DataResponse DeleteProfile(string uuid)
|
override public DataResponse DeleteProfile(string uuid)
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection();
|
try
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (dbm.Manager.deleteRegion(uuid))
|
|
||||||
{
|
|
||||||
return DataResponse.RESPONSE_OK;
|
|
||||||
}
|
|
||||||
return DataResponse.RESPONSE_ERROR;
|
|
||||||
} finally
|
|
||||||
{
|
{
|
||||||
dbm.Release();
|
if (m_database.deleteRegion(uuid))
|
||||||
|
return DataResponse.RESPONSE_OK;
|
||||||
|
else
|
||||||
|
return DataResponse.RESPONSE_ERROR;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return DataResponse.RESPONSE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,33 +390,32 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
override public ReservationData GetReservationAtPoint(uint x, uint y)
|
override public ReservationData GetReservationAtPoint(uint x, uint y)
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection();
|
|
||||||
|
|
||||||
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 =
|
|
||||||
dbm.Manager.Query(
|
|
||||||
"SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y",
|
|
||||||
param);
|
|
||||||
IDataReader reader = result.ExecuteReader();
|
|
||||||
|
|
||||||
ReservationData row = dbm.Manager.readReservationRow(reader);
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
reader.Close();
|
{
|
||||||
result.Dispose();
|
dbcon.Open();
|
||||||
|
|
||||||
return row;
|
using (IDbCommand result = m_database.Query(dbcon,
|
||||||
|
"SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y",
|
||||||
|
param))
|
||||||
|
{
|
||||||
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
|
{
|
||||||
|
ReservationData row = m_database.readReservationRow(reader);
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return null;
|
return null;
|
||||||
} finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -79,14 +79,19 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
// This actually does the roll forward assembly stuff
|
// This actually does the roll forward assembly stuff
|
||||||
Assembly assem = GetType().Assembly;
|
Assembly assem = GetType().Assembly;
|
||||||
Migration m = new Migration(database.Connection, assem, "LogStore");
|
|
||||||
|
|
||||||
// TODO: After rev 6000, remove this. People should have
|
using (MySql.Data.MySqlClient.MySqlConnection dbcon = new MySql.Data.MySqlClient.MySqlConnection(connect))
|
||||||
// been rolled onto the new migration code by then.
|
{
|
||||||
TestTables(m);
|
dbcon.Open();
|
||||||
|
|
||||||
m.Update();
|
Migration m = new Migration(dbcon, assem, "LogStore");
|
||||||
|
|
||||||
|
// TODO: After rev 6000, remove this. People should have
|
||||||
|
// been rolled onto the new migration code by then.
|
||||||
|
TestTables(m);
|
||||||
|
|
||||||
|
m.Update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary></summary>
|
/// <summary></summary>
|
||||||
|
@ -128,7 +133,6 @@ namespace OpenSim.Data.MySQL
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
database.Reconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,16 +45,13 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The database connection object
|
|
||||||
/// </summary>
|
|
||||||
private MySqlConnection dbcon;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Connection string for ADO.net
|
/// Connection string for ADO.net
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private string connectionString;
|
private string connectionString;
|
||||||
|
|
||||||
|
private object m_dbLock = new object();
|
||||||
|
|
||||||
private const string m_waitTimeoutSelect = "select @@wait_timeout";
|
private const string m_waitTimeoutSelect = "select @@wait_timeout";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -109,11 +106,11 @@ namespace OpenSim.Data.MySQL
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
connectionString = connect;
|
connectionString = connect;
|
||||||
dbcon = new MySqlConnection(connectionString);
|
//dbcon = new MySqlConnection(connectionString);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dbcon.Open();
|
//dbcon.Open();
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
|
@ -134,18 +131,21 @@ namespace OpenSim.Data.MySQL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void GetWaitTimeout()
|
protected void GetWaitTimeout()
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon);
|
using (MySqlConnection dbcon = new MySqlConnection(connectionString))
|
||||||
|
|
||||||
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
|
||||||
{
|
{
|
||||||
if (dbReader.Read())
|
dbcon.Open();
|
||||||
{
|
|
||||||
m_waitTimeout
|
|
||||||
= Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbReader.Close();
|
using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon))
|
||||||
cmd.Dispose();
|
{
|
||||||
|
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||||
|
{
|
||||||
|
if (dbReader.Read())
|
||||||
|
{
|
||||||
|
m_waitTimeout
|
||||||
|
= Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lastConnectionUse = DateTime.Now.Ticks;
|
m_lastConnectionUse = DateTime.Now.Ticks;
|
||||||
|
@ -154,66 +154,9 @@ namespace OpenSim.Data.MySQL
|
||||||
"[REGION DB]: Connection wait timeout {0} seconds", m_waitTimeout / TimeSpan.TicksPerSecond);
|
"[REGION DB]: Connection wait timeout {0} seconds", m_waitTimeout / TimeSpan.TicksPerSecond);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public string ConnectionString
|
||||||
/// Should be called before any db operation. This checks to see if the connection has not timed out
|
|
||||||
/// </summary>
|
|
||||||
public void CheckConnection()
|
|
||||||
{
|
{
|
||||||
//m_log.Debug("[REGION DB]: Checking connection");
|
get { return connectionString; }
|
||||||
|
|
||||||
long timeNow = DateTime.Now.Ticks;
|
|
||||||
if (timeNow - m_lastConnectionUse > m_waitTimeout || dbcon.State != ConnectionState.Open)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting");
|
|
||||||
Reconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strictly, we should set this after the actual db operation. But it's more convenient to set here rather
|
|
||||||
// than require the code to call another method - the timeout leeway should be large enough to cover the
|
|
||||||
// inaccuracy.
|
|
||||||
m_lastConnectionUse = timeNow;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get the connection being used
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>MySqlConnection Object</returns>
|
|
||||||
public MySqlConnection Connection
|
|
||||||
{
|
|
||||||
get { return dbcon; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Shuts down the database connection
|
|
||||||
/// </summary>
|
|
||||||
public void Close()
|
|
||||||
{
|
|
||||||
dbcon.Close();
|
|
||||||
dbcon = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Reconnects to the database
|
|
||||||
/// </summary>
|
|
||||||
public void Reconnect()
|
|
||||||
{
|
|
||||||
m_log.Info("[REGION DB] Reconnecting database");
|
|
||||||
|
|
||||||
lock (dbcon)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Close the DB connection
|
|
||||||
dbcon.Close();
|
|
||||||
// Try reopen it
|
|
||||||
dbcon = new MySqlConnection(connectionString);
|
|
||||||
dbcon.Open();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error("Unable to reconnect to database " + e.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -264,9 +207,13 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <param name="name">name of embedded resource</param>
|
/// <param name="name">name of embedded resource</param>
|
||||||
public void ExecuteResourceSql(string name)
|
public void ExecuteResourceSql(string name)
|
||||||
{
|
{
|
||||||
CheckConnection();
|
using (MySqlConnection dbcon = new MySqlConnection(connectionString))
|
||||||
MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon);
|
{
|
||||||
cmd.ExecuteNonQuery();
|
dbcon.Open();
|
||||||
|
|
||||||
|
MySqlCommand cmd = new MySqlCommand(getResourceString(name), dbcon);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -275,22 +222,29 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <param name="sql">sql string to execute</param>
|
/// <param name="sql">sql string to execute</param>
|
||||||
public void ExecuteSql(string sql)
|
public void ExecuteSql(string sql)
|
||||||
{
|
{
|
||||||
CheckConnection();
|
using (MySqlConnection dbcon = new MySqlConnection(connectionString))
|
||||||
MySqlCommand cmd = new MySqlCommand(sql, dbcon);
|
{
|
||||||
cmd.ExecuteNonQuery();
|
dbcon.Open();
|
||||||
|
|
||||||
|
MySqlCommand cmd = new MySqlCommand(sql, dbcon);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ExecuteParameterizedSql(string sql, Dictionary<string, string> parameters)
|
public void ExecuteParameterizedSql(string sql, Dictionary<string, string> parameters)
|
||||||
{
|
{
|
||||||
CheckConnection();
|
using (MySqlConnection dbcon = new MySqlConnection(connectionString))
|
||||||
|
|
||||||
MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand();
|
|
||||||
cmd.CommandText = sql;
|
|
||||||
foreach (KeyValuePair<string, string> param in parameters)
|
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue(param.Key, param.Value);
|
dbcon.Open();
|
||||||
|
|
||||||
|
MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand();
|
||||||
|
cmd.CommandText = sql;
|
||||||
|
foreach (KeyValuePair<string, string> param in parameters)
|
||||||
|
{
|
||||||
|
cmd.Parameters.AddWithValue(param.Key, param.Value);
|
||||||
|
}
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -299,35 +253,37 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <param name="tableList"></param>
|
/// <param name="tableList"></param>
|
||||||
public void GetTableVersion(Dictionary<string, string> tableList)
|
public void GetTableVersion(Dictionary<string, string> tableList)
|
||||||
{
|
{
|
||||||
lock (dbcon)
|
lock (m_dbLock)
|
||||||
{
|
{
|
||||||
CheckConnection();
|
using (MySqlConnection dbcon = new MySqlConnection(connectionString))
|
||||||
|
|
||||||
MySqlCommand tablesCmd =
|
|
||||||
new MySqlCommand(
|
|
||||||
"SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname",
|
|
||||||
dbcon);
|
|
||||||
tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database);
|
|
||||||
|
|
||||||
using (MySqlDataReader tables = tablesCmd.ExecuteReader())
|
|
||||||
{
|
{
|
||||||
while (tables.Read())
|
dbcon.Open();
|
||||||
|
|
||||||
|
using (MySqlCommand tablesCmd = new MySqlCommand(
|
||||||
|
"SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", dbcon))
|
||||||
{
|
{
|
||||||
try
|
tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database);
|
||||||
|
|
||||||
|
using (MySqlDataReader tables = tablesCmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
string tableName = (string) tables["TABLE_NAME"];
|
while (tables.Read())
|
||||||
string comment = (string) tables["TABLE_COMMENT"];
|
|
||||||
if (tableList.ContainsKey(tableName))
|
|
||||||
{
|
{
|
||||||
tableList[tableName] = comment;
|
try
|
||||||
|
{
|
||||||
|
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,28 +293,27 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Runs a query with protection against SQL Injection by using parameterised input.
|
/// Runs a query with protection against SQL Injection by using parameterised input.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="dbcon">Database connection</param>
|
||||||
/// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param>
|
/// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param>
|
||||||
/// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param>
|
/// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param>
|
||||||
/// <returns>A MySQL DB Command</returns>
|
/// <returns>A MySQL DB Command</returns>
|
||||||
public IDbCommand Query(string sql, Dictionary<string, object> parameters)
|
public IDbCommand Query(MySqlConnection dbcon, string sql, Dictionary<string, object> parameters)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
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 +649,6 @@ namespace OpenSim.Data.MySQL
|
||||||
ret.Add(attachpoint, item);
|
ret.Add(attachpoint, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Close();
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -727,12 +680,17 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IDbCommand result = Query(sql, parameters);
|
using (MySqlConnection dbcon = new MySqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
|
||||||
if (result.ExecuteNonQuery() == 1)
|
IDbCommand result = Query(dbcon, sql, parameters);
|
||||||
returnval = true;
|
|
||||||
|
|
||||||
result.Dispose();
|
if (result.ExecuteNonQuery() == 1)
|
||||||
|
returnval = true;
|
||||||
|
|
||||||
|
result.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -778,7 +736,7 @@ namespace OpenSim.Data.MySQL
|
||||||
string aboutText, string firstText,
|
string aboutText, string firstText,
|
||||||
UUID profileImage, UUID firstImage, UUID webLoginKey, int userFlags, int godLevel, string customType, UUID partner)
|
UUID profileImage, UUID firstImage, UUID webLoginKey, int userFlags, int godLevel, string customType, UUID partner)
|
||||||
{
|
{
|
||||||
m_log.Debug("[MySQLManager]: Fetching profile for " + uuid.ToString());
|
m_log.Debug("[MySQLManager]: Creating profile for \"" + username + " " + lastname + "\" (" + uuid + ")");
|
||||||
string sql =
|
string sql =
|
||||||
"INSERT INTO users (`UUID`, `username`, `lastname`, `email`, `passwordHash`, `passwordSalt`, `homeRegion`, `homeRegionID`, ";
|
"INSERT INTO users (`UUID`, `username`, `lastname`, `email`, `passwordHash`, `passwordSalt`, `homeRegion`, `homeRegionID`, ";
|
||||||
sql +=
|
sql +=
|
||||||
|
@ -828,12 +786,17 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IDbCommand result = Query(sql, parameters);
|
using (MySqlConnection dbcon = new MySqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
|
||||||
if (result.ExecuteNonQuery() == 1)
|
IDbCommand result = Query(dbcon, sql, parameters);
|
||||||
returnval = true;
|
|
||||||
|
|
||||||
result.Dispose();
|
if (result.ExecuteNonQuery() == 1)
|
||||||
|
returnval = true;
|
||||||
|
|
||||||
|
result.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -927,12 +890,17 @@ namespace OpenSim.Data.MySQL
|
||||||
bool returnval = false;
|
bool returnval = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IDbCommand result = Query(sql, parameters);
|
using (MySqlConnection dbcon = new MySqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
|
||||||
if (result.ExecuteNonQuery() == 1)
|
IDbCommand result = Query(dbcon, sql, parameters);
|
||||||
returnval = true;
|
|
||||||
|
|
||||||
result.Dispose();
|
if (result.ExecuteNonQuery() == 1)
|
||||||
|
returnval = true;
|
||||||
|
|
||||||
|
result.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1030,18 +998,23 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IDbCommand result = Query(sql, parameters);
|
using (MySqlConnection dbcon = new MySqlConnection(connectionString))
|
||||||
|
|
||||||
// int x;
|
|
||||||
// if ((x = result.ExecuteNonQuery()) > 0)
|
|
||||||
// {
|
|
||||||
// returnval = true;
|
|
||||||
// }
|
|
||||||
if (result.ExecuteNonQuery() > 0)
|
|
||||||
{
|
{
|
||||||
returnval = true;
|
dbcon.Open();
|
||||||
|
|
||||||
|
IDbCommand result = Query(dbcon, sql, parameters);
|
||||||
|
|
||||||
|
// int x;
|
||||||
|
// if ((x = result.ExecuteNonQuery()) > 0)
|
||||||
|
// {
|
||||||
|
// returnval = true;
|
||||||
|
// }
|
||||||
|
if (result.ExecuteNonQuery() > 0)
|
||||||
|
{
|
||||||
|
returnval = true;
|
||||||
|
}
|
||||||
|
result.Dispose();
|
||||||
}
|
}
|
||||||
result.Dispose();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1070,18 +1043,23 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
parameters["?uuid"] = uuid;
|
parameters["?uuid"] = uuid;
|
||||||
|
|
||||||
IDbCommand result = Query(sql, parameters);
|
using (MySqlConnection dbcon = new MySqlConnection(connectionString))
|
||||||
|
|
||||||
// int x;
|
|
||||||
// if ((x = result.ExecuteNonQuery()) > 0)
|
|
||||||
// {
|
|
||||||
// returnval = true;
|
|
||||||
// }
|
|
||||||
if (result.ExecuteNonQuery() > 0)
|
|
||||||
{
|
{
|
||||||
returnval = true;
|
dbcon.Open();
|
||||||
|
|
||||||
|
IDbCommand result = Query(dbcon, sql, parameters);
|
||||||
|
|
||||||
|
// int x;
|
||||||
|
// if ((x = result.ExecuteNonQuery()) > 0)
|
||||||
|
// {
|
||||||
|
// returnval = true;
|
||||||
|
// }
|
||||||
|
if (result.ExecuteNonQuery() > 0)
|
||||||
|
{
|
||||||
|
returnval = true;
|
||||||
|
}
|
||||||
|
result.Dispose();
|
||||||
}
|
}
|
||||||
result.Dispose();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1122,18 +1100,23 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IDbCommand result = Query(sql, parameters);
|
using (MySqlConnection dbcon = new MySqlConnection(connectionString))
|
||||||
|
|
||||||
// int x;
|
|
||||||
// if ((x = result.ExecuteNonQuery()) > 0)
|
|
||||||
// {
|
|
||||||
// returnval = true;
|
|
||||||
// }
|
|
||||||
if (result.ExecuteNonQuery() > 0)
|
|
||||||
{
|
{
|
||||||
returnval = true;
|
dbcon.Open();
|
||||||
|
|
||||||
|
IDbCommand result = Query(dbcon, sql, parameters);
|
||||||
|
|
||||||
|
// int x;
|
||||||
|
// if ((x = result.ExecuteNonQuery()) > 0)
|
||||||
|
// {
|
||||||
|
// returnval = true;
|
||||||
|
// }
|
||||||
|
if (result.ExecuteNonQuery() > 0)
|
||||||
|
{
|
||||||
|
returnval = true;
|
||||||
|
}
|
||||||
|
result.Dispose();
|
||||||
}
|
}
|
||||||
result.Dispose();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1167,45 +1150,51 @@ namespace OpenSim.Data.MySQL
|
||||||
bool returnval = false;
|
bool returnval = false;
|
||||||
|
|
||||||
// we want to send in byte data, which means we can't just pass down strings
|
// we want to send in byte data, which means we can't just pass down strings
|
||||||
try {
|
try
|
||||||
MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand();
|
{
|
||||||
cmd.CommandText = sql;
|
using (MySqlConnection dbcon = new MySqlConnection(connectionString))
|
||||||
cmd.Parameters.AddWithValue("?owner", appearance.Owner.ToString());
|
{
|
||||||
cmd.Parameters.AddWithValue("?serial", appearance.Serial);
|
dbcon.Open();
|
||||||
cmd.Parameters.AddWithValue("?visual_params", appearance.VisualParams);
|
|
||||||
cmd.Parameters.AddWithValue("?texture", appearance.Texture.GetBytes());
|
|
||||||
cmd.Parameters.AddWithValue("?avatar_height", appearance.AvatarHeight);
|
|
||||||
cmd.Parameters.AddWithValue("?body_item", appearance.BodyItem.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?body_asset", appearance.BodyAsset.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?skin_item", appearance.SkinItem.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?skin_asset", appearance.SkinAsset.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?hair_item", appearance.HairItem.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?hair_asset", appearance.HairAsset.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?eyes_item", appearance.EyesItem.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?eyes_asset", appearance.EyesAsset.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?shirt_item", appearance.ShirtItem.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?shirt_asset", appearance.ShirtAsset.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?pants_item", appearance.PantsItem.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?pants_asset", appearance.PantsAsset.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?shoes_item", appearance.ShoesItem.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?shoes_asset", appearance.ShoesAsset.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?socks_item", appearance.SocksItem.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?socks_asset", appearance.SocksAsset.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?jacket_item", appearance.JacketItem.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?jacket_asset", appearance.JacketAsset.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?gloves_item", appearance.GlovesItem.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?gloves_asset", appearance.GlovesAsset.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?undershirt_item", appearance.UnderShirtItem.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?undershirt_asset", appearance.UnderShirtAsset.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?underpants_item", appearance.UnderPantsItem.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?underpants_asset", appearance.UnderPantsAsset.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?skirt_item", appearance.SkirtItem.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?skirt_asset", appearance.SkirtAsset.ToString());
|
|
||||||
|
|
||||||
if (cmd.ExecuteNonQuery() > 0)
|
using (MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand())
|
||||||
returnval = true;
|
{
|
||||||
|
cmd.CommandText = sql;
|
||||||
|
cmd.Parameters.AddWithValue("?owner", appearance.Owner.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?serial", appearance.Serial);
|
||||||
|
cmd.Parameters.AddWithValue("?visual_params", appearance.VisualParams);
|
||||||
|
cmd.Parameters.AddWithValue("?texture", appearance.Texture.GetBytes());
|
||||||
|
cmd.Parameters.AddWithValue("?avatar_height", appearance.AvatarHeight);
|
||||||
|
cmd.Parameters.AddWithValue("?body_item", appearance.BodyItem.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?body_asset", appearance.BodyAsset.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?skin_item", appearance.SkinItem.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?skin_asset", appearance.SkinAsset.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?hair_item", appearance.HairItem.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?hair_asset", appearance.HairAsset.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?eyes_item", appearance.EyesItem.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?eyes_asset", appearance.EyesAsset.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?shirt_item", appearance.ShirtItem.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?shirt_asset", appearance.ShirtAsset.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?pants_item", appearance.PantsItem.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?pants_asset", appearance.PantsAsset.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?shoes_item", appearance.ShoesItem.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?shoes_asset", appearance.ShoesAsset.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?socks_item", appearance.SocksItem.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?socks_asset", appearance.SocksAsset.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?jacket_item", appearance.JacketItem.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?jacket_asset", appearance.JacketAsset.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?gloves_item", appearance.GlovesItem.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?gloves_asset", appearance.GlovesAsset.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?undershirt_item", appearance.UnderShirtItem.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?undershirt_asset", appearance.UnderShirtAsset.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?underpants_item", appearance.UnderPantsItem.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?underpants_asset", appearance.UnderPantsAsset.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?skirt_item", appearance.SkirtItem.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?skirt_asset", appearance.SkirtAsset.ToString());
|
||||||
|
|
||||||
cmd.Dispose();
|
if (cmd.ExecuteNonQuery() > 0)
|
||||||
|
returnval = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1221,33 +1210,38 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
string sql = "delete from avatarattachments where UUID = ?uuid";
|
string sql = "delete from avatarattachments where UUID = ?uuid";
|
||||||
|
|
||||||
MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand();
|
using (MySqlConnection dbcon = new MySqlConnection(connectionString))
|
||||||
cmd.CommandText = sql;
|
|
||||||
cmd.Parameters.AddWithValue("?uuid", agentID.ToString());
|
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
|
|
||||||
if (data == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
sql = "insert into avatarattachments (UUID, attachpoint, item, asset) values (?uuid, ?attachpoint, ?item, ?asset)";
|
|
||||||
|
|
||||||
cmd = (MySqlCommand) dbcon.CreateCommand();
|
|
||||||
cmd.CommandText = sql;
|
|
||||||
|
|
||||||
foreach (DictionaryEntry e in data)
|
|
||||||
{
|
{
|
||||||
int attachpoint = Convert.ToInt32(e.Key);
|
dbcon.Open();
|
||||||
|
|
||||||
Hashtable item = (Hashtable)e.Value;
|
MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand();
|
||||||
|
cmd.CommandText = sql;
|
||||||
cmd.Parameters.Clear();
|
|
||||||
cmd.Parameters.AddWithValue("?uuid", agentID.ToString());
|
cmd.Parameters.AddWithValue("?uuid", agentID.ToString());
|
||||||
cmd.Parameters.AddWithValue("?attachpoint", attachpoint);
|
|
||||||
cmd.Parameters.AddWithValue("?item", item["item"]);
|
|
||||||
cmd.Parameters.AddWithValue("?asset", item["asset"]);
|
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
if (data == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
sql = "insert into avatarattachments (UUID, attachpoint, item, asset) values (?uuid, ?attachpoint, ?item, ?asset)";
|
||||||
|
|
||||||
|
cmd = (MySqlCommand)dbcon.CreateCommand();
|
||||||
|
cmd.CommandText = sql;
|
||||||
|
|
||||||
|
foreach (DictionaryEntry e in data)
|
||||||
|
{
|
||||||
|
int attachpoint = Convert.ToInt32(e.Key);
|
||||||
|
|
||||||
|
Hashtable item = (Hashtable)e.Value;
|
||||||
|
|
||||||
|
cmd.Parameters.Clear();
|
||||||
|
cmd.Parameters.AddWithValue("?uuid", agentID.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?attachpoint", attachpoint);
|
||||||
|
cmd.Parameters.AddWithValue("?item", item["item"]);
|
||||||
|
cmd.Parameters.AddWithValue("?asset", item["asset"]);
|
||||||
|
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,16 +38,21 @@ namespace OpenSim.Data.MySQL
|
||||||
public class MySqlRegionData : MySqlFramework, IRegionData
|
public class MySqlRegionData : MySqlFramework, IRegionData
|
||||||
{
|
{
|
||||||
private string m_Realm;
|
private string m_Realm;
|
||||||
private List<string> m_ColumnNames = null;
|
private List<string> m_ColumnNames;
|
||||||
// private int m_LastExpire = 0;
|
//private string m_connectionString;
|
||||||
|
|
||||||
public MySqlRegionData(string connectionString, string realm)
|
public MySqlRegionData(string connectionString, string realm)
|
||||||
: base(connectionString)
|
: base(connectionString)
|
||||||
{
|
{
|
||||||
m_Realm = realm;
|
m_Realm = realm;
|
||||||
|
m_connectionString = connectionString;
|
||||||
|
|
||||||
Migration m = new Migration(m_Connection, GetType().Assembly, "GridStore");
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
m.Update();
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
Migration m = new Migration(dbcon, GetType().Assembly, "GridStore");
|
||||||
|
m.Update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RegionData> Get(string regionName, UUID scopeID)
|
public List<RegionData> Get(string regionName, UUID scopeID)
|
||||||
|
@ -56,12 +61,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 +76,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 +96,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,74 +115,79 @@ 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 (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
|
|
||||||
while (result.Read())
|
|
||||||
{
|
{
|
||||||
RegionData ret = new RegionData();
|
dbcon.Open();
|
||||||
ret.Data = new Dictionary<string, object>();
|
cmd.Connection = dbcon;
|
||||||
|
|
||||||
UUID regionID;
|
using (IDataReader result = cmd.ExecuteReader())
|
||||||
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>();
|
while (result.Read())
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
if (row["ColumnName"] != null)
|
m_ColumnNames = new List<string>();
|
||||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
|
||||||
|
DataTable schemaTable = result.GetSchemaTable();
|
||||||
|
foreach (DataRow row in schemaTable.Rows)
|
||||||
|
{
|
||||||
|
if (row["ColumnName"] != null)
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,76 +214,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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,16 +38,21 @@ namespace OpenSim.Data.MySQL
|
||||||
public class MySqlUserAccountData : MySqlFramework, IUserAccountData
|
public class MySqlUserAccountData : MySqlFramework, IUserAccountData
|
||||||
{
|
{
|
||||||
private string m_Realm;
|
private string m_Realm;
|
||||||
private List<string> m_ColumnNames = null;
|
private List<string> m_ColumnNames;
|
||||||
// private int m_LastExpire = 0;
|
// private string m_connectionString;
|
||||||
|
|
||||||
public MySqlUserAccountData(string connectionString, string realm)
|
public MySqlUserAccountData(string connectionString, string realm)
|
||||||
: base(connectionString)
|
: base(connectionString)
|
||||||
{
|
{
|
||||||
m_Realm = realm;
|
m_Realm = realm;
|
||||||
|
m_connectionString = connectionString;
|
||||||
|
|
||||||
Migration m = new Migration(m_Connection, GetType().Assembly, "UserStore");
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
m.Update();
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
Migration m = new Migration(dbcon, GetType().Assembly, "UserStore");
|
||||||
|
m.Update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserAccountData> Query(UUID principalID, UUID scopeID, string query)
|
public List<UserAccountData> Query(UUID principalID, UUID scopeID, string query)
|
||||||
|
@ -64,49 +69,49 @@ 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 (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
|
||||||
|
|
||||||
IDataReader result = ExecuteReader(cmd);
|
|
||||||
|
|
||||||
if (result.Read())
|
|
||||||
{
|
{
|
||||||
ret.PrincipalID = principalID;
|
dbcon.Open();
|
||||||
UUID scope;
|
MySqlCommand cmd = new MySqlCommand(command, dbcon);
|
||||||
UUID.TryParse(result["ScopeID"].ToString(), out scope);
|
|
||||||
ret.ScopeID = scope;
|
|
||||||
|
|
||||||
if (m_ColumnNames == null)
|
cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
||||||
|
|
||||||
|
IDataReader result = cmd.ExecuteReader();
|
||||||
|
|
||||||
|
if (result.Read())
|
||||||
{
|
{
|
||||||
m_ColumnNames = new List<string>();
|
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;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
foreach (string s in m_ColumnNames)
|
|
||||||
{
|
{
|
||||||
if (s == "UUID")
|
return null;
|
||||||
continue;
|
|
||||||
if (s == "ScopeID")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ret.Data[s] = result[s].ToString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Close();
|
|
||||||
CloseReaderCommand(cmd);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Close();
|
|
||||||
CloseReaderCommand(cmd);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Store(UserAccountData data)
|
public bool Store(UserAccountData data)
|
||||||
|
@ -118,61 +123,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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ using System.Reflection;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
|
||||||
|
@ -45,15 +46,9 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
/// <summary>
|
private MySQLManager m_database;
|
||||||
/// Database manager for MySQL
|
private string m_connectionString;
|
||||||
/// </summary>
|
private object m_dbLock = new object();
|
||||||
public MySQLManager database;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Better DB manager. Swap-in replacement too.
|
|
||||||
/// </summary>
|
|
||||||
public Dictionary<int, MySQLSuperManager> m_dbconnections = new Dictionary<int, MySQLSuperManager>();
|
|
||||||
|
|
||||||
public int m_maxConnections = 10;
|
public int m_maxConnections = 10;
|
||||||
public int m_lastConnect;
|
public int m_lastConnect;
|
||||||
|
@ -63,7 +58,6 @@ namespace OpenSim.Data.MySQL
|
||||||
private string m_userFriendsTableName = "userfriends";
|
private string m_userFriendsTableName = "userfriends";
|
||||||
private string m_appearanceTableName = "avatarappearance";
|
private string m_appearanceTableName = "avatarappearance";
|
||||||
private string m_attachmentsTableName = "avatarattachments";
|
private string m_attachmentsTableName = "avatarattachments";
|
||||||
private string m_connectString;
|
|
||||||
|
|
||||||
public override void Initialise()
|
public override void Initialise()
|
||||||
{
|
{
|
||||||
|
@ -71,41 +65,6 @@ namespace OpenSim.Data.MySQL
|
||||||
throw new PluginNotInitialisedException(Name);
|
throw new PluginNotInitialisedException(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MySQLSuperManager GetLockedConnection(string why)
|
|
||||||
{
|
|
||||||
int lockedCons = 0;
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
m_lastConnect++;
|
|
||||||
|
|
||||||
// Overflow protection
|
|
||||||
if (m_lastConnect == int.MaxValue)
|
|
||||||
m_lastConnect = 0;
|
|
||||||
|
|
||||||
MySQLSuperManager x = m_dbconnections[m_lastConnect%m_maxConnections];
|
|
||||||
if (!x.Locked)
|
|
||||||
{
|
|
||||||
x.GetLock();
|
|
||||||
x.Running = why;
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
lockedCons++;
|
|
||||||
if (lockedCons > m_maxConnections)
|
|
||||||
{
|
|
||||||
lockedCons = 0;
|
|
||||||
Thread.Sleep(1000); // Wait some time before searching them again.
|
|
||||||
m_log.Debug(
|
|
||||||
"WARNING: All threads are in use. Probable cause: Something didnt release a mutex properly, or high volume of requests inbound.");
|
|
||||||
m_log.Debug("Current connections-in-use dump:");
|
|
||||||
foreach (KeyValuePair<int, MySQLSuperManager> kvp in m_dbconnections)
|
|
||||||
{
|
|
||||||
m_log.Debug(kvp.Value.Running);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initialise User Interface
|
/// Initialise User Interface
|
||||||
/// Loads and initialises the MySQL storage plugin
|
/// Loads and initialises the MySQL storage plugin
|
||||||
|
@ -115,55 +74,18 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <param name="connect">connect string.</param>
|
/// <param name="connect">connect string.</param>
|
||||||
public override void Initialise(string connect)
|
public override void Initialise(string connect)
|
||||||
{
|
{
|
||||||
if (connect == String.Empty)
|
m_connectionString = connect;
|
||||||
{
|
m_database = new MySQLManager(connect);
|
||||||
// TODO: actually do something with our connect string
|
|
||||||
// instead of loading the second config
|
|
||||||
|
|
||||||
m_log.Warn("Using obsoletely mysql_connection.ini, try using user_source connect string instead");
|
|
||||||
IniFile iniFile = new IniFile("mysql_connection.ini");
|
|
||||||
string settingHostname = iniFile.ParseFileReadValue("hostname");
|
|
||||||
string settingDatabase = iniFile.ParseFileReadValue("database");
|
|
||||||
string settingUsername = iniFile.ParseFileReadValue("username");
|
|
||||||
string settingPassword = iniFile.ParseFileReadValue("password");
|
|
||||||
string settingPooling = iniFile.ParseFileReadValue("pooling");
|
|
||||||
string settingPort = iniFile.ParseFileReadValue("port");
|
|
||||||
|
|
||||||
m_connectString = "Server=" + settingHostname + ";Port=" + settingPort + ";Database=" + settingDatabase +
|
|
||||||
";User ID=" +
|
|
||||||
settingUsername + ";Password=" + settingPassword + ";Pooling=" + settingPooling + ";";
|
|
||||||
|
|
||||||
m_log.Info("Creating " + m_maxConnections + " DB connections...");
|
|
||||||
for (int i = 0; i < m_maxConnections; i++)
|
|
||||||
{
|
|
||||||
m_log.Info("Connecting to DB... [" + i + "]");
|
|
||||||
MySQLSuperManager msm = new MySQLSuperManager();
|
|
||||||
msm.Manager = new MySQLManager(m_connectString);
|
|
||||||
m_dbconnections.Add(i, msm);
|
|
||||||
}
|
|
||||||
|
|
||||||
database = new MySQLManager(m_connectString);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_connectString = connect;
|
|
||||||
database = new MySQLManager(m_connectString);
|
|
||||||
|
|
||||||
m_log.Info("Creating " + m_maxConnections + " DB connections...");
|
|
||||||
for (int i = 0; i < m_maxConnections; i++)
|
|
||||||
{
|
|
||||||
m_log.Info("Connecting to DB... [" + i + "]");
|
|
||||||
MySQLSuperManager msm = new MySQLSuperManager();
|
|
||||||
msm.Manager = new MySQLManager(m_connectString);
|
|
||||||
m_dbconnections.Add(i, msm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This actually does the roll forward assembly stuff
|
// This actually does the roll forward assembly stuff
|
||||||
Assembly assem = GetType().Assembly;
|
Assembly assem = GetType().Assembly;
|
||||||
Migration m = new Migration(database.Connection, assem, "UserStore");
|
|
||||||
|
|
||||||
m.Update();
|
using (MySql.Data.MySqlClient.MySqlConnection dbcon = new MySql.Data.MySqlClient.MySqlConnection(m_connectionString))
|
||||||
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
Migration m = new Migration(dbcon, assem, "UserStore");
|
||||||
|
m.Update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
|
@ -173,35 +95,32 @@ namespace OpenSim.Data.MySQL
|
||||||
// see IUserDataPlugin
|
// see IUserDataPlugin
|
||||||
public override UserProfileData GetUserByName(string user, string last)
|
public override UserProfileData GetUserByName(string user, string last)
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection("GetUserByName");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||||
param["?first"] = user;
|
param["?first"] = user;
|
||||||
param["?second"] = last;
|
param["?second"] = last;
|
||||||
|
|
||||||
IDbCommand result =
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
dbm.Manager.Query(
|
{
|
||||||
"SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param);
|
dbcon.Open();
|
||||||
IDataReader reader = result.ExecuteReader();
|
|
||||||
|
|
||||||
UserProfileData row = dbm.Manager.readUserRow(reader);
|
using (IDbCommand result = m_database.Query(dbcon,
|
||||||
|
"SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param))
|
||||||
reader.Dispose();
|
{
|
||||||
result.Dispose();
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
return row;
|
{
|
||||||
|
UserProfileData row = m_database.readUserRow(reader);
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region User Friends List Data
|
#region User Friends List Data
|
||||||
|
@ -216,38 +135,38 @@ namespace OpenSim.Data.MySQL
|
||||||
param["?friendPerms"] = perms.ToString();
|
param["?friendPerms"] = perms.ToString();
|
||||||
param["?datetimestamp"] = dtvalue.ToString();
|
param["?datetimestamp"] = dtvalue.ToString();
|
||||||
|
|
||||||
MySQLSuperManager dbm = GetLockedConnection("AddNewUserFriend");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IDbCommand adder =
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
dbm.Manager.Query(
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
|
||||||
|
using (IDbCommand adder = m_database.Query(dbcon,
|
||||||
"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 = m_database.Query(dbcon,
|
||||||
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();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void RemoveUserFriend(UUID friendlistowner, UUID friend)
|
public override void RemoveUserFriend(UUID friendlistowner, UUID friend)
|
||||||
|
@ -256,32 +175,32 @@ namespace OpenSim.Data.MySQL
|
||||||
param["?ownerID"] = friendlistowner.ToString();
|
param["?ownerID"] = friendlistowner.ToString();
|
||||||
param["?friendID"] = friend.ToString();
|
param["?friendID"] = friend.ToString();
|
||||||
|
|
||||||
MySQLSuperManager dbm = GetLockedConnection("RemoveUserFriend");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IDbCommand updater =
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
dbm.Manager.Query(
|
{
|
||||||
"delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID",
|
dbcon.Open();
|
||||||
param);
|
|
||||||
updater.ExecuteNonQuery();
|
|
||||||
|
|
||||||
updater =
|
using (IDbCommand updater = m_database.Query(dbcon,
|
||||||
dbm.Manager.Query(
|
"delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID",
|
||||||
"delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID",
|
param))
|
||||||
param);
|
{
|
||||||
updater.ExecuteNonQuery();
|
updater.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
using (IDbCommand updater = m_database.Query(dbcon,
|
||||||
|
"delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID",
|
||||||
|
param))
|
||||||
|
{
|
||||||
|
updater.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
|
public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
|
||||||
|
@ -291,28 +210,27 @@ namespace OpenSim.Data.MySQL
|
||||||
param["?friendID"] = friend.ToString();
|
param["?friendID"] = friend.ToString();
|
||||||
param["?friendPerms"] = perms.ToString();
|
param["?friendPerms"] = perms.ToString();
|
||||||
|
|
||||||
MySQLSuperManager dbm = GetLockedConnection("UpdateUserFriendPerms");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IDbCommand updater =
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
dbm.Manager.Query(
|
{
|
||||||
"update " + m_userFriendsTableName +
|
dbcon.Open();
|
||||||
" SET friendPerms = ?friendPerms " +
|
|
||||||
"where ownerID = ?ownerID and friendID = ?friendID",
|
using (IDbCommand updater = m_database.Query(dbcon,
|
||||||
param);
|
"update " + m_userFriendsTableName +
|
||||||
updater.ExecuteNonQuery();
|
" SET friendPerms = ?friendPerms " +
|
||||||
|
"where ownerID = ?ownerID and friendID = ?friendID",
|
||||||
|
param))
|
||||||
|
{
|
||||||
|
updater.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override List<FriendListItem> GetUserFriendList(UUID friendlistowner)
|
public override List<FriendListItem> GetUserFriendList(UUID friendlistowner)
|
||||||
|
@ -322,87 +240,83 @@ namespace OpenSim.Data.MySQL
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||||
param["?ownerID"] = friendlistowner.ToString();
|
param["?ownerID"] = friendlistowner.ToString();
|
||||||
|
|
||||||
MySQLSuperManager dbm = GetLockedConnection("GetUserFriendList");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Left Join userfriends to itself
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
IDbCommand result =
|
{
|
||||||
dbm.Manager.Query(
|
dbcon.Open();
|
||||||
|
|
||||||
|
//Left Join userfriends to itself
|
||||||
|
using (IDbCommand result = m_database.Query(dbcon,
|
||||||
"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();
|
{
|
||||||
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
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"]);
|
||||||
|
|
||||||
while (reader.Read())
|
// 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"]);
|
||||||
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
|
Lfli.Add(fli);
|
||||||
fli.FriendListOwnerPerms = (uint) Convert.ToInt32(reader["ownerperms"]);
|
}
|
||||||
|
}
|
||||||
Lfli.Add(fli);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.Dispose();
|
|
||||||
result.Dispose();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return Lfli;
|
return Lfli;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Lfli;
|
return Lfli;
|
||||||
}
|
}
|
||||||
|
|
||||||
override public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids)
|
override public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids)
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection("GetFriendRegionInfos");
|
|
||||||
Dictionary<UUID, FriendRegionInfo> infos = new Dictionary<UUID,FriendRegionInfo>();
|
Dictionary<UUID, FriendRegionInfo> infos = new Dictionary<UUID,FriendRegionInfo>();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (UUID uuid in uuids)
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
{
|
{
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
dbcon.Open();
|
||||||
param["?uuid"] = uuid.ToString();
|
|
||||||
IDbCommand result =
|
|
||||||
dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName +
|
|
||||||
" where UUID = ?uuid", param);
|
|
||||||
|
|
||||||
IDataReader reader = result.ExecuteReader();
|
foreach (UUID uuid in uuids)
|
||||||
while (reader.Read())
|
|
||||||
{
|
{
|
||||||
FriendRegionInfo fri = new FriendRegionInfo();
|
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||||
fri.isOnline = (sbyte)reader["agentOnline"] != 0;
|
param["?uuid"] = uuid.ToString();
|
||||||
fri.regionHandle = (ulong)reader["currentHandle"];
|
|
||||||
|
|
||||||
infos[uuid] = fri;
|
using (IDbCommand result = m_database.Query(dbcon, "select agentOnline,currentHandle from " + m_agentsTableName +
|
||||||
|
" where UUID = ?uuid", param))
|
||||||
|
{
|
||||||
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
FriendRegionInfo fri = new FriendRegionInfo();
|
||||||
|
fri.isOnline = (sbyte)reader["agentOnline"] != 0;
|
||||||
|
fri.regionHandle = (ulong)reader["currentHandle"];
|
||||||
|
|
||||||
|
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();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return infos;
|
return infos;
|
||||||
|
@ -423,76 +337,73 @@ 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) + "%";
|
||||||
param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], String.Empty) + "%";
|
param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], String.Empty) + "%";
|
||||||
MySQLSuperManager dbm = GetLockedConnection("GeneratePickerResults");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IDbCommand result =
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
dbm.Manager.Query(
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
|
||||||
|
using (IDbCommand result = m_database.Query(dbcon,
|
||||||
"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();
|
{
|
||||||
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
while (reader.Read())
|
{
|
||||||
{
|
while (reader.Read())
|
||||||
AvatarPickerAvatar user = new AvatarPickerAvatar();
|
{
|
||||||
user.AvatarID = new UUID((string) reader["UUID"]);
|
AvatarPickerAvatar user = new AvatarPickerAvatar();
|
||||||
user.firstName = (string) reader["username"];
|
user.AvatarID = new UUID((string)reader["UUID"]);
|
||||||
user.lastName = (string) reader["lastname"];
|
user.firstName = (string)reader["username"];
|
||||||
returnlist.Add(user);
|
user.lastName = (string)reader["lastname"];
|
||||||
|
returnlist.Add(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reader.Dispose();
|
|
||||||
result.Dispose();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return returnlist;
|
return returnlist;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection("GeneratePickerResults");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
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 (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
dbm.Manager.Query(
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
|
||||||
|
using (IDbCommand result = m_database.Query(dbcon,
|
||||||
"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();
|
{
|
||||||
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
while (reader.Read())
|
{
|
||||||
{
|
while (reader.Read())
|
||||||
AvatarPickerAvatar user = new AvatarPickerAvatar();
|
{
|
||||||
user.AvatarID = new UUID((string) reader["UUID"]);
|
AvatarPickerAvatar user = new AvatarPickerAvatar();
|
||||||
user.firstName = (string) reader["username"];
|
user.AvatarID = new UUID((string)reader["UUID"]);
|
||||||
user.lastName = (string) reader["lastname"];
|
user.firstName = (string)reader["username"];
|
||||||
returnlist.Add(user);
|
user.lastName = (string)reader["lastname"];
|
||||||
|
returnlist.Add(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reader.Dispose();
|
|
||||||
result.Dispose();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return returnlist;
|
return returnlist;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return returnlist;
|
return returnlist;
|
||||||
}
|
}
|
||||||
|
@ -504,32 +415,30 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <returns>User profile data</returns>
|
/// <returns>User profile data</returns>
|
||||||
public override UserProfileData GetUserByUUID(UUID uuid)
|
public override UserProfileData GetUserByUUID(UUID uuid)
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection("GetUserByUUID");
|
|
||||||
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 " + m_usersTableName + " WHERE UUID = ?uuid", param);
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
IDataReader reader = result.ExecuteReader();
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
|
||||||
UserProfileData row = dbm.Manager.readUserRow(reader);
|
using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param))
|
||||||
|
{
|
||||||
reader.Dispose();
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
result.Dispose();
|
{
|
||||||
|
UserProfileData row = m_database.readUserRow(reader);
|
||||||
return row;
|
return row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -565,25 +474,18 @@ namespace OpenSim.Data.MySQL
|
||||||
param["?UUID"] = AgentID.ToString();
|
param["?UUID"] = AgentID.ToString();
|
||||||
param["?webLoginKey"] = WebLoginKey.ToString();
|
param["?webLoginKey"] = WebLoginKey.ToString();
|
||||||
|
|
||||||
MySQLSuperManager dbm = GetLockedConnection("StoreWebLoginKey");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dbm.Manager.ExecuteParameterizedSql(
|
m_database.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();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -593,34 +495,30 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <returns>The users session</returns>
|
/// <returns>The users session</returns>
|
||||||
public override UserAgentData GetAgentByUUID(UUID uuid)
|
public override UserAgentData GetAgentByUUID(UUID uuid)
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection("GetAgentByUUID");
|
|
||||||
|
|
||||||
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 " + m_agentsTableName + " WHERE UUID = ?uuid",
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
param);
|
{
|
||||||
IDataReader reader = result.ExecuteReader();
|
dbcon.Open();
|
||||||
|
|
||||||
UserAgentData row = dbm.Manager.readAgentRow(reader);
|
using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param))
|
||||||
|
{
|
||||||
reader.Dispose();
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
result.Dispose();
|
{
|
||||||
|
UserAgentData row = m_database.readAgentRow(reader);
|
||||||
return row;
|
return row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -634,27 +532,22 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MySQLSuperManager dbm = GetLockedConnection("AddNewUserProfile");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dbm.Manager.insertUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
|
m_database.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();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -668,19 +561,13 @@ namespace OpenSim.Data.MySQL
|
||||||
if (agent.ProfileID == zero || agent.SessionID == zero)
|
if (agent.ProfileID == zero || agent.SessionID == zero)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MySQLSuperManager dbm = GetLockedConnection("AddNewUserAgent");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dbm.Manager.insertAgentRow(agent);
|
m_database.insertAgentRow(agent);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -690,24 +577,24 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <param name="user">The profile data to use to update the DB</param>
|
/// <param name="user">The profile data to use to update the DB</param>
|
||||||
public override bool UpdateUserProfile(UserProfileData user)
|
public override bool UpdateUserProfile(UserProfileData user)
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection("UpdateUserProfile");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dbm.Manager.updateUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
|
m_database.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
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -742,41 +629,40 @@ namespace OpenSim.Data.MySQL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override AvatarAppearance GetUserAppearance(UUID user)
|
public override AvatarAppearance GetUserAppearance(UUID user)
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection("GetUserAppearance");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
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 (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
"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());
|
dbcon.Open();
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
appearance.SetAttachments(GetUserAttachments(user));
|
|
||||||
|
|
||||||
return appearance;
|
using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param))
|
||||||
|
{
|
||||||
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
|
{
|
||||||
|
AvatarAppearance appearance = m_database.readAppearanceRow(reader);
|
||||||
|
|
||||||
|
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();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -787,22 +673,16 @@ namespace OpenSim.Data.MySQL
|
||||||
// override
|
// override
|
||||||
public override void UpdateUserAppearance(UUID user, AvatarAppearance appearance)
|
public override void UpdateUserAppearance(UUID user, AvatarAppearance appearance)
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection("UpdateUserAppearance");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
appearance.Owner = user;
|
appearance.Owner = user;
|
||||||
dbm.Manager.insertAppearanceRow(appearance);
|
m_database.insertAppearanceRow(appearance);
|
||||||
|
|
||||||
UpdateUserAttachments(user, appearance.GetAttachments());
|
UpdateUserAttachments(user, appearance.GetAttachments());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -829,43 +709,33 @@ namespace OpenSim.Data.MySQL
|
||||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||||
param["?uuid"] = agentID.ToString();
|
param["?uuid"] = agentID.ToString();
|
||||||
|
|
||||||
MySQLSuperManager dbm = GetLockedConnection("GetUserAttachments");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IDbCommand result = dbm.Manager.Query(
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
"SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param);
|
{
|
||||||
IDataReader reader = result.ExecuteReader();
|
dbcon.Open();
|
||||||
|
|
||||||
Hashtable ret = dbm.Manager.readAttachments(reader);
|
using (IDbCommand result = m_database.Query(dbcon,
|
||||||
|
"SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param))
|
||||||
reader.Dispose();
|
{
|
||||||
result.Dispose();
|
using (IDataReader reader = result.ExecuteReader())
|
||||||
return ret;
|
{
|
||||||
|
Hashtable ret = m_database.readAttachments(reader);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateUserAttachments(UUID agentID, Hashtable data)
|
public void UpdateUserAttachments(UUID agentID, Hashtable data)
|
||||||
{
|
{
|
||||||
MySQLSuperManager dbm = GetLockedConnection("UpdateUserAttachments");
|
m_database.writeAttachments(agentID, data);
|
||||||
try
|
|
||||||
{
|
|
||||||
dbm.Manager.writeAttachments(agentID, data);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ResetAttachments(UUID userID)
|
public override void ResetAttachments(UUID userID)
|
||||||
|
@ -873,19 +743,10 @@ namespace OpenSim.Data.MySQL
|
||||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
param["?uuid"] = userID.ToString();
|
param["?uuid"] = userID.ToString();
|
||||||
|
|
||||||
MySQLSuperManager dbm = GetLockedConnection("ResetAttachments");
|
m_database.ExecuteParameterizedSql(
|
||||||
|
"UPDATE " + m_attachmentsTableName +
|
||||||
try
|
" SET asset = '00000000-0000-0000-0000-000000000000' WHERE UUID = ?uuid",
|
||||||
{
|
param);
|
||||||
dbm.Manager.ExecuteParameterizedSql(
|
|
||||||
"UPDATE " + m_attachmentsTableName +
|
|
||||||
" SET asset = '00000000-0000-0000-0000-000000000000' WHERE UUID = ?uuid",
|
|
||||||
param);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void LogoutUsers(UUID regionID)
|
public override void LogoutUsers(UUID regionID)
|
||||||
|
@ -893,25 +754,18 @@ namespace OpenSim.Data.MySQL
|
||||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
param["?regionID"] = regionID.ToString();
|
param["?regionID"] = regionID.ToString();
|
||||||
|
|
||||||
MySQLSuperManager dbm = GetLockedConnection("LogoutUsers");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dbm.Manager.ExecuteParameterizedSql(
|
m_database.ExecuteParameterizedSql(
|
||||||
"update " + m_agentsTableName + " SET agentOnline = 0 " +
|
"update " + m_agentsTableName + " SET agentOnline = 0 " +
|
||||||
"where currentRegion = ?regionID",
|
"where currentRegion = ?regionID",
|
||||||
param);
|
param);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
dbm.Manager.Reconnect();
|
m_log.Error(e.Message, e);
|
||||||
m_log.Error(e.ToString());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
dbm.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,47 +110,58 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
public bool MoveItem(string id, string newParent)
|
public bool MoveItem(string id, string newParent)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
using (MySqlCommand cmd = new MySqlCommand())
|
||||||
|
{
|
||||||
|
|
||||||
cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm);
|
cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm);
|
||||||
cmd.Parameters.AddWithValue("?ParentFolderID", newParent);
|
cmd.Parameters.AddWithValue("?ParentFolderID", newParent);
|
||||||
cmd.Parameters.AddWithValue("?InventoryID", id);
|
cmd.Parameters.AddWithValue("?InventoryID", id);
|
||||||
|
|
||||||
return ExecuteNonQuery(cmd) == 0 ? false : true;
|
return ExecuteNonQuery(cmd) == 0 ? false : true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public XInventoryItem[] GetActiveGestures(UUID principalID)
|
public XInventoryItem[] GetActiveGestures(UUID principalID)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
using (MySqlCommand cmd = new MySqlCommand())
|
||||||
cmd.CommandText = String.Format("select * from inventoryitems where avatarId = ?uuid and assetType = ?type and flags = 1", m_Realm);
|
{
|
||||||
|
cmd.CommandText = String.Format("select * from inventoryitems where avatarId = ?uuid and assetType = ?type and flags = 1", m_Realm);
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("?uuid", principalID.ToString());
|
cmd.Parameters.AddWithValue("?uuid", principalID.ToString());
|
||||||
cmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture);
|
cmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture);
|
||||||
|
|
||||||
return DoQuery(cmd);
|
return DoQuery(cmd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetAssetPermissions(UUID principalID, UUID assetID)
|
public int GetAssetPermissions(UUID principalID, UUID assetID)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||||
|
|
||||||
cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = ?PrincipalID and assetID = ?AssetID group by assetID", m_Realm);
|
|
||||||
cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString());
|
|
||||||
cmd.Parameters.AddWithValue("?AssetID", assetID.ToString());
|
|
||||||
|
|
||||||
IDataReader reader = ExecuteReader(cmd);
|
|
||||||
|
|
||||||
int perms = 0;
|
|
||||||
|
|
||||||
if (reader.Read())
|
|
||||||
{
|
{
|
||||||
perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]);
|
dbcon.Open();
|
||||||
|
|
||||||
|
using (MySqlCommand cmd = new MySqlCommand())
|
||||||
|
{
|
||||||
|
cmd.Connection = dbcon;
|
||||||
|
|
||||||
|
cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = ?PrincipalID and assetID = ?AssetID group by assetID", m_Realm);
|
||||||
|
cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?AssetID", assetID.ToString());
|
||||||
|
|
||||||
|
using (IDataReader reader = cmd.ExecuteReader())
|
||||||
|
{
|
||||||
|
|
||||||
|
int perms = 0;
|
||||||
|
|
||||||
|
if (reader.Read())
|
||||||
|
{
|
||||||
|
perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return perms;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.Close();
|
|
||||||
CloseReaderCommand(cmd);
|
|
||||||
|
|
||||||
return perms;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ using OpenSim.Data.Tests;
|
||||||
using log4net;
|
using log4net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using OpenSim.Tests.Common;
|
using OpenSim.Tests.Common;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
|
||||||
namespace OpenSim.Data.MySQL.Tests
|
namespace OpenSim.Data.MySQL.Tests
|
||||||
{
|
{
|
||||||
|
@ -65,9 +66,13 @@ namespace OpenSim.Data.MySQL.Tests
|
||||||
|
|
||||||
// This actually does the roll forward assembly stuff
|
// This actually does the roll forward assembly stuff
|
||||||
Assembly assem = GetType().Assembly;
|
Assembly assem = GetType().Assembly;
|
||||||
Migration m = new Migration(database.Connection, assem, "GridStore");
|
|
||||||
|
|
||||||
m.Update();
|
using (MySqlConnection dbcon = new MySqlConnection(connect))
|
||||||
|
{
|
||||||
|
dbcon.Open();
|
||||||
|
Migration m = new Migration(dbcon, assem, "AssetStore");
|
||||||
|
m.Update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestFixtureTearDown]
|
[TestFixtureTearDown]
|
||||||
|
|
|
@ -5177,6 +5177,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
{
|
{
|
||||||
ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack;
|
ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack;
|
||||||
|
|
||||||
|
//m_log.DebugFormat("[CLIENT]: Received ScriptDialogReply from {0}", rdialog.Data.ObjectID);
|
||||||
|
|
||||||
#region Packet Session and User Check
|
#region Packet Session and User Check
|
||||||
if (m_checkPackets)
|
if (m_checkPackets)
|
||||||
{
|
{
|
||||||
|
@ -5197,7 +5199,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
args.Type = ChatTypeEnum.Shout;
|
args.Type = ChatTypeEnum.Shout;
|
||||||
args.Position = new Vector3();
|
args.Position = new Vector3();
|
||||||
args.Scene = Scene;
|
args.Scene = Scene;
|
||||||
args.Sender = this;
|
args.Sender = this;
|
||||||
ChatMessage handlerChatFromClient2 = OnChatFromClient;
|
ChatMessage handlerChatFromClient2 = OnChatFromClient;
|
||||||
if (handlerChatFromClient2 != null)
|
if (handlerChatFromClient2 != null)
|
||||||
handlerChatFromClient2(this, args);
|
handlerChatFromClient2(this, args);
|
||||||
|
|
|
@ -115,7 +115,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||||
// client.OnAvatarNowWearing -= AvatarIsWearing;
|
// client.OnAvatarNowWearing -= AvatarIsWearing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance)
|
public void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance)
|
||||||
{
|
{
|
||||||
IInventoryService invService = m_scene.InventoryService;
|
IInventoryService invService = m_scene.InventoryService;
|
||||||
|
@ -139,7 +138,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat("[APPEARANCE]: Can't find inventory item {0}, setting to default", appearance.Wearables[i].ItemID);
|
m_log.ErrorFormat(
|
||||||
|
"[APPEARANCE]: Can't find inventory item {0} for {1}, setting to default",
|
||||||
|
appearance.Wearables[i].ItemID, (WearableType)i);
|
||||||
|
|
||||||
appearance.Wearables[i].AssetID = def.Wearables[i].AssetID;
|
appearance.Wearables[i].AssetID = def.Wearables[i].AssetID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -358,18 +358,18 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
|
||||||
// tmptex.DefaultTexture.Fullbright = true;
|
// tmptex.DefaultTexture.Fullbright = true;
|
||||||
|
|
||||||
part.UpdateTexture(tmptex);
|
part.UpdateTexture(tmptex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0))
|
if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0))
|
||||||
{
|
{
|
||||||
if (oldAsset == null) oldAsset = scene.AssetService.Get(oldID.ToString());
|
if (oldAsset == null) oldAsset = scene.AssetService.Get(oldID.ToString());
|
||||||
if (oldAsset != null)
|
if (oldAsset != null)
|
||||||
{
|
{
|
||||||
if (oldAsset.Temporary == true)
|
if (oldAsset.Temporary == true)
|
||||||
{
|
{
|
||||||
scene.AssetService.Delete(oldID.ToString());
|
scene.AssetService.Delete(oldID.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -342,6 +342,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
|
||||||
m_log.Error(
|
m_log.Error(
|
||||||
"[VECTORRENDERMODULE]: OpenJpeg Encode Failed. Empty byte data returned!");
|
"[VECTORRENDERMODULE]: OpenJpeg Encode Failed. Empty byte data returned!");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_textureManager.ReturnData(id, imageJ2000);
|
m_textureManager.ReturnData(id, imageJ2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -435,12 +435,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
|
||||||
}
|
}
|
||||||
|
|
||||||
OSDMap resp = new OSDMap(2);
|
OSDMap resp = new OSDMap(2);
|
||||||
string reason = String.Empty;
|
string reason = String.Empty;
|
||||||
uint teleportFlags = 0;
|
uint teleportFlags = 0;
|
||||||
if (args.ContainsKey("teleport_flags"))
|
if (args.ContainsKey("teleport_flags"))
|
||||||
{
|
{
|
||||||
teleportFlags = args["teleport_flags"].AsUInteger();
|
teleportFlags = args["teleport_flags"].AsUInteger();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the meaning of POST agent
|
// This is the meaning of POST agent
|
||||||
m_regionClient.AdjustUserInformation(aCircuit);
|
m_regionClient.AdjustUserInformation(aCircuit);
|
||||||
|
|
|
@ -43,10 +43,67 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face);
|
int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face);
|
||||||
UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams,
|
UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams,
|
||||||
int updateTimer);
|
int updateTimer);
|
||||||
|
|
||||||
|
/// Apply a dynamically generated texture to all sides of the given prim. The texture is not persisted to the
|
||||||
|
/// asset service.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="simID">The simulator in which the texture is being generated</param>
|
||||||
|
/// <param name="primID">The prim to which to apply the texture.</param>
|
||||||
|
/// <param name="contentType">The content type to create. Current choices are "vector" to create a vector
|
||||||
|
/// based texture or "image" to create a texture from an image at a particular URL</param>
|
||||||
|
/// <param name="data">The data for the generator</param>
|
||||||
|
/// <param name="extraParams">Parameters for the generator that don't form part of the main data.</param>
|
||||||
|
/// <param name="updateTimer">If zero, the image is never updated after the first generation. If positive
|
||||||
|
/// the image is updated at the given interval. Not implemented for </param>
|
||||||
|
/// <param name="SetBlending">
|
||||||
|
/// If true, the newly generated texture is blended with the appropriate existing ones on the prim
|
||||||
|
/// </param>
|
||||||
|
/// <param name="AlphaValue">
|
||||||
|
/// The alpha value of the generated texture.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// The UUID of the texture updater, not the texture UUID. If you need the texture UUID then you will need
|
||||||
|
/// to obtain it directly from the SceneObjectPart. For instance, if ALL_SIDES is set then this texture
|
||||||
|
/// can be obtained as SceneObjectPart.Shape.Textures.DefaultTexture.TextureID
|
||||||
|
/// </returns>
|
||||||
UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams,
|
UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams,
|
||||||
int updateTimer, bool SetBlending, byte AlphaValue);
|
int updateTimer, bool SetBlending, byte AlphaValue);
|
||||||
UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams,
|
|
||||||
int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face);
|
/// <summary>
|
||||||
|
/// Apply a dynamically generated texture to the given prim.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="simID">The simulator in which the texture is being generated</param>
|
||||||
|
/// <param name="primID">The prim to which to apply the texture.</param>
|
||||||
|
/// <param name="contentType">The content type to create. Current choices are "vector" to create a vector
|
||||||
|
/// based texture or "image" to create a texture from an image at a particular URL</param>
|
||||||
|
/// <param name="data">The data for the generator</param>
|
||||||
|
/// <param name="extraParams">Parameters for the generator that don't form part of the main data.</param>
|
||||||
|
/// <param name="updateTimer">If zero, the image is never updated after the first generation. If positive
|
||||||
|
/// the image is updated at the given interval. Not implemented for </param>
|
||||||
|
/// <param name="SetBlending">
|
||||||
|
/// If true, the newly generated texture is blended with the appropriate existing ones on the prim
|
||||||
|
/// </param>
|
||||||
|
/// <param name="disp">
|
||||||
|
/// Display flags. If DISP_EXPIRE then the old texture is deleted if it is replaced by a
|
||||||
|
/// newer generated texture (may not currently be implemented). If DISP_TEMP then the asset is flagged as
|
||||||
|
/// temporary, which often means that it is not persisted to the database.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="AlphaValue">
|
||||||
|
/// The alpha value of the generated texture.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="face">
|
||||||
|
/// The face of the prim on which to put the generated texture. If ALL_SIDES then all sides of the prim are
|
||||||
|
/// set
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// The UUID of the texture updater, not the texture UUID. If you need the texture UUID then you will need
|
||||||
|
/// to obtain it directly from the SceneObjectPart. For instance, if ALL_SIDES is set then this texture
|
||||||
|
/// can be obtained as SceneObjectPart.Shape.Textures.DefaultTexture.TextureID
|
||||||
|
/// </returns>
|
||||||
|
UUID AddDynamicTextureData(
|
||||||
|
UUID simID, UUID primID, string contentType, string data, string extraParams,
|
||||||
|
int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face);
|
||||||
|
|
||||||
void GetDrawStringSize(string contentType, string text, string fontName, int fontSize,
|
void GetDrawStringSize(string contentType, string text, string fontName, int fontSize,
|
||||||
out double xSize, out double ySize);
|
out double xSize, out double ySize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,6 +209,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
public event OnSendNewWindlightProfileTargetedDelegate OnSendNewWindlightProfileTargeted;
|
public event OnSendNewWindlightProfileTargetedDelegate OnSendNewWindlightProfileTargeted;
|
||||||
public event OnSaveNewWindlightProfileDelegate OnSaveNewWindlightProfile;
|
public event OnSaveNewWindlightProfileDelegate OnSaveNewWindlightProfile;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Triggered when an object or attachment enters a scene
|
||||||
|
/// </summary>
|
||||||
|
public event OnIncomingSceneObjectDelegate OnIncomingSceneObject;
|
||||||
|
public delegate void OnIncomingSceneObjectDelegate(SceneObjectGroup so);
|
||||||
|
|
||||||
public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel);
|
public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel);
|
||||||
|
|
||||||
public event NewInventoryItemUploadComplete OnNewInventoryItemUploadComplete;
|
public event NewInventoryItemUploadComplete OnNewInventoryItemUploadComplete;
|
||||||
|
@ -411,7 +417,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
|
public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
|
||||||
{
|
{
|
||||||
|
@ -1228,6 +1234,27 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void TriggerOnIncomingSceneObject(SceneObjectGroup so)
|
||||||
|
{
|
||||||
|
OnIncomingSceneObjectDelegate handlerIncomingSceneObject = OnIncomingSceneObject;
|
||||||
|
if (handlerIncomingSceneObject != null)
|
||||||
|
{
|
||||||
|
foreach (OnIncomingSceneObjectDelegate d in handlerIncomingSceneObject.GetInvocationList())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
d(so);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[EVENT MANAGER]: Delegate for TriggerOnIncomingSceneObject failed - continuing. {0} {1}",
|
||||||
|
e.Message, e.StackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void TriggerOnRegisterCaps(UUID agentID, Caps caps)
|
public void TriggerOnRegisterCaps(UUID agentID, Caps caps)
|
||||||
{
|
{
|
||||||
RegisterCapsEvent handlerRegisterCaps = OnRegisterCaps;
|
RegisterCapsEvent handlerRegisterCaps = OnRegisterCaps;
|
||||||
|
|
|
@ -2433,9 +2433,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
return successYN;
|
return successYN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when objects or attachments cross the border between regions.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sog"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public bool IncomingCreateObject(ISceneObject sog)
|
public bool IncomingCreateObject(ISceneObject sog)
|
||||||
{
|
{
|
||||||
//m_log.Debug(" >>> IncomingCreateObject <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted);
|
//m_log.Debug(" >>> IncomingCreateObject(sog) <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted);
|
||||||
SceneObjectGroup newObject;
|
SceneObjectGroup newObject;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -2452,7 +2457,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_log.DebugFormat("[SCENE]: Problem adding scene object {0} in {1} ", sog.UUID, RegionInfo.RegionName);
|
m_log.DebugFormat("[SCENE]: Problem adding scene object {0} in {1} ", sog.UUID, RegionInfo.RegionName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 1);
|
newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 1);
|
||||||
|
|
||||||
|
// Do this as late as possible so that listeners have full access to the incoming object
|
||||||
|
EventManager.TriggerOnIncomingSceneObject(newObject);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2464,6 +2474,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// <returns>False</returns>
|
/// <returns>False</returns>
|
||||||
public virtual bool IncomingCreateObject(UUID userID, UUID itemID)
|
public virtual bool IncomingCreateObject(UUID userID, UUID itemID)
|
||||||
{
|
{
|
||||||
|
//m_log.DebugFormat(" >>> IncomingCreateObject(userID, itemID) <<< {0} {1}", userID, itemID);
|
||||||
|
|
||||||
ScenePresence sp = GetScenePresence(userID);
|
ScenePresence sp = GetScenePresence(userID);
|
||||||
if (sp != null)
|
if (sp != null)
|
||||||
{
|
{
|
||||||
|
@ -2498,7 +2510,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
foreach (SceneObjectPart p in sceneObject.Children.Values)
|
foreach (SceneObjectPart p in sceneObject.Children.Values)
|
||||||
p.LocalId = 0;
|
p.LocalId = 0;
|
||||||
|
|
||||||
if ((sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) && (sceneObject.RootPart.Shape.State != 0)) // Attachment
|
if (sceneObject.IsAttachmentCheckFull()) // Attachment
|
||||||
{
|
{
|
||||||
sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez);
|
sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez);
|
||||||
sceneObject.RootPart.AddFlag(PrimFlags.Phantom);
|
sceneObject.RootPart.AddFlag(PrimFlags.Phantom);
|
||||||
|
@ -2523,29 +2535,23 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
//RootPrim.SetParentLocalId(parentLocalID);
|
//RootPrim.SetParentLocalId(parentLocalID);
|
||||||
|
|
||||||
m_log.DebugFormat("[ATTACHMENT]: Received " +
|
m_log.DebugFormat(
|
||||||
"attachment {0}, inworld asset id {1}",
|
"[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.GetFromItemID(), grp.UUID);
|
||||||
//grp.RootPart.LastOwnerID.ToString(),
|
|
||||||
grp.GetFromItemID(),
|
|
||||||
grp.UUID.ToString());
|
|
||||||
|
|
||||||
//grp.SetFromAssetID(grp.RootPart.LastOwnerID);
|
//grp.SetFromAssetID(grp.RootPart.LastOwnerID);
|
||||||
m_log.DebugFormat("[ATTACHMENT]: Attach " +
|
m_log.DebugFormat(
|
||||||
"to avatar {0} at position {1}",
|
"[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
|
||||||
sp.UUID.ToString(), grp.AbsolutePosition);
|
|
||||||
AttachObject(sp.ControllingClient,
|
AttachObject(
|
||||||
grp.LocalId, (uint)0,
|
sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false);
|
||||||
grp.GroupRotation,
|
|
||||||
grp.AbsolutePosition, false);
|
|
||||||
RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
|
RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
|
||||||
grp.SendGroupFullUpdate();
|
grp.SendGroupFullUpdate();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
|
RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
|
||||||
RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
|
RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -191,7 +191,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
if (handlerChildAgentUpdate != null)
|
if (handlerChildAgentUpdate != null)
|
||||||
handlerChildAgentUpdate(cAgentData);
|
handlerChildAgentUpdate(cAgentData);
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -337,7 +337,16 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsAttachmentCheckFull()
|
/// <summary>
|
||||||
|
/// Check both the attachment property and the relevant properties of the underlying root part.
|
||||||
|
/// </summary>
|
||||||
|
/// This is necessary in some cases, particularly when a scene object has just crossed into a region and doesn't
|
||||||
|
/// have the IsAttachment property yet checked.
|
||||||
|
///
|
||||||
|
/// FIXME: However, this should be fixed so that this property
|
||||||
|
/// propertly reflects the underlying status.
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool IsAttachmentCheckFull()
|
||||||
{
|
{
|
||||||
return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0));
|
return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4171,9 +4171,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
ScheduleFullUpdate();
|
ScheduleFullUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Added to handle bug in libsecondlife's TextureEntry.ToBytes()
|
/// <summary>
|
||||||
// not handling RGBA properly. Cycles through, and "fixes" the color
|
/// Update the textures on the part.
|
||||||
// info
|
/// </summary>
|
||||||
|
/// Added to handle bug in libsecondlife's TextureEntry.ToBytes()
|
||||||
|
/// not handling RGBA properly. Cycles through, and "fixes" the color
|
||||||
|
/// info
|
||||||
|
/// <param name="tex"></param>
|
||||||
public void UpdateTexture(Primitive.TextureEntry tex)
|
public void UpdateTexture(Primitive.TextureEntry tex)
|
||||||
{
|
{
|
||||||
//Color4 tmpcolor;
|
//Color4 tmpcolor;
|
||||||
|
|
|
@ -106,6 +106,16 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
protected ScenePresenceAnimator m_animator;
|
protected ScenePresenceAnimator m_animator;
|
||||||
|
|
||||||
|
/// <value>
|
||||||
|
/// The scene objects attached to this avatar. Do not change this list directly - use methods such as
|
||||||
|
/// AddAttachment() and RemoveAttachment(). Lock this list when performing any read operations upon it.
|
||||||
|
/// </value>
|
||||||
|
public List<SceneObjectGroup> Attachments
|
||||||
|
{
|
||||||
|
get { return m_attachments; }
|
||||||
|
}
|
||||||
|
protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>();
|
||||||
|
|
||||||
private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>();
|
private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>();
|
||||||
private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO;
|
private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO;
|
||||||
private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO;
|
private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO;
|
||||||
|
@ -223,9 +233,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
// Agent's Draw distance.
|
// Agent's Draw distance.
|
||||||
protected float m_DrawDistance;
|
protected float m_DrawDistance;
|
||||||
|
|
||||||
protected AvatarAppearance m_appearance;
|
protected AvatarAppearance m_appearance;
|
||||||
|
|
||||||
protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>();
|
|
||||||
|
|
||||||
// neighbouring regions we have enabled a child agent in
|
// neighbouring regions we have enabled a child agent in
|
||||||
// holds the seed cap for the child agent in that region
|
// holds the seed cap for the child agent in that region
|
||||||
|
@ -640,12 +648,16 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructor(s)
|
#region Constructor(s)
|
||||||
|
|
||||||
private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo)
|
public ScenePresence()
|
||||||
{
|
{
|
||||||
m_animator = new ScenePresenceAnimator(this);
|
|
||||||
m_sendCourseLocationsMethod = SendCoarseLocationsDefault;
|
m_sendCourseLocationsMethod = SendCoarseLocationsDefault;
|
||||||
CreateSceneViewer();
|
CreateSceneViewer();
|
||||||
|
m_animator = new ScenePresenceAnimator(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this()
|
||||||
|
{
|
||||||
m_rootRegionHandle = reginfo.RegionHandle;
|
m_rootRegionHandle = reginfo.RegionHandle;
|
||||||
m_controllingClient = client;
|
m_controllingClient = client;
|
||||||
m_firstname = m_controllingClient.FirstName;
|
m_firstname = m_controllingClient.FirstName;
|
||||||
|
@ -669,7 +681,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize);
|
m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize);
|
||||||
m_reprioritization_timer.AutoReset = false;
|
m_reprioritization_timer.AutoReset = false;
|
||||||
|
|
||||||
|
|
||||||
AdjustKnownSeeds();
|
AdjustKnownSeeds();
|
||||||
Animator.TrySetMovementAnimation("STAND");
|
Animator.TrySetMovementAnimation("STAND");
|
||||||
// we created a new ScenePresence (a new child agent) in a fresh region.
|
// we created a new ScenePresence (a new child agent) in a fresh region.
|
||||||
|
@ -1150,7 +1161,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look);
|
m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look);
|
||||||
SendInitialData();
|
SendInitialData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -3388,8 +3398,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
|
m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
|
||||||
m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong
|
m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong
|
||||||
m_physicsActor.SubscribeEvents(500);
|
m_physicsActor.SubscribeEvents(500);
|
||||||
m_physicsActor.LocalID = LocalId;
|
m_physicsActor.LocalID = LocalId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OutOfBoundsCall(Vector3 pos)
|
private void OutOfBoundsCall(Vector3 pos)
|
||||||
|
@ -3399,7 +3408,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
//AddToPhysicalScene(flying);
|
//AddToPhysicalScene(flying);
|
||||||
if (ControllingClient != null)
|
if (ControllingClient != null)
|
||||||
ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.",true);
|
ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event called by the physics plugin to tell the avatar about a collision.
|
// Event called by the physics plugin to tell the avatar about a collision.
|
||||||
|
@ -3539,13 +3548,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_animator = null;
|
m_animator = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScenePresence()
|
|
||||||
{
|
|
||||||
m_sendCourseLocationsMethod = SendCoarseLocationsDefault;
|
|
||||||
CreateSceneViewer();
|
|
||||||
m_animator = new ScenePresenceAnimator(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddAttachment(SceneObjectGroup gobj)
|
public void AddAttachment(SceneObjectGroup gobj)
|
||||||
{
|
{
|
||||||
lock (m_attachments)
|
lock (m_attachments)
|
||||||
|
|
|
@ -1575,6 +1575,7 @@ Console.WriteLine(" JointCreateFixed");
|
||||||
{
|
{
|
||||||
//Console.WriteLine("Move " + m_primName);
|
//Console.WriteLine("Move " + m_primName);
|
||||||
if (!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009
|
if (!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009
|
||||||
|
/*
|
||||||
// NON-'VEHICLES' are dealt with here
|
// NON-'VEHICLES' are dealt with here
|
||||||
if (d.BodyIsEnabled(Body) && !m_angularlock.ApproxEquals(Vector3.Zero, 0.003f))
|
if (d.BodyIsEnabled(Body) && !m_angularlock.ApproxEquals(Vector3.Zero, 0.003f))
|
||||||
{
|
{
|
||||||
|
@ -1587,6 +1588,7 @@ Console.WriteLine(" JointCreateFixed");
|
||||||
avel2.Z = 0;
|
avel2.Z = 0;
|
||||||
d.BodySetAngularVel(Body, avel2.X, avel2.Y, avel2.Z);
|
d.BodySetAngularVel(Body, avel2.X, avel2.Y, avel2.Z);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
//float PID_P = 900.0f;
|
//float PID_P = 900.0f;
|
||||||
|
|
||||||
float m_mass = CalculateMass();
|
float m_mass = CalculateMass();
|
||||||
|
|
|
@ -0,0 +1,251 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Xml;
|
||||||
|
using log4net;
|
||||||
|
using Nini.Config;
|
||||||
|
|
||||||
|
namespace Careminster
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the Configuration files into nIni
|
||||||
|
/// </summary>
|
||||||
|
public class ConfigurationLoader
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A source of Configuration data
|
||||||
|
/// </summary>
|
||||||
|
protected IConfigSource m_config;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Console logger
|
||||||
|
/// </summary>
|
||||||
|
private static readonly ILog m_log =
|
||||||
|
LogManager.GetLogger(
|
||||||
|
MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
public ConfigurationLoader()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the region configuration
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="argvSource">Parameters passed into the process when started</param>
|
||||||
|
/// <param name="configSettings"></param>
|
||||||
|
/// <param name="networkInfo"></param>
|
||||||
|
/// <returns>A configuration that gets passed to modules</returns>
|
||||||
|
public IConfigSource LoadConfigSettings()
|
||||||
|
{
|
||||||
|
bool iniFileExists = false;
|
||||||
|
|
||||||
|
List<string> sources = new List<string>();
|
||||||
|
|
||||||
|
string iniFileName = "OpenSim.ini";
|
||||||
|
string iniFilePath = Path.Combine(".", iniFileName);
|
||||||
|
|
||||||
|
if (IsUri(iniFileName))
|
||||||
|
{
|
||||||
|
if (!sources.Contains(iniFileName))
|
||||||
|
sources.Add(iniFileName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (File.Exists(iniFilePath))
|
||||||
|
{
|
||||||
|
if (!sources.Contains(iniFilePath))
|
||||||
|
sources.Add(iniFilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_config = new IniConfigSource();
|
||||||
|
m_config.Merge(DefaultConfig());
|
||||||
|
|
||||||
|
m_log.Info("[CONFIG] Reading configuration settings");
|
||||||
|
|
||||||
|
if (sources.Count == 0)
|
||||||
|
{
|
||||||
|
m_log.FatalFormat("[CONFIG] Could not load any configuration");
|
||||||
|
m_log.FatalFormat("[CONFIG] Did you copy the OpenSim.ini.example file to OpenSim.ini?");
|
||||||
|
Environment.Exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0 ; i < sources.Count ; i++)
|
||||||
|
{
|
||||||
|
if (ReadConfig(sources[i]))
|
||||||
|
iniFileExists = true;
|
||||||
|
AddIncludes(sources);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!iniFileExists)
|
||||||
|
{
|
||||||
|
m_log.FatalFormat("[CONFIG] Could not load any configuration");
|
||||||
|
m_log.FatalFormat("[CONFIG] Configuration exists, but there was an error loading it!");
|
||||||
|
Environment.Exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds the included files as ini configuration files
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sources">List of URL strings or filename strings</param>
|
||||||
|
private void AddIncludes(List<string> sources)
|
||||||
|
{
|
||||||
|
//loop over config sources
|
||||||
|
foreach (IConfig config in m_config.Configs)
|
||||||
|
{
|
||||||
|
// Look for Include-* in the key name
|
||||||
|
string[] keys = config.GetKeys();
|
||||||
|
foreach (string k in keys)
|
||||||
|
{
|
||||||
|
if (k.StartsWith("Include-"))
|
||||||
|
{
|
||||||
|
// read the config file to be included.
|
||||||
|
string file = config.GetString(k);
|
||||||
|
if (IsUri(file))
|
||||||
|
{
|
||||||
|
if (!sources.Contains(file))
|
||||||
|
sources.Add(file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string basepath = Path.GetFullPath(".");
|
||||||
|
string path = Path.Combine(basepath, file);
|
||||||
|
string[] paths = Util.Glob(path);
|
||||||
|
foreach (string p in paths)
|
||||||
|
{
|
||||||
|
if (!sources.Contains(p))
|
||||||
|
sources.Add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Check if we can convert the string to a URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file">String uri to the remote resource</param>
|
||||||
|
/// <returns>true if we can convert the string to a Uri object</returns>
|
||||||
|
bool IsUri(string file)
|
||||||
|
{
|
||||||
|
Uri configUri;
|
||||||
|
|
||||||
|
return Uri.TryCreate(file, UriKind.Absolute,
|
||||||
|
out configUri) && configUri.Scheme == Uri.UriSchemeHttp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provide same ini loader functionality for standard ini and master ini - file system or XML over http
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="iniPath">Full path to the ini</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private bool ReadConfig(string iniPath)
|
||||||
|
{
|
||||||
|
bool success = false;
|
||||||
|
|
||||||
|
if (!IsUri(iniPath))
|
||||||
|
{
|
||||||
|
m_log.InfoFormat("[CONFIG] Reading configuration file {0}",
|
||||||
|
Path.GetFullPath(iniPath));
|
||||||
|
|
||||||
|
m_config.Merge(new IniConfigSource(iniPath));
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_log.InfoFormat("[CONFIG] {0} is a http:// URI, fetching ...",
|
||||||
|
iniPath);
|
||||||
|
|
||||||
|
// The ini file path is a http URI
|
||||||
|
// Try to read it
|
||||||
|
//
|
||||||
|
try
|
||||||
|
{
|
||||||
|
XmlReader r = XmlReader.Create(iniPath);
|
||||||
|
XmlConfigSource cs = new XmlConfigSource(r);
|
||||||
|
m_config.Merge(cs);
|
||||||
|
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.FatalFormat("[CONFIG] Exception reading config from URI {0}\n" + e.ToString(), iniPath);
|
||||||
|
Environment.Exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Setup a default config values in case they aren't present in the ini file
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A Configuration source containing the default configuration</returns>
|
||||||
|
private static IConfigSource DefaultConfig()
|
||||||
|
{
|
||||||
|
IConfigSource defaultConfig = new IniConfigSource();
|
||||||
|
|
||||||
|
{
|
||||||
|
IConfig config = defaultConfig.Configs["Startup"];
|
||||||
|
|
||||||
|
if (null == config)
|
||||||
|
config = defaultConfig.AddConfig("Startup");
|
||||||
|
|
||||||
|
config.Set("region_info_source", "filesystem");
|
||||||
|
|
||||||
|
config.Set("gridmode", false);
|
||||||
|
config.Set("physics", "OpenDynamicsEngine");
|
||||||
|
config.Set("meshing", "Meshmerizer");
|
||||||
|
config.Set("physical_prim", true);
|
||||||
|
config.Set("see_into_this_sim_from_neighbor", true);
|
||||||
|
config.Set("serverside_object_permissions", false);
|
||||||
|
config.Set("storage_plugin", "OpenSim.Data.SQLite.dll");
|
||||||
|
config.Set("storage_connection_string", "URI=file:OpenSim.db,version=3");
|
||||||
|
config.Set("storage_prim_inventories", true);
|
||||||
|
config.Set("startup_console_commands_file", String.Empty);
|
||||||
|
config.Set("shutdown_console_commands_file", String.Empty);
|
||||||
|
config.Set("DefaultScriptEngine", "XEngine");
|
||||||
|
config.Set("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll");
|
||||||
|
// life doesn't really work without this
|
||||||
|
config.Set("EventQueue", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
IConfig config = defaultConfig.Configs["StandAlone"];
|
||||||
|
|
||||||
|
if (null == config)
|
||||||
|
config = defaultConfig.AddConfig("StandAlone");
|
||||||
|
|
||||||
|
config.Set("accounts_authenticate", true);
|
||||||
|
config.Set("welcome_message", "Welcome to OpenSimulator");
|
||||||
|
config.Set("inventory_plugin", "OpenSim.Data.SQLite.dll");
|
||||||
|
config.Set("inventory_source", "");
|
||||||
|
config.Set("userDatabase_plugin", "OpenSim.Data.SQLite.dll");
|
||||||
|
config.Set("user_source", "");
|
||||||
|
config.Set("LibrariesXMLFile", string.Format(".{0}inventory{0}Libraries.xml", Path.DirectorySeparatorChar));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
IConfig config = defaultConfig.Configs["Network"];
|
||||||
|
|
||||||
|
if (null == config)
|
||||||
|
config = defaultConfig.AddConfig("Network");
|
||||||
|
|
||||||
|
config.Set("default_location_x", 1000);
|
||||||
|
config.Set("default_location_y", 1000);
|
||||||
|
config.Set("grid_send_key", "null");
|
||||||
|
config.Set("grid_recv_key", "null");
|
||||||
|
config.Set("user_send_key", "null");
|
||||||
|
config.Set("user_recv_key", "null");
|
||||||
|
config.Set("secure_inventory_server", "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
using Nini.Config;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Careminster
|
||||||
|
{
|
||||||
|
public class Configger
|
||||||
|
{
|
||||||
|
public static int Main(string[] args)
|
||||||
|
{
|
||||||
|
ArgvConfigSource argvConfig = new ArgvConfigSource(args);
|
||||||
|
argvConfig.AddSwitch("Startup", "format", "f");
|
||||||
|
|
||||||
|
IConfig startupConfig = argvConfig.Configs["Startup"];
|
||||||
|
|
||||||
|
string format = startupConfig.GetString("format", "ini");
|
||||||
|
|
||||||
|
ConfigurationLoader loader = new ConfigurationLoader();
|
||||||
|
|
||||||
|
IConfigSource s = loader.LoadConfigSettings();
|
||||||
|
|
||||||
|
if (format == "mysql")
|
||||||
|
{
|
||||||
|
foreach (IConfig c in s.Configs)
|
||||||
|
{
|
||||||
|
foreach (string k in c.GetKeys())
|
||||||
|
{
|
||||||
|
string v = c.GetString(k);
|
||||||
|
|
||||||
|
if (k.StartsWith("Include-"))
|
||||||
|
continue;
|
||||||
|
Console.WriteLine("insert ignore into config (section, name, value) values ('{0}', '{1}', '{2}');", c.Name, k, v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (format == "xml")
|
||||||
|
{
|
||||||
|
Console.WriteLine("<Nini>");
|
||||||
|
|
||||||
|
foreach (IConfig c in s.Configs)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
foreach (string k in c.GetKeys())
|
||||||
|
{
|
||||||
|
if (k.StartsWith("Include-"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine("<Section Name=\"{0}\">", c.Name);
|
||||||
|
|
||||||
|
foreach (string k in c.GetKeys())
|
||||||
|
{
|
||||||
|
string v = c.GetString(k);
|
||||||
|
|
||||||
|
if (k.StartsWith("Include-"))
|
||||||
|
continue;
|
||||||
|
Console.WriteLine(" <Key Name=\"{0}\" Value=\"{1}\" />", k, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("</Section>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Console.WriteLine("</Nini>");
|
||||||
|
}
|
||||||
|
else if (format == "ini")
|
||||||
|
{
|
||||||
|
foreach (IConfig c in s.Configs)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
foreach (string k in c.GetKeys())
|
||||||
|
{
|
||||||
|
if (k.StartsWith("Include-"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine("[{0}]", c.Name);
|
||||||
|
|
||||||
|
foreach (string k in c.GetKeys())
|
||||||
|
{
|
||||||
|
string v = c.GetString(k);
|
||||||
|
|
||||||
|
if (k.StartsWith("Include-"))
|
||||||
|
continue;
|
||||||
|
Console.WriteLine("{0} = \"{1}\"", k, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error: unknown format: {0}", format);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
|
using log4net;
|
||||||
|
using Nini.Config;
|
||||||
|
|
||||||
|
namespace Careminster
|
||||||
|
{
|
||||||
|
public static class Util
|
||||||
|
{
|
||||||
|
public static string[] Glob(string path)
|
||||||
|
{
|
||||||
|
string vol=String.Empty;
|
||||||
|
|
||||||
|
if (Path.VolumeSeparatorChar != Path.DirectorySeparatorChar)
|
||||||
|
{
|
||||||
|
string[] vcomps = path.Split(new char[] {Path.VolumeSeparatorChar}, 2, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
if (vcomps.Length > 1)
|
||||||
|
{
|
||||||
|
path = vcomps[1];
|
||||||
|
vol = vcomps[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] comps = path.Split(new char[] {Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar}, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
// Glob
|
||||||
|
|
||||||
|
path = vol;
|
||||||
|
if (vol != String.Empty)
|
||||||
|
path += new String(new char[] {Path.VolumeSeparatorChar, Path.DirectorySeparatorChar});
|
||||||
|
else
|
||||||
|
path = new String(new char[] {Path.DirectorySeparatorChar});
|
||||||
|
|
||||||
|
List<string> paths = new List<string>();
|
||||||
|
List<string> found = new List<string>();
|
||||||
|
paths.Add(path);
|
||||||
|
|
||||||
|
int compIndex = -1;
|
||||||
|
foreach (string c in comps)
|
||||||
|
{
|
||||||
|
compIndex++;
|
||||||
|
|
||||||
|
List<string> addpaths = new List<string>();
|
||||||
|
foreach (string p in paths)
|
||||||
|
{
|
||||||
|
string[] dirs = Directory.GetDirectories(p, c);
|
||||||
|
|
||||||
|
if (dirs.Length != 0)
|
||||||
|
{
|
||||||
|
foreach (string dir in dirs)
|
||||||
|
addpaths.Add(Path.Combine(path, dir));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only add files if that is the last path component
|
||||||
|
if (compIndex == comps.Length - 1)
|
||||||
|
{
|
||||||
|
string[] files = Directory.GetFiles(p, c);
|
||||||
|
foreach (string f in files)
|
||||||
|
found.Add(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
paths = addpaths;
|
||||||
|
}
|
||||||
|
|
||||||
|
return found.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
prebuild.xml
22
prebuild.xml
|
@ -2916,6 +2916,28 @@
|
||||||
</Files>
|
</Files>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
|
<Project frameworkVersion="v3_5" name="OpenSim.Tools.Configger" path="OpenSim/Tools/Configger" type="Exe">
|
||||||
|
<Configuration name="Debug">
|
||||||
|
<Options>
|
||||||
|
<OutputPath>../../../bin/</OutputPath>
|
||||||
|
</Options>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration name="Release">
|
||||||
|
<Options>
|
||||||
|
<OutputPath>../../../bin/</OutputPath>
|
||||||
|
</Options>
|
||||||
|
</Configuration>
|
||||||
|
|
||||||
|
<ReferencePath>../../../bin/</ReferencePath>
|
||||||
|
<Reference name="System"/>
|
||||||
|
<Reference name="Nini.dll"/>
|
||||||
|
<Reference name="log4net.dll"/>
|
||||||
|
|
||||||
|
<Files>
|
||||||
|
<Match pattern="*.cs" recurse="true"/>
|
||||||
|
</Files>
|
||||||
|
</Project>
|
||||||
|
|
||||||
<!-- Test Suite -->
|
<!-- Test Suite -->
|
||||||
<Project frameworkVersion="v3_5" name="OpenSim.TestSuite" path="OpenSim/TestSuite" type="Exe">
|
<Project frameworkVersion="v3_5" name="OpenSim.TestSuite" path="OpenSim/TestSuite" type="Exe">
|
||||||
<Configuration name="Debug">
|
<Configuration name="Debug">
|
||||||
|
|
Loading…
Reference in New Issue