Beispiel #1
0
        /// <summary>
        /// 删除在线用户信息
        /// </summary>
        /// <param name="onlineUser"></param>
        public void Delete(OnlineUser onlineUser)
        {
            // 创建删除命令
            OnlineUserDeleteCmd delCmd = new OnlineUserDeleteCmd(this.m_db, onlineUser);

            // 将命令添加到队列
            this.m_cmdQueueA.Enqueue(delCmd);

            // 处理命令队列
            this.BeginProcessCmdQueue();
        }
Beispiel #2
0
        /// <summary>
        /// 保存在线用户信息
        /// </summary>
        /// <param name="onlineUser"></param>
        public void Persist(OnlineUser onlineUser)
        {
            // 创建删除命令
            OnlineUserDeleteCmd delCmd = new OnlineUserDeleteCmd(this.m_db, onlineUser);
            // 创建插入命令
            OnlineUserInsertCmd insCmd = new OnlineUserInsertCmd(this.m_db, onlineUser);

            // 将命令添加到队列
            this.m_cmdQueueA.Enqueue(delCmd);
            this.m_cmdQueueA.Enqueue(insCmd);

            // 处理命令队列
            this.BeginProcessCmdQueue();
        }
Beispiel #3
0
            /// <summary>
            /// 类参数构造器
            /// </summary>
            /// <param name="delUser"></param>
            public PredicateDelete(OnlineUser delUser)
            {
                this.m_delUser = delUser;

                if (this.m_delUser == null)
                {
                    return;
                }

                // 用户 ID
                this.m_isNullCondation &= this.m_delUser.UniqueID <= 0;
                // 名称
                this.m_isNullCondation &= String.IsNullOrEmpty(this.m_delUser.UserName);
                // SessionID
                this.m_isNullCondation &= String.IsNullOrEmpty(this.m_delUser.SessionID);
            }
Beispiel #4
0
        public OnlineUser GetUserByAuthenticationId(string authenticationId)
        {
            //return m_db.GetOnlineUsers().Where(u => u.AuthenticationId == authenticationId).FirstOrDefault();

            OnlineUser user = null;

            var users = m_db.GetOnlineUsers();

            for (var i = users.Count - 1; i >= 0; i--)
            {
                if (users[i].AuthenticationId == authenticationId)
                {
                    user = users[i];
                    break;
                }
            }

            return(user);
        }
Beispiel #5
0
        public OnlineUser GetUser(string userName)
        {
            //return m_db.GetOnlineUsers().Where(u => u.UserName.ToLower() == userName.ToLower()).FirstOrDefault();

            OnlineUser user = null;

            var users = m_db.GetOnlineUsers();

            for (var i = users.Count - 1; i >= 0; i--)
            {
                if (users[i].UserName.ToLower() == userName.ToLower())
                {
                    user = users[i];
                    break;
                }
            }

            return(user);
        }
Beispiel #6
0
        /// <summary>
        /// 比较两个用户的活动时间
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        private static int CompareByActiveTime(OnlineUser x, OnlineUser y)
        {
            if (x == null)
            {
                throw new NullReferenceException("X 值为空 ( X Is Null )");
            }

            if (y == null)
            {
                throw new NullReferenceException("Y 值为空 ( Y Is Null )");
            }

            if (x.ActiveTime > y.ActiveTime)
            {
                return(-1);
            }

            if (x.ActiveTime < y.ActiveTime)
            {
                return(+1);
            }

            return(0);
        }
 /// <summary>
 /// 类参数构造器
 /// </summary>
 /// <param name="db">在线用户数据库</param>
 /// <param name="currUser">当前被删除的用户</param>
 public OnlineUserDeleteCmd(OnlineUserDB db, OnlineUser currUser)
     : base(db, currUser)
 {
 }
Beispiel #8
0
 /// <summary>
 /// 新增用户
 /// </summary>
 /// <param name="user"></param>
 public void AddUser(OnlineUser user)
 {
     this.m_db.Insert(user);
 }
Beispiel #9
0
 /// <summary>
 /// 类参数构造器
 /// </summary>
 /// <param name="db">在线用户数据库</param>
 /// <param name="currUser">当前用户</param>
 public OnlineUserCmdBase(OnlineUserDB db, OnlineUser currUser)
 {
     this.OnlineUserDB = db;
     this.CurrentUser  = currUser;
 }
 /// <summary>
 /// 类参数构造器
 /// </summary>
 /// <param name="db">在线用户数据库</param>
 /// <param name="currUser">当前插入的新用户</param>
 public OnlineUserInsertCmd(OnlineUserDB db, OnlineUser currUser)
     : base(db, currUser)
 {
 }