Example #1
0
 /// <summary>
 /// Adds specified GeolocationUnit to the geolocation. Requires Save()
 /// </summary>
 public void AddGeolocation(GeolocationUnit unit)
 {
     GeolocatedCC       = (String.IsNullOrEmpty(unit.CountryCodes)) ? GeolocatedCC : unit.CountryCodes;
     GeolocatedCities   = (String.IsNullOrEmpty(unit.Cities)) ? GeolocatedCities : unit.Cities;
     GeolocationProfile = (unit.Profile.Count == 0) ? GeolocationProfile : unit.Profile;
     GeolocatedAgeMax   = (unit.MaxAge == 0) ? GeolocatedAgeMax : unit.MaxAge;
     GeolocatedAgeMin   = (unit.MinAge == 0) ? GeolocatedAgeMin : unit.MinAge;
     GeolocatedGender   = (unit.Gender == Gender.Null) ? GeolocatedGender : unit.Gender;
 }
Example #2
0
    protected void CreateAdButton_Click(object sender, EventArgs e)
    {
        ErrorMessagePanel.Visible = false;
        SuccMessagePanel.Visible  = false;

        if (Page.IsValid)
        {
            try
            {
                AppSettings.DemoCheck();
                AppSettings.Misc.Reload();

                Member User = Member.Current;

                int   HowManyNeeded = Convert.ToInt32(HowMany.Text);
                Money PPA, AdCost;

                try
                {
                    PPA = Money.Parse(Amount.Text);

                    Decimal CalculatedPercent = (Decimal)(AppSettings.CPAGPT.MoneyTakenFromCPAOffersPercent + 100) / (Decimal)100;
                    CalculatedPercent = CalculatedPercent * HowManyNeeded;

                    AdCost = CalculatedPercent * PPA;

                    if (PPA == new Money(0))
                    {
                        throw new MsgException(L1.ERCPA);
                    }
                }
                catch (Exception ex)
                {
                    throw new MsgException(L1.ERCPA);
                }

                if (PPA < AppSettings.CPAGPT.MinimalCPAPrice)
                {
                    throw new MsgException("Your PPA can't be less than minimum: " + AppSettings.CPAGPT.MinimalCPAPrice.ToString());
                }

                if (chbGeolocation.Checked)
                {
                    //AdCost += AppSettings.BannerAdverts.GeolocationCost;

                    //Now get it from client-state
                    var             countriesSelectedDelimited = Request.Form[GeoCountriesValues.Name].Substring(1);
                    GeolocationUnit unit = GeolocationUnit.ParseFromCountries(countriesSelectedDelimited);

                    //Cities
                    unit.Cities = GeoCities.Text;
                    unit.MinAge = Convert.ToInt32(GeoAgeMin.Text);
                    unit.MaxAge = Convert.ToInt32(GeoAgeMax.Text);
                    unit.Gender = (Gender)Convert.ToInt32(GeoGenderList.SelectedValue);

                    NewCPAAdvert.AddGeolocation(unit);
                }

                NewCPAAdvert.Title       = InputChecker.HtmlEncode(Title.Text, 50, L1.TITLE);
                NewCPAAdvert.Description = InputChecker.HtmlEncode(Description.Text, 3800, L1.DESCRIPTION);
                NewCPAAdvert.Category    = new CPACategory(Convert.ToInt32(CategoriesList.SelectedValue));

                //Take money and save the user
                var targetBalance = TargetBalanceRadioButtonList.TargetBalance;
                PurchaseOption.ChargeBalance(User, AdCost, TargetBalanceRadioButtonList.Feature, targetBalance, "CPA/GPT advertising");

                NewCPAAdvert.TargetBalance      = targetBalance;
                NewCPAAdvert.AdvertiserUsername = (User.Name);
                NewCPAAdvert.Status             = AdvertStatusExtensions.GetStartingStatus();

                if (Member.CurrentName == "admin")
                {
                    NewCPAAdvert.Status = AdvertStatus.Paused;
                }

                //Set basics - add to db
                NewCPAAdvert.TargetURL = URL.Text;
                //NewBannerAdvert.Pack = Pack;
                NewCPAAdvert.LoginBoxRequired       = LoginIDBox.Checked;
                NewCPAAdvert.EmailBoxRequired       = EmailIDBox.Checked;
                NewCPAAdvert.IsDaily                = IsDaily.Checked;
                NewCPAAdvert.MaxDailyCredits        = 1;
                NewCPAAdvert.CreditsBought          = HowManyNeeded;
                NewCPAAdvert.IsFromAutomaticNetwork = false;
                NewCPAAdvert.BaseValue              = PPA;
                NewCPAAdvert.DateAdded              = DateTime.Now;
                NewCPAAdvert.LastCredited           = OffersManager.DateTimeZero;
                NewCPAAdvert.RequiredMembership     = Membership.Standard.Id;

                if (AppSettings.Site.Mode == WebsiteMode.GPTWithPointsOnly)
                {
                    NewCPAAdvert.CreditOfferAs = CreditOfferAs.NonCash;
                }
                else
                {
                    NewCPAAdvert.CreditOfferAs = CreditOfferAs.Cash;
                }

                NewCPAAdvert.Save();

                //Add history entry 1
                History.AddPurchase(User.Name, AdCost, "CPA/GPT campaign");

                SuccMessagePanel.Visible = true;
                SuccMessage.Text         = U3501.ADCREATED;

                Session["YourCampaigns_NewAAABannerAdvert"] = null;

                Response.Redirect("cpaoffers.aspx");
            }
            catch (MsgException ex)
            {
                ErrorMessagePanel.Visible = true;
                ErrorMessage.Text         = ex.Message;
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex);
                throw ex;
            }
        }
    }
