public ActionResult Index(int cType = 0) { ViewBag.ContentType = cType; NovelRecentReadListView readLog = RecentReadContext.Get(RecentReadContext.GetCookieName(cType), _logService, currentUser.UserName, currentUser.UserId); return(View(new SimpleResponse <NovelRecentReadListView>((!readLog.IsNullOrEmpty <NovelRecentReadListView>() && !readLog.List.IsNullOrEmpty <IList <NovelRecentReadView> >()), readLog))); }
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 static NovelRecentReadListView Get(string cookieName, int id = 0) { string host = StringHelper.GetHost(); NovelRecentReadListView readLog = Get(cookieName, Constants.SecurityKey.key, Constants.SecurityKey.IV); //if (readLog != null && readLog.List != null && readLog.List.Count > 0 && string.Compare(readLog.Host, Host, true) == 0 && readLog.Id == id) if (readLog != null && readLog.List != null && readLog.List.Count > 0 && string.Compare(readLog.Host, host, true) == 0) { return(readLog); } return(null); }
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)); }
/// <summary> /// 获取最近阅读记录 /// </summary> /// <param name="cookieName"></param> /// <param name="id"></param> /// <returns></returns> public static NovelRecentReadView First(string cookieName, int id = 0) { if (!string.IsNullOrEmpty(cookieName)) { string host = StringHelper.GetHost(); NovelRecentReadListView readLog = Get(cookieName, Constants.SecurityKey.key, Constants.SecurityKey.IV); //if (readLog != null && readLog.List != null && readLog.List.Count > 0 && readLog.Id == id) if (readLog != null && readLog.List != null && readLog.List.Count > 0) { return(readLog.List.OrderByDescending <NovelRecentReadView, System.DateTime>(t => t.ReadTime).First <NovelRecentReadView>()); } } return(null); }
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)); }
protected void ChapterReadLogSync(string userName, string cookieName, int userId = 0) { if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(cookieName)) { return; } try { NovelRecentReadListView readLog = RecentReadContext.Get(cookieName, userId); if (readLog != null && !readLog.List.IsNullOrEmpty <NovelRecentReadView>()) { ILogService service = DataContext.ResolveService <ILogService>(); NovelReadRecordInfo novelReadRecordInfo = null; foreach (NovelRecentReadView item in readLog.List) { novelReadRecordInfo = new NovelReadRecordInfo(); novelReadRecordInfo.AddTime = DateTime.Now; novelReadRecordInfo.ChannelId = ""; novelReadRecordInfo.ChapterCode = item.ChapterCode; novelReadRecordInfo.ChapterId = 0; novelReadRecordInfo.ClientId = 0; novelReadRecordInfo.CookieId = ""; novelReadRecordInfo.IMEI = ""; novelReadRecordInfo.IMSI = ""; novelReadRecordInfo.NovelId = item.Id; novelReadRecordInfo.Position = 0; novelReadRecordInfo.RecentReadTime = item.ReadTime; novelReadRecordInfo.RouteChannelId = item.RouteChannelId; novelReadRecordInfo.SourceType = (int)Constants.Version.wap; novelReadRecordInfo.UserAgent = ""; novelReadRecordInfo.UserId = userId; novelReadRecordInfo.UserName = userName; novelReadRecordInfo.Version = ""; service.ChapterReadLogLocalSync(novelReadRecordInfo); } } } catch { } }
private static NovelRecentReadListView Get(string cookieName, string key, string IV) { NovelRecentReadListView readList = null; string value = ""; if (CookieHelper.Get(cookieName, key, IV, out value)) { readList = SerializeHelper.DeSerialize <NovelRecentReadListView>(value); if (readList == null || readList.List.IsNullOrEmpty <NovelRecentReadView>()) { NovelRecentReadLog readLog = SerializeHelper.DeSerialize <NovelRecentReadLog>(value); if (readLog != null && !readLog.List.IsNullOrEmpty <NovelReadInfo>()) { readList = readLog.ToNovelRecentReadListView(); } } } return(readList); }
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)); }