diff options
author | John Hurliman | 2009-10-05 17:38:27 -0700 |
---|---|---|
committer | John Hurliman | 2009-10-05 17:38:27 -0700 |
commit | 7ddb6fbced5f2a98aa0201e354987ebc32adf7d2 (patch) | |
tree | 903b87112e7f851218e7b3d41c681f1b8f512af2 /OpenSim/Data/MSSQL/MSSQLAuthenticationData.cs | |
parent | Beginning work on the new LLUDP implementation (diff) | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-7ddb6fbced5f2a98aa0201e354987ebc32adf7d2.zip opensim-SC_OLD-7ddb6fbced5f2a98aa0201e354987ebc32adf7d2.tar.gz opensim-SC_OLD-7ddb6fbced5f2a98aa0201e354987ebc32adf7d2.tar.bz2 opensim-SC_OLD-7ddb6fbced5f2a98aa0201e354987ebc32adf7d2.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim into htb-throttle
Diffstat (limited to 'OpenSim/Data/MSSQL/MSSQLAuthenticationData.cs')
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLAuthenticationData.cs | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLAuthenticationData.cs b/OpenSim/Data/MSSQL/MSSQLAuthenticationData.cs index 099faea..9a17e47 100644 --- a/OpenSim/Data/MSSQL/MSSQLAuthenticationData.cs +++ b/OpenSim/Data/MSSQL/MSSQLAuthenticationData.cs | |||
@@ -43,6 +43,7 @@ namespace OpenSim.Data.MSSQL | |||
43 | private List<string> m_ColumnNames = null; | 43 | private List<string> m_ColumnNames = null; |
44 | private int m_LastExpire = 0; | 44 | private int m_LastExpire = 0; |
45 | private string m_ConnectionString; | 45 | private string m_ConnectionString; |
46 | private MSSQLManager m_database; | ||
46 | 47 | ||
47 | public MSSQLAuthenticationData(string connectionString, string realm) | 48 | public MSSQLAuthenticationData(string connectionString, string realm) |
48 | { | 49 | { |
@@ -61,12 +62,12 @@ namespace OpenSim.Data.MSSQL | |||
61 | AuthenticationData ret = new AuthenticationData(); | 62 | AuthenticationData ret = new AuthenticationData(); |
62 | ret.Data = new Dictionary<string, object>(); | 63 | ret.Data = new Dictionary<string, object>(); |
63 | 64 | ||
64 | string sql = string.Format("select * from '{0}' where UUID = @principalID", m_Realm); | 65 | string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm); |
65 | 66 | ||
66 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 67 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
67 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 68 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
68 | { | 69 | { |
69 | cmd.Parameters.AddWithValue("@principalID", principalID.ToString()); | 70 | cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID)); |
70 | conn.Open(); | 71 | conn.Open(); |
71 | using (SqlDataReader result = cmd.ExecuteReader()) | 72 | using (SqlDataReader result = cmd.ExecuteReader()) |
72 | { | 73 | { |
@@ -108,34 +109,33 @@ namespace OpenSim.Data.MSSQL | |||
108 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 109 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
109 | using (SqlCommand cmd = new SqlCommand()) | 110 | using (SqlCommand cmd = new SqlCommand()) |
110 | { | 111 | { |
111 | updateBuilder.AppendFormat("update '{0}' set ", m_Realm); | 112 | updateBuilder.AppendFormat("update {0} set ", m_Realm); |
112 | 113 | ||
113 | bool first = true; | 114 | bool first = true; |
114 | foreach (string field in fields) | 115 | foreach (string field in fields) |
115 | { | 116 | { |
116 | if (!first) | 117 | if (!first) |
117 | updateBuilder.Append(", "); | 118 | updateBuilder.Append(", "); |
118 | updateBuilder.AppendFormat("'{0}' = @{0}",field); | 119 | updateBuilder.AppendFormat("{0} = @{0}",field); |
119 | 120 | ||
120 | first = false; | 121 | first = false; |
121 | 122 | cmd.Parameters.Add(m_database.CreateParameter("@" + field, data.Data[field])); | |
122 | cmd.Parameters.AddWithValue("@" + field, data.Data[field]); | ||
123 | } | 123 | } |
124 | 124 | ||
125 | updateBuilder.Append(" where UUID = @principalID"); | 125 | updateBuilder.Append(" where UUID = @principalID"); |
126 | 126 | ||
127 | cmd.CommandText = updateBuilder.ToString(); | 127 | cmd.CommandText = updateBuilder.ToString(); |
128 | cmd.Connection = conn; | 128 | cmd.Connection = conn; |
129 | 129 | cmd.Parameters.Add(m_database.CreateParameter("@principalID", data.PrincipalID)); | |
130 | cmd.Parameters.AddWithValue("@principalID", data.PrincipalID.ToString()); | 130 | |
131 | conn.Open(); | 131 | conn.Open(); |
132 | if (cmd.ExecuteNonQuery() < 1) | 132 | if (cmd.ExecuteNonQuery() < 1) |
133 | { | 133 | { |
134 | StringBuilder insertBuilder = new StringBuilder(); | 134 | StringBuilder insertBuilder = new StringBuilder(); |
135 | 135 | ||
136 | insertBuilder.AppendFormat("insert into '{0}' ('UUID', '", m_Realm); | 136 | insertBuilder.AppendFormat("insert into {0} (UUID, ", m_Realm); |
137 | insertBuilder.Append(String.Join("', '", fields)); | 137 | insertBuilder.Append(String.Join(", ", fields)); |
138 | insertBuilder.Append("') values (@principalID, @"); | 138 | insertBuilder.Append(") values ( @principalID, @"); |
139 | insertBuilder.Append(String.Join(", @", fields)); | 139 | insertBuilder.Append(String.Join(", @", fields)); |
140 | insertBuilder.Append(")"); | 140 | insertBuilder.Append(")"); |
141 | 141 | ||
@@ -152,12 +152,11 @@ namespace OpenSim.Data.MSSQL | |||
152 | 152 | ||
153 | public bool SetDataItem(UUID principalID, string item, string value) | 153 | public bool SetDataItem(UUID principalID, string item, string value) |
154 | { | 154 | { |
155 | string sql = string.Format("update '{0}' set '{1}' = @{1} where UUID = @UUID", m_Realm, item); | 155 | string sql = string.Format("update {0} set {1} = @{1} where UUID = @UUID", m_Realm, item); |
156 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 156 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
157 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 157 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
158 | { | 158 | { |
159 | cmd.Parameters.AddWithValue("@" + item, value); | 159 | cmd.Parameters.Add(m_database.CreateParameter("@" + item, value)); |
160 | cmd.Parameters.AddWithValue("@UUID", principalID.ToString()); | ||
161 | conn.Open(); | 160 | conn.Open(); |
162 | if (cmd.ExecuteNonQuery() > 0) | 161 | if (cmd.ExecuteNonQuery() > 0) |
163 | return true; | 162 | return true; |
@@ -173,9 +172,9 @@ namespace OpenSim.Data.MSSQL | |||
173 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 172 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
174 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 173 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
175 | { | 174 | { |
176 | cmd.Parameters.AddWithValue("@principalID", principalID.ToString()); | 175 | cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID)); |
177 | cmd.Parameters.AddWithValue("@token", token); | 176 | cmd.Parameters.Add(m_database.CreateParameter("@token", token)); |
178 | cmd.Parameters.AddWithValue("@lifetime", lifetime.ToString()); | 177 | cmd.Parameters.Add(m_database.CreateParameter("@lifetime", lifetime)); |
179 | conn.Open(); | 178 | conn.Open(); |
180 | 179 | ||
181 | if (cmd.ExecuteNonQuery() > 0) | 180 | if (cmd.ExecuteNonQuery() > 0) |
@@ -194,9 +193,9 @@ namespace OpenSim.Data.MSSQL | |||
194 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 193 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
195 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 194 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
196 | { | 195 | { |
197 | cmd.Parameters.AddWithValue("@principalID", principalID.ToString()); | 196 | cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID)); |
198 | cmd.Parameters.AddWithValue("@token", token); | 197 | cmd.Parameters.Add(m_database.CreateParameter("@token", token)); |
199 | cmd.Parameters.AddWithValue("@lifetime", lifetime.ToString()); | 198 | cmd.Parameters.Add(m_database.CreateParameter("@lifetime", lifetime)); |
200 | conn.Open(); | 199 | conn.Open(); |
201 | 200 | ||
202 | if (cmd.ExecuteNonQuery() > 0) | 201 | if (cmd.ExecuteNonQuery() > 0) |