Ejemplo n.º 1
0
        protected void Page_Load(Object sender, EventArgs e)
        {
            try
            {
                if ((Request.QueryString["vendorid"] != null) && (Request.QueryString["bannerid"] != null))
                {
                    int intVendorId = int.Parse(Request.QueryString["vendorid"]);
                    int intBannerId = int.Parse(Request.QueryString["bannerid"]);

                    string strURL = "~/" + Globals.glbDefaultPage;

                    BannerController objBanners = new BannerController();
                    BannerInfo       objBanner  = objBanners.GetBanner(intBannerId, intVendorId, PortalSettings.PortalId);
                    if (objBanner == null)
                    {
                        //Try a Host Banner
                        objBanner = objBanners.GetBanner(intBannerId, intVendorId, Null.NullInteger);
                    }
                    if (objBanner != null)
                    {
                        if (!Null.IsNull(objBanner.URL))
                        {
                            strURL = Globals.LinkClick(objBanner.URL, -1, -1, false);
                        }
                        else
                        {
                            VendorController objVendors = new VendorController();
                            VendorInfo       objVendor  = objVendors.GetVendor(objBanner.VendorId, PortalSettings.PortalId);
                            if (objVendor == null)
                            {
                                //Try a Host Vendor
                                objVendor = objVendors.GetVendor(objBanner.VendorId, Null.NullInteger);
                            }
                            if (objVendor != null)
                            {
                                if (!String.IsNullOrEmpty(objVendor.Website))
                                {
                                    strURL = Globals.AddHTTP(objVendor.Website);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (Request.UrlReferrer != null)
                        {
                            strURL = Request.UrlReferrer.ToString();
                        }
                    }

                    objBanners.UpdateBannerClickThrough(intBannerId, intVendorId);

                    Response.Redirect(strURL, true);
                }
            }
            catch (Exception exc)  //Page failed to load
            {
                Exceptions.ProcessPageLoadException(exc);
            }
        }
        protected void OnEmailClick(object sender, EventArgs e)
        {
            //send email summary to vendor
            var objBanners = new BannerController();
            var objBanner  = objBanners.GetBanner(BannerId);

            if (objBanner != null)
            {
                var objVendors = new VendorController();
                var objVendor  = objVendors.GetVendor(objBanner.VendorId, PortalId);
                if (objVendor != null)
                {
                    if (!Null.IsNull(objVendor.Email))
                    {
                        var Custom = new ArrayList();
                        Custom.Add(objBanner.BannerName);
                        Custom.Add(objBanner.Description);
                        Custom.Add(objBanner.ImageFile);
                        Custom.Add(objBanner.CPM.ToString("#0.#####"));
                        Custom.Add(objBanner.Impressions.ToString());
                        Custom.Add(objBanner.StartDate.ToShortDateString());
                        Custom.Add(objBanner.EndDate.ToShortDateString());
                        Custom.Add(objBanner.Views.ToString());
                        Custom.Add(objBanner.ClickThroughs.ToString());

                        var errorMsg = Mail.SendMail(PortalSettings.Email,
                                                     objVendor.Email,
                                                     "",
                                                     Localization.GetSystemMessage(PortalSettings, "EMAIL_BANNER_NOTIFICATION_SUBJECT", Localization.GlobalResourceFile, Custom),
                                                     Localization.GetSystemMessage(PortalSettings, "EMAIL_BANNER_NOTIFICATION_BODY", Localization.GlobalResourceFile, Custom),
                                                     "",
                                                     "",
                                                     "",
                                                     "",
                                                     "",
                                                     "");
                        string strMessage;
                        if (String.IsNullOrEmpty(errorMsg))
                        {
                            strMessage = Localization.GetString("EmailSuccess", LocalResourceFile);
                            UI.Skins.Skin.AddModuleMessage(this, strMessage, ModuleMessage.ModuleMessageType.GreenSuccess);
                        }
                        else
                        {
                            strMessage = Localization.GetString("EmailFailure", LocalResourceFile);
                            strMessage = string.Format(strMessage, errorMsg);
                            UI.Skins.Skin.AddModuleMessage(this, strMessage, ModuleMessage.ModuleMessageType.RedError);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void GetBanner()
        {
            // Arrange

            var controller = new BannerController();

            controller.Request = new HttpRequestMessage();

            // Act
            var response = controller.GetBanner("10");

            // Assert
            BannerModel banner;

            Assert.IsTrue(response.TryGetContentValue <BannerModel>(out banner));
            Assert.AreEqual(10, banner.Id);
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(Request.QueryString["BannerId"]))
            {
                _bannerInfo = _bannerController.GetBanner(Int32.Parse(Request.QueryString["BannerId"]));
            }

            if (Page.IsPostBack)
            {
                return;
            }

            LoadTime();
            LoadPriority();

            if (_bannerInfo.BannerId != -1)
            {
                RenderForm();
            }
        }
Ejemplo n.º 5
0
        public void PostBanner()
        {
            // Arrange

            var controller = new BannerController();

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();

            // Act
            var response     = controller.GetBanner("10");
            var actionResult = controller.PostBanner(new BannerModel {
                Id = "Banner1", Html = "Product1", createdOn = DateTime.Now, ModifiedOn = DateTime.Now
            });

            // Assert
            BannerModel banner;

            Assert.IsTrue(response.TryGetContentValue <BannerModel>(out banner));
            Assert.AreEqual(10, banner.Id);
        }
Ejemplo n.º 6
0
        public void Should_return_banner_with_correct_id()
        {
            var banner = new Banner {
                Id = 1
            };

            A.CallTo(() => _repository.TryGet(A <int> .Ignored, out banner))
            .Invokes((call) =>
            {
                var a = call.Arguments.ArgumentNames;
            })
            .Returns(true)
            .AssignsOutAndRefParameters(banner);

            var result = _controller.GetBanner(1) as ObjectResult;

            result.StatusCode.Should().Be(StatusCodes.Status200OK);

            result.Value.Should().BeOfType <Banner>();

            ((Banner)result.Value).Id.Should().Be(1);
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	9/21/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            cmdCancel.Click += OnCancelClick;
            cmdCopy.Click   += OnCopyClick;
            cmdDelete.Click += OnDeleteClick;
            cmdEmail.Click  += OnEmailClick;
            cmdUpdate.Click += OnUpdateClick;
            DNNTxtBannerGroup.PopulateOnDemand += PopulateBannersOnDemand;

            try
            {
                if ((Request.QueryString["VendorId"] != null))
                {
                    VendorId = Int32.Parse(Request.QueryString["VendorId"]);
                }
                if ((Request.QueryString["BannerId"] != null))
                {
                    BannerId = Int32.Parse(Request.QueryString["BannerId"]);
                }

                //this needs to execute always to the client script code is registred in InvokePopupCal
                cmdStartCalendar.NavigateUrl = Calendar.InvokePopupCal(txtStartDate);
                cmdEndCalendar.NavigateUrl   = Calendar.InvokePopupCal(txtEndDate);

                if (Page.IsPostBack == false)
                {
                    ctlImage.FileFilter = Globals.glbImageFileTypes;
                    ClientAPI.AddButtonConfirm(cmdDelete, Localization.GetString("DeleteItem"));

                    var objBannerTypes = new BannerTypeController();
                    //Get the banner types from the database
                    cboBannerType.DataSource = objBannerTypes.GetBannerTypes();
                    cboBannerType.DataBind();

                    var objBanners = new BannerController();
                    if (BannerId != Null.NullInteger)
                    {
                        //Obtain a single row of banner information
                        BannerInfo objBanner = objBanners.GetBanner(BannerId);
                        if (objBanner != null)
                        {
                            txtBannerName.Text = objBanner.BannerName;
                            cboBannerType.Items.FindByValue(objBanner.BannerTypeId.ToString()).Selected = true;
                            DNNTxtBannerGroup.Text = objBanner.GroupName;
                            ctlImage.Url           = objBanner.ImageFile;
                            if (objBanner.Width != 0)
                            {
                                txtWidth.Text = objBanner.Width.ToString();
                            }
                            if (objBanner.Height != 0)
                            {
                                txtHeight.Text = objBanner.Height.ToString();
                            }
                            txtDescription.Text = objBanner.Description;
                            if (!String.IsNullOrEmpty(objBanner.URL))
                            {
                                ctlURL.Url = objBanner.URL;
                            }
                            txtImpressions.Text = objBanner.Impressions.ToString();
                            txtCPM.Text         = objBanner.CPM.ToString();
                            if (!Null.IsNull(objBanner.StartDate))
                            {
                                txtStartDate.Text = objBanner.StartDate.ToShortDateString();
                            }
                            if (!Null.IsNull(objBanner.EndDate))
                            {
                                txtEndDate.Text = objBanner.EndDate.ToShortDateString();
                            }
                            optCriteria.Items.FindByValue(objBanner.Criteria.ToString()).Selected = true;

                            ctlAudit.CreatedByUser = objBanner.CreatedByUser;
                            ctlAudit.CreatedDate   = objBanner.CreatedDate.ToString();

                            var arrBanners = new ArrayList();

                            arrBanners.Add(objBanner);
                            bannersRow.Visible    = true;
                            lstBanners.DataSource = arrBanners;
                            lstBanners.DataBind();
                        }
                        else //security violation attempt to access item not related to this Module
                        {
                            Response.Redirect(EditUrl("VendorId", VendorId.ToString()), true);
                        }
                    }
                    else
                    {
                        txtImpressions.Text = "0";
                        txtCPM.Text         = "0";
                        optCriteria.Items.FindByValue("1").Selected = true;
                        cmdDelete.Visible = false;
                        cmdCopy.Visible   = false;
                        cmdEmail.Visible  = false;
                        ctlAudit.Visible  = false;
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 8
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	9/21/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            cmdCancel.Click += OnCancelClick;
            cmdCopy.Click   += OnCopyClick;
            cmdDelete.Click += OnDeleteClick;
            cmdEmail.Click  += OnEmailClick;
            cmdUpdate.Click += OnUpdateClick;

            try
            {
                if ((Request.QueryString["VendorId"] != null))
                {
                    VendorId = Int32.Parse(Request.QueryString["VendorId"]);
                }
                if ((Request.QueryString["BannerId"] != null))
                {
                    BannerId = Int32.Parse(Request.QueryString["BannerId"]);
                }

                if (Page.IsPostBack == false)
                {
                    ctlImage.FileFilter = Globals.glbImageFileTypes;

                    var objBannerTypes = new BannerTypeController();
                    //Get the banner types from the database
                    cboBannerType.DataSource = objBannerTypes.GetBannerTypes();
                    cboBannerType.DataBind();

                    var objBanners = new BannerController();
                    if (BannerId != Null.NullInteger)
                    {
                        //Obtain a single row of banner information
                        BannerInfo banner = objBanners.GetBanner(BannerId);
                        if (banner != null)
                        {
                            txtBannerName.Text = banner.BannerName;
                            cboBannerType.Items.FindByValue(banner.BannerTypeId.ToString()).Selected = true;
                            DNNTxtBannerGroup.Text = banner.GroupName;
                            ctlImage.Url           = banner.ImageFile;
                            if (banner.Width != 0)
                            {
                                txtWidth.Text = banner.Width.ToString();
                            }
                            if (banner.Height != 0)
                            {
                                txtHeight.Text = banner.Height.ToString();
                            }
                            txtDescription.Text = banner.Description;
                            if (!String.IsNullOrEmpty(banner.URL))
                            {
                                ctlURL.Url = banner.URL;
                            }
                            txtImpressions.Text = banner.Impressions.ToString();
                            txtCPM.Text         = banner.CPM.ToString();

                            StartDatePicker.SelectedDate = Null.IsNull(banner.StartDate) ? (DateTime?)null : banner.StartDate;
                            EndDatePicker.SelectedDate   = Null.IsNull(banner.EndDate) ? (DateTime?)null : banner.EndDate;

                            optCriteria.Items.FindByValue(banner.Criteria.ToString()).Selected = true;

                            ctlAudit.CreatedByUser = banner.CreatedByUser;
                            ctlAudit.CreatedDate   = banner.CreatedDate.ToString();

                            var arrBanners = new ArrayList();

                            arrBanners.Add(banner);
                            bannersRow.Visible    = true;
                            lstBanners.DataSource = arrBanners;
                            lstBanners.DataBind();
                        }
                        else //security violation attempt to access item not related to this Module
                        {
                            Response.Redirect(EditUrl("VendorId", VendorId.ToString()), true);
                        }
                    }
                    else
                    {
                        txtImpressions.Text = "0";
                        txtCPM.Text         = "0";
                        optCriteria.Items.FindByValue("1").Selected = true;
                        cmdDelete.Visible = false;
                        cmdCopy.Visible   = false;
                        cmdEmail.Visible  = false;
                        ctlAudit.Visible  = false;
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 9
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //exit without incrementing count if page is indexed by crawler
            if (Request.Browser.Crawler)
            {
                return;
            }
            try
            {
                if ((Request.QueryString["vendorid"] != null) && (Request.QueryString["bannerid"] != null))
                {
                    int intVendorId = -1;
                    if (Regex.IsMatch(Request.QueryString["vendorid"], "^\\d+$"))
                    {
                        intVendorId = int.Parse(Request.QueryString["vendorid"]);
                    }
                    int intBannerId = -1;
                    if (Regex.IsMatch(Request.QueryString["bannerid"], "^\\d+$"))
                    {
                        intBannerId = int.Parse(Request.QueryString["bannerid"]);
                    }
                    int intPortalId = -1;
                    if ((Request.QueryString["portalid"] != null))
                    {
                        if (Regex.IsMatch(Request.QueryString["portalid"], "^\\d+$"))
                        {
                            intPortalId = int.Parse(Request.QueryString["portalid"]);
                        }
                    }
                    else
                    {
                        intPortalId = Globals.GetPortalSettings().PortalId;
                    }
                    if (intBannerId != -1 && intVendorId != -1 && intPortalId != -1)
                    {
                        string strURL = "~/" + Globals.glbDefaultPage;

                        var        objBanners = new BannerController();
                        BannerInfo objBanner  = objBanners.GetBanner(intBannerId);
                        if (objBanner != null)
                        {
                            if (objBanners.IsBannerActive(objBanner))
                            {
                                if (!Null.IsNull(objBanner.URL))
                                {
                                    strURL = Globals.LinkClick(objBanner.URL, -1, -1, false);
                                }
                                else
                                {
                                    var        objVendors = new VendorController();
                                    VendorInfo objVendor  = objVendors.GetVendor(objBanner.VendorId, intPortalId);
                                    if (objVendor == null)
                                    {
                                        objVendor = objVendors.GetVendor(objBanner.VendorId, Null.NullInteger);
                                    }
                                    if (objVendor != null)
                                    {
                                        if (!String.IsNullOrEmpty(objVendor.Website))
                                        {
                                            strURL = Globals.AddHTTP(objVendor.Website);
                                        }
                                    }
                                }
                                objBanners.UpdateBannerClickThrough(intBannerId, intVendorId);
                            }
                        }
                        else if (Request.UrlReferrer != null)
                        {
                            strURL = Request.UrlReferrer.ToString();
                        }
                        Response.Redirect(strURL, true);
                    }
                }
            }
            catch (ThreadAbortException)
            {
                //ignore the abort thread expcetion.
            }
            catch (Exception exc) //Page failed to load
            {
                Exceptions.ProcessPageLoadException(exc);
            }
        }