diff options
Diffstat (limited to 'OpenSim/Data/MSSQL/MSSQLAssetData.cs')
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLAssetData.cs | 54 |
1 files changed, 23 insertions, 31 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs index 1ce4abf..d6ea262 100644 --- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs +++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs | |||
@@ -49,6 +49,7 @@ namespace OpenSim.Data.MSSQL | |||
49 | /// Database manager | 49 | /// Database manager |
50 | /// </summary> | 50 | /// </summary> |
51 | private MSSQLManager m_database; | 51 | private MSSQLManager m_database; |
52 | private string m_connectionString; | ||
52 | 53 | ||
53 | #region IPlugin Members | 54 | #region IPlugin Members |
54 | 55 | ||
@@ -75,23 +76,8 @@ namespace OpenSim.Data.MSSQL | |||
75 | { | 76 | { |
76 | m_ticksToEpoch = new System.DateTime(1970, 1, 1).Ticks; | 77 | m_ticksToEpoch = new System.DateTime(1970, 1, 1).Ticks; |
77 | 78 | ||
78 | if (!string.IsNullOrEmpty(connectionString)) | 79 | m_database = new MSSQLManager(connectionString); |
79 | { | 80 | m_connectionString = connectionString; |
80 | m_database = new MSSQLManager(connectionString); | ||
81 | } | ||
82 | else | ||
83 | { | ||
84 | IniFile gridDataMSSqlFile = new IniFile("mssql_connection.ini"); | ||
85 | string settingDataSource = gridDataMSSqlFile.ParseFileReadValue("data_source"); | ||
86 | string settingInitialCatalog = gridDataMSSqlFile.ParseFileReadValue("initial_catalog"); | ||
87 | string settingPersistSecurityInfo = gridDataMSSqlFile.ParseFileReadValue("persist_security_info"); | ||
88 | string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id"); | ||
89 | string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password"); | ||
90 | |||
91 | m_database = | ||
92 | new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, | ||
93 | settingPassword); | ||
94 | } | ||
95 | 81 | ||
96 | //New migration to check for DB changes | 82 | //New migration to check for DB changes |
97 | m_database.CheckMigration(_migrationStore); | 83 | m_database.CheckMigration(_migrationStore); |
@@ -125,17 +111,20 @@ namespace OpenSim.Data.MSSQL | |||
125 | override public AssetBase GetAsset(UUID assetID) | 111 | override public AssetBase GetAsset(UUID assetID) |
126 | { | 112 | { |
127 | string sql = "SELECT * FROM assets WHERE id = @id"; | 113 | string sql = "SELECT * FROM assets WHERE id = @id"; |
128 | using (AutoClosingSqlCommand command = m_database.Query(sql)) | 114 | using (SqlConnection conn = new SqlConnection(m_connectionString)) |
115 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
129 | { | 116 | { |
130 | command.Parameters.Add(m_database.CreateParameter("id", assetID)); | 117 | cmd.Parameters.Add(m_database.CreateParameter("id", assetID)); |
131 | using (SqlDataReader reader = command.ExecuteReader()) | 118 | conn.Open(); |
119 | using (SqlDataReader reader = cmd.ExecuteReader()) | ||
132 | { | 120 | { |
133 | if (reader.Read()) | 121 | if (reader.Read()) |
134 | { | 122 | { |
135 | AssetBase asset = new AssetBase( | 123 | AssetBase asset = new AssetBase( |
136 | new UUID((Guid)reader["id"]), | 124 | new UUID((Guid)reader["id"]), |
137 | (string)reader["name"], | 125 | (string)reader["name"], |
138 | Convert.ToSByte(reader["assetType"]) | 126 | Convert.ToSByte(reader["assetType"]), |
127 | String.Empty | ||
139 | ); | 128 | ); |
140 | // Region Main | 129 | // Region Main |
141 | asset.Description = (string)reader["description"]; | 130 | asset.Description = (string)reader["description"]; |
@@ -190,7 +179,8 @@ namespace OpenSim.Data.MSSQL | |||
190 | m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); | 179 | m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); |
191 | } | 180 | } |
192 | 181 | ||
193 | using (AutoClosingSqlCommand command = m_database.Query(sql)) | 182 | using (SqlConnection conn = new SqlConnection(m_connectionString)) |
183 | using (SqlCommand command = new SqlCommand(sql, conn)) | ||
194 | { | 184 | { |
195 | int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000); | 185 | int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000); |
196 | command.Parameters.Add(m_database.CreateParameter("id", asset.FullID)); | 186 | command.Parameters.Add(m_database.CreateParameter("id", asset.FullID)); |
@@ -202,7 +192,7 @@ namespace OpenSim.Data.MSSQL | |||
202 | command.Parameters.Add(m_database.CreateParameter("access_time", now)); | 192 | command.Parameters.Add(m_database.CreateParameter("access_time", now)); |
203 | command.Parameters.Add(m_database.CreateParameter("create_time", now)); | 193 | command.Parameters.Add(m_database.CreateParameter("create_time", now)); |
204 | command.Parameters.Add(m_database.CreateParameter("data", asset.Data)); | 194 | command.Parameters.Add(m_database.CreateParameter("data", asset.Data)); |
205 | 195 | conn.Open(); | |
206 | try | 196 | try |
207 | { | 197 | { |
208 | command.ExecuteNonQuery(); | 198 | command.ExecuteNonQuery(); |
@@ -238,7 +228,8 @@ namespace OpenSim.Data.MSSQL | |||
238 | m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on update"); | 228 | m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on update"); |
239 | } | 229 | } |
240 | 230 | ||
241 | using (AutoClosingSqlCommand command = m_database.Query(sql)) | 231 | using (SqlConnection conn = new SqlConnection(m_connectionString)) |
232 | using (SqlCommand command = new SqlCommand(sql, conn)) | ||
242 | { | 233 | { |
243 | command.Parameters.Add(m_database.CreateParameter("id", asset.FullID)); | 234 | command.Parameters.Add(m_database.CreateParameter("id", asset.FullID)); |
244 | command.Parameters.Add(m_database.CreateParameter("name", assetName)); | 235 | command.Parameters.Add(m_database.CreateParameter("name", assetName)); |
@@ -248,7 +239,7 @@ namespace OpenSim.Data.MSSQL | |||
248 | command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary)); | 239 | command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary)); |
249 | command.Parameters.Add(m_database.CreateParameter("data", asset.Data)); | 240 | command.Parameters.Add(m_database.CreateParameter("data", asset.Data)); |
250 | command.Parameters.Add(m_database.CreateParameter("@keyId", asset.FullID)); | 241 | command.Parameters.Add(m_database.CreateParameter("@keyId", asset.FullID)); |
251 | 242 | conn.Open(); | |
252 | try | 243 | try |
253 | { | 244 | { |
254 | command.ExecuteNonQuery(); | 245 | command.ExecuteNonQuery(); |
@@ -307,13 +298,14 @@ namespace OpenSim.Data.MSSQL | |||
307 | string sql = @"SELECT (name,description,assetType,temporary,id), Row = ROW_NUMBER() | 298 | string sql = @"SELECT (name,description,assetType,temporary,id), Row = ROW_NUMBER() |
308 | OVER (ORDER BY (some column to order by)) | 299 | OVER (ORDER BY (some column to order by)) |
309 | WHERE Row >= @Start AND Row < @Start + @Count"; | 300 | WHERE Row >= @Start AND Row < @Start + @Count"; |
310 | |||
311 | using (AutoClosingSqlCommand command = m_database.Query(sql)) | ||
312 | { | ||
313 | command.Parameters.Add(m_database.CreateParameter("start", start)); | ||
314 | command.Parameters.Add(m_database.CreateParameter("count", count)); | ||
315 | 301 | ||
316 | using (SqlDataReader reader = command.ExecuteReader()) | 302 | using (SqlConnection conn = new SqlConnection(m_connectionString)) |
303 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
304 | { | ||
305 | cmd.Parameters.Add(m_database.CreateParameter("start", start)); | ||
306 | cmd.Parameters.Add(m_database.CreateParameter("count", count)); | ||
307 | conn.Open(); | ||
308 | using (SqlDataReader reader = cmd.ExecuteReader()) | ||
317 | { | 309 | { |
318 | while (reader.Read()) | 310 | while (reader.Read()) |
319 | { | 311 | { |