aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorUbitUmarov2015-09-15 06:28:21 +0100
committerUbitUmarov2015-09-15 06:28:21 +0100
commit0a67cda22423cad4bdce98205626e55e66fdeeb6 (patch)
tree4ff0e1dba08af76f77a60c5f9df10b5719b9c02b /OpenSim
parent mute watchdog timeouts on world map work threads. They do wait for events fo... (diff)
downloadopensim-SC_OLD-0a67cda22423cad4bdce98205626e55e66fdeeb6.zip
opensim-SC_OLD-0a67cda22423cad4bdce98205626e55e66fdeeb6.tar.gz
opensim-SC_OLD-0a67cda22423cad4bdce98205626e55e66fdeeb6.tar.bz2
opensim-SC_OLD-0a67cda22423cad4bdce98205626e55e66fdeeb6.tar.xz
remove redundant using(){}
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs87
1 files changed, 40 insertions, 47 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 76b1e38..1488e1a 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -160,52 +160,48 @@ namespace OpenSim.Data.MySQL
160 { 160 {
161 dbcon.Open(); 161 dbcon.Open();
162 162
163 string assetName = asset.Name;
164 if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
165 {
166 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
167 m_log.WarnFormat(
168 "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
169 asset.Name, asset.ID, asset.Name.Length, assetName.Length);
170 }
171
172 string assetDescription = asset.Description;
173 if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
174 {
175 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
176 m_log.WarnFormat(
177 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
178 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
179 }
180
163 using (MySqlCommand cmd = 181 using (MySqlCommand cmd =
164 new MySqlCommand( 182 new MySqlCommand(
165 "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + 183 "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" +
166 "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)", 184 "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)",
167 dbcon)) 185 dbcon))
168 { 186 {
169 string assetName = asset.Name;
170 if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
171 {
172 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
173 m_log.WarnFormat(
174 "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
175 asset.Name, asset.ID, asset.Name.Length, assetName.Length);
176 }
177
178 string assetDescription = asset.Description;
179 if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
180 {
181 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
182 m_log.WarnFormat(
183 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
184 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
185 }
186
187 try 187 try
188 { 188 {
189 using (cmd) 189 // create unix epoch time
190 { 190 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
191 // create unix epoch time 191 cmd.Parameters.AddWithValue("?id", asset.ID);
192 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); 192 cmd.Parameters.AddWithValue("?name", assetName);
193 cmd.Parameters.AddWithValue("?id", asset.ID); 193 cmd.Parameters.AddWithValue("?description", assetDescription);
194 cmd.Parameters.AddWithValue("?name", assetName); 194 cmd.Parameters.AddWithValue("?assetType", asset.Type);
195 cmd.Parameters.AddWithValue("?description", assetDescription); 195 cmd.Parameters.AddWithValue("?local", asset.Local);
196 cmd.Parameters.AddWithValue("?assetType", asset.Type); 196 cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
197 cmd.Parameters.AddWithValue("?local", asset.Local); 197 cmd.Parameters.AddWithValue("?create_time", now);
198 cmd.Parameters.AddWithValue("?temporary", asset.Temporary); 198 cmd.Parameters.AddWithValue("?access_time", now);
199 cmd.Parameters.AddWithValue("?create_time", now); 199 cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID);
200 cmd.Parameters.AddWithValue("?access_time", now); 200 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
201 cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); 201 cmd.Parameters.AddWithValue("?data", asset.Data);
202 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); 202 cmd.ExecuteNonQuery();
203 cmd.Parameters.AddWithValue("?data", asset.Data); 203 return true;
204 cmd.ExecuteNonQuery();
205 return true;
206 }
207 } 204 }
208
209 catch (Exception e) 205 catch (Exception e)
210 { 206 {
211 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}", 207 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
@@ -227,21 +223,18 @@ namespace OpenSim.Data.MySQL
227 { 223 {
228 try 224 try
229 { 225 {
230 using (cmd) 226 // create unix epoch time
231 { 227 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
232 // create unix epoch time 228 cmd.Parameters.AddWithValue("?id", asset.ID);
233 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); 229 cmd.Parameters.AddWithValue("?access_time", now);
234 cmd.Parameters.AddWithValue("?id", asset.ID); 230 cmd.ExecuteNonQuery();
235 cmd.Parameters.AddWithValue("?access_time", now);
236 cmd.ExecuteNonQuery();
237 }
238 } 231 }
239 catch (Exception e) 232 catch (Exception e)
240 { 233 {
241 m_log.Error( 234 m_log.Error(
242 string.Format( 235 string.Format(
243 "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ", 236 "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ",
244 asset.FullID, asset.Name), 237 asset.FullID, asset.Name),
245 e); 238 e);
246 } 239 }
247 } 240 }