コード例 #1
0
        public string GetRecentReadChannelId(int id, string channelId, out Constants.Novel.StatisticType statisticType)
        {
            statisticType = Constants.Novel.StatisticType.none;

            if (id <= 0)
            {
                return(channelId);
            }

            using (var conn = DbConnection(DbOperation.Read))
            {
                using (var tran = BeginTransaction(conn))
                {
                    var repo = new Repository.ChannelCompanyRepo(conn, tran);
                    if (!string.IsNullOrEmpty(channelId) && repo.GetCount(id, channelId) > 0)
                    {
                        statisticType = Constants.Novel.StatisticType.promotion;
                    }
                    else
                    {
                        statisticType = Constants.Novel.StatisticType.menu;
                        channelId     = repo.GetRecentReadDefaultChannelId(id);
                    }

                    tran.Commit();
                }
            }

            return(channelId);
        }
コード例 #2
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));
        }