protected RoleInOnline GetData(Guid roleId)
        {
            RoleInOnline temp = new RoleInOnline();

            temp.SortOrder  = _Request.Get <int>("sortorder." + roleId, Method.Post, 0);
            temp.RoleID     = roleId;
            temp.RoleName   = _Request.Get("rolename." + roleId, Method.Post);
            temp.LogoUrlSrc = _Request.Get("logourl." + roleId, Method.Post);
            return(temp);
        }
Exemple #2
0
        /// <summary>
        /// 当更新在线角色图标设置时 要调用此方法
        /// </summary>
        public void UpdateUsersOnlineRole()
        {
            OnlineMemberCollection members = GetAllOnlineMembers();

            UserCollection users = UserBO.Instance.GetUsers(members.GetKeys());

            foreach (User user in users)
            {
                RoleInOnline roleInOnline = GetUserRoleInOnline(user.UserID);
                OnlineMember member       = GetOnlineMember(user.UserID);
                member.RoleSortOrder = roleInOnline.SortOrder;
            }
        }
Exemple #3
0
 protected string GetEveryoneIcon(string imgStyle)
 {
     if (everyoneIcon == null)
     {
         RoleInOnline roleInOnline = OnlineUserPool.Instance.GetEveryoneRole();
         if (roleInOnline != null)
         {
             everyoneIcon = string.Format(imgStyle, roleInOnline.LogoUrl, roleInOnline.RoleName);
         }
         else
         {
             everyoneIcon = "";
         }
     }
     return(everyoneIcon);
 }
Exemple #4
0
        protected string GetRoleLogoUrl(OnlineMember member)
        {
            if (DisplayUserInfo(member) == false)
            {
                return(EveryoneRoleLogoUrl);
            }

            RoleInOnline role = GetRoleInOnline(member.RoleSortOrder);

            if (role == null)
            {
                return(string.Empty);
            }
            else
            {
                return(role.LogoUrl);
            }
        }
 protected RoleInOnline GetData(Guid roleId)
 {
     RoleInOnline temp = new RoleInOnline();
     temp.SortOrder = _Request.Get<int>("sortorder." + roleId, Method.Post, 0);
     temp.RoleID = roleId;
     temp.RoleName = _Request.Get("rolename." + roleId, Method.Post);
     temp.LogoUrlSrc = _Request.Get("logourl." + roleId, Method.Post);
     return temp;
 }
