aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs')
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs153
1 files changed, 0 insertions, 153 deletions
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs
deleted file mode 100644
index 57dbfc6..0000000
--- a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs
+++ /dev/null
@@ -1,153 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenGrid.Framework.Data;
5using libsecondlife;
6
7namespace OpenGrid.Framework.Data.MySQL
8{
9 class MySQLUserData : IUserData
10 {
11 public MySQLManager database;
12
13 public void Initialise()
14 {
15 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
16 string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
17 string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
18 string settingUsername = GridDataMySqlFile.ParseFileReadValue("username");
19 string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
20 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
21 string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
22
23 database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort);
24 }
25
26 public UserProfileData getUserByName(string name)
27 {
28 return getUserByName(name.Split(' ')[0], name.Split(' ')[1]);
29 }
30
31 public UserProfileData getUserByName(string user, string last)
32 {
33 try
34 {
35 lock (database)
36 {
37 Dictionary<string, string> param = new Dictionary<string, string>();
38 param["?first"] = user;
39 param["?second"] = last;
40
41 System.Data.IDbCommand result = database.Query("SELECT * FROM users WHERE username = ?first AND lastname = ?second", param);
42 System.Data.IDataReader reader = result.ExecuteReader();
43
44 UserProfileData row = database.getUserRow(reader);
45
46 reader.Close();
47 result.Dispose();
48
49 return row;
50 }
51 }
52 catch (Exception e)
53 {
54 Console.WriteLine(e.ToString());
55 return null;
56 }
57 }
58
59 public UserProfileData getUserByUUID(LLUUID uuid)
60 {
61 try
62 {
63 lock (database)
64 {
65 Dictionary<string, string> param = new Dictionary<string, string>();
66 param["?uuid"] = uuid.ToStringHyphenated();
67
68 System.Data.IDbCommand result = database.Query("SELECT * FROM users WHERE UUID = ?uuid", param);
69 System.Data.IDataReader reader = result.ExecuteReader();
70
71 UserProfileData row = database.getUserRow(reader);
72
73 reader.Close();
74 result.Dispose();
75
76 return row;
77 }
78 }
79 catch (Exception e)
80 {
81 Console.WriteLine(e.ToString());
82 return null;
83 }
84 }
85
86 public UserAgentData getAgentByName(string name)
87 {
88 return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
89 }
90
91 public UserAgentData getAgentByName(string user, string last)
92 {
93 UserProfileData profile = getUserByName(user, last);
94 return getAgentByUUID(profile.UUID);
95 }
96
97 public UserAgentData getAgentByUUID(LLUUID uuid)
98 {
99 try
100 {
101 lock (database)
102 {
103 Dictionary<string, string> param = new Dictionary<string, string>();
104 param["?uuid"] = uuid.ToStringHyphenated();
105
106 System.Data.IDbCommand result = database.Query("SELECT * FROM agents WHERE UUID = ?uuid", param);
107 System.Data.IDataReader reader = result.ExecuteReader();
108
109 UserAgentData row = database.getAgentRow(reader);
110
111 reader.Close();
112 result.Dispose();
113
114 return row;
115 }
116 }
117 catch (Exception e)
118 {
119 Console.WriteLine(e.ToString());
120 return null;
121 }
122 }
123
124 public void addNewUserProfile(UserProfileData user)
125 {
126 }
127
128 public void addNewUserAgent(UserAgentData agent)
129 {
130 // Do nothing.
131 }
132
133 public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount)
134 {
135 return false;
136 }
137
138 public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
139 {
140 return false;
141 }
142
143 public string getName()
144 {
145 return "MySQL Userdata Interface";
146 }
147
148 public string getVersion()
149 {
150 return "0.1";
151 }
152 }
153}