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

namespace JuSNS.Factory
{
    public interface IUser
    {
        /// <summary>
        /// 判断信箱是否已经注册
        /// </summary>
        /// <param name="UserEmail">用户Email</param>
        /// <returns></returns>
        bool IsExist(string UserEmail);
        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="ui">用户对象</param>
        /// <returns>所影响的行数</returns>
        EnumRegister Register(UserInfo ui, UserBasicInfo bi);
        /// <summary>
        /// 注册确认,验证后同时设置最后登录
        /// </summary>
        /// <param name="code"></param>
        /// <param name="userId"></param>
        /// <param name="userName"></param>
        /// <param name="md5Password"></param>
        /// <returns>0成功,-1验证码不正确,-2该用户已通过验证,-3数据修改失败</returns>
        int RegisterConfirm(string code, string email, out int userId, out string userName, out string md5Password);

        /// <summary>
        /// 激活电子邮件
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        int EmailActive(string email, UserInfo ui);

        /// <summary>
        /// 邀请用户注册
        /// </summary>
        /// <param name="ui"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        EnumRegister InviterRegister(UserInfo ui, UserBasicInfo bi, EnumFriendInviteMode mode, string code, out int userId);
        /// <summary>
        /// 退出
        /// </summary>
        /// <param name="Email">用户Email</param>
        /// <returns></returns>
        int Exit(int userID);
        /// <summary>
        /// 修改Email
        /// </summary>
        /// <param name="UserID">用户ID</param>
        /// <param name="Email">新Email</param>
        /// <returns></returns>
        int ChangeEmail(int UserID, string Email);
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="UserID">用户ID</param>
        /// <param name="Password">新Password</param>
        /// <returns></returns>
        int ChangePassword(int UserID, string Password);
        /// <summary>
        /// 修改所在地
        /// </summary>
        /// <param name="UserID">用户ID</param>
        /// <param name="Province">省份</param>
        /// <param name="City">城市</param>
        /// <returns></returns>
        int ChangeAddr(int UserID, int Province, int City);
        /// <summary>
        /// 保存MSN
        /// </summary>
        /// <param name="UserID">用户ID</param>
        /// <param name="MSN">MSN帐号</param>
        /// <returns></returns>
        int ChangeMSN(int UserID, string MSN);
        /// <summary>
        /// 保存GTalk
        /// </summary>
        /// <param name="UserID">用户ID</param>
        /// <param name="MSN">GTalk帐号</param>
        /// <returns></returns>
        int ChangeGTalk(int UserID, string GTalk);
        /// <summary>
        /// 保存Mobile
        /// </summary>
        /// <param name="UserID">用户ID</param>
        /// <param name="MSN">Mobile帐号</param>
        /// <returns></returns>
        int ChangeMobile(int UserID, string Mobile);
        #region 检查登录
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="Email">用户Email</param>
        /// <param name="Password">密码</param>
        /// <returns></returns>
        EnumLoginState Login(string email, string password, out int userId, out string userName, out string portrait,out int loginNum);
        /// <summary>
        /// 检查登录
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        EnumLoginState CheckLogin(int userId, string password, out int loginNum);
        #endregion
        /// <summary>
        /// 获取用户实体类
        /// </summary>
        /// <param name="UserID">用户ID</param>
        /// <returns></returns>
        UserInfo GetUserInfo(int UserID);
        /// <summary>
        /// 获取用户基本信息实体类
        /// </summary>
        /// <param name="UserID">用户ID</param>
        /// <returns></returns>
        UserBasicInfo GetUserBasic(int UserID);
        /// <summary>
        /// 获取隐私及个人动态设置类实例
        /// </summary>
        /// <param name="UserID">用户ID</param>
        /// <returns></returns>
        UserSettingInfo GetUSetInfo(int UserID);

        #region
        //编辑（个人信息）
        //编辑（个人信息）
        /// <summary>
        /// 保存基本信息
        /// </summary>
        /// <param name="ubi">用户基本信息对象</param>
        /// <param name="Province">省份</param>
        /// <param name="City">城市</param>
        /// <returns></returns>
        int SaveBasic(JuSNS.Model.UserBasicInfo ubi, int Province, int City);

