Mantis#1736. Thank you kindly, StrawberryFride for a patch that:

Many issues with handling connections in MSSQL, have rearchitected to 
ensure that connections are always opened and closed in a timely fashion 
& disposed of cleanly, and removed unnecessary lock statements. SQL 
Server performance seems to have improved considerably as a result, 
and various timeout errors seem to have been fixed.
0.6.0-stable
Charles Krinke 2008-07-17 13:43:31 +00:00
parent ed4241583f
commit e8412dcd42
8 changed files with 780 additions and 709 deletions

View File

@ -0,0 +1,216 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace OpenSim.Data.MSSQL
{
/// <summary>
/// Encapsulates a SqlCommand object but ensures that when it is disposed, its connection is closed and disposed also.
/// </summary>
internal class AutoClosingSqlCommand : IDbCommand
{
private SqlCommand realCommand;
public AutoClosingSqlCommand(SqlCommand cmd)
{
realCommand = cmd;
}
#region IDbCommand Members
public void Cancel()
{
realCommand.Cancel();
}
public string CommandText
{
get
{
return realCommand.CommandText;
}
set
{
realCommand.CommandText = value;
}
}
public int CommandTimeout
{
get
{
return realCommand.CommandTimeout;
}
set
{
realCommand.CommandTimeout = value;
}
}
public CommandType CommandType
{
get
{
return realCommand.CommandType;
}
set
{
realCommand.CommandType = value;
}
}
IDbConnection IDbCommand.Connection
{
get
{
return realCommand.Connection;
}
set
{
realCommand.Connection = (SqlConnection) value;
}
}
public SqlConnection Connection
{
get
{
return realCommand.Connection;
}
}
IDbDataParameter IDbCommand.CreateParameter()
{
return realCommand.CreateParameter();
}
public SqlParameter CreateParameter()
{
return realCommand.CreateParameter();
}
public int ExecuteNonQuery()
{
return realCommand.ExecuteNonQuery();
}
IDataReader IDbCommand.ExecuteReader(CommandBehavior behavior)
{
return realCommand.ExecuteReader(behavior);
}
public SqlDataReader ExecuteReader(CommandBehavior behavior)
{
return realCommand.ExecuteReader(behavior);
}
IDataReader IDbCommand.ExecuteReader()
{
return realCommand.ExecuteReader();
}
public SqlDataReader ExecuteReader()
{
return realCommand.ExecuteReader();
}
public object ExecuteScalar()
{
return realCommand.ExecuteScalar();
}
IDataParameterCollection IDbCommand.Parameters
{
get { return realCommand.Parameters; }
}
public SqlParameterCollection Parameters
{
get { return realCommand.Parameters; }
}
public void Prepare()
{
realCommand.Prepare();
}
IDbTransaction IDbCommand.Transaction
{
get
{
return realCommand.Transaction;
}
set
{
realCommand.Transaction = (SqlTransaction) value;
}
}
UpdateRowSource IDbCommand.UpdatedRowSource
{
get
{
return realCommand.UpdatedRowSource;
}
set
{
realCommand.UpdatedRowSource = value;
}
}
#endregion
#region IDisposable Members
public void Dispose()
{
SqlConnection conn = realCommand.Connection;
try
{
realCommand.Dispose();
}
finally
{
try
{
conn.Close();
}
finally
{
conn.Dispose();
}
}
}
#endregion
}
}

View File

@ -86,19 +86,14 @@ namespace OpenSim.Data.MSSQL
/// <returns></returns>
override public AssetBase FetchAsset(LLUUID assetID)
{
AssetBase asset = null;
Dictionary<string, string> param = new Dictionary<string, string>();
param["id"] = assetID.ToString();
IDbCommand result = database.Query("SELECT * FROM assets WHERE id = @id", param);
IDataReader reader = result.ExecuteReader();
asset = database.getAssetRow(reader);
reader.Close();
result.Dispose();
return asset;
using (IDbCommand result = database.Query("SELECT * FROM assets WHERE id = @id", param))
using (IDataReader reader = result.ExecuteReader())
{
return database.getAssetRow(reader);
}
}
/// <summary>
@ -113,15 +108,13 @@ namespace OpenSim.Data.MSSQL
}
SqlCommand cmd =
new SqlCommand(
using (AutoClosingSqlCommand cmd =
database.Query(
"INSERT INTO assets ([id], [name], [description], [assetType], [local], [temporary], [data])" +
" VALUES " +
"(@id, @name, @description, @assetType, @local, @temporary, @data)",
database.getConnection());
using (cmd)
"(@id, @name, @description, @assetType, @local, @temporary, @data)"))
{
//SqlParameter p = cmd.Parameters.Add("id", SqlDbType.NVarChar);
//p.Value = asset.FullID.ToString();
cmd.Parameters.AddWithValue("id", asset.FullID.ToString());
@ -135,16 +128,8 @@ namespace OpenSim.Data.MSSQL
h.Value = asset.Temporary;
SqlParameter i = cmd.Parameters.Add("data", SqlDbType.Image);
i.Value = asset.Data;
try
{
cmd.ExecuteNonQuery();
}
catch (Exception)
{
throw;
}
cmd.Dispose();
cmd.ExecuteNonQuery();
}
}
@ -154,38 +139,40 @@ namespace OpenSim.Data.MSSQL
/// <param name="asset">the asset</param>
override public void UpdateAsset(AssetBase asset)
{
SqlCommand command = new SqlCommand("UPDATE assets set id = @id, " +
using (IDbCommand command = database.Query("UPDATE assets set id = @id, " +
"name = @name, " +
"description = @description," +
"assetType = @assetType," +
"local = @local," +
"temporary = @temporary," +
"data = @data where " +
"id = @keyId;", database.getConnection());
SqlParameter param1 = new SqlParameter("@id", asset.FullID.ToString());
SqlParameter param2 = new SqlParameter("@name", asset.Name);
SqlParameter param3 = new SqlParameter("@description", asset.Description);
SqlParameter param4 = new SqlParameter("@assetType", asset.Type);
SqlParameter param6 = new SqlParameter("@local", asset.Local);
SqlParameter param7 = new SqlParameter("@temporary", asset.Temporary);
SqlParameter param8 = new SqlParameter("@data", asset.Data);
SqlParameter param9 = new SqlParameter("@keyId", asset.FullID.ToString());
command.Parameters.Add(param1);
command.Parameters.Add(param2);
command.Parameters.Add(param3);
command.Parameters.Add(param4);
command.Parameters.Add(param6);
command.Parameters.Add(param7);
command.Parameters.Add(param8);
command.Parameters.Add(param9);
"id = @keyId;"))
{
SqlParameter param1 = new SqlParameter("@id", asset.FullID.ToString());
SqlParameter param2 = new SqlParameter("@name", asset.Name);
SqlParameter param3 = new SqlParameter("@description", asset.Description);
SqlParameter param4 = new SqlParameter("@assetType", asset.Type);
SqlParameter param6 = new SqlParameter("@local", asset.Local);
SqlParameter param7 = new SqlParameter("@temporary", asset.Temporary);
SqlParameter param8 = new SqlParameter("@data", asset.Data);
SqlParameter param9 = new SqlParameter("@keyId", asset.FullID.ToString());
command.Parameters.Add(param1);
command.Parameters.Add(param2);
command.Parameters.Add(param3);
command.Parameters.Add(param4);
command.Parameters.Add(param6);
command.Parameters.Add(param7);
command.Parameters.Add(param8);
command.Parameters.Add(param9);
try
{
command.ExecuteNonQuery();
}
catch (Exception e)
{
m_log.Error(e.ToString());
try
{
command.ExecuteNonQuery();
}
catch (Exception e)
{
m_log.Error(e.ToString());
}
}
}
@ -228,12 +215,12 @@ namespace OpenSim.Data.MSSQL
/// <remarks>it use mssql_connection.ini</remarks>
override 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 gridDataMSSqlFile = new IniFile("mssql_connection.ini");
string settingDataSource = gridDataMSSqlFile.ParseFileReadValue("data_source");
string settingInitialCatalog = gridDataMSSqlFile.ParseFileReadValue("initial_catalog");
string settingPersistSecurityInfo = gridDataMSSqlFile.ParseFileReadValue("persist_security_info");
string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id");
string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password");
database =
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,

View File

@ -1758,7 +1758,7 @@ namespace OpenSim.Data.MSSQL
}
catch (SqlException)
{
m_log.Info("[REGION DB]: MySql Database doesn't exist... creating");
m_log.Info("[REGION DB]: MS Sql Database doesn't exist... creating");
InitDB(conn);
}

