diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLAssetData.cs | 54 |
1 files changed, 22 insertions, 32 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs index 437c09c..b1faf0b 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,18 +111,19 @@ 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"]) |
139 | UUID.Zero.ToString() | ||
140 | ); | 127 | ); |
141 | // Region Main | 128 | // Region Main |
142 | asset.Description = (string)reader["description"]; | 129 | asset.Description = (string)reader["description"]; |
@@ -191,7 +178,8 @@ namespace OpenSim.Data.MSSQL | |||
191 | m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); | 178 | m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); |
192 | } | 179 | } |
193 | 180 | ||
194 | using (AutoClosingSqlCommand command = m_database.Query(sql)) | 181 | using (SqlConnection conn = new SqlConnection(m_connectionString)) |
182 | using (SqlCommand command = new SqlCommand(sql, conn)) | ||
195 | { | 183 | { |
196 | int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000); | 184 | int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000); |
197 | command.Parameters.Add(m_database.CreateParameter("id", asset.FullID)); | 185 | command.Parameters.Add(m_database.CreateParameter("id", asset.FullID)); |
@@ -203,7 +191,7 @@ namespace OpenSim.Data.MSSQL | |||
203 | command.Parameters.Add(m_database.CreateParameter("access_time", now)); | 191 | command.Parameters.Add(m_database.CreateParameter("access_time", now)); |
204 | command.Parameters.Add(m_database.CreateParameter("create_time", now)); | 192 | command.Parameters.Add(m_database.CreateParameter("create_time", now)); |
205 | command.Parameters.Add(m_database.CreateParameter("data", asset.Data)); | 193 | command.Parameters.Add(m_database.CreateParameter("data", asset.Data)); |
206 | 194 | conn.Open(); | |
207 | try | 195 | try |
208 | { | 196 | { |
209 | command.ExecuteNonQuery(); | 197 | command.ExecuteNonQuery(); |
@@ -239,7 +227,8 @@ namespace OpenSim.Data.MSSQL | |||
239 | m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on update"); | 227 | m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on update"); |
240 | } | 228 | } |
241 | 229 | ||
242 | using (AutoClosingSqlCommand command = m_database.Query(sql)) | 230 | using (SqlConnection conn = new SqlConnection(m_connectionString)) |
231 | using (SqlCommand command = new SqlCommand(sql, conn)) | ||
243 | { | 232 | { |
244 | command.Parameters.Add(m_database.CreateParameter("id", asset.FullID)); | 233 | command.Parameters.Add(m_database.CreateParameter("id", asset.FullID)); |
245 | command.Parameters.Add(m_database.CreateParameter("name", assetName)); | 234 | command.Parameters.Add(m_database.CreateParameter("name", assetName)); |
@@ -249,7 +238,7 @@ namespace OpenSim.Data.MSSQL | |||
249 | command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary)); | 238 | command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary)); |
250 | command.Parameters.Add(m_database.CreateParameter("data", asset.Data)); | 239 | command.Parameters.Add(m_database.CreateParameter("data", asset.Data)); |
251 | command.Parameters.Add(m_database.CreateParameter("@keyId", asset.FullID)); | 240 | command.Parameters.Add(m_database.CreateParameter("@keyId", asset.FullID)); |
252 | 241 | conn.Open(); | |
253 | try | 242 | try |
254 | { | 243 | { |
255 | command.ExecuteNonQuery(); | 244 | command.ExecuteNonQuery(); |
@@ -308,13 +297,14 @@ namespace OpenSim.Data.MSSQL | |||
308 | string sql = @"SELECT (name,description,assetType,temporary,id), Row = ROW_NUMBER() | 297 | string sql = @"SELECT (name,description,assetType,temporary,id), Row = ROW_NUMBER() |
309 | OVER (ORDER BY (some column to order by)) | 298 | OVER (ORDER BY (some column to order by)) |
310 | WHERE Row >= @Start AND Row < @Start + @Count"; | 299 | WHERE Row >= @Start AND Row < @Start + @Count"; |
311 | |||
312 | using (AutoClosingSqlCommand command = m_database.Query(sql)) | ||
313 | { | ||
314 | command.Parameters.Add(m_database.CreateParameter("start", start)); | ||
315 | command.Parameters.Add(m_database.CreateParameter("count", count)); | ||
316 | 300 | ||
317 | using (SqlDataReader reader = command.ExecuteReader()) | 301 | using (SqlConnection conn = new SqlConnection(m_connectionString)) |
302 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
303 | { | ||
304 | cmd.Parameters.Add(m_database.CreateParameter("start", start)); | ||
305 | cmd.Parameters.Add(m_database.CreateParameter("count", count)); | ||
306 | conn.Open(); | ||
307 | using (SqlDataReader reader = cmd.ExecuteReader()) | ||
318 | { | 308 | { |
319 | while (reader.Read()) | 309 | while (reader.Read()) |
320 | { | 310 | { |