mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 00:46:02 +08:00
* Split out MSSQLManager Test/Init into each provider.
* Made regions table name configurable (MSSQL only) * Added a note in ini.example pointing out that the sql resources have to change if you change table names * Removed duplicate picker method from GridData interface [Provided by openlifegrid.com]
This commit is contained in:
@@ -47,21 +47,48 @@ namespace OpenSim.Framework.Data.MSSQL
|
||||
/// </summary>
|
||||
private MSSQLManager database;
|
||||
|
||||
private string m_regionsTableName;
|
||||
|
||||
/// <summary>
|
||||
/// Initialises the Grid Interface
|
||||
/// </summary>
|
||||
public void Initialise()
|
||||
{
|
||||
IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini");
|
||||
string settingDataSource = GridDataMySqlFile.ParseFileReadValue("data_source");
|
||||
string settingInitialCatalog = GridDataMySqlFile.ParseFileReadValue("initial_catalog");
|
||||
string settingPersistSecurityInfo = GridDataMySqlFile.ParseFileReadValue("persist_security_info");
|
||||
string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id");
|
||||
string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
|
||||
IniFile iniFile = new IniFile("mssql_connection.ini");
|
||||
|
||||
string settingDataSource = iniFile.ParseFileReadValue("data_source");
|
||||
string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog");
|
||||
string settingPersistSecurityInfo = iniFile.ParseFileReadValue("persist_security_info");
|
||||
string settingUserId = iniFile.ParseFileReadValue("user_id");
|
||||
string settingPassword = iniFile.ParseFileReadValue("password");
|
||||
|
||||
m_regionsTableName = iniFile.ParseFileReadValue("regionstablename");
|
||||
if (m_regionsTableName == null)
|
||||
{
|
||||
m_regionsTableName = "regions";
|
||||
}
|
||||
|
||||
database =
|
||||
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
|
||||
settingPassword);
|
||||
|
||||
TestTables();
|
||||
}
|
||||
|
||||
private void TestTables()
|
||||
{
|
||||
IDbCommand cmd = database.Query("SELECT * FROM "+m_regionsTableName, new Dictionary<string, string>());
|
||||
|
||||
try
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Dispose();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
m_log.Info("[DATASTORE]: MSSQL Database doesn't exist... creating");
|
||||
database.ExecuteResourceSql("Mssql-regions.sql");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -115,7 +142,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
||||
{
|
||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||
param["handle"] = handle.ToString();
|
||||
IDbCommand result = database.Query("SELECT * FROM regions WHERE regionHandle = @handle", param);
|
||||
IDbCommand result = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE regionHandle = @handle", param);
|
||||
reader = result.ExecuteReader();
|
||||
|
||||
RegionProfileData row = database.getRegionRow(reader);
|
||||
@@ -134,89 +161,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// // Returns a list of avatar and UUIDs that match the query
|
||||
/// </summary>
|
||||
public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
|
||||
{
|
||||
List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
|
||||
string[] querysplit;
|
||||
querysplit = query.Split(' ');
|
||||
if (querysplit.Length == 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (database)
|
||||
{
|
||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||
param["first"] = querysplit[0];
|
||||
param["second"] = querysplit[1];
|
||||
|
||||
IDbCommand result =
|
||||
database.Query(
|
||||
"SELECT UUID,username,surname FROM users WHERE username = @first AND lastname = @second",
|
||||
param);
|
||||
IDataReader reader = result.ExecuteReader();
|
||||
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
AvatarPickerAvatar user = new AvatarPickerAvatar();
|
||||
user.AvatarID = new LLUUID((string) reader["UUID"]);
|
||||
user.firstName = (string) reader["username"];
|
||||
user.lastName = (string) reader["surname"];
|
||||
returnlist.Add(user);
|
||||
}
|
||||
reader.Close();
|
||||
result.Dispose();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
database.Reconnect();
|
||||
m_log.Error(e.ToString());
|
||||
return returnlist;
|
||||
}
|
||||
}
|
||||
else if (querysplit.Length == 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (database)
|
||||
{
|
||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||
param["first"] = querysplit[0];
|
||||
param["second"] = querysplit[1];
|
||||
|
||||
IDbCommand result =
|
||||
database.Query(
|
||||
"SELECT UUID,username,surname FROM users WHERE username = @first OR lastname = @second",
|
||||
param);
|
||||
IDataReader reader = result.ExecuteReader();
|
||||
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
AvatarPickerAvatar user = new AvatarPickerAvatar();
|
||||
user.AvatarID = new LLUUID((string) reader["UUID"]);
|
||||
user.firstName = (string) reader["username"];
|
||||
user.lastName = (string) reader["surname"];
|
||||
returnlist.Add(user);
|
||||
}
|
||||
reader.Close();
|
||||
result.Dispose();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
database.Reconnect();
|
||||
m_log.Error(e.ToString());
|
||||
return returnlist;
|
||||
}
|
||||
}
|
||||
return returnlist;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a sim profile from it's UUID
|
||||
/// </summary>
|
||||
@@ -226,7 +171,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
||||
{
|
||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||
param["uuid"] = uuid.ToString();
|
||||
IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = @uuid", param);
|
||||
IDbCommand result = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE uuid = @uuid", param);
|
||||
IDataReader reader = result.ExecuteReader();
|
||||
|
||||
RegionProfileData row = database.getRegionRow(reader);
|
||||
|
||||
Reference in New Issue
Block a user