Example #3
0
    protected void CreateAdButton_Click(object sender, EventArgs e)
    {
        ErrorMessagePanel.Visible = false;
        SuccMessagePanel.Visible  = false;

        if (Page.IsValid)
        {
            try
            {
                User = Member.Current;

                AppSettings.DemoCheck();

                if (URL.Enabled)
                {
                    throw new MsgException(U4200.CHECKURL);
                }

                var Ad = new LoginAd
                {
                    TargetUrl = URL.Text,
                };

                if (AppSettings.LoginAds.LoginAdsCreditsEnabled && LoginAdsCreditsCheckBox.Checked)
                {
                    //Login Ads Credits
                    Ad.PricePaid = new Money((int)LoginAdCreditsPrice);
                }
                else
                {
                    Ad.PricePaid = AppSettings.LoginAds.Price;
                }

                if (chbGeolocation.Checked && AppSettings.LoginAds.IsGeolocationEnabled)
                {
                    //Now get it from client-state
                    var             countriesSelectedDelimited = Request.Form[GeoCountriesValues.Name].Substring(1);
                    GeolocationUnit unit = GeolocationUnit.ParseFromCountries(countriesSelectedDelimited);

                    //Cities
                    unit.Cities = GeoCities.Text;
                    unit.MinAge = Convert.ToInt32(GeoAgeMin.Text);
                    unit.MaxAge = Convert.ToInt32(GeoAgeMax.Text);
                    unit.Gender = (Gender)Convert.ToInt32(GeoGenderList.SelectedValue);

                    Ad.AddGeolocation(unit);
                }

                Ad.CreatorUserId = User.Id;
                Ad.Status        = AdvertStatusExtensions.GetStartingStatus();

                var displayDate = AdDisplayDateCalendar.SelectedDate;

                if (displayDate <= DateTime.Now.Date)
                {
                    throw new MsgException(U4200.SELECTDIFFERENTDISPLAYDATE);
                }

                if (LoginManager.GetNumberOfAdsPurchasedForDay(displayDate) >= AppSettings.LoginAds.AdsPerDay)
                {
                    throw new MsgException(U4200.SELECTDIFFERENTDISPLAYDATE);
                }

                Ad.DisplayDate  = displayDate;
                Ad.PurchaseDate = DateTime.Now;

                if (AppSettings.LoginAds.LoginAdsCreditsEnabled && LoginAdsCreditsCheckBox.Checked)
                {
                    Ad.TargetBalance = PurchaseBalances.LoginAdsCredits;
                    PurchaseOption.ChargeBalance(User, Ad.PricePaid, PurchaseBalances.LoginAdsCredits, U5001.LOGINAD);

                    string extraViews = string.Format(@"({0} {1})", User.LoginAdsCredits, U4200.AVAILABLE);
                    AvailableLoginAdsCreditsLiteral.Text = extraViews;
                    History.AddPurchase(User.Name, Ad.PricePaid.AsPoints(), U5001.LOGINAD);
                }
                else
                {
                    Ad.TargetBalance = TargetBalanceRadioButtonList.TargetBalance;
                    PurchaseOption.ChargeBalance(User, Ad.PricePaid, TargetBalanceRadioButtonList.Feature, TargetBalanceRadioButtonList.TargetBalance, U5001.LOGINAD);

                    //Pools
                    PoolDistributionManager.AddProfit(ProfitSource.LoginAds, Ad.PricePaid);
                    //Add history entry 1
                    History.AddPurchase(User.Name, Ad.PricePaid, U5001.LOGINAD);
                    MatrixBase.TryAddMemberAndCredit(User, Ad.PricePaid, AdvertType.Login);
                }

                //Save advert
                Ad.Save();

                SuccMessagePanel.Visible = true;
                SuccMessage.Text         = U4200.ADAWAITSAPPROVAL;

                URL.Text               = "http://";
                URL.Enabled            = true;
                CheckURLButton.Visible = true;
            }
            catch (MsgException ex)
            {
                SuccMessagePanel.Visible  = false;
                ErrorMessagePanel.Visible = true;
                ErrorMessage.Text         = ex.Message;
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex);
                throw ex;
            }
        }
    }
Example #4
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);
            }
        }
    }