aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.MSSQL/MSSQLAssetData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Data.MSSQL/MSSQLAssetData.cs')
-rw-r--r--OpenSim/Framework/Data.MSSQL/MSSQLAssetData.cs59
1 files changed, 26 insertions, 33 deletions
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLAssetData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLAssetData.cs
index cc0422c..08fbef0 100644
--- a/OpenSim/Framework/Data.MSSQL/MSSQLAssetData.cs
+++ b/OpenSim/Framework/Data.MSSQL/MSSQLAssetData.cs
@@ -27,18 +27,18 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Data;
31using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Data;
32using System.Data.SqlClient; 32using System.Data.SqlClient;
33
34using libsecondlife; 33using libsecondlife;
35using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
36 35
37namespace OpenSim.Framework.Data.MSSQL 36namespace OpenSim.Framework.Data.MSSQL
38{ 37{
39 class MSSQLAssetData : IAssetProvider 38 internal class MSSQLAssetData : IAssetProvider
40 { 39 {
41 MSSQLManager database; 40 private MSSQLManager database;
41
42 #region IAssetProvider Members 42 #region IAssetProvider Members
43 43
44 private void UpgradeAssetsTable(string tableName) 44 private void UpgradeAssetsTable(string tableName)
@@ -46,7 +46,7 @@ namespace OpenSim.Framework.Data.MSSQL
46 // null as the version, indicates that the table didn't exist 46 // null as the version, indicates that the table didn't exist
47 if (tableName == null) 47 if (tableName == null)
48 { 48 {
49 MainLog.Instance.Notice("ASSETS", "Creating new database tables"); 49 MainLog.Instance.Notice("ASSETS", "Creating new database tables");
50 database.ExecuteResourceSql("CreateAssetsTable.sql"); 50 database.ExecuteResourceSql("CreateAssetsTable.sql");
51 return; 51 return;
52 } 52 }
@@ -57,14 +57,12 @@ namespace OpenSim.Framework.Data.MSSQL
57 /// </summary> 57 /// </summary>
58 private void TestTables() 58 private void TestTables()
59 { 59 {
60
61 Dictionary<string, string> tableList = new Dictionary<string, string>(); 60 Dictionary<string, string> tableList = new Dictionary<string, string>();
62 61
63 tableList["assets"] = null; 62 tableList["assets"] = null;
64 database.GetTableVersion(tableList); 63 database.GetTableVersion(tableList);
65 64
66 UpgradeAssetsTable(tableList["assets"]); 65 UpgradeAssetsTable(tableList["assets"]);
67
68 } 66 }
69 67
70 public AssetBase FetchAsset(LLUUID assetID) 68 public AssetBase FetchAsset(LLUUID assetID)
@@ -80,30 +78,27 @@ namespace OpenSim.Framework.Data.MSSQL
80 asset = database.getAssetRow(reader); 78 asset = database.getAssetRow(reader);
81 reader.Close(); 79 reader.Close();
82 result.Dispose(); 80 result.Dispose();
83 81
84 return asset; 82 return asset;
85 } 83 }
86 84
87 public void CreateAsset(AssetBase asset) 85 public void CreateAsset(AssetBase asset)
88 { 86 {
89 87 if (ExistsAsset((LLUUID) asset.FullID))
90 if (ExistsAsset((LLUUID)asset.FullID))
91 { 88 {
92 return; 89 return;
93 } 90 }
94 91
95 92
96
97 SqlCommand cmd = 93 SqlCommand cmd =
98 new SqlCommand( 94 new SqlCommand(
99 "INSERT INTO assets ([id], [name], [description], [assetType], [invType], [local], [temporary], [data])"+ 95 "INSERT INTO assets ([id], [name], [description], [assetType], [invType], [local], [temporary], [data])" +
100 " VALUES "+ 96 " VALUES " +
101 "(@id, @name, @description, @assetType, @invType, @local, @temporary, @data)", 97 "(@id, @name, @description, @assetType, @invType, @local, @temporary, @data)",
102 database.getConnection()); 98 database.getConnection());
103 99
104 using (cmd) 100 using (cmd)
105 { 101 {
106
107 //SqlParameter p = cmd.Parameters.Add("id", SqlDbType.NVarChar); 102 //SqlParameter p = cmd.Parameters.Add("id", SqlDbType.NVarChar);
108 //p.Value = asset.FullID.ToString(); 103 //p.Value = asset.FullID.ToString();
109 cmd.Parameters.AddWithValue("id", asset.FullID.ToString()); 104 cmd.Parameters.AddWithValue("id", asset.FullID.ToString());
@@ -127,24 +122,23 @@ namespace OpenSim.Framework.Data.MSSQL
127 { 122 {
128 throw; 123 throw;
129 } 124 }
130 125
131 cmd.Dispose(); 126 cmd.Dispose();
132 } 127 }
133
134 } 128 }
135 129
136 130
137 public void UpdateAsset(AssetBase asset) 131 public void UpdateAsset(AssetBase asset)
138 { 132 {
139 SqlCommand command = new SqlCommand("UPDATE assets set id = @id, " + 133 SqlCommand command = new SqlCommand("UPDATE assets set id = @id, " +
140 "name = @name, " + 134 "name = @name, " +
141 "description = @description," + 135 "description = @description," +
142 "assetType = @assetType," + 136 "assetType = @assetType," +
143 "invType = @invType," + 137 "invType = @invType," +
144 "local = @local,"+ 138 "local = @local," +
145 "temporary = @temporary," + 139 "temporary = @temporary," +
146 "data = @data where " + 140 "data = @data where " +
147 "id = @keyId;", database.getConnection()); 141 "id = @keyId;", database.getConnection());
148 SqlParameter param1 = new SqlParameter("@id", asset.FullID.ToString()); 142 SqlParameter param1 = new SqlParameter("@id", asset.FullID.ToString());
149 SqlParameter param2 = new SqlParameter("@name", asset.Name); 143 SqlParameter param2 = new SqlParameter("@name", asset.Name);
150 SqlParameter param3 = new SqlParameter("@description", asset.Description); 144 SqlParameter param3 = new SqlParameter("@description", asset.Description);
@@ -172,12 +166,12 @@ namespace OpenSim.Framework.Data.MSSQL
172 { 166 {
173 MainLog.Instance.Error(e.ToString()); 167 MainLog.Instance.Error(e.ToString());
174 } 168 }
175
176 } 169 }
177 170
178 public bool ExistsAsset(LLUUID uuid) 171 public bool ExistsAsset(LLUUID uuid)
179 { 172 {
180 if (FetchAsset(uuid) != null) { 173 if (FetchAsset(uuid) != null)
174 {
181 return true; 175 return true;
182 } 176 }
183 return false; 177 return false;
@@ -194,11 +188,8 @@ namespace OpenSim.Framework.Data.MSSQL
194 188
195 #region IPlugin Members 189 #region IPlugin Members
196 190
197
198
199 public void Initialise() 191 public void Initialise()
200 { 192 {
201
202 IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini"); 193 IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini");
203 string settingDataSource = GridDataMySqlFile.ParseFileReadValue("data_source"); 194 string settingDataSource = GridDataMySqlFile.ParseFileReadValue("data_source");
204 string settingInitialCatalog = GridDataMySqlFile.ParseFileReadValue("initial_catalog"); 195 string settingInitialCatalog = GridDataMySqlFile.ParseFileReadValue("initial_catalog");
@@ -206,7 +197,9 @@ namespace OpenSim.Framework.Data.MSSQL
206 string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id"); 197 string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id");
207 string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); 198 string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
208 199
209 this.database = new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, settingPassword); 200 database =
201 new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
202 settingPassword);
210 203
211 TestTables(); 204 TestTables();
212 } 205 }
@@ -214,7 +207,7 @@ namespace OpenSim.Framework.Data.MSSQL
214 public string Version 207 public string Version
215 { 208 {
216// get { return database.getVersion(); } 209// get { return database.getVersion(); }
217 get { return database.getVersion(); } 210 get { return database.getVersion(); }
218 } 211 }
219 212
220 public string Name 213 public string Name
@@ -224,4 +217,4 @@ namespace OpenSim.Framework.Data.MSSQL
224 217
225 #endregion 218 #endregion
226 } 219 }
227} 220} \ No newline at end of file