public int CompareTo(Object obj) { OnlineUser target = obj as OnlineUser; if (target.LastActive > this.LastActive) { return(1); } return(-1); }
private static void addNewVisitor( MvcContext ctx, String sid ) { OnlineUser visitor = new OnlineUser(); visitor.Name = sid; visitor.StartTime = DateTime.Now; populateOnline( visitor, ctx ); Dictionary<String, Object> dic = getIndexMap( visitor ); visitor.insertByIndex( dic ); if (ctx.viewer != null && ctx.viewer.Id > 0) OnlineStats.Instance.AddMemberCount(); }
private static void addNewVisitor(MvcContext ctx, String sid) { OnlineUser visitor = new OnlineUser(); visitor.Name = sid; visitor.StartTime = DateTime.Now; populateOnline(visitor, ctx); Dictionary <String, Object> dic = getIndexMap(visitor); visitor.insertByIndex(dic); if (ctx.viewer != null && ctx.viewer.Id > 0) { OnlineStats.Instance.AddMemberCount(); } }
private static void UpdateOnline(MvcContext ctx) { String sid = getSessionId(ctx); List <OnlineUser> result = cdb.findByName <OnlineUser>(sid); Boolean isNew = (result.Count == 0 ? true : false); if (isNew) { OnlineUser myOnline = new OnlineUser(); myOnline.Name = sid; myOnline.StartTime = DateTime.Now; populateOnline(myOnline, ctx); Dictionary <String, Object> dic = getIndexMap(myOnline); myOnline.insertByIndex(dic); } else { OnlineUser myOnline = result[0]; populateOnline(myOnline, ctx); Dictionary <String, Object> dic = getIndexMap(myOnline); myOnline.updateByIndex(dic); } // 检查是否有同名的登录用户 if (ctx.viewer != null && ctx.viewer.IsLogin) { List <OnlineUser> sameUsers = cdb.findBy <OnlineUser>("UserName", ctx.viewer.obj.Name); if (sameUsers.Count > 1) { foreach (OnlineUser u in sameUsers) { if (u.Name == sid) { continue; } cdb.delete(u); } } } }
private static void populateOnline(OnlineUser visitor, MvcContext ctx) { visitor.Role = ""; visitor.Ip = ctx.Ip; visitor.TrueIp = ctx.Ip; visitor.Agent = strUtil.CutString(ctx.web.ClientAgent, 240); if (ctx.viewer != null && ctx.viewer.obj != null) { visitor.UserName = ctx.viewer.obj.Name; visitor.UserId = ctx.viewer.Id; visitor.UserUrl = Link.ToMember(ctx.viewer.obj); visitor.UserPicUrl = ctx.viewer.obj.PicSmall; } else // 游客 { visitor.UserName = "******"; visitor.UserId = 0; visitor.UserUrl = ""; visitor.UserPicUrl = ""; } if (ctx.owner != null && ctx.owner.obj != null) { visitor.Target = ctx.owner.obj.Name; } visitor.IsHidden = 0; String referrer = ""; if (ctx.web.PathReferrer != null) { referrer = ctx.web.PathReferrer; } visitor.Referrer = referrer; visitor.LastActive = DateTime.Now; visitor.Location = getLocation(ctx); }
private static void CountOnlineData(MvcContext ctx) { List <OnlineUser> allVisitors = cdb.findAll <OnlineUser>(); OnlineStats.Instance.Count = allVisitors.Count; int memberCount = 0; for (int i = 0; i < allVisitors.Count; i++) { OnlineUser online = allVisitors[i] as OnlineUser; if (online == null) { continue; } if (online.UserId > 0) { memberCount++; } } OnlineStats.Instance.MemberCount = memberCount; OnlineStats.Instance.GuestCount = OnlineStats.Instance.Count - OnlineStats.Instance.MemberCount; }
private static void DeleteTimeoutVisitor(MvcContext ctx) { List <OnlineUser> allVisitors = cdb.findAll <OnlineUser>(); for (int i = 0; i < allVisitors.Count; i++) { OnlineUser online = allVisitors[i] as OnlineUser; if (online == null) { continue; } TimeSpan span = DateTime.Now.Subtract(online.LastActive); try { if (span.TotalMinutes > 20) { online.delete(); } } catch (Exception ex) { logger.Error("DeleteTimeoutVisitor:" + ex); } } }
private static void deleteTimeoutVisitor() { logger.Info( "---------------deleteTimeoutVisitor---------------" ); List<OnlineUser> allVisitors = cdb.findAll<OnlineUser>(); for (int i = 0; i < allVisitors.Count; i++) { OnlineUser online = allVisitors[i] as OnlineUser; if (online == null) continue; TimeSpan span = DateTime.Now.Subtract( online.LastActive ); try { if (span.TotalMinutes > 20) { online.delete(); } } catch (Exception ex) { logger.Error( "DeleteTimeoutVisitor:" + ex ); } } OnlineStats.Instance.ReCount(); }
private void bindUserSingle( IBlock block, OnlineUser user ) { String ip = ctx.viewer.IsAdministrator() ? user.Ip : user.GetIp( 1 ); String lblValue = "【" + lang( "ipAddress" ) + "】" + ip + "\n【" + lang( "osInfo" ) + "】" + user.Agent + "\n【" + lang( "startTime" ) + "】" + user.StartTime.ToString() + "\n【" + lang( "lastActive" ) + "】" + user.LastActive.ToString() + "\n【" + lang( "clocation" ) + "】" + user.Location; if (user.UserId > 0) { block.Set( "u.Name", user.UserName ); block.Set( "u.Face", user.UserPicUrl ); block.Set( "u.Link", user.UserUrl ); } else { block.Set( "u.Name", UserFactory.Guest.Name ); block.Set( "u.Face", UserFactory.Guest.PicSmall ); block.Set( "u.Link", "javascript:;" ); } block.Set( "u.Info", lblValue ); }
private static Dictionary<String, Object> getIndexMap( OnlineUser visitor ) { Dictionary<String, Object> dic = new Dictionary<String, Object>(); dic.Add( "Name", visitor.Name ); dic.Add( "UserName", visitor.UserName ); return dic; }
private static void updateVisitor( MvcContext ctx, OnlineUser myOnline ) { populateOnline( myOnline, ctx ); Dictionary<String, Object> dic = getIndexMap( myOnline ); myOnline.updateByIndex( dic ); }
private static void populateOnline( OnlineUser visitor, MvcContext ctx ) { visitor.Role = ""; visitor.Ip = ctx.Ip; visitor.TrueIp = ctx.Ip; visitor.Agent = strUtil.CutString( ctx.web.ClientAgent, 240 ); if (ctx.viewer != null && ctx.viewer.obj != null) { visitor.UserName = ctx.viewer.obj.Name; visitor.UserId = ctx.viewer.Id; visitor.UserUrl = Link.ToMember( ctx.viewer.obj ); visitor.UserPicUrl = ctx.viewer.obj.PicSmall; } else { // 游客 visitor.UserName = "******"; visitor.UserId = 0; visitor.UserUrl = ""; visitor.UserPicUrl = ""; } if (ctx.owner != null && ctx.owner.obj != null) visitor.Target = ctx.owner.obj.Name; visitor.IsHidden = 0; String referrer = ""; if (ctx.web.PathReferrer != null) referrer = ctx.web.PathReferrer; visitor.Referrer = referrer; visitor.LastActive = DateTime.Now; visitor.Location = getLocation( ctx ); }
private static void UpdateOnline( MvcContext ctx ) { String sid = getSessionId( ctx ); List<OnlineUser> result = cdb.findByName<OnlineUser>( sid ); Boolean isNew = (result.Count == 0 ? true : false); if (isNew) { OnlineUser myOnline = new OnlineUser(); myOnline.Name = sid; myOnline.StartTime = DateTime.Now; populateOnline( myOnline, ctx ); Dictionary<String, Object> dic = getIndexMap( myOnline ); myOnline.insertByIndex( dic ); } else { OnlineUser myOnline = result[0]; populateOnline( myOnline, ctx ); Dictionary<String, Object> dic = getIndexMap( myOnline ); myOnline.updateByIndex( dic ); } // 检查是否有同名的登录用户 if ( ctx.viewer != null && ctx.viewer.IsLogin) { List<OnlineUser> sameUsers = cdb.findBy<OnlineUser>( "UserName", ctx.viewer.obj.Name ); if (sameUsers.Count > 1) { foreach (OnlineUser u in sameUsers) { if (u.Name == sid) continue; cdb.delete( u ); } } } }
private static void populateOnline( OnlineUser myOnline, MvcContext ctx ) { myOnline.Role = String.Empty; myOnline.Ip = ctx.Ip; myOnline.TrueIp = ctx.Ip; myOnline.Agent = strUtil.CutString( ctx.web.ClientAgent, 240 ); if (ctx.viewer != null && ctx.viewer.obj != null) { myOnline.UserName = ctx.viewer.obj.Name; myOnline.UserId = ctx.viewer.Id; myOnline.UserUrl = Link.ToMember( ctx.viewer.obj ); myOnline.UserPicUrl = ctx.viewer.obj.PicSmall; } else myOnline.UserName = "******"; if (ctx.owner != null && ctx.owner.obj != null) myOnline.Target = ctx.owner.obj.Name; myOnline.IsHidden = 0; String referrer = ""; if (ctx.web.PathReferrer != null) referrer = ctx.web.PathReferrer; myOnline.Referrer = referrer; myOnline.LastActive = DateTime.Now; myOnline.Location = getLocation( ctx ); }
// TODO 判断是否在当前论坛 private Boolean isInCurrentForum( OnlineUser user, ForumApp forum ) { return true; }