/// <summary> /// 获取最近阅读记录 /// </summary> /// <param name="cookieNameList"></param> /// <param name="id"></param> /// <returns></returns> public static NovelRecentReadView First(string[] cookieNameList, int id = 0) { if (!StringHelper.IsNullOrEmpty(cookieNameList)) { NovelRecentReadView model = null, temp = null; foreach (string cookieName in cookieNameList) { if (!string.IsNullOrEmpty(cookieName)) { temp = First(cookieName, id); if (temp != null && temp.Id > 0) { if (model == null || (model != null && model.ReadTime < temp.ReadTime)) { model = temp; } } } } return(model); } return(null); }
/// <summary> /// 保存最近阅读记录 /// </summary> /// <param name="novelInfo"></param> /// <param name="chapterTitle"></param> /// <param name="chapterCode"></param> /// <param name="routeChannelId"></param> /// <param name="id"></param> public static void Save(Novel novelInfo, string chapterTitle, int chapterCode, string routeChannelId = "", int id = 0) { NovelRecentReadView readInfo = new NovelRecentReadView(); readInfo.Id = novelInfo.Id; readInfo.ChapterName = chapterTitle; readInfo.ChapterCode = chapterCode; readInfo.ContentType = novelInfo.ContentType; readInfo.Title = novelInfo.Title; readInfo.ReadTime = DateTime.Now; readInfo.RouteChannelId = routeChannelId; Save(GetCookieName(novelInfo.ContentType), readInfo, 5, id); }
public static void Save(string cookieName, NovelRecentReadView readInfo, int recordCount, int id = 0) { if (readInfo == null || readInfo.Id <= 0) { return; } string host = StringHelper.GetHost(); NovelRecentReadListView readLog = Get(cookieName, Constants.SecurityKey.key, Constants.SecurityKey.IV); //if (readLog == null || string.Compare(readLog.Host, Host, true) != 0 || readLog.Id != id) if (readLog == null || string.Compare(readLog.Host, host, true) != 0) { readLog = new NovelRecentReadListView(); readLog.Id = id; readLog.Host = host; readLog.List = new List <NovelRecentReadView>(); } //if (readLog != null && string.Compare(readLog.Host, Host, true) == 0 && readLog.Id == id) if (readLog != null && string.Compare(readLog.Host, host, true) == 0) { if (readLog.List == null) { readLog.List = new List <NovelRecentReadView>(); } if (readLog.List != null) { if (readLog.List.Count > 0) { IEnumerable <NovelRecentReadView> list = readLog.List.Where <NovelRecentReadView>(t => t.Id != readInfo.Id); if (list != null) { readLog.List = list.Count <NovelRecentReadView>() > 0 ? list.ToList <NovelRecentReadView>() : new List <NovelRecentReadView>(); } } } readLog.List.Add(readInfo); while (readLog.List.Count > recordCount) { readLog.List.RemoveAt(0); } } CookieHelper <NovelRecentReadListView> .Set(readLog, cookieName, Constants.SecurityKey.key, Constants.SecurityKey.IV, DateTime.Now.AddMonths(1)); }
public ActionResult Open(int cType = 0) { string url = "/".GetChannelRouteUrl(RouteChannelId); NovelRecentReadListView readLog = RecentReadContext.Get(RecentReadContext.GetCookieName(cType), _logService, currentUser.UserName, currentUser.UserId); if (!readLog.IsNullOrEmpty <NovelRecentReadListView>() && !readLog.List.IsNullOrEmpty <IList <NovelRecentReadView> >()) { NovelRecentReadView info = readLog.List.Reverse().FirstOrDefault(); if (info != null && info.Id > 0) { string channelId = string.IsNullOrEmpty(info.RouteChannelId) ? RouteChannelId : info.RouteChannelId; url = ChapterContext.GetUrl("/chapter/detail", info.Id, info.ChapterCode, channelId: channelId); } } return(Redirect(url)); }
public ActionResult Open(int cType = 0, int ccid = 0) { Constants.Novel.StatisticType statisticType = Constants.Novel.StatisticType.none; string channelId = _channelCompanyService.GetRecentReadChannelId(ccid, RouteChannelId, out statisticType); if (IsRouteChannel) { string promotionCode = HeaderInfo.PromotionCode; if (statisticType == Constants.Novel.StatisticType.promotion) { PromotionLink promote = _promotionLinkService.Detail("and ChannelCode = @channelId and PromotionCode = @promotionCode", new { channelId, promotionCode }); if (promote != null && promote.Id > 0 && !string.IsNullOrEmpty(promotionCode)) { #region 统计推广码关注人数 if (ccid > 0) { string follow = CookieHelper.Get(string.Concat("tgf_", ccid)); if (string.IsNullOrEmpty(follow)) { _promotionLinkService.Update(" FollowCount = ISNULL(FollowCount, 0) + 1 ", promote.Id); CookieHelper.Set(string.Concat("tgf_", ccid), StringHelper.ToString(DateTime.Now.ToFileTime())); } } #endregion 统计推广码关注人数 } else { } } } string url = "/".GetChannelRouteUrl(channelId); NovelRecentReadListView readLog = RecentReadContext.Get(RecentReadContext.GetCookieName(cType), _logService, currentUser.UserName, currentUser.UserId); if (!readLog.IsNullOrEmpty <NovelRecentReadListView>() && !readLog.List.IsNullOrEmpty <IList <NovelRecentReadView> >()) { NovelRecentReadView info = readLog.List.Reverse().FirstOrDefault(); if (info != null && info.Id > 0) { url = ChapterContext.GetUrl("/chapter/detail", info.Id, info.ChapterCode, channelId: channelId); } } return(Redirect(url)); }
public ActionResult Open(int cType = 0, int?cid = 0) { int channelCompanyId = cid.HasValue ? cid.ToInt() : 0; string channelId = _channelCompanyService.GetRecentReadChannelId(channelCompanyId, RouteChannelId); string url = "/".GetChannelRouteUrl(channelId); NovelRecentReadListView readLog = RecentReadContext.Get(RecentReadContext.GetCookieName(cType), currentUser.UserId); if (!readLog.IsNullOrEmpty <NovelRecentReadListView>() && !readLog.List.IsNullOrEmpty <IList <NovelRecentReadView> >()) { NovelRecentReadView info = readLog.List.Reverse().FirstOrDefault(); if (info != null && info.Id > 0) { url = ChapterContext.GetUrl("/chapter/detail", info.Id, info.ChapterCode, channelId: channelId); } } return(Redirect(url)); }
/// <summary> /// 获取最近阅读记录 /// </summary> /// <param name="cookieName"></param> /// <param name="id"></param> /// <returns></returns> public static NovelRecentReadView First(string cookieName, ILogService logService, string userName, int id = 0) { if (logService != null && !string.IsNullOrEmpty(userName)) { NovelReadRecordInfo recordInfo = GetRecentChapter(cookieName, logService, userName); if (recordInfo != null && recordInfo.Id > 0) { NovelRecentReadView readInfo = new NovelRecentReadView(); readInfo.Id = recordInfo.NovelId; readInfo.ChapterName = recordInfo.ChapterName; readInfo.ChapterCode = recordInfo.ChapterCode; readInfo.ContentType = recordInfo.NovelContentType; readInfo.Title = recordInfo.NovelTitle; readInfo.ReadTime = recordInfo.RecentReadTime; readInfo.RouteChannelId = recordInfo.RouteChannelId; return(readInfo); } } return(First(cookieName, id)); }
public static NovelRecentReadListView Get(string cookieName, ILogService logService, string userName, int id = 0) { if (logService != null && !string.IsNullOrEmpty(userName)) { IEnumerable <NovelReadRecordInfo> recordList = GetRecentChapterList(cookieName, logService, userName); if (!recordList.IsNullOrEmpty <NovelReadRecordInfo>()) { NovelRecentReadListView readList = new NovelRecentReadListView(); readList.Id = id; readList.Host = ""; #region IList <NovelRecentReadView> list = new List <NovelRecentReadView>(); NovelRecentReadView readInfo = null; foreach (NovelReadRecordInfo recordInfo in recordList) { readInfo = new NovelRecentReadView(); readInfo.Id = recordInfo.NovelId; readInfo.ChapterName = recordInfo.ChapterName; readInfo.ChapterCode = recordInfo.ChapterCode; readInfo.ContentType = recordInfo.NovelContentType; readInfo.Title = recordInfo.NovelTitle; readInfo.ReadTime = recordInfo.RecentReadTime; readInfo.RouteChannelId = recordInfo.RouteChannelId; list.Add(readInfo); } readList.List = StringHelper.Reverse <NovelRecentReadView>(list); //readList.List = StringHelper.Reverse<NovelRecentReadView>(recordList.ToList().ToNovelRecentReadViewList()); #endregion 最近阅读记录 return(readList); } } return(Get(cookieName, id)); }