Beispiel #1
0
    protected void MyBannersGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            var advert = new ExternalBannerAdvert(Convert.ToInt32(e.Row.Cells[0].Text));

            try
            {
                var bannerImage     = advert.Image;
                var imageWebControl = new Image
                {
                    ImageUrl = bannerImage.Path,
                    Width    = Unit.Pixel(bannerImage.Width / 10),
                    Height   = Unit.Pixel(bannerImage.Height / 10)
                };

                e.Row.Cells[2].Text = string.Empty;
                e.Row.Cells[2].Controls.Add(imageWebControl);

                e.Row.Cells[4].Text = bannerImage.Width + " x " + bannerImage.Height;
                e.Row.Cells[5].Text = HtmlCreator.GenerateCPAAdProgressHTML(advert.ClicksReceived, advert.ClicksBought);
            }
            catch (Exception ex)
            {
                e.Row.Cells[2].Text = string.Empty;
            }
        }
    }
Beispiel #2
0
    protected void BuyBannerButton_Click(object sender, EventArgs e)
    {
        try
        {
            if (Page.IsValid)
            {
                AppSettings.DemoCheck();

                ErrorMessagePanel.Visible = SuccessMessagePanel.Visible = false;
                var pack = new ExternalBannerAdvertPack(Convert.ToInt32(PacksDDL.SelectedValue));
                ExternalBannerAdvert.Buy(Member.Current, BannerUrlTextBox.Text, Convert.ToInt32(CategoriesDDL.SelectedValue), TempImage, pack, TargetBalanceRadioButtonList.TargetBalance);

                SuccessMessagePanel.Visible = true;
                SuccessMessage.Text         = U6000.REQUESTSENTPLEASEWAIT;
                ClearNewBannerFields(true);
            }
        }
        catch (Exception ex)
        {
            if (ex is MsgException)
            {
                ErrorMessagePanel.Visible = true;
                ErrorMessage.Text         = ex.Message;
            }
            else
            {
                ErrorLogger.Log(ex);
            }

            DeleteOldImage();
            ClearNewBannerFields(false);
        }
    }
Beispiel #3
0
        public static void CreditAfterCampaignRejection(ExternalBannerAdvert advert)
        {
            if (AppSettings.TitanFeatures.ReferralMatrixEnabled)
            {
                return;
            }

            var user = new Member(advert.UserId);

            CreditBalance(user, advert.TargetBalance, advert.PricePaid, "External Banner Advert rejected by administrator");
        }
Beispiel #4
0
    public static void Buy(Member user, string url, int categoryId, Banner image, ExternalBannerAdvertPack pack, PurchaseBalances targetBalance)
    {
        PurchaseOption.ChargeBalance(user, pack.Price, PurchaseOption.Features.ExternalBanner.ToString(), targetBalance, "External Banner advertisement");

        var banner = new ExternalBannerAdvert(user.Id, url, categoryId, pack, image, targetBalance);

        banner.Save();

        History.AddPurchase(user.Name, pack.Price, "Banner campaign");

        MatrixBase.TryAddMemberAndCredit(user, pack.Price, AdvertType.ExternalBanner);
    }
Beispiel #5
0
    protected void BuyBannerView_Activate(object sender, EventArgs e)
    {
        BuyBannersPlaceHolder.Visible = ExternalBannerAdvert.IsBuyingAvaliable();

        if (!BuyBannersPlaceHolder.Visible)
        {
            NewBannerUnavailable.Visible    = true;
            NewBannerUnavailable.HeaderText = U6000.NEWBANNERSUNAVAILABLEHEADER;
            NewBannerUnavailable.Reason     = U6000.NEWBANNERSUNAVAILABLEREASON;
        }
        else
        {
            NewBannerUnavailable.Visible = false;
        }
    }
Beispiel #6
0
    public static void ChangeAllStatuses(IEnumerable <int> externalBannersIds, AdvertStatus status)
    {
        foreach (var externalBannerId in externalBannersIds)
        {
            var externalBanner = new ExternalBannerAdvert(externalBannerId);

            if (status == AdvertStatus.Active)
            {
                externalBanner.Accept();
            }
            else if (status == AdvertStatus.Rejected)
            {
                externalBanner.Reject();
            }
        }
    }
Beispiel #7
0
    protected void ImageUploadButton_Click(object sender, EventArgs e)
    {
        try
        {
            if (!Page.IsValid)
            {
                return;
            }

            if
            (!((Banners.TryCreateBannerFromUrl(BannerFileUrlTextBox.Text, out tempImage) ||
                Banner.TryFromStream(ImageUpload.PostedFile.InputStream, out tempImage))
               &&
               ExternalBannerAdvert.DoesImageHaveValidDimensions(tempImage,
                                                                 new ExternalBannerAdvertPack(Convert.ToInt32(PacksDDL.SelectedValue)))))
            {
                throw new MsgException(U6000.INVALIDBANNERIMAGEORDIMENSIONS);
            }

            //banner
            ErrorMessagePanel.Visible = SuccessMessagePanel.Visible = false;

            //DeleteOldImage();

            TempImage = TempImage.Save(AppSettings.FolderPaths.BannerAdvertImages);

            ImagePreview.ImageUrl = tempImage.Path;

            ClearUpload();
        }
        catch (Exception ex)
        {
            ErrorMessagePanel.Visible = true;
            ErrorMessage.Text         = ex.Message;
            DeleteOldImage();
        }
    }
Beispiel #8
0
 public ExternalBannerManager(string host, int dimensionsId, int publishersWebsiteId)
 {
     PublishersWebsite = PublishersWebsite.GetActiveWebsite(host, publishersWebsiteId);
     Banner            = GetBanner(dimensionsId);
 }