View File

@ -84,17 +84,17 @@ namespace OpenSim.Data.MSSQL
/// </summary>
private void TestTables()
{
IDbCommand cmd = database.Query("SELECT TOP 1 * FROM "+m_regionsTableName, new Dictionary<string, string>());
try
using (IDbCommand cmd = database.Query("SELECT TOP 1 * FROM " + m_regionsTableName, new Dictionary<string, string>()))
{
cmd.ExecuteNonQuery();
cmd.Dispose();
}
catch (Exception)
{
m_log.Info("[GRID DB]: MSSQL Database doesn't exist... creating");
database.ExecuteResourceSql("Mssql-regions.sql");
try
{
cmd.ExecuteNonQuery();
}
catch (Exception)
{
m_log.Info("[GRID DB]: MSSQL Database doesn't exist... creating");
database.ExecuteResourceSql("Mssql-regions.sql");
}
}
}
@ -103,7 +103,7 @@ namespace OpenSim.Data.MSSQL
/// </summary>
override public void Close()
{
database.Close();
// nothing to close
}
/// <summary>
@ -146,32 +146,22 @@ namespace OpenSim.Data.MSSQL
/// <returns>Sim profile</returns>
override public RegionProfileData GetProfileByHandle(ulong handle)
{
IDataReader reader = null;
Dictionary<string, string> param = new Dictionary<string, string>();
param["handle"] = handle.ToString();
try
{
if (database.getConnection().State == ConnectionState.Closed)
using (IDbCommand result = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE regionHandle = @handle", param))
using (IDataReader reader = result.ExecuteReader())
{
database.Reconnect();
return database.getRegionRow(reader);
}
Dictionary<string, string> param = new Dictionary<string, string>();
param["handle"] = handle.ToString();
IDbCommand result = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE regionHandle = @handle", param);
reader = result.ExecuteReader();
RegionProfileData row = database.getRegionRow(reader);
reader.Close();
result.Dispose();
return row;
}
catch (Exception)
catch
{
if (reader != null)
{
reader.Close();
}
return null;
}
return null;
}
/// <summary>
@ -183,14 +173,13 @@ namespace OpenSim.Data.MSSQL
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["uuid"] = uuid.ToString();
IDbCommand result = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE uuid = @uuid", param);
IDataReader reader = result.ExecuteReader();
RegionProfileData row = database.getRegionRow(reader);
reader.Close();
result.Dispose();
using (IDbCommand result = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE uuid = @uuid", param))
using (IDataReader reader = result.ExecuteReader())
{
return database.getRegionRow(reader);
}
return row;
}
/// <summary>
@ -204,25 +193,19 @@ namespace OpenSim.Data.MSSQL
{
try
{
lock (database)
Dictionary<string, string> param = new Dictionary<string, string>();
// Add % because this is a like query.
param["?regionName"] = regionName + "%";
// Order by statement will return shorter matches first. Only returns one record or no record.
using (IDbCommand result = database.Query("SELECT top 1 * FROM " + m_regionsTableName + " WHERE regionName like ?regionName order by regionName", param))
using (IDataReader reader = result.ExecuteReader())
{
Dictionary<string, string> param = new Dictionary<string, string>();
// Add % because this is a like query.
param["?regionName"] = regionName + "%";
// Order by statement will return shorter matches first. Only returns one record or no record.
IDbCommand result = database.Query("SELECT top 1 * FROM " + m_regionsTableName + " WHERE regionName like ?regionName order by regionName", param);
IDataReader reader = result.ExecuteReader();
RegionProfileData row = database.getRegionRow(reader);
reader.Close();
result.Dispose();
return row;
return database.getRegionRow(reader);
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
return null;
}
@ -324,12 +307,13 @@ namespace OpenSim.Data.MSSQL
try
{
IDbCommand result = database.Query(sql, parameters);
using (IDbCommand result = database.Query(sql, parameters))
{
if (result.ExecuteNonQuery() == 1)
returnval = true;
if (result.ExecuteNonQuery() == 1)
returnval = true;
result.Dispose();
}
}
catch (Exception e)
{
@ -347,17 +331,15 @@ namespace OpenSim.Data.MSSQL
{
//Insert new region
string sql =
"INSERT INTO " + m_regionsTableName + " ([regionHandle], [regionName], [uuid], [regionRecvKey], [regionSecret], [regionSendKey], [regionDataURI], ";
sql +=
"[serverIP], [serverPort], [serverURI], [locX], [locY], [locZ], [eastOverrideHandle], [westOverrideHandle], [southOverrideHandle], [northOverrideHandle], [regionAssetURI], [regionAssetRecvKey], ";
sql +=
"[regionAssetSendKey], [regionUserURI], [regionUserRecvKey], [regionUserSendKey], [regionMapTexture], [serverHttpPort], [serverRemotingPort], [owner_uuid]) VALUES ";
sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, ";
sql +=
"@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, ";
sql +=
"@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey, @regionMapTexture, @serverHttpPort, @serverRemotingPort, @owner_uuid);";
"INSERT INTO " + m_regionsTableName + @" ([regionHandle], [regionName], [uuid], [regionRecvKey], [regionSecret], [regionSendKey], [regionDataURI],
[serverIP], [serverPort], [serverURI], [locX], [locY], [locZ], [eastOverrideHandle], [westOverrideHandle],
[southOverrideHandle], [northOverrideHandle], [regionAssetURI], [regionAssetRecvKey], [regionAssetSendKey],
[regionUserURI], [regionUserRecvKey], [regionUserSendKey], [regionMapTexture], [serverHttpPort],
[serverRemotingPort], [owner_uuid])
VALUES (@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI,
@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle,
@southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, @regionAssetSendKey,
@regionUserURI, @regionUserRecvKey, @regionUserSendKey, @regionMapTexture, @serverHttpPort, @serverRemotingPort, @owner_uuid);";
Dictionary<string, string> parameters = new Dictionary<string, string>();
@ -393,12 +375,11 @@ namespace OpenSim.Data.MSSQL
try
{
IDbCommand result = database.Query(sql, parameters);
if (result.ExecuteNonQuery() == 1)
returnval = true;
result.Dispose();
using (IDbCommand result = database.Query(sql, parameters))
{
if (result.ExecuteNonQuery() == 1)
returnval = true;
}
}
catch (Exception e)
{

View File

@ -67,12 +67,12 @@ namespace OpenSim.Data.MSSQL
public void Initialise(string connect)
{
// TODO: actually use the provided connect string
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 gridDataMSSqlFile = new IniFile("mssql_connection.ini");
string settingDataSource = gridDataMSSqlFile.ParseFileReadValue("data_source");
string settingInitialCatalog = gridDataMSSqlFile.ParseFileReadValue("initial_catalog");
string settingPersistSecurityInfo = gridDataMSSqlFile.ParseFileReadValue("persist_security_info");
string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id");
string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password");
database =
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
@ -165,29 +165,26 @@ namespace OpenSim.Data.MSSQL
{
try
{
lock (database)
List<InventoryItemBase> items = new List<InventoryItemBase>();
Dictionary<string, string> param = new Dictionary<string, string>();
param["parentFolderID"] = folderID.ToString();
using (IDbCommand result =
database.Query("SELECT * FROM inventoryitems WHERE parentFolderID = @parentFolderID", param))
using (IDataReader reader = result.ExecuteReader())
{
List<InventoryItemBase> items = new List<InventoryItemBase>();
Dictionary<string, string> param = new Dictionary<string, string>();
param["parentFolderID"] = folderID.ToString();
IDbCommand result =
database.Query("SELECT * FROM inventoryitems WHERE parentFolderID = @parentFolderID", param);
IDataReader reader = result.ExecuteReader();
while (reader.Read())
items.Add(readInventoryItem(reader));
reader.Close();
result.Dispose();
return items;
}
return items;
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
return null;
}
@ -202,30 +199,26 @@ namespace OpenSim.Data.MSSQL
{
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["uuid"] = user.ToString();
param["zero"] = LLUUID.Zero.ToString();
Dictionary<string, string> param = new Dictionary<string, string>();
param["uuid"] = user.ToString();
param["zero"] = LLUUID.Zero.ToString();
IDbCommand result =
database.Query(
"SELECT * FROM inventoryfolders WHERE parentFolderID = @zero AND agentID = @uuid", param);
IDataReader reader = result.ExecuteReader();
using (IDbCommand result =
database.Query(
"SELECT * FROM inventoryfolders WHERE parentFolderID = @zero AND agentID = @uuid", param))
using (IDataReader reader = result.ExecuteReader())
{
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
while (reader.Read())
items.Add(readInventoryFolder(reader));
reader.Close();
result.Dispose();
return items;
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
return null;
}
@ -240,16 +233,15 @@ namespace OpenSim.Data.MSSQL
{
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["uuid"] = user.ToString();
param["zero"] = LLUUID.Zero.ToString();
Dictionary<string, string> param = new Dictionary<string, string>();
param["uuid"] = user.ToString();
param["zero"] = LLUUID.Zero.ToString();
IDbCommand result =
database.Query(
"SELECT * FROM inventoryfolders WHERE parentFolderID = @zero AND agentID = @uuid", param);
IDataReader reader = result.ExecuteReader();
using (IDbCommand result =
database.Query(
"SELECT * FROM inventoryfolders WHERE parentFolderID = @zero AND agentID = @uuid", param))
using (IDataReader reader = result.ExecuteReader())
{
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
while (reader.Read())
@ -267,15 +259,12 @@ namespace OpenSim.Data.MSSQL
rootFolder = items[0];
}
reader.Close();
result.Dispose();
return rootFolder;
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
return null;
}
@ -290,30 +279,23 @@ namespace OpenSim.Data.MSSQL
{
try
{
lock (database)
Dictionary<string, string> param = new Dictionary<string, string>();
param["parentFolderID"] = parentID.ToString();
using (IDbCommand result =
database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = @parentFolderID", param))
using (IDataReader reader = result.ExecuteReader())
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["parentFolderID"] = parentID.ToString();
IDbCommand result =
database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = @parentFolderID", param);
IDataReader reader = result.ExecuteReader();
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
while (reader.Read())
items.Add(readInventoryFolder(reader));
reader.Close();
result.Dispose();
return items;
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
return null;
}
@ -369,28 +351,23 @@ namespace OpenSim.Data.MSSQL
{
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["inventoryID"] = itemID.ToString();
Dictionary<string, string> param = new Dictionary<string, string>();
param["inventoryID"] = itemID.ToString();
IDbCommand result =
database.Query("SELECT * FROM inventoryitems WHERE inventoryID = @inventoryID", param);
IDataReader reader = result.ExecuteReader();
using (IDbCommand result =
database.Query("SELECT * FROM inventoryitems WHERE inventoryID = @inventoryID", param))
using (IDataReader reader = result.ExecuteReader())
{
InventoryItemBase item = null;
if (reader.Read())
item = readInventoryItem(reader);
reader.Close();
result.Dispose();
return item;
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
}
return null;
@ -431,25 +408,22 @@ namespace OpenSim.Data.MSSQL
{
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["uuid"] = folderID.ToString();
Dictionary<string, string> param = new Dictionary<string, string>();
param["uuid"] = folderID.ToString();
IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE folderID = @uuid", param);
IDataReader reader = result.ExecuteReader();
using (IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE folderID = @uuid", param))
using (IDataReader reader = result.ExecuteReader())
{
reader.Read();
InventoryFolderBase folder = readInventoryFolder(reader);
reader.Close();
result.Dispose();
return folder;
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
return null;
}
@ -479,9 +453,8 @@ namespace OpenSim.Data.MSSQL
+ ", @inventoryBasePermissions, @inventoryEveryOnePermissions, @salePrice, @saleType"
+ ", @creationDate, @groupID, @groupOwned, @flags);";
try
using (AutoClosingSqlCommand command = database.Query(sql))
{
SqlCommand command = new SqlCommand(sql, database.getConnection());
command.Parameters.AddWithValue("inventoryID", item.ID.ToString());
command.Parameters.AddWithValue("assetID", item.AssetID.ToString());
command.Parameters.AddWithValue("assetType", item.AssetType.ToString());
@ -502,13 +475,16 @@ namespace OpenSim.Data.MSSQL
command.Parameters.AddWithValue("groupOwned", item.GroupOwned);
command.Parameters.AddWithValue("flags", ConvertUint32BitFieldToInt32(item.Flags));
command.ExecuteNonQuery();
command.Dispose();
}
catch (SqlException e)
{
m_log.Error(e.ToString());
try
{
command.ExecuteNonQuery();
}
catch (SqlException e)
{
m_log.Error(e.ToString());
}
}
}
/// <summary>
@ -517,7 +493,7 @@ namespace OpenSim.Data.MSSQL
/// <param name="item">Inventory item to update</param>
public void updateInventoryItem(InventoryItemBase item)
{
SqlCommand command = new SqlCommand("UPDATE inventoryitems set inventoryID = @inventoryID, " +
using (AutoClosingSqlCommand command = database.Query("UPDATE inventoryitems set inventoryID = @inventoryID, " +
"assetID = @assetID, " +
"assetType = @assetType," +
"parentFolderID = @parentFolderID," +
@ -529,42 +505,44 @@ namespace OpenSim.Data.MSSQL
"invType = @invType," +
"creatorID = @creatorID," +
"inventoryBasePermissions = @inventoryBasePermissions," +
"inventoryEveryOnePermissions = @inventoryEveryOnePermissions," +
"inventoryEveryOnePermissions = @inventoryEveryOnePermissions," +
"salePrice = @salePrice," +
"saleType = @saleType," +
"saleType = @saleType," +
"creationDate = @creationDate," +
"groupID = @groupID," +
"groupOwned = @groupOwned," +
"groupID = @groupID," +
"groupOwned = @groupOwned," +
"flags = @flags where " +
"inventoryID = @keyInventoryID;", database.getConnection());
command.Parameters.AddWithValue("inventoryID", item.ID.ToString());
command.Parameters.AddWithValue("assetID", item.AssetID.ToString());
command.Parameters.AddWithValue("assetType", item.AssetType.ToString());
command.Parameters.AddWithValue("parentFolderID", item.Folder.ToString());
command.Parameters.AddWithValue("avatarID", item.Owner.ToString());
command.Parameters.AddWithValue("inventoryName", item.Name);
command.Parameters.AddWithValue("inventoryDescription", item.Description);
command.Parameters.AddWithValue("inventoryNextPermissions", ConvertUint32BitFieldToInt32(item.NextPermissions));
command.Parameters.AddWithValue("inventoryCurrentPermissions", ConvertUint32BitFieldToInt32(item.CurrentPermissions));
command.Parameters.AddWithValue("invType", item.InvType);
command.Parameters.AddWithValue("creatorID", item.Creator.ToString());
command.Parameters.AddWithValue("inventoryBasePermissions", ConvertUint32BitFieldToInt32(item.BasePermissions));
command.Parameters.AddWithValue("inventoryEveryOnePermissions", ConvertUint32BitFieldToInt32(item.EveryOnePermissions));
command.Parameters.AddWithValue("salePrice", item.SalePrice);
command.Parameters.AddWithValue("saleType", item.SaleType);
command.Parameters.AddWithValue("creationDate", item.CreationDate);
command.Parameters.AddWithValue("groupID", item.GroupID.ToString());
command.Parameters.AddWithValue("groupOwned", item.GroupOwned);
command.Parameters.AddWithValue("flags", ConvertUint32BitFieldToInt32(item.Flags));
command.Parameters.AddWithValue("@keyInventoryID", item.ID.ToString());
"inventoryID = @keyInventoryID;"))
{
command.Parameters.AddWithValue("inventoryID", item.ID.ToString());
command.Parameters.AddWithValue("assetID", item.AssetID.ToString());
command.Parameters.AddWithValue("assetType", item.AssetType.ToString());
command.Parameters.AddWithValue("parentFolderID", item.Folder.ToString());
command.Parameters.AddWithValue("avatarID", item.Owner.ToString());
command.Parameters.AddWithValue("inventoryName", item.Name);
command.Parameters.AddWithValue("inventoryDescription", item.Description);
command.Parameters.AddWithValue("inventoryNextPermissions", ConvertUint32BitFieldToInt32(item.NextPermissions));
command.Parameters.AddWithValue("inventoryCurrentPermissions", ConvertUint32BitFieldToInt32(item.CurrentPermissions));
command.Parameters.AddWithValue("invType", item.InvType);
command.Parameters.AddWithValue("creatorID", item.Creator.ToString());
command.Parameters.AddWithValue("inventoryBasePermissions", ConvertUint32BitFieldToInt32(item.BasePermissions));
command.Parameters.AddWithValue("inventoryEveryOnePermissions", ConvertUint32BitFieldToInt32(item.EveryOnePermissions));
command.Parameters.AddWithValue("salePrice", item.SalePrice);
command.Parameters.AddWithValue("saleType", item.SaleType);
command.Parameters.AddWithValue("creationDate", item.CreationDate);
command.Parameters.AddWithValue("groupID", item.GroupID.ToString());
command.Parameters.AddWithValue("groupOwned", item.GroupOwned);
command.Parameters.AddWithValue("flags", ConvertUint32BitFieldToInt32(item.Flags));
command.Parameters.AddWithValue("@keyInventoryID", item.ID.ToString());
try
{
command.ExecuteNonQuery();
}
catch (Exception e)
{
m_log.Error(e.ToString());
try
{
command.ExecuteNonQuery();
}
catch (Exception e)
{
m_log.Error(e.ToString());
}
}
}
@ -579,13 +557,13 @@ namespace OpenSim.Data.MSSQL
Dictionary<string, string> param = new Dictionary<string, string>();
param["uuid"] = itemID.ToString();
IDbCommand cmd = database.Query("DELETE FROM inventoryitems WHERE inventoryID=@uuid", param);
cmd.ExecuteNonQuery();
cmd.Dispose();
using (IDbCommand cmd = database.Query("DELETE FROM inventoryitems WHERE inventoryID=@uuid", param))
{
cmd.ExecuteNonQuery();
}
}
catch (SqlException e)
{
database.Reconnect();
m_log.Error(e.ToString());
}
}
@ -601,23 +579,24 @@ namespace OpenSim.Data.MSSQL
sql += "(@folderID, @agentID, @parentFolderID, @folderName, @type, @version);";
SqlCommand command = new SqlCommand(sql, database.getConnection());
command.Parameters.AddWithValue("folderID", folder.ID.ToString());
command.Parameters.AddWithValue("agentID", folder.Owner.ToString());
command.Parameters.AddWithValue("parentFolderID", folder.ParentID.ToString());
command.Parameters.AddWithValue("folderName", folder.Name);
command.Parameters.AddWithValue("type", folder.Type);
command.Parameters.AddWithValue("version", Convert.ToInt32(folder.Version));
using (AutoClosingSqlCommand command = database.Query(sql))
{
command.Parameters.AddWithValue("folderID", folder.ID.ToString());
command.Parameters.AddWithValue("agentID", folder.Owner.ToString());
command.Parameters.AddWithValue("parentFolderID", folder.ParentID.ToString());
command.Parameters.AddWithValue("folderName", folder.Name);
command.Parameters.AddWithValue("type", folder.Type);
command.Parameters.AddWithValue("version", Convert.ToInt32(folder.Version));
try
{
//IDbCommand result = database.Query(sql, param);
command.ExecuteNonQuery();
command.Dispose();
}
catch (Exception e)
{
m_log.Error(e.ToString());
try
{
//IDbCommand result = database.Query(sql, param);
command.ExecuteNonQuery();
}
catch (Exception e)
{
m_log.Error(e.ToString());
}
}
}
@ -627,35 +606,37 @@ namespace OpenSim.Data.MSSQL
/// <param name="folder">Folder to update</param>
public void updateInventoryFolder(InventoryFolderBase folder)
{
SqlCommand command = new SqlCommand("UPDATE inventoryfolders set folderID = @folderID, " +
using (IDbCommand command = database.Query("UPDATE inventoryfolders set folderID = @folderID, " +
"agentID = @agentID, " +
"parentFolderID = @parentFolderID," +
"folderName = @folderName," +
"type = @type," +
"version = @version where " +
"folderID = @keyFolderID;", database.getConnection());
SqlParameter param1 = new SqlParameter("@folderID", folder.ID.ToString());
SqlParameter param2 = new SqlParameter("@agentID", folder.Owner.ToString());
SqlParameter param3 = new SqlParameter("@parentFolderID", folder.ParentID.ToString());
SqlParameter param4 = new SqlParameter("@folderName", folder.Name);
SqlParameter param5 = new SqlParameter("@type", folder.Type);
SqlParameter param6 = new SqlParameter("@version", Convert.ToInt32(folder.Version));
SqlParameter param7 = new SqlParameter("@keyFolderID", folder.ID.ToString());
command.Parameters.Add(param1);
command.Parameters.Add(param2);
command.Parameters.Add(param3);
command.Parameters.Add(param4);
command.Parameters.Add(param5);
command.Parameters.Add(param6);
command.Parameters.Add(param7);
"folderID = @keyFolderID;"))
{
SqlParameter param1 = new SqlParameter("@folderID", folder.ID.ToString());
SqlParameter param2 = new SqlParameter("@agentID", folder.Owner.ToString());
SqlParameter param3 = new SqlParameter("@parentFolderID", folder.ParentID.ToString());
SqlParameter param4 = new SqlParameter("@folderName", folder.Name);
SqlParameter param5 = new SqlParameter("@type", folder.Type);
SqlParameter param6 = new SqlParameter("@version", Convert.ToInt32(folder.Version));
SqlParameter param7 = new SqlParameter("@keyFolderID", folder.ID.ToString());
command.Parameters.Add(param1);
command.Parameters.Add(param2);
command.Parameters.Add(param3);
command.Parameters.Add(param4);
command.Parameters.Add(param5);
command.Parameters.Add(param6);
command.Parameters.Add(param7);
try
{
command.ExecuteNonQuery();
}
catch (Exception e)
{
m_log.Error(e.ToString());
try
{
command.ExecuteNonQuery();
}
catch (Exception e)
{
m_log.Error(e.ToString());
}
}
}
@ -665,23 +646,25 @@ namespace OpenSim.Data.MSSQL
/// <param name="folder">Folder to update</param>
public void moveInventoryFolder(InventoryFolderBase folder)
{
SqlCommand command = new SqlCommand("UPDATE inventoryfolders set folderID = @folderID, " +
using (IDbCommand command = database.Query("UPDATE inventoryfolders set folderID = @folderID, " +
"parentFolderID = @parentFolderID," +
"folderID = @keyFolderID;", database.getConnection());
SqlParameter param1 = new SqlParameter("@folderID", folder.ID.ToString());
SqlParameter param2 = new SqlParameter("@parentFolderID", folder.ParentID.ToString());
SqlParameter param3 = new SqlParameter("@keyFolderID", folder.ID.ToString());
command.Parameters.Add(param1);
command.Parameters.Add(param2);
command.Parameters.Add(param3);
"folderID = @keyFolderID;"))
{
SqlParameter param1 = new SqlParameter("@folderID", folder.ID.ToString());
SqlParameter param2 = new SqlParameter("@parentFolderID", folder.ParentID.ToString());
SqlParameter param3 = new SqlParameter("@keyFolderID", folder.ID.ToString());
command.Parameters.Add(param1);
command.Parameters.Add(param2);
command.Parameters.Add(param3);
try
{
command.ExecuteNonQuery();
}
catch (Exception e)
{
m_log.Error(e.ToString());
try
{
command.ExecuteNonQuery();
}
catch (Exception e)
{
m_log.Error(e.ToString());
}
}
}
@ -721,13 +704,13 @@ namespace OpenSim.Data.MSSQL
Dictionary<string, string> param = new Dictionary<string, string>();
param["folderID"] = folderID.ToString();
IDbCommand cmd = database.Query("DELETE FROM inventoryfolders WHERE folderID=@folderID", param);
cmd.ExecuteNonQuery();
cmd.Dispose();
using (IDbCommand cmd = database.Query("DELETE FROM inventoryfolders WHERE folderID=@folderID", param))
{
cmd.ExecuteNonQuery();
}
}
catch (SqlException e)
{
database.Reconnect();
m_log.Error(e.ToString());
}
}
@ -744,14 +727,14 @@ namespace OpenSim.Data.MSSQL
param["parentFolderID"] = folderID.ToString();
IDbCommand cmd =
database.Query("DELETE FROM inventoryitems WHERE parentFolderID=@parentFolderID", param);
cmd.ExecuteNonQuery();
cmd.Dispose();
using (IDbCommand cmd =
database.Query("DELETE FROM inventoryitems WHERE parentFolderID=@parentFolderID", param))
{
cmd.ExecuteNonQuery();
}
}
catch (SqlException e)
{
database.Reconnect();
m_log.Error(e.ToString());
}
}
@ -762,7 +745,7 @@ namespace OpenSim.Data.MSSQL
/// <param name="folderId">Id of folder to delete</param>
public void deleteInventoryFolder(LLUUID folderID)
{
lock (database)
// lock (database)
{
List<InventoryFolderBase> subFolders = getFolderHierarchy(folderID);

View File

@ -31,7 +31,7 @@ using System.Data;
namespace OpenSim.Data.MSSQL
{
/// <summary>
/// An interface to the log database for MySQL
/// An interface to the log database for MSSQL
/// </summary>
internal class MSSQLLogData : ILogData
{
@ -46,26 +46,27 @@ namespace OpenSim.Data.MSSQL
public void Initialise(string connect)
{
// TODO: do something with the connect string
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 gridDataMSSqlFile = new IniFile("mssql_connection.ini");
string settingDataSource = gridDataMSSqlFile.ParseFileReadValue("data_source");
string settingInitialCatalog = gridDataMSSqlFile.ParseFileReadValue("initial_catalog");
string settingPersistSecurityInfo = gridDataMSSqlFile.ParseFileReadValue("persist_security_info");
string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id");
string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password");
database =
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
settingPassword);
IDbCommand cmd = database.Query("select top 1 * from logs", new Dictionary<string, string>());
try
using (IDbCommand cmd = database.Query("select top 1 * from logs", new Dictionary<string, string>()))
{
cmd.ExecuteNonQuery();
cmd.Dispose();
}
catch
{
database.ExecuteResourceSql("Mssql-logs.sql");
try
{
cmd.ExecuteNonQuery();
}
catch
{
database.ExecuteResourceSql("Mssql-logs.sql");
}
}
}
@ -88,7 +89,7 @@ namespace OpenSim.Data.MSSQL
}
catch
{
database.Reconnect();
// it didn't log, don't worry about it
}
}

View File

@ -44,11 +44,6 @@ namespace OpenSim.Data.MSSQL
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// The database connection object
/// </summary>
private IDbConnection dbcon;
/// <summary>
/// Connection string for ADO.net
/// </summary>
@ -57,11 +52,24 @@ namespace OpenSim.Data.MSSQL
public MSSQLManager(string dataSource, string initialCatalog, string persistSecurityInfo, string userId,
string password)
{
connectionString = "Data Source=" + dataSource + ";Initial Catalog=" + initialCatalog +
";Persist Security Info=" + persistSecurityInfo + ";User ID=" + userId + ";Password=" +
password + ";";
dbcon = new SqlConnection(connectionString);
dbcon.Open();
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
builder.DataSource = dataSource;
builder.InitialCatalog = initialCatalog;
builder.PersistSecurityInfo = Convert.ToBoolean(persistSecurityInfo);
builder.UserID = userId;
builder.Password = password;
builder.ApplicationName = Assembly.GetEntryAssembly().Location;
connectionString = builder.ToString();
}
private SqlConnection createConnection()
{
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
return conn;
}
//private DataTable createRegionsTable()
@ -121,7 +129,7 @@ namespace OpenSim.Data.MSSQL
}
/// <summary>
///
/// Define Table function
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
@ -178,35 +186,11 @@ namespace OpenSim.Data.MSSQL
}
}
/// <summary>
/// Shuts down the database connection
/// </summary>
public void Close()
{
dbcon.Close();
dbcon = null;
}
/// <summary>
/// Reconnects to the database
/// </summary>
public void Reconnect()
private static readonly Dictionary<string, string> emptyDictionary = new Dictionary<string, string>();
internal AutoClosingSqlCommand Query(string sql)
{
lock (dbcon)
{
try
{
// Close the DB connection
dbcon.Close();
// Try reopen it
dbcon = new SqlConnection(connectionString);
dbcon.Open();
}
catch (Exception e)
{
m_log.Error("Unable to reconnect to database " + e.ToString());
}
}
return Query(sql, emptyDictionary);
}
/// <summary>
@ -215,18 +199,20 @@ namespace OpenSim.Data.MSSQL
/// <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>
/// <returns>A Sql DB Command</returns>
public IDbCommand Query(string sql, Dictionary<string, string> parameters)
internal AutoClosingSqlCommand Query(string sql, Dictionary<string, string> parameters)
{
SqlCommand dbcommand = (SqlCommand)dbcon.CreateCommand();
SqlCommand dbcommand = createConnection().CreateCommand();
dbcommand.CommandText = sql;
foreach (KeyValuePair<string, string> param in parameters)
{
dbcommand.Parameters.AddWithValue(param.Key, param.Value);
}
return (IDbCommand)dbcommand;
return new AutoClosingSqlCommand(dbcommand);
}
/// <summary>
/// Runs a database reader object and returns a region row
/// </summary>
@ -400,7 +386,6 @@ namespace OpenSim.Data.MSSQL
if (reader.Read())
{
// Region Main
asset = new AssetBase();
asset.Data = (byte[])reader["data"];
asset.Description = (string)reader["description"];
@ -443,19 +428,20 @@ namespace OpenSim.Data.MSSQL
bool returnval = false;
try
using (IDbCommand result = Query(sql, parameters))
{
IDbCommand result = Query(sql, parameters);
try
{
if (result.ExecuteNonQuery() == 1)
returnval = true;
if (result.ExecuteNonQuery() == 1)
returnval = true;
result.Dispose();
}
catch (Exception e)
{
m_log.Error(e.ToString());
return false;
}
catch (Exception e)
{
m_log.Error(e.ToString());
return false;
}
}
return returnval;
@ -467,19 +453,12 @@ namespace OpenSim.Data.MSSQL
/// <param name="name">the ressource string</param>
public void ExecuteResourceSql(string name)
{
SqlCommand cmd = new SqlCommand(getResourceString(name), (SqlConnection)dbcon);
cmd.ExecuteNonQuery();
cmd.Dispose();
using (IDbCommand cmd = Query(getResourceString(name), new Dictionary<string,string>()))
{
cmd.ExecuteNonQuery();
}
}
/// <summary>
///
/// </summary>
/// <returns>The actual SqlConnection</returns>
public SqlConnection getConnection()
{
return (SqlConnection)dbcon;
}
/// <summary>
/// Given a list of tables, return the version of the tables, as seen in the database
@ -487,30 +466,29 @@ namespace OpenSim.Data.MSSQL
/// <param name="tableList"></param>
public void GetTableVersion(Dictionary<string, string> tableList)
{
lock (dbcon)
Dictionary<string, string> param = new Dictionary<string, string>();
param["dbname"] = new SqlConnectionStringBuilder(connectionString).InitialCatalog;
using (IDbCommand tablesCmd =
Query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_CATALOG=@dbname", param))
using (IDataReader tables = tablesCmd.ExecuteReader())
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["dbname"] = dbcon.Database;
IDbCommand tablesCmd =
Query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_CATALOG=@dbname", param);
using (IDataReader tables = tablesCmd.ExecuteReader())
while (tables.Read())
{
while (tables.Read())
try
{
try
{
string tableName = (string)tables["TABLE_NAME"];
if (tableList.ContainsKey(tableName))
tableList[tableName] = tableName;
}
catch (Exception e)
{
m_log.Error(e.ToString());
}
string tableName = (string)tables["TABLE_NAME"];
if (tableList.ContainsKey(tableName))
tableList[tableName] = tableName;
}
catch (Exception e)
{
m_log.Error(e.ToString());
}
tables.Close();
}
tables.Close();
}
}
/// <summary>
@ -546,7 +524,6 @@ namespace OpenSim.Data.MSSQL
// string dllName = module.Assembly.ManifestModule.Name;
Version dllVersion = module.Assembly.GetName().Version;
return
string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
dllVersion.Revision);

View File

@ -44,7 +44,7 @@ namespace OpenSim.Data.MSSQL
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Database manager for MySQL
/// Database manager for MSSQL
/// </summary>
public MSSQLManager database;
@ -100,36 +100,41 @@ namespace OpenSim.Data.MSSQL
/// <returns></returns>
private bool TestTables()
{
IDbCommand cmd;
cmd = database.Query("select top 1 * from " + m_usersTableName, new Dictionary<string, string>());
try
using (IDbCommand cmd = database.Query("select top 1 * from " + m_usersTableName, new Dictionary<string, string>()))
{
cmd.ExecuteNonQuery();
}
catch
{
database.ExecuteResourceSql("Mssql-users.sql");
try
{
cmd.ExecuteNonQuery();
}
catch
{
database.ExecuteResourceSql("Mssql-users.sql");
}
}
cmd = database.Query("select top 1 * from " + m_agentsTableName, new Dictionary<string, string>());
try
using (IDbCommand cmd = database.Query("select top 1 * from " + m_agentsTableName, new Dictionary<string, string>()))
{
cmd.ExecuteNonQuery();
}
catch
{
database.ExecuteResourceSql("Mssql-agents.sql");
try
{
cmd.ExecuteNonQuery();
}
catch
{
database.ExecuteResourceSql("Mssql-agents.sql");
}
}
cmd = database.Query("select top 1 * from " + m_userFriendsTableName, new Dictionary<string, string>());
try
using (IDbCommand cmd = database.Query("select top 1 * from " + m_userFriendsTableName, new Dictionary<string, string>()))
{
cmd.ExecuteNonQuery();
}
catch
{
database.ExecuteResourceSql("CreateUserFriendsTable.sql");
try
{
cmd.ExecuteNonQuery();
}
catch
{
database.ExecuteResourceSql("CreateUserFriendsTable.sql");
}
}
return true;
@ -145,27 +150,18 @@ namespace OpenSim.Data.MSSQL
{
try
{
lock (database)
Dictionary<string, string> param = new Dictionary<string, string>();
param["first"] = user;
param["second"] = last;
using (IDbCommand result = database.Query("SELECT * FROM " + m_usersTableName + " WHERE username = @first AND lastname = @second", param))
using (IDataReader reader = result.ExecuteReader())
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["first"] = user;
param["second"] = last;
IDbCommand result =
database.Query("SELECT * FROM " + m_usersTableName + " WHERE username = @first AND lastname = @second", param);
IDataReader reader = result.ExecuteReader();
UserProfileData row = database.readUserRow(reader);
reader.Close();
result.Dispose();
return row;
return database.readUserRow(reader);
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
return null;
}
@ -191,32 +187,30 @@ namespace OpenSim.Data.MSSQL
try
{
lock (database)
using (IDbCommand adder =
database.Query(
"INSERT INTO " + m_userFriendsTableName + " " +
"(ownerID,friendID,friendPerms,datetimestamp) " +
"VALUES " +
"(@ownerID,@friendID,@friendPerms,@datetimestamp)",
param))
{
IDbCommand adder =
database.Query(
"INSERT INTO " + m_userFriendsTableName + " " +
"(ownerID,friendID,friendPerms,datetimestamp) " +
"VALUES " +
"(@ownerID,@friendID,@friendPerms,@datetimestamp)",
param);
adder.ExecuteNonQuery();
adder =
database.Query(
"INSERT INTO " + m_userFriendsTableName + " " +
"(ownerID,friendID,friendPerms,datetimestamp) " +
"VALUES " +
"(@friendID,@ownerID,@friendPerms,@datetimestamp)",
param);
}
using (IDbCommand adder =
database.Query(
"INSERT INTO " + m_userFriendsTableName + " " +
"(ownerID,friendID,friendPerms,datetimestamp) " +
"VALUES " +
"(@friendID,@ownerID,@friendPerms,@datetimestamp)",
param))
{
adder.ExecuteNonQuery();
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
return;
}
@ -236,27 +230,26 @@ namespace OpenSim.Data.MSSQL
try
{
lock (database)
using (IDbCommand updater =
database.Query(
"delete from " + m_userFriendsTableName + " where ownerID = @ownerID and friendID = @friendID",
param))
{
IDbCommand updater =
database.Query(
"delete from " + m_userFriendsTableName + " where ownerID = @ownerID and friendID = @friendID",
param);
updater.ExecuteNonQuery();
updater =
database.Query(
"delete from " + m_userFriendsTableName + " where ownerID = @friendID and friendID = @ownerID",
param);
updater.ExecuteNonQuery();
}
using (IDbCommand updater =
database.Query(
"delete from " + m_userFriendsTableName + " where ownerID = @friendID and friendID = @ownerID",
param))
{
updater.ExecuteNonQuery();
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
return;
}
}
@ -276,23 +269,19 @@ namespace OpenSim.Data.MSSQL
try
{
lock (database)
using (IDbCommand updater =
database.Query(
"update " + m_userFriendsTableName +
" SET friendPerms = @friendPerms " +
"where ownerID = @ownerID and friendID = @friendID",
param))
{
IDbCommand updater =
database.Query(
"update " + m_userFriendsTableName +
" SET friendPerms = @friendPerms " +
"where ownerID = @ownerID and friendID = @friendID",
param);
updater.ExecuteNonQuery();
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
return;
}
}
@ -310,17 +299,14 @@ namespace OpenSim.Data.MSSQL
try
{
lock (database)
//Left Join userfriends to itself
using (IDbCommand result =
database.Query(
"select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" +
" where a.ownerID = @ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID",
param))
using (IDataReader reader = result.ExecuteReader())
{
//Left Join userfriends to itself
IDbCommand result =
database.Query(
"select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" +
" where a.ownerID = @ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID",
param);
IDataReader reader = result.ExecuteReader();
while (reader.Read())
{
FriendListItem fli = new FriendListItem();
@ -333,15 +319,11 @@ namespace OpenSim.Data.MSSQL
Lfli.Add(fli);
}
reader.Close();
result.Dispose();
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
return Lfli;
}
return Lfli;
@ -375,19 +357,13 @@ namespace OpenSim.Data.MSSQL
{
try
{
lock (database)
Dictionary<string, string> param = new Dictionary<string, string>();
param["first"] = querysplit[0];
param["second"] = querysplit[1];
using (IDbCommand result = database.Query("SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username = @first AND lastname = @second", param))
using (IDataReader reader = result.ExecuteReader())
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["first"] = querysplit[0];
param["second"] = querysplit[1];
IDbCommand result =
database.Query(
"SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username = @first AND lastname = @second",
param);
IDataReader reader = result.ExecuteReader();
while (reader.Read())
{
AvatarPickerAvatar user = new AvatarPickerAvatar();
@ -395,34 +371,24 @@ namespace OpenSim.Data.MSSQL
user.firstName = (string)reader["username"];
user.lastName = (string)reader["lastname"];
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];
using (IDbCommand result = database.Query("SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username = @first OR lastname = @first", param))
using (IDataReader reader = result.ExecuteReader())
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["first"] = querysplit[0];
IDbCommand result =
database.Query(
"SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username = @first OR lastname = @first",
param);
IDataReader reader = result.ExecuteReader();
while (reader.Read())
{
AvatarPickerAvatar user = new AvatarPickerAvatar();
@ -431,15 +397,11 @@ namespace OpenSim.Data.MSSQL
user.lastName = (string)reader["lastname"];
returnlist.Add(user);
}
reader.Close();
result.Dispose();
}
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
return returnlist;
}
}
return returnlist;
@ -454,25 +416,17 @@ namespace OpenSim.Data.MSSQL
{
try
{
lock (database)
Dictionary<string, string> param = new Dictionary<string, string>();
param["uuid"] = uuid.ToString();
using (IDbCommand result = database.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = @uuid", param))
using (IDataReader reader = result.ExecuteReader())
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["uuid"] = uuid.ToString();
IDbCommand result = database.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = @uuid", param);
IDataReader reader = result.ExecuteReader();
UserProfileData row = database.readUserRow(reader);
reader.Close();
result.Dispose();
return row;
return database.readUserRow(reader);
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
return null;
}
@ -509,25 +463,17 @@ namespace OpenSim.Data.MSSQL
{
try
{
lock (database)
Dictionary<string, string> param = new Dictionary<string, string>();
param["uuid"] = uuid.ToString();
using (IDbCommand result = database.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = @uuid", param))
using (IDataReader reader = result.ExecuteReader())
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["uuid"] = uuid.ToString();
IDbCommand result = database.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = @uuid", param);
IDataReader reader = result.ExecuteReader();
UserAgentData row = database.readAgentRow(reader);
reader.Close();
result.Dispose();
return row;
return database.readAgentRow(reader);
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
return null;
}
@ -554,21 +500,17 @@ namespace OpenSim.Data.MSSQL
{
try
{
lock (database)
{
InsertUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt,
user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y,
user.HomeLocation.Z,
user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created,
user.LastLogin, user.UserInventoryURI, user.UserAssetURI,
user.CanDoMask, user.WantDoMask,
user.AboutText, user.FirstLifeAboutText, user.Image,
user.FirstLifeImage, user.WebLoginKey);
}
InsertUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt,
user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y,
user.HomeLocation.Z,
user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created,
user.LastLogin, user.UserInventoryURI, user.UserAssetURI,
user.CanDoMask, user.WantDoMask,
user.AboutText, user.FirstLifeAboutText, user.Image,
user.FirstLifeImage, user.WebLoginKey);
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
}
}
@ -646,16 +588,13 @@ namespace OpenSim.Data.MSSQL
parameters["profileFirstImage"] = firstImage.ToString();
parameters["webLoginKey"] = LLUUID.Random().ToString();
bool returnval = false;
try
{
IDbCommand result = database.Query(sql, parameters);
if (result.ExecuteNonQuery() == 1)
returnval = true;
result.Dispose();
using (IDbCommand result = database.Query(sql, parameters))
{
return (result.ExecuteNonQuery() == 1);
}
}
catch (Exception e)
{
@ -663,7 +602,6 @@ namespace OpenSim.Data.MSSQL
return false;
}
return returnval;
}
/// <summary>
@ -682,7 +620,7 @@ namespace OpenSim.Data.MSSQL
/// <returns></returns>
override public bool UpdateUserProfile(UserProfileData user)
{
SqlCommand command = new SqlCommand("UPDATE " + m_usersTableName + " set UUID = @uuid, " +
using (IDbCommand command = database.Query("UPDATE " + m_usersTableName + " set UUID = @uuid, " +
"username = @username, " +
"lastname = @lastname," +
"passwordHash = @passwordHash," +
@ -705,71 +643,66 @@ namespace OpenSim.Data.MSSQL
"profileImage = @profileImage," +
"profileFirstImage = @profileFirstImage, " +
"webLoginKey = @webLoginKey where " +
"UUID = @keyUUUID;", database.getConnection());
SqlParameter param1 = new SqlParameter("@uuid", user.ID.ToString());
SqlParameter param2 = new SqlParameter("@username", user.FirstName);
SqlParameter param3 = new SqlParameter("@lastname", user.SurName);
SqlParameter param4 = new SqlParameter("@passwordHash", user.PasswordHash);
SqlParameter param5 = new SqlParameter("@passwordSalt", user.PasswordSalt);
SqlParameter param6 = new SqlParameter("@homeRegion", Convert.ToInt64(user.HomeRegion));
SqlParameter param7 = new SqlParameter("@homeLocationX", user.HomeLocation.X);
SqlParameter param8 = new SqlParameter("@homeLocationY", user.HomeLocation.Y);
SqlParameter param9 = new SqlParameter("@homeLocationZ", user.HomeLocation.Y);
SqlParameter param10 = new SqlParameter("@homeLookAtX", user.HomeLookAt.X);
SqlParameter param11 = new SqlParameter("@homeLookAtY", user.HomeLookAt.Y);
SqlParameter param12 = new SqlParameter("@homeLookAtZ", user.HomeLookAt.Z);
SqlParameter param13 = new SqlParameter("@created", Convert.ToInt32(user.Created));
SqlParameter param14 = new SqlParameter("@lastLogin", Convert.ToInt32(user.LastLogin));
SqlParameter param15 = new SqlParameter("@userInventoryURI", user.UserInventoryURI);
SqlParameter param16 = new SqlParameter("@userAssetURI", user.UserAssetURI);
SqlParameter param17 = new SqlParameter("@profileCanDoMask", Convert.ToInt32(user.CanDoMask));
SqlParameter param18 = new SqlParameter("@profileWantDoMask", Convert.ToInt32(user.WantDoMask));
SqlParameter param19 = new SqlParameter("@profileAboutText", user.AboutText);
SqlParameter param20 = new SqlParameter("@profileFirstText", user.FirstLifeAboutText);
SqlParameter param21 = new SqlParameter("@profileImage", user.Image.ToString());
SqlParameter param22 = new SqlParameter("@profileFirstImage", user.FirstLifeImage.ToString());
SqlParameter param23 = new SqlParameter("@keyUUUID", user.ID.ToString());
SqlParameter param24 = new SqlParameter("@webLoginKey", user.WebLoginKey.UUID.ToString());
command.Parameters.Add(param1);
command.Parameters.Add(param2);
command.Parameters.Add(param3);
command.Parameters.Add(param4);
command.Parameters.Add(param5);
command.Parameters.Add(param6);
command.Parameters.Add(param7);
command.Parameters.Add(param8);
command.Parameters.Add(param9);
command.Parameters.Add(param10);
command.Parameters.Add(param11);
command.Parameters.Add(param12);
command.Parameters.Add(param13);
command.Parameters.Add(param14);
command.Parameters.Add(param15);
command.Parameters.Add(param16);
command.Parameters.Add(param17);
command.Parameters.Add(param18);
command.Parameters.Add(param19);
command.Parameters.Add(param20);
command.Parameters.Add(param21);
command.Parameters.Add(param22);
command.Parameters.Add(param23);
command.Parameters.Add(param24);
try
"UUID = @keyUUUID;"))
{
int affected = command.ExecuteNonQuery();
if (affected != 0)
SqlParameter param1 = new SqlParameter("@uuid", user.ID.ToString());
SqlParameter param2 = new SqlParameter("@username", user.FirstName);
SqlParameter param3 = new SqlParameter("@lastname", user.SurName);
SqlParameter param4 = new SqlParameter("@passwordHash", user.PasswordHash);
SqlParameter param5 = new SqlParameter("@passwordSalt", user.PasswordSalt);
SqlParameter param6 = new SqlParameter("@homeRegion", Convert.ToInt64(user.HomeRegion));
SqlParameter param7 = new SqlParameter("@homeLocationX", user.HomeLocation.X);
SqlParameter param8 = new SqlParameter("@homeLocationY", user.HomeLocation.Y);
SqlParameter param9 = new SqlParameter("@homeLocationZ", user.HomeLocation.Y);
SqlParameter param10 = new SqlParameter("@homeLookAtX", user.HomeLookAt.X);
SqlParameter param11 = new SqlParameter("@homeLookAtY", user.HomeLookAt.Y);
SqlParameter param12 = new SqlParameter("@homeLookAtZ", user.HomeLookAt.Z);
SqlParameter param13 = new SqlParameter("@created", Convert.ToInt32(user.Created));
SqlParameter param14 = new SqlParameter("@lastLogin", Convert.ToInt32(user.LastLogin));
SqlParameter param15 = new SqlParameter("@userInventoryURI", user.UserInventoryURI);
SqlParameter param16 = new SqlParameter("@userAssetURI", user.UserAssetURI);
SqlParameter param17 = new SqlParameter("@profileCanDoMask", Convert.ToInt32(user.CanDoMask));
SqlParameter param18 = new SqlParameter("@profileWantDoMask", Convert.ToInt32(user.WantDoMask));
SqlParameter param19 = new SqlParameter("@profileAboutText", user.AboutText);
SqlParameter param20 = new SqlParameter("@profileFirstText", user.FirstLifeAboutText);
SqlParameter param21 = new SqlParameter("@profileImage", user.Image.ToString());
SqlParameter param22 = new SqlParameter("@profileFirstImage", user.FirstLifeImage.ToString());
SqlParameter param23 = new SqlParameter("@keyUUUID", user.ID.ToString());
SqlParameter param24 = new SqlParameter("@webLoginKey", user.WebLoginKey.UUID.ToString());
command.Parameters.Add(param1);
command.Parameters.Add(param2);
command.Parameters.Add(param3);
command.Parameters.Add(param4);
command.Parameters.Add(param5);
command.Parameters.Add(param6);
command.Parameters.Add(param7);
command.Parameters.Add(param8);
command.Parameters.Add(param9);
command.Parameters.Add(param10);
command.Parameters.Add(param11);
command.Parameters.Add(param12);
command.Parameters.Add(param13);
command.Parameters.Add(param14);
command.Parameters.Add(param15);
command.Parameters.Add(param16);
command.Parameters.Add(param17);
command.Parameters.Add(param18);
command.Parameters.Add(param19);
command.Parameters.Add(param20);
command.Parameters.Add(param21);
command.Parameters.Add(param22);
command.Parameters.Add(param23);
command.Parameters.Add(param24);
try
{
return true;
int affected = command.ExecuteNonQuery();
return (affected != 0);
}
else
catch (Exception e)
{
return false;
m_log.Error(e.ToString());
}
}
catch (Exception e)
{
m_log.Error(e.ToString());
}
return false;
}
@ -805,28 +738,21 @@ namespace OpenSim.Data.MSSQL
// return new AvatarAppearance();
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["@UUID"] = user.ToString();
IDbCommand result =
database.Query("SELECT * FROM avatarappearance WHERE owner = @UUID", param);
IDataReader reader = result.ExecuteReader();
AvatarAppearance item = null;
if (reader.Read())
item = readUserAppearance(reader);
reader.Close();
result.Dispose();
return item;
}
using (IDbCommand result =
database.Query("SELECT * FROM avatarappearance WHERE owner = @UUID", param))
using (IDataReader reader = result.ExecuteReader())
{
AvatarAppearance item = null;
if (reader.Read())
item = readUserAppearance(reader);
return item;
}
}
catch (Exception e)
{
database.Reconnect();
m_log.Error(e.ToString());
}
return null;
@ -906,49 +832,49 @@ namespace OpenSim.Data.MSSQL
sql += "@jacket_item, @jacket_asset, @gloves_item, @gloves_asset, @undershirt_item, @undershirt_asset, @underpants_item, @underpants_asset, ";
sql += "@skirt_item, @skirt_asset)";
SqlCommand cmd = new SqlCommand(sql, database.getConnection());
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.ToBytes());
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());
try
using (AutoClosingSqlCommand cmd = database.Query(sql))
{
cmd.ExecuteNonQuery();
cmd.Dispose();
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.ToBytes());
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());
try
{
cmd.ExecuteNonQuery();
}
catch (Exception e)
{
m_log.Error(e.ToString());
}
}
catch (Exception e)
{
m_log.Error(e.ToString());
}
return;
}
/// <summary>
@ -958,7 +884,7 @@ namespace OpenSim.Data.MSSQL
/// <param name="item">the item UUID</param>
override public void AddAttachment(LLUUID user, LLUUID item)
{
return;
// TBI?
}
/// <summary>
@ -968,7 +894,7 @@ namespace OpenSim.Data.MSSQL
/// <param name="item">the item UUID</param>
override public void RemoveAttachment(LLUUID user, LLUUID item)
{
return;
// TBI?
}
/// <summary>