protected void TrafficRefreshUpdatePanel_Load(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(Request.Params.Get("__EVENTARGUMENT"))) { string agrument = Request.Params.Get("__EVENTARGUMENT"); if (PTCSercurityManager.IsTrafficAdvertFound(agrument)) { PTCSercurityManager.Release(); L_Clicked.Text = Member.Current.TrafficGridHitsToday.ToString(); } } }
protected void LoadAds() { Form.Action = Request.RawUrl; List <PtcAdvert> AvailableAdList; CreatedCustomCategories = new List <int>(); Member user = null; if (Member.IsLogged) { user = Member.Current; int temporaryAdvertId = 0; if (AppSettings.PtcAdverts.BlockPtcAdvertsAfterMissingPointer && Request.Params.Get("__EVENTARGUMENT5") != null && Int32.TryParse(Request.Params.Get("__EVENTARGUMENT5"), out temporaryAdvertId)) { // User missed the anti-robot button 3 times // Blocking this particualr ad for him List <int> av = user.AdsViewed; av.Add(temporaryAdvertId); // Blocking = adding to watched user.AdsViewed = av; user.Save(); NotificationManager.RefreshWithMember(NotificationType.NewAds, user); } AvailableAdList = PtcAdvert.GetActiveAdsForUser(user); } else { AvailableAdList = PtcAdvert.GetAllActiveAds(); } if (AvailableAdList.Count == 0) { MenuMultiView.Visible = false; NoPTCpanelWrapper.Visible = true; NoPTCpanel.Visible = true; NoPTCpanel.Text = U6003.NOPTC; } else { if (!string.IsNullOrWhiteSpace(Request.Params.Get("__EVENTARGUMENT"))) { string agrument = Request.Params.Get("__EVENTARGUMENT"); if (PTCSercurityManager.IsPTCAdvertFound(agrument, AvailableAdList)) { PTCSercurityManager.Release(); } } //Sort by favorite? if (Member.IsLogged) { if (SortBy1.SelectedValue == "Favorite") { var favorites = FavoriteAd.GetUserFavorites(Member.CurrentId, FavoriteAdType.PTC); AvailableAdList = AvailableAdList.OrderByDescending(i => favorites.Contains(i.Id)).ToList(); } else if (SortBy1.SelectedValue == "Voted") { var favorites = FavoriteAd.GetUserFavorites(Member.CurrentId, FavoriteAdType.PTC); AvailableAdList = AvailableAdList.OrderByDescending(i => i.CaptchaYesAnswers - i.CaptchaNoAnswers).ToList(); } } //Display proper ads to the Member try { //Lets get the proper ads to the member foreach (PtcAdvert Ad in AvailableAdList) { bool IsSearch = !string.IsNullOrWhiteSpace(SearchTextBox.Text); if (!IsSearch || (IsSearch && IsSearchRequirementsMeet(Ad, SearchTextBox.Text))) { if (AppSettings.PtcAdverts.PTCCategoryPolicy == AppSettings.PTCCategoryPolicy.Custom) { //Display Custom Categories CustomCategoriesPlaceHolder.Visible = true; if (!CreatedCustomCategories.Contains(Ad.CategoryId)) { CreatedCustomCategories.Add(Ad.CategoryId); } CustomCategoriesPlaceHolder.Controls.Add(GetAdHTML(Ad, user)); } else { if (string.IsNullOrEmpty(Ad.Description) && Ad.IsStarredAd == false) { SmallAdsLiteral.Controls.Add(GetAdHTML(Ad, user, "")); } else { AdsLiteral.Controls.Add(GetAdHTML(Ad, user, "")); } } } } if (AppSettings.PtcAdverts.PTCCategoryPolicy == AppSettings.PTCCategoryPolicy.Custom) { foreach (var categoryId in CreatedCustomCategories) { LoadCustomCategoryButton(categoryId); } } } catch (Exception ex) { ErrorLogger.Log(ex); throw ex; } } }