private void Initialize() { externalUsername = Request.Form["__SubId"]; ptcOfferWallTitle = Request.Form["__OfferWallTitle"]; subId2 = Request.Form["__SubId2"]; subId3 = Request.Form["__SubId3"]; countryCode = Request.Form["__CountryCode"]; Gender tempGender; if (!Enum.TryParse(Request.Form["__Gender"], true, out tempGender)) { gender = Gender.Null; } else { gender = tempGender; } age = Request.Form["__Age"].ToNullableInt(); int tempPtcOfferWallId; int temppublishersWebsiteId; if (!int.TryParse(Request.Form["__OfferWallId"], out tempPtcOfferWallId) || !int.TryParse(Request.Form["__PublishersWebsiteId"], out temppublishersWebsiteId) || string.IsNullOrEmpty(externalUsername) || string.IsNullOrEmpty(ptcOfferWallTitle)) { HandleError(); } ptcOfferWallId = Convert.ToInt32(Request.Form["__OfferWallId"]); publishersWebsiteId = Convert.ToInt32(Request.Form["__PublishersWebsiteId"]); LangAdder.Add(CreditAfterCaptchaButton, U6003.DONE); LangAdder.Add(CustomValidator1, L1.ER_BADCAPTCHA); PTCOfferWall offerWall = null; try { offerWall = new PTCOfferWall(ptcOfferWallId); } catch { HandleError(); } var urls = PTCOfferWallManager.GetUserUrls(ptcOfferWallId).Select(u => u.Url).ToList(); if (urls.Count == 0) { HandleError(); } LoadAds(urls, offerWall); }
protected void CreateOfferWallView_Activate(object sender, EventArgs e) { bool packsConfigured = PTCOfferWall.ArePacksConfigured(); bool userHasActiveUrls = UserUrl.UserHasActive(Member.CurrentId); CreateOfferWallsPlaceHolder.Visible = packsConfigured && userHasActiveUrls; if (!CreateOfferWallsPlaceHolder.Visible) { NewOfferWallUnavailable.Visible = true; NewOfferWallUnavailable.HeaderText = U6000.NEWADVERTUNAVAILABLEHEADER; string reason = !packsConfigured ? U6000.NEWADVERTUNAVAILABLEREASON : U6002.PLEASEADDURLSFIRST; NewOfferWallUnavailable.Reason = reason; } else { NewOfferWallUnavailable.Visible = false; } }
protected void MyOfferWallsGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var offerWall = new PTCOfferWall(Convert.ToInt32(e.Row.Cells[0].Text)); e.Row.Cells[3].Text = HtmlCreator.GenerateCPAAdProgressHTML(offerWall.CompletionTimes, offerWall.CompletionTimesBought, U6000.SUBMISSIONS); GridView urlsGridView = e.Row.FindControl("MyOfferWallsUrlsGridView") as GridView; using (var bridge = ParserPool.Acquire(Database.Client)) { urlsGridView.DataSource = bridge.Instance.ExecuteRawCommandToDataTable( @"SELECT urls.Url FROM PTCOfferWallsUserUrls mappings JOIN UserUrls urls ON mappings.UserUrlId = urls.Id WHERE mappings.PTCOfferWallId = " + offerWall.Id); } urlsGridView.DataBind(); } }
protected void CreateOfferWallButton_Click(object sender, EventArgs e) { try { if (Page.IsValid) { AppSettings.DemoCheck(); ErrorMessagePanel.Visible = SuccessMessagePanel.Visible = false; string title = InputChecker.HtmlEncode(TitleTextBox.Text, TitleTextBox.MaxLength, L1.TITLE); string description = InputChecker.HtmlEncode(DescriptionTextBox.Text, DescriptionTextBox.MaxLength, L1.DESCRIPTION); var pack = new PTCOfferWallPack(Convert.ToInt32(PacksDDL.SelectedValue)); List <UserUrl> urlIds = UserUrlsCheckBoxList.Items.Cast <ListItem>() .Where(x => x.Selected) .Select(x => new UserUrl(Convert.ToInt32(x.Value))) .ToList(); GeolocationUnit geolocationUnit = null; if (GeolocationCheckBox.Checked) { var validCountries = GeolocationUtils.GeoCountData.Keys; var countryNames = new StringBuilder(); foreach (ListItem item in GeoCountriesListBox.Items) { if (validCountries.Contains <string>(item.Value)) { countryNames.Append(item.Value); countryNames.Append("#"); } } var minAge = Convert.ToInt32(GeoAgeMin.Text); var maxAge = Convert.ToInt32(GeoAgeMax.Text); var gender = (Gender)Convert.ToInt32(GeoGenderList.SelectedValue); var countryCodes = GeolocationUnit.ParseFromCountriesString(countryNames.ToString()); var cities = string.Empty; geolocationUnit = new GeolocationUnit(countryCodes, cities, minAge, maxAge, gender); } var pcAllowed = PcAllowedCheckBox.Checked; var mobileAllowed = MobileAllowedCheckBox.Checked; var autosurfEnabled = AutosurfAllowedCheckBox.Checked; var maxSingleUserDailyViews = Convert.ToInt32(MaxSingleUserDailyViewsTextBox.Text); PTCOfferWall.Buy(Member.Current, pack, TargetBalanceRadioButtonList.TargetBalance, urlIds, title, description, geolocationUnit, pcAllowed, mobileAllowed, autosurfEnabled, maxSingleUserDailyViews); SuccessMessagePanel.Visible = true; SuccessMessage.Text = U3501.ADCREATED; ClearAll(); } } catch (Exception ex) { if (ex is MsgException) { ErrorMessagePanel.Visible = true; ErrorMessage.Text = ex.Message; } else { ErrorLogger.Log(ex); } } }
void LoadAds(List <string> urls, PTCOfferWall offerWall) { JsonData = JsonConvert.SerializeObject(new { offerWall.Title, offerWall.Description, offerWall.DisplayTime, offerWall.AutosurfEnabled, urls }); }