public static ThreadVisitInfo GetThreadVisitInfo(int threadID) { if (HttpContext.Current != null) { var key = UserKeys.StringSessionKey + SecurityContext.CurrentAccount.ID.ToString(); var hash = HttpContext.Current.Session[key] as Hashtable; if (hash == null) { hash = Hashtable.Synchronized(new Hashtable()); HttpContext.Current.Session.Add(key, hash); foreach (var f in ForumDataProvider.InitFirstVisit()) { hash[UserKeys.StringThreadKey + f.ThreadID.ToString(CultureInfo.InvariantCulture)] = f; } } var threadKey = UserKeys.StringThreadKey + threadID.ToString(CultureInfo.InvariantCulture); var tvi = new ThreadVisitInfo { ThreadID = threadID }; if (hash.Contains(threadKey)) { tvi = (ThreadVisitInfo)hash[threadKey]; } else { hash[threadKey] = tvi; } return tvi; } return null; }
public static ThreadVisitInfo GetThreadVisitInfo(int threadID) { HttpContext context = HttpContext.Current; if (context != null) { Guid userID = SecurityContext.CurrentAccount.ID; Hashtable hash = null; if (context.Session[UserKeys.StringSessionKey + userID.ToString()] == null) { hash = Hashtable.Synchronized(new Hashtable()); context.Session.Add(UserKeys.StringSessionKey + userID.ToString(), hash); } else hash = (Hashtable)context.Session[UserKeys.StringSessionKey + userID.ToString()]; var threadKey = UserKeys.StringThreadKey + threadID.ToString(); var tvi = new ThreadVisitInfo() { ThreadID = threadID }; if (hash.Contains(threadKey)) tvi = (ThreadVisitInfo)hash[threadKey]; else hash[threadKey] = tvi; return tvi; } return null; }