aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MSSQL/MSSQLUserData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/MSSQL/MSSQLUserData.cs')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLUserData.cs114
1 files changed, 4 insertions, 110 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLUserData.cs b/OpenSim/Data/MSSQL/MSSQLUserData.cs
index 22b3c94..2016ae3 100644
--- a/OpenSim/Data/MSSQL/MSSQLUserData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLUserData.cs
@@ -55,6 +55,7 @@ namespace OpenSim.Data.MSSQL
55 private const string m_usersTableName = "users"; 55 private const string m_usersTableName = "users";
56 private const string m_userFriendsTableName = "userfriends"; 56 private const string m_userFriendsTableName = "userfriends";
57 57
58 [Obsolete("Cannot be default-initialized!")]
58 override public void Initialise() 59 override public void Initialise()
59 { 60 {
60 m_log.Info("[MSSQLUserData]: " + Name + " cannot be default-initialized!"); 61 m_log.Info("[MSSQLUserData]: " + Name + " cannot be default-initialized!");
@@ -69,7 +70,7 @@ namespace OpenSim.Data.MSSQL
69 override public void Initialise(string connect) 70 override public void Initialise(string connect)
70 { 71 {
71 72
72 if (string.IsNullOrEmpty(connect)) 73 if (!string.IsNullOrEmpty(connect))
73 { 74 {
74 database = new MSSQLManager(connect); 75 database = new MSSQLManager(connect);
75 } 76 }
@@ -86,27 +87,6 @@ namespace OpenSim.Data.MSSQL
86 database = new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, settingPassword); 87 database = new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, settingPassword);
87 } 88 }
88 89
89// m_usersTableName = iniFile.ParseFileReadValue("userstablename");
90// if (m_usersTableName == null)
91// {
92// m_usersTableName = "users";
93// }
94//
95// m_userFriendsTableName = iniFile.ParseFileReadValue("userfriendstablename");
96// if (m_userFriendsTableName == null)
97// {
98// m_userFriendsTableName = "userfriends";
99// }
100//
101// m_agentsTableName = iniFile.ParseFileReadValue("agentstablename");
102// if (m_agentsTableName == null)
103// {
104// m_agentsTableName = "agents";
105// }
106
107 //TODO this can be removed at one time!!!!!
108 TestTables();
109
110 //Check migration on DB 90 //Check migration on DB
111 database.CheckMigration(_migrationStore); 91 database.CheckMigration(_migrationStore);
112 } 92 }
@@ -116,93 +96,6 @@ namespace OpenSim.Data.MSSQL
116 /// </summary> 96 /// </summary>
117 override public void Dispose() { } 97 override public void Dispose() { }
118 98
119 /// <summary>
120 /// Can be deleted at one time!
121 /// </summary>
122 /// <returns></returns>
123 private void TestTables()
124 {
125 using (IDbCommand cmd = database.Query("select top 1 * from " + m_usersTableName))
126 {
127 try
128 {
129 cmd.ExecuteNonQuery();
130 }
131 catch
132 {
133 database.ExecuteResourceSql("Mssql-users.sql");
134 }
135 }
136
137 using (IDbCommand cmd = database.Query("select top 1 * from " + m_agentsTableName, new Dictionary<string, string>()))
138 {
139 try
140 {
141 cmd.ExecuteNonQuery();
142 }
143 catch
144 {
145 database.ExecuteResourceSql("Mssql-agents.sql");
146 }
147 }
148
149 using (IDbCommand cmd = database.Query("select top 1 * from " + m_userFriendsTableName, new Dictionary<string, string>()))
150 {
151 try
152 {
153 cmd.ExecuteNonQuery();
154 }
155 catch
156 {
157 database.ExecuteResourceSql("CreateUserFriendsTable.sql");
158 }
159 }
160
161 using (IDbCommand cmd = database.Query("select top 1 * from avatarappearance", new Dictionary<string, string>()))
162 {
163 try
164 {
165 cmd.ExecuteNonQuery();
166 }
167 catch
168 {
169 database.ExecuteResourceSql("AvatarAppearance.sql");
170 }
171 }
172
173 //Special for Migrations
174 using (AutoClosingSqlCommand cmd = database.Query("select * from migrations where name = 'UserStore'"))
175 {
176 try
177 {
178 bool insert = true;
179 using (SqlDataReader reader = cmd.ExecuteReader())
180 {
181 if (reader.Read()) insert = false;
182 }
183 if (insert)
184 {
185 cmd.CommandText = "insert into migrations(name, version) values('UserStore', 1)";
186 cmd.ExecuteNonQuery();
187 }
188 }
189 catch
190 {
191 //No migrations table
192 //HACK create one and add data
193 cmd.CommandText = "create table migrations(name varchar(100), version int)";
194 cmd.ExecuteNonQuery();
195
196 cmd.CommandText = "insert into migrations(name, version) values('migrations', 1)";
197 cmd.ExecuteNonQuery();
198
199 cmd.CommandText = "insert into migrations(name, version) values('UserStore', 1)";
200 cmd.ExecuteNonQuery();
201 }
202 }
203 return;
204 }
205
206 #region User table methods 99 #region User table methods
207 100
208 /// <summary> 101 /// <summary>
@@ -679,7 +572,7 @@ namespace OpenSim.Data.MSSQL
679 /// <param name="appearance">the appearence</param> 572 /// <param name="appearance">the appearence</param>
680 override public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) 573 override public void UpdateUserAppearance(UUID user, AvatarAppearance appearance)
681 { 574 {
682 m_log.Error("[USER DB] updating user appearance for user ID " + user.Guid.ToString()); 575 m_log.Error("[USER DB] updating user appearance for user ID " + user.Guid);
683 string sql = String.Empty; 576 string sql = String.Empty;
684 sql += "DELETE FROM avatarappearance WHERE owner=@owner "; 577 sql += "DELETE FROM avatarappearance WHERE owner=@owner ";
685 sql += "INSERT INTO avatarappearance "; 578 sql += "INSERT INTO avatarappearance ";
@@ -1112,6 +1005,7 @@ ELSE
1112 /// <param name="uuid">User ID</param> 1005 /// <param name="uuid">User ID</param>
1113 /// <param name="username">First part of the login</param> 1006 /// <param name="username">First part of the login</param>
1114 /// <param name="lastname">Second part of the login</param> 1007 /// <param name="lastname">Second part of the login</param>
1008 /// <param name="email">Email of person</param>
1115 /// <param name="passwordHash">A salted hash of the users password</param> 1009 /// <param name="passwordHash">A salted hash of the users password</param>
1116 /// <param name="passwordSalt">The salt used for the password hash</param> 1010 /// <param name="passwordSalt">The salt used for the password hash</param>
1117 /// <param name="homeRegion">A regionHandle of the users home region</param> 1011 /// <param name="homeRegion">A regionHandle of the users home region</param>