aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices-Source/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs
diff options
context:
space:
mode:
authorMW2007-05-24 12:16:50 +0000
committerMW2007-05-24 12:16:50 +0000
commit3376b82501000692d6dac24b051af738cdaf2737 (patch)
tree90ed0a5d4955236f011fa63fce9d555186b0d179 /OpenGridServices-Source/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs
parentAdded "terrain save grdmap <filename> <gradientmap>" function to console. Gra... (diff)
downloadopensim-SC_OLD-3376b82501000692d6dac24b051af738cdaf2737.zip
opensim-SC_OLD-3376b82501000692d6dac24b051af738cdaf2737.tar.gz
opensim-SC_OLD-3376b82501000692d6dac24b051af738cdaf2737.tar.bz2
opensim-SC_OLD-3376b82501000692d6dac24b051af738cdaf2737.tar.xz
Some more code refactoring, plus a restructuring of the directories so that the Grid servers can be a separate solution to the region server.
Diffstat (limited to 'OpenGridServices-Source/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs')
-rw-r--r--OpenGridServices-Source/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs136
1 files changed, 136 insertions, 0 deletions
diff --git a/OpenGridServices-Source/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs b/OpenGridServices-Source/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs
new file mode 100644
index 0000000..0741272
--- /dev/null
+++ b/OpenGridServices-Source/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs
@@ -0,0 +1,136 @@
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 database = new MySQLManager("host", "database", "user", "password", "false");
16 }
17
18 public UserProfileData getUserByName(string name)
19 {
20 return getUserByName(name.Split(' ')[0], name.Split(' ')[1]);
21 }
22
23 public UserProfileData getUserByName(string user, string last)
24 {
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 }
49 }
50
51 public UserProfileData getUserByUUID(LLUUID uuid)
52 {
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 }
76 }
77
78 public UserAgentData getAgentByName(string name)
79 {
80 return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
81 }
82
83 public UserAgentData getAgentByName(string user, string last)
84 {
85 UserProfileData profile = getUserByName(user, last);
86 return getAgentByUUID(profile.UUID);
87 }
88
89 public UserAgentData getAgentByUUID(LLUUID uuid)
90 {
91 try
92 {
93 lock (database)
94 {
95 Dictionary<string, string> param = new Dictionary<string, string>();
96 param["?uuid"] = uuid.ToStringHyphenated();
97
98 System.Data.IDbCommand result = database.Query("SELECT * FROM agents WHERE UUID = ?uuid", param);
99 System.Data.IDataReader reader = result.ExecuteReader();
100
101 UserAgentData row = database.getAgentRow(reader);
102
103 reader.Close();
104 result.Dispose();
105
106 return row;
107 }
108 }
109 catch (Exception e)
110 {
111 Console.WriteLine(e.ToString());
112 return null;
113 }
114 }
115
116 public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount)
117 {
118 return false;
119 }
120
121 public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
122 {
123 return false;
124 }
125
126 public string getName()
127 {
128 return "MySQL Userdata Interface";
129 }
130
131 public string getVersion()
132 {
133 return "0.1";
134 }
135 }
136}