diff options
-rw-r--r-- | OpenGrid.Framework.Data.MySQL/MySQLUserData.cs | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs b/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs index 4f35a59..05d65cf 100644 --- a/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs +++ b/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs | |||
@@ -8,11 +8,11 @@ namespace OpenGrid.Framework.Data.MySQL | |||
8 | { | 8 | { |
9 | class MySQLUserData : IUserData | 9 | class MySQLUserData : IUserData |
10 | { | 10 | { |
11 | public MySQLManager manager; | 11 | public MySQLManager database; |
12 | 12 | ||
13 | public void Initialise() | 13 | public void Initialise() |
14 | { | 14 | { |
15 | manager = new MySQLManager("host", "database", "user", "password", "false"); | 15 | database = new MySQLManager("host", "database", "user", "password", "false"); |
16 | } | 16 | } |
17 | 17 | ||
18 | public UserProfileData getUserByName(string name) | 18 | public UserProfileData getUserByName(string name) |
@@ -22,12 +22,57 @@ namespace OpenGrid.Framework.Data.MySQL | |||
22 | 22 | ||
23 | public UserProfileData getUserByName(string user, string last) | 23 | public UserProfileData getUserByName(string user, string last) |
24 | { | 24 | { |
25 | return new UserProfileData(); | 25 | try |
26 | { | ||
27 | lock (database) | ||
28 | { | ||
29 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
30 | param["?first"] = user; | ||
31 | param["?second"] = last; | ||
32 | |||
33 | System.Data.IDbCommand result = database.Query("SELECT * FROM users WHERE username = ?first AND lastname = ?second", param); | ||
34 | System.Data.IDataReader reader = result.ExecuteReader(); | ||
35 | |||
36 | UserProfileData row = database.getUserRow(reader); | ||
37 | |||
38 | reader.Close(); | ||
39 | result.Dispose(); | ||
40 | |||
41 | return row; | ||
42 | } | ||
43 | } | ||
44 | catch (Exception e) | ||
45 | { | ||
46 | Console.WriteLine(e.ToString()); | ||
47 | return null; | ||
48 | } | ||
26 | } | 49 | } |
27 | 50 | ||
28 | public UserProfileData getUserByUUID(LLUUID uuid) | 51 | public UserProfileData getUserByUUID(LLUUID uuid) |
29 | { | 52 | { |
30 | return new UserProfileData(); | 53 | try |
54 | { | ||
55 | lock (database) | ||
56 | { | ||
57 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
58 | param["?uuid"] = uuid.ToStringHyphenated(); | ||
59 | |||
60 | System.Data.IDbCommand result = database.Query("SELECT * FROM users WHERE UUID = ?uuid", param); | ||
61 | System.Data.IDataReader reader = result.ExecuteReader(); | ||
62 | |||
63 | UserProfileData row = database.getUserRow(reader); | ||
64 | |||
65 | reader.Close(); | ||
66 | result.Dispose(); | ||
67 | |||
68 | return row; | ||
69 | } | ||
70 | } | ||
71 | catch (Exception e) | ||
72 | { | ||
73 | Console.WriteLine(e.ToString()); | ||
74 | return null; | ||
75 | } | ||
31 | } | 76 | } |
32 | 77 | ||
33 | public UserAgentData getAgentByName(string name) | 78 | public UserAgentData getAgentByName(string name) |