123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- 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 SQLiteFriendsData : SQLiteGenericTableHandler<FriendsData>, IFriendsData
- {
- public SQLiteFriendsData(string connectionString, string realm)
- : base(connectionString, realm, "FriendsStore")
- {
- }
- public FriendsData[] GetFriends(UUID principalID)
- {
- return GetFriends(principalID.ToString());
- }
- public FriendsData[] GetFriends(string userID)
- {
- SqliteCommand cmd = new SqliteCommand();
- cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm);
- cmd.Parameters.AddWithValue(":PrincipalID", userID.ToString());
- return DoQuery(cmd);
- }
- public bool Delete(UUID principalID, string friend)
- {
- return Delete(principalID.ToString(), friend);
- }
- public bool Delete(string principalID, string friend)
- {
- SqliteCommand cmd = new SqliteCommand();
- cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm);
- cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString());
- cmd.Parameters.AddWithValue(":Friend", friend);
- ExecuteNonQuery(cmd, cmd.Connection);
- return true;
- }
- }
- }
|