Ejemplo n.º 1
0
        /// <summary>
        /// 获取在线用户列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <returns>数据表</returns>
        public DataTable GetOnLineState(BaseUserInfo userInfo)
        {
            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var userLogOnManager = new BaseUserLogOnManager(dbHelper, userInfo);
                // 设置为在线状态
                userLogOnManager.OnLine(userInfo.Id);
                if (MessageService.LaseOnLineStateCheck == DateTime.MinValue)
                {
                }
                else
                {
                    // 2008.01.23 JiRiGaLa 修正错误
                    TimeSpan timeSpan = DateTime.Now - MessageService.LaseOnLineStateCheck;
                    if ((timeSpan.Minutes * 60 + timeSpan.Seconds) >= BaseSystemInfo.OnLineCheck)
                    {
                    }
                }
                if (OnLineStateDT == null)
                {
                    // 检查用户在线状态(服务器专用)
                    userLogOnManager.CheckOnLine();
                    // 获取在线状态列表
                    OnLineStateDT                       = userLogOnManager.GetOnLineStateDT();
                    OnLineStateDT.TableName             = BaseUserEntity.TableName;
                    MessageService.LaseOnLineStateCheck = DateTime.Now;
                }
            });

            return(InnerOrganizeDT);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 服务器端检查在线状态
        /// </summary>
        /// <param name="taskId">任务标识</param>
        /// <returns>离线人数</returns>
        public int ServerCheckOnLine(string taskId)
        {
            int result = 0;

            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(BaseSystemInfo.UserCenterWriteDbConnection);
                    var userLogOnManager = new BaseUserLogOnManager(dbHelper);
                    result = userLogOnManager.CheckOnLine();
                }
                catch (Exception ex)
                {
                    LogUtil.WriteException(ex);
                    throw;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 检查在线状态
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="onLineState">用户在线状态</param>
        /// <returns>离线人数</returns>
        public int CheckOnLine(BaseUserInfo userInfo, int onLineState)
        {
            int result = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var userLogOnManager = new BaseUserLogOnManager(dbHelper);
                // 设置为在线状态
                userLogOnManager.OnLine(userInfo.Id, onLineState);
                result = userLogOnManager.CheckOnLine();
            });
            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 激活用户
        /// </summary>
        /// <param name="taskId">任务标识</param>
        /// <param name="userInfo">用户</param>
        /// <param name="openId">唯一识别码</param>
        /// <returns>用户实体</returns>
        public BaseUserInfo AccountActivation(string taskId, BaseUserInfo userInfo, string openId)
        {
            BaseUserInfo result = null;

            var parameter = ServiceInfo.Create(taskId, userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var userLogOnManager = new BaseUserLogOnManager(dbHelper, userInfo);
                // 先侦测是否在线
                userLogOnManager.CheckOnLine();
                // 再进行登录
                var userManager = new BaseUserManager(dbHelper, userInfo);
                result          = userManager.AccountActivation(openId);
            });

            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 按唯一识别码登录
        /// </summary>
        /// <param name="taskId">任务标识</param>
        /// <param name="userInfo">用户</param>
        /// <param name="openId">唯一识别码</param>
        /// <returns>用户实体</returns>
        public UserLogOnResult LogOnByOpenId(string taskId, BaseUserInfo userInfo, string openId)
        {
            UserLogOnResult result = new UserLogOnResult();

            var parameter = ServiceInfo.Create(taskId, userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                // 先侦测是否在线
                BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager();
                userLogOnManager.CheckOnLine();
                // 若是单点登录,那就不能判断ip地址,因为不是直接登录,是间接登录
                var userManager = new BaseUserManager(userInfo);
                result          = userManager.LogOnByOpenId(openId, string.Empty, string.Empty);
            });

            return(result);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获得用户列表
        /// </summary>
        /// <param name="taskId">任务标识</param>
        /// <param name="userInfo">用户</param>
        /// <returns>数据表</returns>
        public DataTable GetUserDT(string taskId, BaseUserInfo userInfo)
        {
            var result = new DataTable(BaseUserEntity.TableName);

            var parameter = ServiceInfo.Create(taskId, userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                // 检查用户在线状态(服务器专用)
                BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager();
                userLogOnManager.CheckOnLine();
                var userManager = new BaseUserManager(dbHelper, userInfo);
                // 获取允许登录列表
                List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();
                parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldEnabled, 1));
                parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldDeletionStateCode, 0));
                result           = userManager.GetDataTable(parameters, BaseUserEntity.FieldSortCode);
                result.TableName = BaseUserEntity.TableName;
            });

            return(result);
        }