예제 #1
0
        public static Discuz.Common.Generic.List <OnlineUserInfo> GetOnlineUserCollection(out int totaluser, out int guest, out int user, out int invisibleuser)
        {
            Discuz.Common.Generic.List <OnlineUserInfo> coll = new Discuz.Common.Generic.List <OnlineUserInfo>();
#endif
            //在线注册用户数
            user = 0;
            //在线隐身用户数
            invisibleuser = 0;
            //在线总用户数
            totaluser = 0;
            IDataReader reader = DatabaseProvider.GetInstance().GetOnlineUserList();

            while (reader.Read())
            {
                OnlineUserInfo info = LoadSingleOnlineUser(reader);
                //
                if (info.Userid > 0)
                {
                    user++;
                }
                if (info.Invisible == 1)
                {
                    invisibleuser++;
                }
                totaluser++;
                if (info.Userid > 0 || (info.Userid == -1 && GeneralConfigs.GetConfig().Whosonlinecontract == 0))
                {
                    info.Actionname = UserAction.GetActionDescriptionByID((int)(info.Action));
                    coll.Add(info);
                }
            }
            reader.Close();
            int highestonlineusercount = Utils.StrToInt(Statistics.GetStatisticsRowItem("highestonlineusercount"), 1);

            if (totaluser > highestonlineusercount)
            {
                if (Statistics.UpdateStatistics("highestonlineusercount", totaluser) > 0)
                {
                    Statistics.UpdateStatistics("highestonlineusertime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    Statistics.ReSetStatisticsCache();
                }
            }

            //统计游客
            if (totaluser > user)
            {
                guest = totaluser - user;
            }
            else
            {
                guest = 0;
            }
            //返回当前版块的在线用户集合
            return(coll);
        }
예제 #2
0
 /// <summary>
 /// 返回在线用户列表
 /// </summary>
 public static Discuz.Common.Generic.List <OnlineUserInfo> GetOnlineUserCollection()
 {
     Discuz.Common.Generic.List <OnlineUserInfo> coll = new Discuz.Common.Generic.List <OnlineUserInfo>();
     if (appDBCache)
     {
         coll = IOnlineUserService.GetOnlineUserCollection();
     }
     else
     {
         IDataReader reader = DatabaseProvider.GetInstance().GetOnlineUserList();
         while (reader.Read())
         {
             OnlineUserInfo onlineUserInfo = LoadSingleOnlineUser(reader);
             if (onlineUserInfo.Userid > 0 || (onlineUserInfo.Userid == -1 && GeneralConfigs.GetConfig().Whosonlinecontract == 0))
             {
                 onlineUserInfo.Actionname = UserAction.GetActionDescriptionByID((int)(onlineUserInfo.Action));
                 coll.Add(onlineUserInfo);
             }
         }
         reader.Close();
     }
     //返回当前版块的在线用户表
     return(coll);
 }
예제 #3
0
        protected override void ShowPage()
        {
            pagetitle = "在线列表";
            DataTable allonlineuserlist = OnlineUsers.GetOnlineUserList(onlineusercount, out totalonlineguest, out totalonlineuser, out totalonlineinvisibleuser);;

            onlineusernumber = onlineusercount;

            //获取总页数
            pagecount = onlineusernumber % 16 == 0 ? onlineusernumber / 16 : onlineusernumber / 16 + 1;
            pagecount = pagecount == 0 ? 1 : pagecount;

            //修正请求页数中可能的错误
            if (pageid <= 1)
            {
                pageid   = 1;
                startrow = 0;
                endrow   = 15;
            }
            else
            {
                pageid   = pageid > pagecount ? pagecount : pageid;
                startrow = (pageid - 1) * 16;
                endrow   = pageid * 16;
            }

            if (Discuz.Config.EntLibConfigs.GetConfig() != null && Discuz.Config.EntLibConfigs.GetConfig().Cacheonlineuser.Enable)
            {
                foreach (DataRow dr in allonlineuserlist.Rows)
                {
                    try
                    {
                        DataRow newrow = onlineuserlist.NewRow();
                        newrow["username"]       = dr["username"].ToString();
                        newrow["userid"]         = TypeConverter.ObjectToInt(dr["userid"]);
                        newrow["invisible"]      = TypeConverter.ObjectToInt(dr["invisible"]);
                        newrow["lastupdatetime"] = TypeConverter.ObjectToDateTime(dr["lastupdatetime"]);
                        string actionid = dr["action"].ToString().Trim();
                        if (!Utils.StrIsNullOrEmpty(actionid))
                        {
                            newrow["action"] = UserAction.GetActionDescriptionByID(TypeConverter.StrToInt(actionid));
                        }

                        newrow["forumid"]   = TypeConverter.ObjectToInt(dr["forumid"]);
                        newrow["forumname"] = dr["forumname"].ToString();
                        newrow["topicid"]   = TypeConverter.ObjectToInt(dr["titleid"]);
                        newrow["title"]     = dr["title"].ToString();

                        onlineuserlist.Rows.Add(newrow);
                        onlineuserlist.AcceptChanges();
                    }
                    catch {; }
                }
            }
            else
            {
                startrow = startrow >= onlineusernumber ? onlineusernumber - 1 : startrow;
                endrow   = endrow >= onlineusernumber ? onlineusernumber - 1 : endrow;

                for (; startrow <= endrow; startrow++)
                {
                    try
                    {
                        DataRow newrow = onlineuserlist.NewRow();

                        newrow["username"]       = allonlineuserlist.Rows[startrow]["username"];
                        newrow["userid"]         = TypeConverter.ObjectToInt(allonlineuserlist.Rows[startrow]["userid"]);
                        newrow["invisible"]      = TypeConverter.ObjectToInt(allonlineuserlist.Rows[startrow]["invisible"]);
                        newrow["lastupdatetime"] = Convert.ToDateTime(allonlineuserlist.Rows[startrow]["lastupdatetime"]);
                        string actionid = allonlineuserlist.Rows[startrow]["action"].ToString().Trim();
                        if (!Utils.StrIsNullOrEmpty(actionid))
                        {
                            newrow["action"] = UserAction.GetActionDescriptionByID(TypeConverter.StrToInt(actionid));
                        }

                        newrow["forumid"]   = TypeConverter.ObjectToInt(allonlineuserlist.Rows[startrow]["forumid"]);
                        newrow["forumname"] = allonlineuserlist.Rows[startrow]["forumname"];
                        newrow["topicid"]   = TypeConverter.ObjectToInt(allonlineuserlist.Rows[startrow]["titleid"]);
                        newrow["title"]     = allonlineuserlist.Rows[startrow]["title"];

                        onlineuserlist.Rows.Add(newrow);
                        onlineuserlist.AcceptChanges();
                    }
                    catch {; }
                }
            }

            //得到页码链接
            pagenumbers = DNTRequest.GetString("search") == "" ? Utils.GetPageNumbers(pageid, pagecount, "onlineuser.aspx", 8) :
                          Utils.GetPageNumbers(pageid, pagecount, "onlineuser.aspx", 8);

            totalonline            = onlineusercount;
            highestonlineusercount = Statistics.GetStatisticsRowItem("highestonlineusercount");
            highestonlineusertime  = Statistics.GetStatisticsRowItem("highestonlineusertime");
        }
예제 #4
0
        protected override void ShowPage()
        {
            pagetitle = "在线列表";
            DataTable allonlineuserlist = OnlineUsers.GetOnlineUserList(onlineusercount, out totalonlineguest, out totalonlineuser, out totalonlineinvisibleuser);;

            onlineusernumber = onlineusercount;

            onlineuserlist = CreateUserTable();

            //获取总页数
            pagecount = onlineusernumber % upp == 0 ? onlineusernumber / upp : onlineusernumber / upp + 1;
            if (pagecount == 0)
            {
                pagecount = 1;
            }

            //得到当前用户请求的页数
            pageid = DNTRequest.GetInt("page", 1);
            //修正请求页数中可能的错误
            if (pageid <= 1)
            {
                pageid   = 1;
                startrow = 0;
                endrow   = upp - 1;
            }
            else
            {
                if (pageid > pagecount)
                {
                    pageid = pagecount;
                }

                startrow = (pageid - 1) * upp;
                endrow   = pageid * upp;
            }

            if (startrow >= onlineusernumber)
            {
                startrow = onlineusernumber - 1;
            }
            if (endrow >= onlineusernumber)
            {
                endrow = onlineusernumber - 1;
            }

            for (; startrow <= endrow; startrow++)
            {
                try
                {
                    DataRow newrow = onlineuserlist.NewRow();

                    newrow["username"]       = allonlineuserlist.Rows[startrow]["username"].ToString();
                    newrow["userid"]         = Convert.ToInt32(allonlineuserlist.Rows[startrow]["userid"].ToString());
                    newrow["invisible"]      = Convert.ToInt32(allonlineuserlist.Rows[startrow]["invisible"].ToString());
                    newrow["lastupdatetime"] = Convert.ToDateTime(allonlineuserlist.Rows[startrow]["lastupdatetime"].ToString());
                    string actionid = allonlineuserlist.Rows[startrow]["action"].ToString().Trim();
                    if (actionid != "")
                    {
                        newrow["action"] = UserAction.GetActionDescriptionByID(Convert.ToInt32(actionid));
                    }

                    newrow["forumid"]   = Convert.ToInt32(allonlineuserlist.Rows[startrow]["forumid"].ToString());
                    newrow["forumname"] = allonlineuserlist.Rows[startrow]["forumname"].ToString();
                    newrow["topicid"]   = Convert.ToInt32(allonlineuserlist.Rows[startrow]["titleid"].ToString());
                    newrow["title"]     = allonlineuserlist.Rows[startrow]["title"].ToString();

                    onlineuserlist.Rows.Add(newrow);
                    onlineuserlist.AcceptChanges();
                }
                catch
                {; }
            }

            //得到页码链接
            if (DNTRequest.GetString("search") == "")
            {
                pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "onlineuser.aspx", 8);
            }
            else
            {
                pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "onlineuser.aspx", 8);
            }

            totalonline            = onlineusercount;
            highestonlineusercount = Statistics.GetStatisticsRowItem("highestonlineusercount");
            highestonlineusertime  = Statistics.GetStatisticsRowItem("highestonlineusertime");
        }