public static Online CreateUser(int uid) { var Request = HttpContext.Current.Request; if (uid <= 0) { return(CreateGuestUser()); } var user = User.FindByID(uid); if (user == null) { return(CreateGuestUser()); } var online = new Online(); online.SetUser(user); online.SessionID = HttpContext.Current.Session.SessionID; online.IP = WebHelper.UserHost; online.UserAgent = HttpContext.Current.Request.UserAgent; //在页面上貌似没看到有显示这些时间的地方,因为要多查询几张表来查询时间,暂时先不做处理 //online.Lastpostpmtime = "1900-1-1 00:00:00"; //online.Lastsearchtime = "1900-1-1 00:00:00"; //online.LastUpdateTime = DateTime.Now; //online.Action = 0; //online.Lastactivity = 0; online.VerifyCode = CreateAuthStr(5, false); //int privateMessageCount = PrivateMessages.GetPrivateMessageCount(uid, 0, 1); var privateMessageCount = ShortMessage.GetPrivateMessageCount(uid, 0, 1); //int newNoticeCountByUid = Notices.GetNewNoticeCountByUid(uid); int newNoticeCountByUid = Notice.FindCountByUidAndNew(uid, 1); online.Newpms = (Int16)(privateMessageCount > 1000 ? 1000 : privateMessageCount); online.Newnotices = (Int16)(newNoticeCountByUid > 1000 ? 1000 : newNoticeCountByUid); //online.Olid = BBX.Data.OnlineUsers.CreateOnlineUserInfo(online, timeout); online.AddOnlineUser(); if (user.AdminID > 0 && user.AdminID < 4 && Notice.ReNewNotice(NoticeType.AttentionNotice, user.ID) == 0) { Notice.Create(user.ID, NoticeType.AttentionNotice, "请及时查看<a href=\"modcp.aspx?operation=attention&forumid=0\">需要关注的主题</a>"); } User.SetUserOnlineState(uid, true); var cookie = HttpContext.Current.Request.Cookies["bbx"]; if (cookie != null) { cookie["tpp"] = user.Tpp.ToString(); cookie["ppp"] = user.Ppp.ToString(); int num = cookie["expires"].ToInt(0); if (num > 0) { cookie.Expires = DateTime.Now.AddMinutes(num); } } var domain = GeneralConfigInfo.Current.CookieDomain; if (!domain.IsNullOrEmpty() && Request.Url.Host.IndexOf(domain) > -1 && IsValidDomain(Request.Url.Host)) { cookie.Domain = domain; } HttpContext.Current.Response.AppendCookie(cookie); return(online); }