Exemplo n.º 1
0
    protected void PacksDDL_Init(object sender, EventArgs e)
    {
        var packs     = PTCOfferWallPack.GetActive();
        var listItems = new List <ListItem>();

        foreach (var p in packs)
        {
            listItems.Add(
                new ListItem
            {
                Value = p.Id.ToString(),
                Text  = string.Format("{0} {1} ({2} URL(s) x {3}s) - {4}", p.CompletionTimes, U6000.SUBMISSIONS, p.Adverts, p.DisplayTime, p.Price)
            });
        }

        PacksDDL.Controls.Clear();
        PacksDDL.Items.AddRange(listItems.ToArray());
    }
Exemplo n.º 2
0
    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);
            }
        }
    }