GetBanner() public method

public GetBanner ( int BannerId ) : BannerInfo
BannerId int
return BannerInfo
Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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 VendorsController();
                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);
                            DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, strMessage, ModuleMessage.ModuleMessageType.GreenSuccess);
                        }
                        else
                        {
                            strMessage = Localization.GetString("EmailFailure", LocalResourceFile);
                            strMessage = string.Format(strMessage, errorMsg);
                            DotNetNuke.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 VendorsController();
                                    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);
            }
        }