Exemple #6
0
        public void Update(AuthUser my, RequestVariable request, OnlineAction action, int forumID, int threadID, string subject)
        {
            subject = StringUtil.CutString(subject, 20);



            int    userID = my.UserID;
            string ip     = request.IpAddress;

            bool addnew = false;

            //已经登录的用户
            if (userID > 0)
            {
                #region 已经登录的用户的处理

                OnlineMember onlineMember;
                if (m_OnlineMemberTable.TryGetValue(userID, out onlineMember) == false)
                {
                    string       location = IPUtil.GetIpArea(ip);
                    RoleInOnline role     = GetUserRoleInOnline(userID);
                    lock (m_OnlineMembers_Locker)
                    {
                        if (m_OnlineMemberTable.TryGetValue(userID, out onlineMember) == false)
                        {
                            #region 增加一个OnlineMember

                            DateTime now = DateTimeUtil.Now;

                            onlineMember        = new OnlineMember();
                            onlineMember.UserID = userID;

                            onlineMember.Action = action;

                            onlineMember.Username    = my.Username;
                            onlineMember.IsInvisible = my.IsInvisible;

                            onlineMember.IP       = ip;
                            onlineMember.Location = location;

                            onlineMember.ForumID       = forumID;
                            onlineMember.ThreadID      = threadID;
                            onlineMember.ThreadSubject = subject;


                            onlineMember.Platform             = request.Platform;
                            onlineMember.Browser              = request.Browser;
                            onlineMember.CreateDate           = now;
                            onlineMember.UpdateDate           = now;
                            onlineMember.RoleSortOrder        = role.SortOrder;
                            onlineMember.RoleIdentityIDString = my.RoleIdentityIDString;

                            m_OnlineMemberTable.Add(userID, onlineMember);
                            OnlineMemberCollection newOnlineMembers = new OnlineMemberCollection(m_OnlineMembers);
                            newOnlineMembers.Add(onlineMember);
                            m_OnlineMembers = newOnlineMembers;

                            if (forumID != 0)
                            {
                                lock (GetForumOnlineMemberLocker(forumID))
                                {
                                    //加入新的版块
                                    AddForumOnlineMember(forumID, onlineMember);
                                }
                            }

                            #endregion

                            addnew = true;
                        }
                    }
                }

                if (addnew == false)
                {
                    lock (onlineMember)
                    {
                        //ForumID为-1意味着其实已经删除,无需再更新
                        if (onlineMember.ForumID != -1)
                        {
                            #region 更新原来OnlineMember的值

                            onlineMember.Action = action;

                            onlineMember.Username    = my.Username;
                            onlineMember.IsInvisible = my.IsInvisible;

                            if (my.RoleIdentityIDString != onlineMember.RoleIdentityIDString)
                            {
                                RoleInOnline role = GetUserRoleInOnline(userID);
                                onlineMember.RoleSortOrder        = role.SortOrder;
                                onlineMember.RoleIdentityIDString = my.RoleIdentityIDString;
                            }

                            if (onlineMember.IP != ip)
                            {
                                onlineMember.IP       = ip;
                                onlineMember.Location = IPUtil.GetIpArea(ip);
                            }

                            //-----------------

                            int oldForumID = onlineMember.ForumID;
                            onlineMember.ThreadID      = threadID;
                            onlineMember.ThreadSubject = subject;

                            if (oldForumID != forumID)
                            {
                                if (oldForumID != 0 && forumID != 0)
                                {
                                    lock (GetForumOnlineMemberLocker(oldForumID))
                                    {
                                        lock (GetForumOnlineMemberLocker(forumID))
                                        {
                                            //从原来的版块移除
                                            RemoveForumOnlineMember(oldForumID, onlineMember);
                                            //加入新的版块
                                            AddForumOnlineMember(forumID, onlineMember);
                                        }
                                    }
                                }
                                else if (oldForumID != 0)
                                {
                                    lock (GetForumOnlineMemberLocker(oldForumID))
                                    {
                                        //从原来的版块移除
                                        RemoveForumOnlineMember(oldForumID, onlineMember);
                                    }
                                }
                                else if (forumID != 0)
                                {
                                    lock (GetForumOnlineMemberLocker(forumID))
                                    {
                                        //加入新的版块
                                        AddForumOnlineMember(forumID, onlineMember);
                                    }
                                }
                                onlineMember.ForumID = forumID;
                            }


                            onlineMember.Platform   = request.Platform;
                            onlineMember.Browser    = request.Browser;
                            onlineMember.UpdateDate = DateTimeUtil.Now;

                            #endregion
                        }
                        else
                        {
                            LogHelper.CreateDebugLog("OnlineMember线程同步监视1");
                        }
                    }
                }

                #endregion

                //如果是已登陆状态,但客户端仍然提交了GuestID,则把这个GuestID移除
                //if (my.MachineIDIsNew == false)

                string guestID = my.GuestID;

                if (guestID != null)
                {
                    RemoveOnlineGuest(guestID);
                }
            }
            else
            //尚未登录的用户
            {
                //TODO : 暂不统计游客在线情况,因为可能存在溢出,下个版本改进



                #region 尚未登录的用户的处理


                bool   isSpider = request.IsSpider;
                string guestID  = my.BuildGuestID();

                OnlineGuest onlineGuest;
                if (m_OnlineGuestTable.TryGetValue(guestID, out onlineGuest) == false)
                {
                    string location = IPUtil.GetIpArea(ip);

                    lock (m_OnlineGuests_Locker)
                    {
                        //假如游客列表中还没有这个游客
                        if (m_OnlineGuestTable.TryGetValue(guestID, out onlineGuest) == false)
                        {
                            bool success = UpdateOnlineGuestIP(guestID, null, ip, isSpider);// AddGuestToIP(guestID, ip, request.IsSpider);
                            //bool success = true;

                            if (success)
                            {
                                #region 增加一个OnlineGuest

                                DateTime now = DateTimeUtil.Now;

                                onlineGuest          = new OnlineGuest();
                                onlineGuest.GuestID  = my.GuestID;
                                onlineGuest.IsSpider = isSpider;

                                onlineGuest.Action = action;

                                onlineGuest.IP       = ip;
                                onlineGuest.Location = location;


                                onlineGuest.Platform   = request.Platform;
                                onlineGuest.Browser    = request.Browser;
                                onlineGuest.CreateDate = now;
                                onlineGuest.UpdateDate = now;

                                onlineGuest.ForumID       = forumID;
                                onlineGuest.ThreadID      = threadID;
                                onlineGuest.ThreadSubject = subject;

                                m_OnlineGuestTable.Add(guestID, onlineGuest);
                                OnlineGuestCollection newOnlineGuests = new OnlineGuestCollection(m_OnlineGuests);
                                newOnlineGuests.Add(onlineGuest);
                                m_OnlineGuests = newOnlineGuests;

                                if (forumID != 0)
                                {
                                    lock (GetForumOnlineGuestLocker(forumID))
                                    {
                                        //加入新的版块
                                        AddForumOnlineGuest(forumID, onlineGuest);
                                    }
                                }

                                #endregion

                                addnew = true;
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                }

                //如果只是更新原来的值,那么开始更新
                if (addnew == false)
                {
                    lock (onlineGuest)
                    {
                        //ForumID为-1表示其实这个对象已经从在线列表中移除了
                        if (onlineGuest.ForumID != -1)
                        {
                            #region 更新原来OnlineGuest的值

                            onlineGuest.Action = action;

                            //如果这个游客仅仅发生了IP变化,那么要更新IP表
                            if (onlineGuest.IP != ip)
                            {
                                UpdateOnlineGuestIP(guestID, onlineGuest.IP, ip, isSpider);

                                //RemoveGuestFromIP(guestID, onlineGuest.IP);
                                onlineGuest.IsSpider = isSpider;
                                onlineGuest.IP       = ip;
                                onlineGuest.Location = IPUtil.GetIpArea(ip);
                                //AddGuestToIP(guestID, onlineGuest.IP, request.IsSpider);
                            }

                            //----------------------

                            int oldForumID = onlineGuest.ForumID;

                            if (oldForumID != forumID)
                            {
                                if (oldForumID != 0 && forumID != 0)
                                {
                                    lock (GetForumOnlineGuestLocker(oldForumID))
                                    {
                                        lock (GetForumOnlineGuestLocker(forumID))
                                        {
                                            //从原来的版块移除
                                            RemoveForumOnlineGuest(oldForumID, onlineGuest);
                                            //加入新的版块
                                            AddForumOnlineGuest(forumID, onlineGuest);
                                        }
                                    }
                                }
                                else if (oldForumID != 0)
                                {
                                    lock (GetForumOnlineMemberLocker(oldForumID))
                                    {
                                        //从原来的版块移除
                                        RemoveForumOnlineGuest(oldForumID, onlineGuest);
                                    }
                                }
                                else if (forumID != 0)
                                {
                                    lock (GetForumOnlineMemberLocker(forumID))
                                    {
                                        //加入新的版块
                                        AddForumOnlineGuest(forumID, onlineGuest);
                                    }
                                }

                                onlineGuest.ForumID = forumID;
                            }


                            onlineGuest.Platform   = request.Platform;
                            onlineGuest.Browser    = request.Browser;
                            onlineGuest.UpdateDate = DateTimeUtil.Now;

                            onlineGuest.ThreadID      = threadID;
                            onlineGuest.ThreadSubject = subject;
                            #endregion
                        }
                        else
                        {
                            LogHelper.CreateDebugLog("OnlineGuest线程同步监视1");
                        }
                    }
                }

                #endregion
            }
        }
Exemple #7
0
 public void AddRoleInOnline(RoleInOnline r)
 {
     this.RolesInOnline.Add(r);
 }