protected virtual void UpdateHistoryLink(Int32 userId, String URL) { HistoryLink link = HistoryLink.FetchByUserIDAndURL(userId, URL); if (link != null) { link.ModDate = DateTime.Now; link.Description = this.DefaultTitle; link.Icon = this.DefaultIcon; link.SaveAndCleanUp(); } }
protected virtual void CreateHistoryLink(String URL) { HistoryLink link = HistoryLink.Create(); if (this.Request.Url.ToString().Contains("id") || this.Request.Url.ToString().Contains("search")) { link.Url = URL; link.Description = this.DefaultTitle; link.Icon = this.DefaultIcon; link.UserId = CurrentSession.UserId; link.SaveAndCleanUp(); } }
protected void UpdateUserHistoryLinks() { var link = new HistoryLink(); if (HttpPageHelper.CurrentItem.Name.Length > 20) { link.Text = HttpPageHelper.CurrentItem.Name.Substring(0, 20) + "..."; } else { link.Text = HttpPageHelper.CurrentItem.Name; } link.Title = HttpPageHelper.CurrentItem.Name; link.URL = HttpContext.Current.Request.Url.AbsoluteUri; link.IconPath = ResourceStrings.Icon_HistoryLink; if (SecurityContextManager.Current.CurrentUser.UserPreferences == null) { SecurityContextManager.Current.CurrentUser.UserPreferences = new UserPreferences(); } //Only add the link if it's not already in the collection bool exists = false; foreach (var l in ((List <HistoryLink>)SecurityContextManager.Current.CurrentUser.UserPreferences.HistoryLinks)) { if (l.URL == link.URL) { exists = true; } } if (!exists) { ((List <HistoryLink>)SecurityContextManager.Current.CurrentUser.UserPreferences.HistoryLinks).Add(link); } //if (link.URL != ((List<HistoryLink>)SecurityContextManager.Current.CurrentUser.UserPreferences.HistoryLinks)[((List<HistoryLink>)SecurityContextManager.Current.CurrentUser.UserPreferences.HistoryLinks).Count - 1].URL) //{ // ((List<HistoryLink>)SecurityContextManager.Current.CurrentUser.UserPreferences.HistoryLinks).Add(link); //} //Keeps the history link collection at 10 items. if (SecurityContextManager.Current.CurrentUser.UserPreferences.HistoryLinks.Count > 10) { SecurityContextManager.Current.CurrentUser.UserPreferences.HistoryLinks.RemoveAt(0); } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); String pageURL = this.Request.Url.PathAndQuery.Substring(VirtualPathUtility.ToAbsolute("~").Length).StartsWith("/") ? this.Request.Url.PathAndQuery.Substring(VirtualPathUtility.ToAbsolute("~").Length) : "/" + this.Request.Url.PathAndQuery.Substring(VirtualPathUtility.ToAbsolute("~").Length); if (!HistoryLink.FetchAllByUserId(this.CurrentSession.UserId).OfType <HistoryLink>().Any(Link => Link.Url == pageURL)) { this.CreateHistoryLink(pageURL); } else { this.UpdateHistoryLink(this.CurrentSession.UserId, pageURL); } foreach (QuickAccessLink QuickLink in QuickAccessLink.FetchAllByUserId(this.CurrentSession.UserId).OrderBy(Link => Link.Description)) { this.PopulateQuickLink(QuickLink.Url, QuickLink.Description, QuickLink.Icon, QuickLink.Id); } foreach (HistoryLink UserHistoryLink in HistoryLink.FetchAllByUserId(this.CurrentSession.UserId).OrderByDescending(Link => Link.ModDate)) { this.PopulateHistoryLink(UserHistoryLink.Url, UserHistoryLink.Description, UserHistoryLink.Icon, UserHistoryLink.Id); } }