1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using OpenMetaverse;
- using OpenSim.Framework;
- #if CSharpSqlite
- using Community.CsharpSqlite.Sqlite;
- #else
- using Mono.Data.Sqlite;
- #endif
- namespace OpenSim.Data.SQLite
- {
- public class SQLiteUserAccountData : SQLiteGenericTableHandler<UserAccountData>, IUserAccountData
- {
- public SQLiteUserAccountData(string connectionString, string realm)
- : base(connectionString, realm, "UserAccount")
- {
- }
- public UserAccountData[] GetUsers(UUID scopeID, string query)
- {
- string[] words = query.Split(new char[] {' '});
- for (int i = 0 ; i < words.Length ; i++)
- {
- if (words[i].Length < 3)
- {
- if (i != words.Length - 1)
- Array.Copy(words, i + 1, words, i, words.Length - i - 1);
- Array.Resize(ref words, words.Length - 1);
- }
- }
- if (words.Length == 0)
- return new UserAccountData[0];
- if (words.Length > 2)
- return new UserAccountData[0];
- using (SqliteCommand cmd = new SqliteCommand())
- {
- if (words.Length == 1)
- {
- cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')",
- m_Realm, scopeID.ToString(), words[0]);
- }
- else
- {
- cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')",
- m_Realm, scopeID.ToString(), words[0], words[1]);
- }
- return DoQuery(cmd);
- }
- }
- }
- }
|