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 );
            }
        }
Ejemplo n.º 2
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;
            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.º 3
0
        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);
                        }
                    }
                }
            }
        }
        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 (Exception exc) //Page failed to load
            {
                Exceptions.ProcessPageLoadException(exc);
            }
        }