public ActionResult Index() { #region string absoluteUrl = ""; if (EnvSettings.Domain.IsInvalid(out absoluteUrl)) { return(Redirect(absoluteUrl)); } #endregion Novel novel = _bookService.GetNovel(NovelId); if (novel != null && novel.Id > 0) { InitializeChapterPager(); bool IsNovel = novel.ContentType == (int)Constants.Novel.ContentType.小说; if (IsNovel) { Chapter chapter = _chapterService.GetChapter(NovelId, ChapterCode, ChapterDirection, out ChapterCode); if (chapter != null && chapter.Id > 0 && IsRead(_orderService)) { // 分页 string replyText = null; bool isPreChapterCode = false; bool isNextChapterCode = false; string url = GetChapterPager("/preview", ChapterCode, out replyText, out isPreChapterCode, out isNextChapterCode); //小说阅读记录 ReadLog(currentUser.UserName, NovelId, chapter.Id, ChapterCode); //最近阅读日志 RecentReadContext.Save(novel, chapter.ChapterName, ChapterCode, RouteChannelId, currentUser.UserId); ChapterDetailView detailView = new ChapterDetailView() { Novel = new SimpleResponse <Novel>(true, novel), Chapter = new SimpleResponse <Chapter>(true, chapter), ChapterContent = IsNovel ? FileHelper.ReadFile(FileHelper.MergePath("\\", new string[] { novel.FilePath, chapter.FileName }), chapter.ChapterName) : "", IsPreChapterCode = isPreChapterCode, IsNextChapterCode = isNextChapterCode, PreChapterUrl = ChapterContext.GetUrl(url, NovelId, ChapterCode, Constants.Novel.ChapterDirection.pre, channelId: RouteChannelId), NextChapterUrl = ChapterContext.GetUrl(url, NovelId, ChapterCode, Constants.Novel.ChapterDirection.next, channelId: RouteChannelId), ReplyText = replyText }; return(View(detailView)); } } } return(Redirect(DataContext.GetErrorUrl(ErrorMessage.小说不存在, channelId: RouteChannelId))); }
public ActionResult NovelDetail(int NovelId) { StringBuilder sb = new StringBuilder(); Novel novel = _bookService.GetNovel(NovelId); if (novel != null && novel.Id > 0) { Chapter chapter = _chapterService.GetChapter(NovelId, ChapterCode, ChapterDirection, out ChapterCode); if (chapter != null && chapter.Id > 0 && IsRead(_orderService)) { //正文中插入用户信息 string encryptInfo = string.IsNullOrEmpty(currentUser.UserName) ? null : string.Concat("14", ";", currentUser.UserName.Substring(1)); ChapterDetailView detailView = new ChapterDetailView() { ChapterContent = StringHelper.ConvertAndSignTxt((novel.ContentType == (int)Constants.Novel.ContentType.小说) ? FileHelper.ReadFile(FileHelper.MergePath("\\", new string[] { novel.FilePath, chapter.FileName }), chapter.ChapterName) : "", Constants.SecurityKey.userAESId, encryptInfo) }; sb.Append("{\"ChapterContent\": \"" + detailView.ChapterContent + "\"}"); } } return(Json(sb.ToString())); }
public ActionResult Detail() { string hideUrl = ""; if (ChapterContext.VerifyRedirect(NovelId, ChapterCode, ChapterDirection, out hideUrl, SiteSection.Chapter.IsRedirectWeChat)) { return(Redirect(hideUrl)); } SetReadMode(); Novel novel = _bookService.GetNovel(NovelId); if (novel != null && novel.Id > 0) { InitializeChapterPager(); Chapter chapter = _chapterService.GetChapter(NovelId, ChapterCode, ChapterDirection, out ChapterCode); if (chapter != null && chapter.Id > 0 && IsRead(_orderService)) { #region bool isPreChapterCode = false; bool isNextChapterCode = false; string url = GetChapterPager("/chapter/detail", ChapterCode, out isPreChapterCode, out isNextChapterCode); #endregion #region 推荐阅读 //推荐阅读 - 轮循广告 int adClassId = RecSection.BookChapterDetail.Ad; IEnumerable <AD> adList = GetADList(adClassId, novel.Id, 3); #endregion //阅读记录 ReadLog(currentUser.UserName, chapter.NovelId, chapter.Id, chapter.ChapterCode); //最近阅读日志 RecentReadContext.Save(novel, chapter.ChapterName, ChapterCode, RouteChannelId, currentUser.UserId); //是否收藏 bool isMark = _bookmarkService.Exists(NovelId, currentUser.UserName); //漫画目录 IEnumerable <ExtendChapterView> extendChapterList = GetExtendChapterList(novel); //千字价格 int chapterWordSizeFee = GetChapterWordSizeFee(novel.ChapterWordSizeFee); //章节正文 string chapterContent = GetContent(novel.ContentType, chapter.ChapterName, novel.FilePath, chapter.FileName); ChapterDetailView detailView = new ChapterDetailView() { Novel = new SimpleResponse <Novel>(true, novel), Chapter = new SimpleResponse <Chapter>(true, chapter), ChapterFee = GetFee(chapter.WordSize, chapterWordSizeFee), ChapterContent = chapterContent, IsPreChapterCode = isPreChapterCode, IsNextChapterCode = isNextChapterCode, PreChapterUrl = ChapterContext.GetUrl(url, NovelId, ChapterCode, Constants.Novel.ChapterDirection.pre, channelId: RouteChannelId), NextChapterUrl = ChapterContext.GetUrl(url, NovelId, ChapterCode, Constants.Novel.ChapterDirection.next, channelId: RouteChannelId), AdList = new SimpleResponse <IEnumerable <AD> >(!adList.IsNullOrEmpty <AD>(), adList), IsMark = isMark, ExtendChapterList = new SimpleResponse <IEnumerable <ExtendChapterView> >(!extendChapterList.IsNullOrEmpty <ExtendChapterView>(), extendChapterList), ChapterAudioUrl = GetAudioUrl(novel.ContentType, chapter.FileName), HitUrl = GetHitUrl(), ShowQrCodeMinChapterCode = StringHelper.ToInt(UrlParameterHelper.GetParams("qrdx")) }; if (novel.ContentType == (int)Constants.Novel.ContentType.漫画) { return(View("/views/cartoonchapter/detail.cshtml", detailView)); } else if (novel.ContentType == (int)Constants.Novel.ContentType.听书) { return(View("/views/audiochapter/detail.cshtml", detailView)); } else { return(View(detailView)); } } else { if (novel.FeeType == (int)Constants.Novel.FeeType.chapter || novel.FeeType == (int)Constants.Novel.FeeType.novelchapter) { return(Redirect(ChapterContext.GetUrl("/preorder/chapter", NovelId, ChapterCode, channelId: RouteChannelId))); } else if (novel.FeeType == (int)Constants.Novel.FeeType.novel) { return(Redirect(ChapterContext.GetUrl("/preorder/novel", NovelId, ChapterCode, channelId: RouteChannelId))); } } } return(Redirect(DataContext.GetErrorUrl(ErrorMessage.小说不存在, channelId: RouteChannelId))); }
public ActionResult Detail() { #region string absoluteUrl = ""; if (EnvSettings.Domain.IsInvalid(out absoluteUrl)) { return(Redirect(absoluteUrl)); } #endregion SetReadMode(); Novel novel = _bookService.GetNovel(NovelId); if (novel != null && novel.Id > 0) { InitializeChapterPager(); Chapter chapter = _chapterService.GetChapter(NovelId, ChapterCode, ChapterDirection, out ChapterCode); if (chapter != null && chapter.Id > 0 && IsRead(_orderService)) { #region bool isPreChapterCode = false; bool isNextChapterCode = false; string url = GetChapterPager("/chapter/detail", ChapterCode, out isPreChapterCode, out isNextChapterCode); #endregion #region 推荐阅读 //推荐阅读 - 轮循广告 int adClassId = RecSection.BookChapterDetail.Ad; IEnumerable <AD> adList = GetADList(adClassId, novel.Id, 3); #endregion //阅读记录 ReadLog(currentUser.UserName, chapter.NovelId, chapter.Id, chapter.ChapterCode); //最近阅读日志 RecentReadContext.Save(novel, chapter.ChapterName, ChapterCode, RouteChannelId, currentUser.UserId); //是否收藏 bool isMark = _bookmarkService.Exists(NovelId, currentUser.UserName); //漫画目录 IEnumerable <ExtendChapterView> extendChapterList = GetExtendChapterList(novel); // 千字价格 int chapterWordSizeFee = GetChapterWordSizeFee(novel.ChapterWordSizeFee); //正文中插入用户信息 string encryptInfo = string.IsNullOrEmpty(currentUser.UserName) ? null : string.Concat("16", ";", currentUser.UserName.Substring(1)); ChapterDetailView detailView = new ChapterDetailView() { Novel = new SimpleResponse <Novel>(true, novel), Chapter = new SimpleResponse <Chapter>(true, chapter), ChapterFee = GetFee(chapter.WordSize, chapterWordSizeFee), ChapterContent = StringHelper.ConvertAndSignTxt((novel.ContentType == (int)Constants.Novel.ContentType.小说) ? FileHelper.ReadFile(FileHelper.MergePath("\\", new string[] { novel.FilePath, chapter.FileName }), chapter.ChapterName) : "", Constants.SecurityKey.userAESId.ToLower(), encryptInfo), IsPreChapterCode = isPreChapterCode, IsNextChapterCode = isNextChapterCode, PreChapterUrl = ChapterContext.GetUrl(url, NovelId, ChapterCode, Constants.Novel.ChapterDirection.pre, channelId: RouteChannelId), NextChapterUrl = ChapterContext.GetUrl(url, NovelId, ChapterCode, Constants.Novel.ChapterDirection.next, channelId: RouteChannelId), AdList = new SimpleResponse <IEnumerable <AD> >(!adList.IsNullOrEmpty <AD>(), adList), IsMark = isMark, ExtendChapterList = new SimpleResponse <IEnumerable <ExtendChapterView> >(!extendChapterList.IsNullOrEmpty <ExtendChapterView>(), extendChapterList), ChapterAudioUrl = GetAudioUrl(novel.ContentType, chapter.FileName), HitUrl = GetHitUrl(), ShowQrCodeMinChapterCode = StringHelper.ToInt(UrlParameterHelper.GetParams("qrdx")) }; if (novel.ContentType == (int)Constants.Novel.ContentType.漫画) { return(View("/views/cartoonchapter/detail.cshtml", detailView)); } else if (novel.ContentType == (int)Constants.Novel.ContentType.听书) { return(View("/views/audiochapter/detail.cshtml", detailView)); } else { return(View(detailView)); } } else { if (novel.FeeType == (int)Constants.Novel.FeeType.chapter || novel.FeeType == (int)Constants.Novel.FeeType.novelchapter) { return(Redirect(ChapterContext.GetUrl("/preorder/chapter", NovelId, ChapterCode, channelId: RouteChannelId))); } else if (novel.FeeType == (int)Constants.Novel.FeeType.novel) { return(Redirect(ChapterContext.GetUrl("/preorder/novel", NovelId, ChapterCode, channelId: RouteChannelId))); } } } return(Redirect(DataContext.GetErrorUrl(ErrorMessage.小说不存在, channelId: RouteChannelId))); }
public ActionResult Chapter() { SetReadMode(); Novel novel = _bookService.GetNovel(NovelId); if (novel != null && novel.Id > 0) { if (novel.FeeType == (int)Constants.Novel.FeeType.novel) { return(Redirect(DataContext.GetErrorUrl(ErrorMessage.该小说无法按章计费, channelId: RouteChannelId))); } InitializeChapterPager(); Chapter chapter = _chapterService.GetChapter(NovelId, ChapterCode, ChapterDirection, out ChapterCode); if (chapter != null && chapter.Id > 0 && IsRead(_orderService)) { return(Redirect(ChapterContext.GetUrl("/chapter/detail", chapter.NovelId, chapter.ChapterCode, channelId: RouteChannelId))); } if (chapter != null && chapter.Id > 0) { int i = 0; if (int.TryParse(StringHelper.ToString(SessionHelper.Get("ancp")), out i) && i == NovelId) { return(Redirect(ChapterContext.GetUrl("/order/chapter", chapter.NovelId, chapter.ChapterCode, channelId: RouteChannelId))); } #region bool isPreChapterCode = false; bool isNextChapterCode = false; string url = GetChapterPager("/chapter/detail", ChapterCode, out isPreChapterCode, out isNextChapterCode); #endregion bool isMark = _bookmarkService.Exists(NovelId, currentUser.UserName); // 千字价格 int chapterWordSizeFee = GetChapterWordSizeFee(novel.ChapterWordSizeFee); ChapterDetailView detailView = new ChapterDetailView() { Novel = new SimpleResponse <Novel>(true, novel), Chapter = new SimpleResponse <Chapter>(true, chapter), ChapterWordSizeFee = chapterWordSizeFee, ChapterFee = GetFee(chapter.WordSize, chapterWordSizeFee), NovelFee = GetFee((decimal)(novel.WordSize * 0.95f), chapterWordSizeFee), ChapterContent = (novel.ContentType == (int)Constants.Novel.ContentType.小说) ? StringHelper.CutString(FileHelper.ReadFile(FileHelper.MergePath("\\", new string[] { novel.FilePath, chapter.FileName }), chapter.ChapterName), 100, true) : "", IsPreChapterCode = isPreChapterCode, IsNextChapterCode = isNextChapterCode, PreChapterUrl = ChapterContext.GetUrl(url, NovelId, ChapterCode, Constants.Novel.ChapterDirection.pre, channelId: RouteChannelId), NextChapterUrl = ChapterContext.GetUrl(url, NovelId, ChapterCode, Constants.Novel.ChapterDirection.next, channelId: RouteChannelId), UserBalance = GetUserBalance(), IsMark = isMark }; if (novel.ContentType == (int)Constants.Novel.ContentType.漫画) { return(View("/views/cartoonchapter/order.cshtml", detailView)); } else if (novel.ContentType == (int)Constants.Novel.ContentType.听书) { return(View("/views/audiochapter/order.cshtml", detailView)); } else { return(View("/views/chapter/order.cshtml", detailView)); } } else { //章节不存在 return(Redirect(DataContext.GetErrorUrl(ErrorMessage.小说章节不存在, channelId: RouteChannelId))); } } else { //小说不存在 return(Redirect(DataContext.GetErrorUrl(ErrorMessage.小说不存在, channelId: RouteChannelId))); } }