        /// <summary>
        /// 保存教育信息
        /// </summary>
        /// <param name="listEdu">教育信息对象数组</param>
        /// <returns></returns>
        int SaveEducation(List<JuSNS.Model.UserEducationInfo> listEdu);
        /// <summary>
        /// 删除学校
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        int DelEducation(int ID);
        /// <summary>
        /// 保存工作信息
        /// </summary>
        /// <param name="listCareer">工作信息对象数组</param>
        /// <returns></returns>
        int SaveCareer(List<JuSNS.Model.UserCareerInfo> listCareer);
        /// <summary>
        /// 删除工作信息
        /// </summary>
        /// <param name="ID">工作信息ID</param>
        /// <returns></returns>
        int DelCareer(int ID);
        #endregion
        #region 取得用户一些相关的信息
        /// <summary>
        /// 取得用户的教育信息
        /// </summary>
        /// <param name="userid">查看者ID</param>
        /// <param name="friendid">被查看者ID</param>
        /// <returns></returns>
        DataTable GetEducation(int userid, int friendid);
        /// <summary>
        /// 取得工作相关的信息
        /// </summary>
        /// <param name="userid">查看者ID</param>
        /// <param name="friendid">被查看者ID</param>
        /// <returns></returns>
        DataTable GetCareer(int userid, int friendid);
        #endregion
        /// <summary>
        /// 取得用户最高教育相关信息
        /// </summary>
        /// <param name="UserID">会员编号</param>
        /// <returns></returns>
        UserEducationInfo LastEducInfo(int UserID);
        /// <summary>
        /// 取得学校信息
        /// </summary>
        /// <param name="SchoolID">学校编号</param>
        /// <returns></returns>
        DictSchoolInfo GetSchoolInfo(int SchoolID);
        /// <summary>
        /// 取得院系信息
        /// </summary>
        /// <param name="AcademyID">院系编号</param>
        /// <returns></returns>
        DictAcademyInfo GetAcademyInfo(int AcademyID);
        /// <summary>
        /// 随机取出某一网络的用户
        /// </summary>
        /// <param name="topNum"></param>
        /// <param name="networkId"></param>
        /// <returns></returns>
        DataTable GetUserByNetwork(int topNum, int networkId, int userId,int f);
        /// <summary>
        /// 取回密码
        /// </summary>
        /// <param name="Email">Email</param>
        /// <returns>0,成功,-2,邮箱无效</returns>
        int Retrieve(string email);
        /// <summary>
        /// 重设密码,并修改登录次数等
        /// </summary>
        /// <param name="newPwd"></param>
        /// <param name="code"></param>
        /// <returns>0成功，-1没有找到相关的申请记录,-2该申请已完成重设而无效,-3邮箱无效</returns>
        int ResetPwd(string newPwd, string code, out int userId, out string userName, out string userPortrait);

        bool getRestPwdRecord(string r, string email);

        /// <summary>
        /// 取得隐私信息
        /// </summary>
        /// <param name="UserID">用户ID信息</param>
        /// <returns></returns>
        PrivacyInfo GetPrivacy(int UserID);
        /// <summary>
        /// 设置隐私信息
        /// </summary>
        /// <param name="UserID">用户ID</param>
        /// <param name="privacyinfo">隐私信息</param>
        /// <returns></returns>
        int SetPrivacy(int UserID, PrivacyInfo privacyinfo);

        /// <summary>
        /// 更新用户
        /// </summary>
        /// <param name="us">实例类</param>
        /// <param name="UserID">会员编号</param>
        /// <returns></returns>
        int UpdateUser(JuSNS.Model.UserInfo us, int UserID);

        int UpdateBer(int UserID, int integral, int inteyb, int Click);

        /// <summary>
        /// 删除会员
        /// </summary>
        /// <param name="UserID"></param>
        /// <returns></returns>
        int DelUser(int UserID, int flag);


        int DelUserAll();

        /// <summary>
        /// 更新会员基本信息
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        int UpdateUserBase(UserBasicInfo info);

        /// <summary>
        /// 修改会员联系信息可见度
        /// </summary>
        /// <param name="ub"></param>
        /// <returns></returns>
        int UpdateUserPrivacy(UserBasicInfo ub);

        /// <summary>
        /// 根据ID读取教育信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        DataTable getCareerByID(int id);

        /// <summary>
        /// 根据ID读取教育信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        DataTable getEducationByID(int id);

        /// <summary>
        /// 锁定、解锁教育信息
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        int LockEducation(int ID, int value);


        /// <summary>
        /// 锁定、解锁、删除地区信息
        /// </summary>
        /// <param name="ID">地区编号</param>
        /// <param name="value"></param>
        /// <param name="flag"></param>
        /// <returns></returns>
        int LockDelArea(int ID, int value, int flag);

        /// <summary>
        /// 添加、修改地区信息
        /// </summary>
        /// <param name="ID">地区编号</param>
        /// <param name="name"></param>
        /// <param name="flag"></param>
        /// <returns></returns>
        int UpdateAddArea(int ID, int ParentID, string name, int flag);

        /// <summary>
        /// 判断地区有几级
        /// </summary>
        /// <param name="ParentID"></param>
        /// <returns></returns>
        int getArea(int ParentID);

        #region 邀请用户注册相关
        /// <summary>
        /// 取得邀请相关信息
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        InviteInfo GetInviteInfo(string code, EnumFriendInviteMode mode, out Dictionary<string, string> friends);
        #endregion

        /// <summary>
        /// 判断用户是否存在
        /// </summary>
        /// <param name="UserId"></param>
        bool CheckUser(int UserId);

        int GetUserCity(int UserID);
        /// <summary>
        /// 取得最大的USerID
        /// </summary>
        /// <returns></returns>
        int GetMaxUserID();

        void GetInvReg(int UserID);

        void updateinte(int UserID, int Point, int Flag, int ifoat, string Content);

        IDataReader GetUserPoint(int UserID);

        DataTable SearchPointHistoryPage(int UserID,string sTime, string eTime, int PageIndex, int PageSize, out int RecordCount, out int PageCount);
        /// <summary>
        /// 取得用户名
        /// </summary>
        /// <param name="userid">用户ID</param>
        /// <returns></returns>
        string GetUserName(int userid);
        /// <summary>
        /// 取得用户性别
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        int GetUserSex(int userid);

        /// <summary>
        /// 取得头像名称
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        string GetUserHeadPic(int userid);

        int DelUserAdv(int UserID, string Type);
        int DelAllAdv(string Type);
        int DelUserCommAdv(int UserID, string Type);
        int InserDefaultFriend(int UserID);
    }
    public sealed partial class DataAccess
    {
        public static IUser CreateUser()
        {
            string className = path + ".User";
            return (IUser)Assembly.Load(path).CreateInstance(className);
        }
    }
}
