diff options
author | Diva Canto | 2010-02-20 20:13:38 -0800 |
---|---|---|
committer | Diva Canto | 2010-02-20 20:13:38 -0800 |
commit | df59d098b319367394bdeb898d7fd7dacd7104ec (patch) | |
tree | 04d6b7214a1773a686d6fab6f53e8ecddd6a7bf7 /OpenSim/Data/SQLite/SQLiteAuthenticationData.cs | |
parent | Added UserAccountData and auth to the SQLite connector. Compiles, runs, but a... (diff) | |
download | opensim-SC-df59d098b319367394bdeb898d7fd7dacd7104ec.zip opensim-SC-df59d098b319367394bdeb898d7fd7dacd7104ec.tar.gz opensim-SC-df59d098b319367394bdeb898d7fd7dacd7104ec.tar.bz2 opensim-SC-df59d098b319367394bdeb898d7fd7dacd7104ec.tar.xz |
SQLite connector better, but access to tables still doesn't work.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteAuthenticationData.cs | 61 |
1 files changed, 47 insertions, 14 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs b/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs index 271ed47..7dab6bf 100644 --- a/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs +++ b/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs | |||
@@ -52,12 +52,16 @@ namespace OpenSim.Data.SQLite | |||
52 | 52 | ||
53 | if (!m_initialized) | 53 | if (!m_initialized) |
54 | { | 54 | { |
55 | m_Connection = new SqliteConnection(connectionString); | ||
56 | m_Connection.Open(); | ||
57 | |||
55 | using (SqliteConnection dbcon = new SqliteConnection(m_connectionString)) | 58 | using (SqliteConnection dbcon = new SqliteConnection(m_connectionString)) |
56 | { | 59 | { |
57 | dbcon.Open(); | 60 | dbcon.Open(); |
58 | Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore"); | 61 | Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore"); |
59 | m.Update(); | 62 | m.Update(); |
60 | } | 63 | } |
64 | |||
61 | m_initialized = true; | 65 | m_initialized = true; |
62 | } | 66 | } |
63 | } | 67 | } |
@@ -105,7 +109,7 @@ namespace OpenSim.Data.SQLite | |||
105 | } | 109 | } |
106 | 110 | ||
107 | public bool Store(AuthenticationData data) | 111 | public bool Store(AuthenticationData data) |
108 | { | 112 | { |
109 | if (data.Data.ContainsKey("UUID")) | 113 | if (data.Data.ContainsKey("UUID")) |
110 | data.Data.Remove("UUID"); | 114 | data.Data.Remove("UUID"); |
111 | 115 | ||
@@ -117,31 +121,60 @@ namespace OpenSim.Data.SQLite | |||
117 | 121 | ||
118 | SqliteCommand cmd = new SqliteCommand(); | 122 | SqliteCommand cmd = new SqliteCommand(); |
119 | 123 | ||
120 | string update = "update `"+m_Realm+"` set "; | 124 | if (Get(data.PrincipalID) != null) |
121 | bool first = true; | ||
122 | foreach (string field in fields) | ||
123 | { | 125 | { |
124 | if (!first) | ||
125 | update += ", "; | ||
126 | update += "`" + field + "` = " + data.Data[field]; | ||
127 | 126 | ||
128 | first = false; | ||
129 | 127 | ||
130 | } | 128 | string update = "update `" + m_Realm + "` set "; |
129 | bool first = true; | ||
130 | foreach (string field in fields) | ||
131 | { | ||
132 | if (!first) | ||
133 | update += ", "; | ||
134 | update += "`" + field + "` = '" + data.Data[field] + "'"; | ||
131 | 135 | ||
132 | update += " where UUID = '" + data.PrincipalID.ToString() + "'"; | 136 | first = false; |
133 | 137 | ||
134 | cmd.CommandText = update; | 138 | } |
139 | |||
140 | update += " where UUID = '" + data.PrincipalID.ToString() + "'"; | ||
141 | |||
142 | cmd.CommandText = update; | ||
143 | Console.WriteLine("XXX " + cmd.CommandText); | ||
144 | try | ||
145 | { | ||
146 | if (ExecuteNonQuery(cmd) < 1) | ||
147 | { | ||
148 | cmd.Dispose(); | ||
149 | return false; | ||
150 | } | ||
151 | } | ||
152 | catch | ||
153 | { | ||
154 | cmd.Dispose(); | ||
155 | return false; | ||
156 | } | ||
157 | } | ||
135 | 158 | ||
136 | if (ExecuteNonQuery(cmd) < 1) | 159 | else |
137 | { | 160 | { |
138 | string insert = "insert into `" + m_Realm + "` (`UUID`, `" + | 161 | string insert = "insert into `" + m_Realm + "` (`UUID`, `" + |
139 | String.Join("`, `", fields) + | 162 | String.Join("`, `", fields) + |
140 | "`) values ('" + data.PrincipalID.ToString() + "', " + String.Join(", '", values) + "')"; | 163 | "`) values ('" + data.PrincipalID.ToString() + "', '" + String.Join("', '", values) + "')"; |
141 | 164 | ||
142 | cmd.CommandText = insert; | 165 | cmd.CommandText = insert; |
143 | 166 | ||
144 | if (ExecuteNonQuery(cmd) < 1) | 167 | Console.WriteLine("XXX " + cmd.CommandText); |
168 | |||
169 | try | ||
170 | { | ||
171 | if (ExecuteNonQuery(cmd) < 1) | ||
172 | { | ||
173 | cmd.Dispose(); | ||
174 | return false; | ||
175 | } | ||
176 | } | ||
177 | catch | ||
145 | { | 178 | { |
146 | cmd.Dispose(); | 179 | cmd.Dispose(); |
147 | return false; | 180 | return false; |