示例#1
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));
        }
示例#2
0
        public ActionResult T(int id = 0, string type = "")
        {
            Constants.Novel.PromotionType promotionType = Constants.Novel.PromotionType.none;
            string url = "";

            if (id > 0)
            {
                if (EnumHelper.TryParsebyName <Constants.Novel.PromotionType>(type, out promotionType))
                {
                    if (promotionType == Constants.Novel.PromotionType.pmc)
                    {
                        PromotionLink promotionLink = _promotionLinkService.Detail(id);
                        if (promotionLink != null && promotionLink.Id > 0 &&
                            !string.IsNullOrEmpty(promotionLink.ChannelCode) &&
                            !string.IsNullOrEmpty(promotionLink.PromotionCode))
                        {
                            SetSessionHeaderInfoFromRoute(promotionLink.ChannelCode, promotionLink.PromotionCode);

                            string chapterUrl  = "/chapter/detail/".GetChannelRouteUrl(promotionLink.ChannelCode);
                            int    chapterCode = promotionLink.EndChapterCode > promotionLink.StartChapterCode ? promotionLink.EndChapterCode : 0;

                            if (promotionLink.FuncType == 1)
                            {
                                IDictionary <string, object> dict = new Dictionary <string, object>();
                                dict.Add("c", ChapterContext.GetRangeToken(promotionLink.EndChapterCode, promotionLink.FollowChapter));
                                dict.Add("rp", ChapterContext.GetReplyText(promotionLink.ReplyKeywords));
                                chapterUrl = "/preview".GetChannelRouteUrl(promotionLink.ChannelCode).SpliceUrl(dict);
                            }

                            url = ChapterContext.GetUrl(chapterUrl, promotionLink.NovelId, chapterCode, Constants.Novel.ChapterDirection.none, channelId: RouteChannelId);
                        }
                    }
                    else if (promotionType == Constants.Novel.PromotionType.rk)
                    {
                        PromotionLink promotionLink = _promotionLinkService.Detail(id);
                        if (promotionLink != null && promotionLink.Id > 0 &&
                            !string.IsNullOrEmpty(promotionLink.ChannelCode) &&
                            !string.IsNullOrEmpty(promotionLink.PromotionCode))
                        {
                            SetSessionHeaderInfoFromRoute(promotionLink.ChannelCode, promotionLink.PromotionCode);

                            string chapterUrl = "/chapter/detail/".GetChannelRouteUrl(promotionLink.ChannelCode);

                            url = ChapterContext.GetUrl(chapterUrl, promotionLink.NovelId, promotionLink.FollowChapter, Constants.Novel.ChapterDirection.none, channelId: RouteChannelId);
                        }
                    }
                }
                else
                {
                    NovelPromotionChannel model = _novelPromotionChannelService.Detail(id);
                    if (model != null && model.NovelId > 0 && model.ChapterCode >= 0)
                    {
                        string chapterUrl = "chapter/detail";
                        string channelId  = model.ChannelId;

                        if (!string.IsNullOrEmpty(channelId))
                        {
                            chapterUrl = string.Concat(chapterUrl, "?channelid=", channelId);
                        }
                        url = ChapterContext.GetUrl(chapterUrl, model.NovelId, model.ChapterCode, channelId: RouteChannelId);
                    }
                }
            }

            if (string.IsNullOrEmpty(url))
            {
                url = DataContext.GetErrorUrl(channelId: RouteChannelId);
            }

            return(Redirect(url));
        }
示例#3
0
        public async Task PopulateModsList()
        {
            try
            {
                var resp = await HttpClient.GetAsync(Utils.Constants.BeatModsAPIUrl + Utils.Constants.BeatModsModsOptions + "&gameVersion=" + MainWindow.GameVersion);

                var body = await resp.Content.ReadAsStringAsync();

                ModsList = JsonSerializer.Deserialize <Mod[]>(body);
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show($"{FindResource("Mods:LoadFailed")}.\n\n" + e);
                return;
            }

            foreach (Mod mod in ModsList)
            {
                bool preSelected = mod.required;
                if (DefaultMods.Contains(mod.name) || (App.SaveModSelection && App.SavedMods.Contains(mod.name)))
                {
                    preSelected = true;
                    if (!App.SavedMods.Contains(mod.name))
                    {
                        App.SavedMods.Add(mod.name);
                    }
                }

                RegisterDependencies(mod);

                ModListItem ListItem = new ModListItem()
                {
                    IsSelected     = preSelected,
                    IsEnabled      = !mod.required,
                    ModName        = mod.name,
                    ModVersion     = mod.version,
                    ModDescription = mod.description.Replace("\r\n", " ").Replace("\n", " "),
                    ModInfo        = mod,
                    Category       = mod.category
                };

                foreach (Promotion promo in Promotions.ActivePromotions)
                {
                    if (mod.name == promo.ModName)
                    {
                        ListItem.PromotionTexts          = new string[promo.Links.Count];
                        ListItem.PromotionLinks          = new string[promo.Links.Count];
                        ListItem.PromotionTextAfterLinks = new string[promo.Links.Count];

                        for (int i = 0; i < promo.Links.Count; ++i)
                        {
                            PromotionLink link = promo.Links[i];
                            ListItem.PromotionTexts[i]          = link.Text;
                            ListItem.PromotionLinks[i]          = link.Link;
                            ListItem.PromotionTextAfterLinks[i] = link.TextAfterLink;
                        }
                    }
                }

                foreach (Mod installedMod in InstalledMods)
                {
                    if (mod.name == installedMod.name)
                    {
                        ListItem.InstalledModInfo = installedMod;
                        ListItem.IsInstalled      = true;
                        ListItem.InstalledVersion = installedMod.version;
                        break;
                    }
                }

                mod.ListItem = ListItem;

                ModList.Add(ListItem);
            }

            foreach (Mod mod in ModsList)
            {
                ResolveDependencies(mod);
            }
        }