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

namespace JuSNS.Factory
{
    public interface IOnlineUser
    {
        /// <summary>
        /// 是否在线
        /// </summary>
        /// <param name="userid">用户ID</param>
        /// <returns></returns>
        bool IsOnline(int userid);
        /// <summary>
        /// 取得登陆信息
        /// </summary>
        /// <returns></returns>
        OnlineUserInfo getInfo(int ID);
        /// <summary>
        /// 取得登陆信息
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="isuserid"></param>
        /// <returns></returns>
        OnlineUserInfo getInfo(int UserID,bool isuserid);
        /// <summary>
        /// 添加在线用户
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        int Add(OnlineUserInfo info);
        /// <summary>
        /// 更新在线用户
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        int Update(OnlineUserInfo info);
        /// <summary>
        /// 删除在线用户
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        int Delete(int id);        
        /// <summary>
        /// 删除在线用户
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="isuserid"></param>
        /// <returns></returns>
        int Delete(int userid,bool isuserid);
        /// <summary>
        /// 取得在线人数
        /// </summary>
        /// <returns></returns>
        int Count();
        /// <summary>
        /// 检查在线
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="lastip"></param>
        /// <returns></returns>
        bool CheckOnline(int userid, string lastip);
        /// <summary>
        /// 删除过期用户
        /// </summary>
        void DeleteExpires();
        /// <summary>
        /// 在线列表
        /// </summary>
        /// <returns></returns>
        List<OnlineUserInfo> OnlineList();
    }
    public sealed partial class DataAccess
    {
        public static IOnlineUser CreateOnlineUser()
        {
            string className = path + ".OnlineUser";
            return (IOnlineUser)Assembly.Load(path).CreateInstance(className);
        }
    }
}
