Example #1
0
        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)));
        }
Example #2
0
        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)));
        }
Example #3
0
        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));
        }
Example #4
0
        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));
        }
Example #5
0
        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));
        }
Example #6
0
        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 { }
        }
Example #7
0
        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)));
        }
Example #8
0
        public ActionResult Index(Constants.Novel.ClassSpeType cst = Constants.Novel.ClassSpeType.female)
        {
            int timeOut = 30;

            if (SiteSection.Class.IsShowMale && !SiteSection.Class.IsShowFemale)
            {
                cst = Constants.Novel.ClassSpeType.male;
            }

            dynamic recClass = GetRecClass(cst);

            //首页-热门推荐
            var hotRec = DataContext.TryCache <IEnumerable <RecommendView> >(string.Format("{0}_BookIndex_HotRecommend", cst), () =>
            {
                return(GetRecList(recClass.HotRecommend, 7));
            }, timeOut);

            //首页-潜力新作
            var newRec = DataContext.TryCache <IEnumerable <RecommendView> >(string.Format("{0}_BookIndex_PotentialNew", cst), () =>
            {
                return(GetRecList(recClass.PotentialNew, 6));
            }, timeOut);

            //首页-主编力推
            var authorRec = DataContext.TryCache <IEnumerable <RecommendView> >(string.Format("{0}_BookIndex_EditorRecommend", cst), () =>
            {
                return(GetRecList(recClass.EditorRecommend, 3));
            }, timeOut);

            //首页-热销专区
            var sellRec = DataContext.TryCache <IEnumerable <RecommendView> >(string.Format("{0}_BookIndex_HotSale", cst), () =>
            {
                return(GetRecList(recClass.HotSale, 6));
            }, timeOut);

            //首页-听书专区
            var listenRec = DataContext.TryCache <IEnumerable <RecommendView> >("BookIndex_ListenRec", () =>
            {
                return(GetRecList(RecSection.BookIndex.ListenRec, 3));
            }, timeOut);

            //首页-顶端广告位
            var headAD = DataContext.TryCache <IEnumerable <AD> >(string.Format("{0}_BookIndex_HeaderAD", cst), () =>
            {
                return(GetADList(recClass.HeaderAD, 4));
            }, timeOut);

            //首页-中间广告位
            var middleAD = DataContext.TryCache <IEnumerable <AD> >(string.Format("{0}_BookIndex_MiddleAD", cst), () =>
            {
                return(GetADList(recClass.MiddleAD, 1));
            }, timeOut);

            //首页-限时免费
            var freeRec = GetPackageList((int)recClass.Free, Constants.PackageType.LimitFree, 3);

            //获取本地最近阅读
            var recentRead = RecentReadContext.First(new string[] { Constants.SecurityKey.NovelRecentRead_CookieName.ToString(), Constants.SecurityKey.CartoonRecentRead_CookieName.ToString() }, _logService, currentUser.UserName, currentUser.UserId);

            HomeView home = new HomeView()
            {
                HotRecList    = new SimpleResponse <IEnumerable <RecommendView> >(!hotRec.IsNullOrEmpty(), hotRec),
                FreeRecList   = new SimpleResponse <IEnumerable <PackageView> >(!freeRec.IsNullOrEmpty(), freeRec),
                NewRecList    = new SimpleResponse <IEnumerable <RecommendView> >(!newRec.IsNullOrEmpty(), newRec),
                AuthorRecList = new SimpleResponse <IEnumerable <RecommendView> >(!authorRec.IsNullOrEmpty(), authorRec),
                SellRecList   = new SimpleResponse <IEnumerable <RecommendView> >(!sellRec.IsNullOrEmpty(), sellRec),
                ListenRecList = new SimpleResponse <IEnumerable <RecommendView> >(!listenRec.IsNullOrEmpty(), listenRec),
                HeadADList    = new SimpleResponse <IEnumerable <AD> >(!headAD.IsNullOrEmpty(), headAD),
                MiddleADList  = new SimpleResponse <IEnumerable <AD> >(!middleAD.IsNullOrEmpty(), middleAD),
                RecentRead    = new SimpleResponse <NovelRecentReadView>(!recentRead.IsObjectNullOrEmpty(), recentRead),
                ClassSpeType  = cst.ToString()
            };

            return(View(home));
        }
Example #9
0
        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)));
        }