remove redundant using(){}
parent
2d88e4cf73
commit
0a67cda224
|
@ -160,52 +160,48 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
dbcon.Open();
|
dbcon.Open();
|
||||||
|
|
||||||
|
string assetName = asset.Name;
|
||||||
|
if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
|
||||||
|
{
|
||||||
|
assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
|
||||||
|
m_log.WarnFormat(
|
||||||
|
"[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
|
||||||
|
asset.Name, asset.ID, asset.Name.Length, assetName.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
string assetDescription = asset.Description;
|
||||||
|
if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
|
||||||
|
{
|
||||||
|
assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
|
||||||
|
m_log.WarnFormat(
|
||||||
|
"[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
|
||||||
|
asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
|
||||||
|
}
|
||||||
|
|
||||||
using (MySqlCommand cmd =
|
using (MySqlCommand cmd =
|
||||||
new MySqlCommand(
|
new MySqlCommand(
|
||||||
"replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" +
|
"replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" +
|
||||||
"VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)",
|
"VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)",
|
||||||
dbcon))
|
dbcon))
|
||||||
{
|
{
|
||||||
string assetName = asset.Name;
|
|
||||||
if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
|
|
||||||
{
|
|
||||||
assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
|
|
||||||
m_log.WarnFormat(
|
|
||||||
"[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
|
|
||||||
asset.Name, asset.ID, asset.Name.Length, assetName.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
string assetDescription = asset.Description;
|
|
||||||
if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
|
|
||||||
{
|
|
||||||
assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
|
|
||||||
m_log.WarnFormat(
|
|
||||||
"[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
|
|
||||||
asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (cmd)
|
// create unix epoch time
|
||||||
{
|
int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
|
||||||
// create unix epoch time
|
cmd.Parameters.AddWithValue("?id", asset.ID);
|
||||||
int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
|
cmd.Parameters.AddWithValue("?name", assetName);
|
||||||
cmd.Parameters.AddWithValue("?id", asset.ID);
|
cmd.Parameters.AddWithValue("?description", assetDescription);
|
||||||
cmd.Parameters.AddWithValue("?name", assetName);
|
cmd.Parameters.AddWithValue("?assetType", asset.Type);
|
||||||
cmd.Parameters.AddWithValue("?description", assetDescription);
|
cmd.Parameters.AddWithValue("?local", asset.Local);
|
||||||
cmd.Parameters.AddWithValue("?assetType", asset.Type);
|
cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
|
||||||
cmd.Parameters.AddWithValue("?local", asset.Local);
|
cmd.Parameters.AddWithValue("?create_time", now);
|
||||||
cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
|
cmd.Parameters.AddWithValue("?access_time", now);
|
||||||
cmd.Parameters.AddWithValue("?create_time", now);
|
cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID);
|
||||||
cmd.Parameters.AddWithValue("?access_time", now);
|
cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
|
||||||
cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID);
|
cmd.Parameters.AddWithValue("?data", asset.Data);
|
||||||
cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
|
cmd.ExecuteNonQuery();
|
||||||
cmd.Parameters.AddWithValue("?data", asset.Data);
|
return true;
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
|
m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
|
||||||
|
@ -227,21 +223,18 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (cmd)
|
// create unix epoch time
|
||||||
{
|
int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
|
||||||
// create unix epoch time
|
cmd.Parameters.AddWithValue("?id", asset.ID);
|
||||||
int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
|
cmd.Parameters.AddWithValue("?access_time", now);
|
||||||
cmd.Parameters.AddWithValue("?id", asset.ID);
|
cmd.ExecuteNonQuery();
|
||||||
cmd.Parameters.AddWithValue("?access_time", now);
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.Error(
|
m_log.Error(
|
||||||
string.Format(
|
string.Format(
|
||||||
"[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ",
|
"[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ",
|
||||||
asset.FullID, asset.Name),
|
asset.FullID, asset.Name),
|
||||||
e);
|
e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue