using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Reflection;
using JuSNS.Model;

namespace JuSNS.Factory
{
    public interface IFriend
    {
        /// <summary>
        /// 判断是否是好友
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="friendid"></param>
        /// <returns></returns>
        bool IsFriends(int userid, int friendid);


        /// <summary>
        /// 得到好友分类
        /// </summary>
        /// <param name="UserID"></param>
        /// <returns></returns>
        IDataReader GetFriendClass(int UserID);


        int SetFriendClassID(int UserID, int ClassID, int ID);
       /// <summary>
        /// 发送交友请求
        /// </summary>
        /// <param name="proposer"></param>
        /// <param name="friend"></param>
        /// <returns></returns>
        int Request(int proposer, int friend);
        /// <summary>
        /// 回应好友请求
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="requestid"></param>
        /// <param name="reply"></param>
        /// <param name="detail"></param>
        /// <returns></returns>
        int Response(int userid, int requestid, EnumReply reply, string detail);
        /// <summary>
        /// 删除好友
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="friendid"></param>
        /// <returns></returns>
        int Diffidation(int userid, int friendid);
        #region 好友描述
        /*
        /// <summary>
        /// 修改好友描述
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="detail"></param>
        /// <returns></returns>
        int EditFriendsDetail(int userid, int friendid, List<FriendDescInfo> detail);
       
        /// <summary>
        /// 回复好友描述请求
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="friendid"></param>
        /// <param name="isconfirm"></param>
        /// <returns></returns>
        int ReplyFriendDetail(int userid, int friendid, bool isconfirm);
        /// <summary>
        /// 获取好友描述信息
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="friendid"></param>
        /// <returns></returns>
        List<FriendDescInfo> GetDetail(int userid, int friendid); 
        */
        #endregion
        /// <summary>
        /// 打招呼,非好友也可以打招呼
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="friendid"></param>
        /// <returns></returns>
        int Greet(int userid, int friendid);
        #region 留言
        /// <summary>
        /// 发送留言
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="friendid"></param>
        /// <param name="word"></param>
        /// <returns></returns>
        int SendLeaveword(int userid, int friendid, string word);
        /// <summary>
        /// 删除留言
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="wordid"></param>
        /// <returns></returns>
        int DeleteLeaveword(int userid, int wordid);
        #endregion
        /// <summary>
        /// 判断是否在同一网络
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="friendid"></param>
        /// <returns></returns>
        bool IsInSameNetwork(int userid, int friendid);
        /// <summary>
        /// 取得好友
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="friendname"></param>
        /// <returns></returns>
        Dictionary<int, string> GetFriends(int userid, string friendname);
        /// <summary>
        /// 取得好友（群组）
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="GroupID"></param>
        /// <param name="friendname"></param>
        /// <returns></returns>
        Dictionary<int, string> GetFriendsForGroup(int userid, int GroupID, string friendname);
        /// <summary>
        /// 查看两人关系
        /// </summary>
        /// <param name="myid"></param>
        /// <param name="otherid"></param>
        /// <returns>0无任何关系,1本人,2好友,3已发出好友申请,等待确认好友申请,4被申请</returns>
        int GetRelation(int myid, int otherid);
        /// <summary>
        /// 邮件邀请好友
        /// </summary>
        /// <param name="userid">邀请者ID</param>
        /// <param name="emails">被邀请者的email</param>
        /// <param name="postscript">附言</param>
        /// <param name="isRepeat">是否重复邀请</param>
        /// <returns>0成功,1该邮箱已经注册,2该邮箱已被邀请,3写入数据库失败</returns>
        Dictionary<string, int> InviteFriends(int userId, string userName, string[] emails, string postscript, bool isRepeat);
        /// <summary>
        /// 好友邀请统计
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="confirmed">确认了的</param>
        /// <param name="pending">还未确认的</param>
        void InviteStat(int userId, out int confirmed, out int pending);
        /// <summary>
        /// 查看是否具有查看好友列表的权限
        /// </summary>
        /// <param name="guestId"></param>
        /// <param name="masterId"></param>
        /// <returns></returns>
        bool CheckListAuthority(int guestId, int masterId);
        /// <summary>
        /// 寻找MSN,Gtalk好友
        /// </summary>
        /// <param name="eamil">邮件列表</param>
        /// <returns>返回数据表</returns>
        DataTable FindFriend(string eamil);
        IList<FriendInfo> GetList(int pageIndex, int pageSize, out int recordCount, out int pageCount, int userId, int netWork, string searchName, string c, out Dictionary<NetworkInfo, int> stat);
        int UpdateFriendClass(int UserID, string CName, int ID);
        int GetUnClassFriend(int UserID);
        void DelFriendClass(int ID, int UserID);
        void AddFriendClass(string CName, int UserID);
        int GetUserIDFromEmail(string Email);
    }

    public sealed partial class DataAccess
    {
        public static IFriend CreateFriend()
        {
            string className = path + ".Friend";
            return (IFriend)Assembly.Load(path).CreateInstance(className);
        }
    }
}
