diff options
author | lbsa71 | 2007-10-30 09:05:31 +0000 |
---|---|---|
committer | lbsa71 | 2007-10-30 09:05:31 +0000 |
commit | 67e12b95ea7b68f4904a7484d77ecfd787d16d0c (patch) | |
tree | 20b00d24c8a7617017960432ec044852e3ad5fa9 /OpenSim/Framework/Data.MySQL/MySQLAssetData.cs | |
parent | * Deleted .user file (diff) | |
download | opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.zip opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.gz opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.bz2 opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.xz |
* Optimized usings
* Shortened type references
* Removed redundant 'this' qualifier
Diffstat (limited to 'OpenSim/Framework/Data.MySQL/MySQLAssetData.cs')
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLAssetData.cs | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs index bf895c0..055cd92 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs | |||
@@ -28,18 +28,17 @@ | |||
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using MySql.Data.MySqlClient; | 31 | using System.Data; |
32 | |||
33 | using libsecondlife; | 32 | using libsecondlife; |
33 | using MySql.Data.MySqlClient; | ||
34 | using OpenSim.Framework.Console; | 34 | using OpenSim.Framework.Console; |
35 | using OpenSim.Framework.Interfaces; | ||
36 | using OpenSim.Framework; | ||
37 | 35 | ||
38 | namespace OpenSim.Framework.Data.MySQL | 36 | namespace OpenSim.Framework.Data.MySQL |
39 | { | 37 | { |
40 | class MySQLAssetData : IAssetProvider | 38 | internal class MySQLAssetData : IAssetProvider |
41 | { | 39 | { |
42 | MySQLManager _dbConnection; | 40 | private MySQLManager _dbConnection; |
41 | |||
43 | #region IAssetProvider Members | 42 | #region IAssetProvider Members |
44 | 43 | ||
45 | private void UpgradeAssetsTable(string oldVersion) | 44 | private void UpgradeAssetsTable(string oldVersion) |
@@ -58,14 +57,12 @@ namespace OpenSim.Framework.Data.MySQL | |||
58 | /// </summary> | 57 | /// </summary> |
59 | private void TestTables() | 58 | private void TestTables() |
60 | { | 59 | { |
61 | |||
62 | Dictionary<string, string> tableList = new Dictionary<string, string>(); | 60 | Dictionary<string, string> tableList = new Dictionary<string, string>(); |
63 | 61 | ||
64 | tableList["assets"] = null; | 62 | tableList["assets"] = null; |
65 | _dbConnection.GetTableVersion(tableList); | 63 | _dbConnection.GetTableVersion(tableList); |
66 | 64 | ||
67 | UpgradeAssetsTable(tableList["assets"]); | 65 | UpgradeAssetsTable(tableList["assets"]); |
68 | |||
69 | } | 66 | } |
70 | 67 | ||
71 | public AssetBase FetchAsset(LLUUID assetID) | 68 | public AssetBase FetchAsset(LLUUID assetID) |
@@ -73,21 +70,24 @@ namespace OpenSim.Framework.Data.MySQL | |||
73 | AssetBase asset = null; | 70 | AssetBase asset = null; |
74 | lock (_dbConnection) | 71 | lock (_dbConnection) |
75 | { | 72 | { |
76 | MySqlCommand cmd = new MySqlCommand("SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id", _dbConnection.Connection); | 73 | MySqlCommand cmd = |
74 | new MySqlCommand( | ||
75 | "SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id", | ||
76 | _dbConnection.Connection); | ||
77 | MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); | 77 | MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); |
78 | p.Value = assetID.GetBytes(); | 78 | p.Value = assetID.GetBytes(); |
79 | using (MySqlDataReader dbReader = cmd.ExecuteReader(System.Data.CommandBehavior.SingleRow)) | 79 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) |
80 | { | 80 | { |
81 | if (dbReader.Read()) | 81 | if (dbReader.Read()) |
82 | { | 82 | { |
83 | asset = new AssetBase(); | 83 | asset = new AssetBase(); |
84 | asset.Data = (byte[])dbReader["data"]; | 84 | asset.Data = (byte[]) dbReader["data"]; |
85 | asset.Description = (string)dbReader["description"]; | 85 | asset.Description = (string) dbReader["description"]; |
86 | asset.FullID = assetID; | 86 | asset.FullID = assetID; |
87 | asset.InvType = (sbyte)dbReader["invType"]; | 87 | asset.InvType = (sbyte) dbReader["invType"]; |
88 | asset.Local = ((sbyte)dbReader["local"]) != 0 ? true : false; | 88 | asset.Local = ((sbyte) dbReader["local"]) != 0 ? true : false; |
89 | asset.Name = (string)dbReader["name"]; | 89 | asset.Name = (string) dbReader["name"]; |
90 | asset.Type = (sbyte)dbReader["assetType"]; | 90 | asset.Type = (sbyte) dbReader["assetType"]; |
91 | } | 91 | } |
92 | } | 92 | } |
93 | } | 93 | } |
@@ -96,8 +96,11 @@ namespace OpenSim.Framework.Data.MySQL | |||
96 | 96 | ||
97 | public void CreateAsset(AssetBase asset) | 97 | public void CreateAsset(AssetBase asset) |
98 | { | 98 | { |
99 | MySqlCommand cmd = new MySqlCommand("REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" + | 99 | MySqlCommand cmd = |
100 | "VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)", _dbConnection.Connection); | 100 | new MySqlCommand( |
101 | "REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" + | ||
102 | "VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)", | ||
103 | _dbConnection.Connection); | ||
101 | MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); | 104 | MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); |
102 | p.Value = asset.FullID.GetBytes(); | 105 | p.Value = asset.FullID.GetBytes(); |
103 | cmd.Parameters.AddWithValue("?name", asset.Name); | 106 | cmd.Parameters.AddWithValue("?name", asset.Name); |
@@ -148,7 +151,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
148 | 151 | ||
149 | public string Version | 152 | public string Version |
150 | { | 153 | { |
151 | get { return _dbConnection.getVersion(); } | 154 | get { return _dbConnection.getVersion(); } |
152 | } | 155 | } |
153 | 156 | ||
154 | public string Name | 157 | public string Name |
@@ -158,4 +161,4 @@ namespace OpenSim.Framework.Data.MySQL | |||
158 | 161 | ||
159 | #endregion | 162 | #endregion |
160 | } | 163 | } |
161 | } | 164 | } \ No newline at end of file |