Inheritance: IUpgradeable
Exemple #1
0
        private void SetDataSource()
        {
            CreateLetterSearch();

            bool isUnauthorized = false;

            if (_searchFilter.Equals(Localization.GetString("All"), StringComparison.InvariantCultureIgnoreCase))
            {
                _searchFilter = "";
            }
            else if (_searchFilter.Equals(Localization.GetString("Unauthorized"), StringComparison.InvariantCultureIgnoreCase))
            {
                _searchFilter  = "";
                isUnauthorized = true;
            }

            //Get the list of vendors from the database
            var totalRecords     = 0;
            var vendorController = new Dnn.Modules.Vendors.Components.VendorsController();
            int portal           = Globals.IsHostTab(PortalSettings.ActiveTab.TabID) ? Null.NullInteger : PortalId;

            if (String.IsNullOrEmpty(_searchFilter))
            {
                grdVendors.DataSource       = vendorController.GetVendors(portal, isUnauthorized, grdVendors.CurrentPageIndex, grdVendors.PageSize, ref totalRecords);
                grdVendors.VirtualItemCount = totalRecords;
            }
            else
            {
                if (_searchField == "email")
                {
                    grdVendors.DataSource       = vendorController.GetVendorsByEmail(_searchFilter, portal, grdVendors.CurrentPageIndex, grdVendors.PageSize, ref totalRecords);
                    grdVendors.VirtualItemCount = totalRecords;
                }
                else
                {
                    grdVendors.DataSource       = vendorController.GetVendorsByName(_searchFilter, portal, grdVendors.CurrentPageIndex, grdVendors.PageSize, ref totalRecords);
                    grdVendors.VirtualItemCount = totalRecords;
                }
            }
        }
        private void SetDataSource()
        {
            CreateLetterSearch();

            bool isUnauthorized = false;
            if (_searchFilter.Equals(Localization.GetString("All"), StringComparison.InvariantCultureIgnoreCase))
            {
                _searchFilter = "";
            }
            else if (_searchFilter.Equals(Localization.GetString("Unauthorized"), StringComparison.InvariantCultureIgnoreCase))
            {
                _searchFilter = "";
                isUnauthorized = true;
            }
			
            //Get the list of vendors from the database
            var totalRecords = 0;
            var vendorController = new Dnn.Modules.Vendors.Components.VendorsController();
            int portal = Globals.IsHostTab(PortalSettings.ActiveTab.TabID) ? Null.NullInteger : PortalId;
            
			if (String.IsNullOrEmpty(_searchFilter))
			{
			    grdVendors.DataSource = vendorController.GetVendors(portal, isUnauthorized, grdVendors.CurrentPageIndex, grdVendors.PageSize, ref totalRecords);
			    grdVendors.VirtualItemCount = totalRecords;
			}
            else
            {
                if (_searchField == "email")
                {
                    grdVendors.DataSource = vendorController.GetVendorsByEmail(_searchFilter, portal, grdVendors.CurrentPageIndex, grdVendors.PageSize, ref totalRecords);
                    grdVendors.VirtualItemCount = totalRecords;
                }
                else
                {
                    grdVendors.DataSource = vendorController.GetVendorsByName(_searchFilter, portal, grdVendors.CurrentPageIndex, grdVendors.PageSize, ref totalRecords);
                    grdVendors.VirtualItemCount = totalRecords;
                }
            }
        }
		void cmdDeleteUnAuthorized_Click(object sender, EventArgs e)
        {
            try
            {
                var objVendors = new VendorsController();
                if (Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
                {
                    objVendors.DeleteVendors();
                }
                else
                {
                    objVendors.DeleteVendors(PortalId);
                }
                Response.Redirect(Globals.NavigateURL(), true);
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdSend_Click runs when the Send Notification Button is clicked
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/21/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void OnSendClick(object sender, EventArgs e)
        {
            var objVendors = new VendorsController();

            var objVendor = objVendors.GetVendor(VendorId, PortalId);
            if (objVendor != null)
            {
                if (!Null.IsNull(objVendor.Email))
                {
                    var custom = new ArrayList
                                     {
                                         objVendor.VendorName,
                                         Globals.GetPortalDomainName(PortalSettings.PortalAlias.HTTPAlias, Request, true) + "/" + Globals.glbDefaultPage + "?AffiliateId=" + AffiliateId
                                     };
                    var errorMsg = Mail.SendMail(PortalSettings.Email,
                                                    objVendor.Email,
                                                    "",
                                                    Localization.GetSystemMessage(PortalSettings, "EMAIL_AFFILIATE_NOTIFICATION_SUBJECT"),
                                                    Localization.GetSystemMessage(PortalSettings, "EMAIL_AFFILIATE_NOTIFICATION_BODY", Localization.GlobalResourceFile, custom),
                                                    "",
                                                    "",
                                                    "",
                                                    "",
                                                    "",
                                                    "");
                    string strMessage;
                    if (String.IsNullOrEmpty(errorMsg))
                    {
                        strMessage = Localization.GetString("NotificationSuccess", LocalResourceFile);
                        DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, strMessage, ModuleMessage.ModuleMessageType.GreenSuccess);
                    }
                    else
                    {
                        strMessage = Localization.GetString("NotificationFailure", LocalResourceFile);
                        strMessage = string.Format(strMessage, errorMsg);
                        DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, strMessage, ModuleMessage.ModuleMessageType.RedError);
                    }
                }
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdUpdate_Click runs when the Update button is clicked.
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/17/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void OnUpdateClick(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    int portalID;
					if (Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
                    {
                        portalID = -1;
                    }
                    else
                    {
                        portalID = PortalId;
                    }
                    var objVendors = new VendorsController();
                    var objVendor = new VendorInfo
                                        {
                                            PortalId = portalID,
                                            VendorId = VendorID,
                                            VendorName = txtVendorName.Text,
                                            Unit = addresssVendor.Unit,
                                            Street = addresssVendor.Street,
                                            City = addresssVendor.City,
                                            Region = addresssVendor.Region,
                                            Country = addresssVendor.Country,
                                            PostalCode = addresssVendor.Postal,
                                            Telephone = addresssVendor.Telephone,
                                            Fax = addresssVendor.Fax,
                                            Cell = addresssVendor.Cell,
                                            Email = txtEmail.Text,
                                            Website = txtWebsite.Text,
                                            FirstName = txtFirstName.Text,
                                            LastName = txtLastName.Text,
                                            UserName = UserInfo.UserID.ToString(),
                                            LogoFile = ctlLogo.Url,
                                            KeyWords = txtKeyWords.Text,
                                            Authorized = chkAuthorized.Checked
                                        };
                    if (VendorID == -1)
                    {
                        try
                        {
                            VendorID = objVendors.AddVendor(objVendor);
                        }
                        catch(Exception exc)
                        {
                            //AddModuleMessage("ErrorAddVendor", ModuleMessage.ModuleMessageType.RedError);
                            Exceptions.ProcessModuleLoadException(this, exc);
                            return;
                        }
                    }
                    else
                    {
                        VendorInfo vendorCheck = objVendors.GetVendor(VendorID, portalID);
                        if (vendorCheck != null)
                        {
                            objVendors.UpdateVendor(objVendor);
                        }
                        else
                        {
                            Response.Redirect(Globals.NavigateURL());
                        }
                    }

                    if (cmdUpdate.Text == "Signup")
                    {
                        var custom = new ArrayList();
                        custom.Add(DateTime.Now.ToString());
                        custom.Add(txtVendorName.Text);
                        custom.Add(txtFirstName.Text);
                        custom.Add(txtLastName.Text);
                        custom.Add(addresssVendor.Unit);
                        custom.Add(addresssVendor.Street);
                        custom.Add(addresssVendor.City);
                        custom.Add(addresssVendor.Region);
                        custom.Add(addresssVendor.Country);
                        custom.Add(addresssVendor.Postal);
                        custom.Add(addresssVendor.Telephone);
                        custom.Add(addresssVendor.Fax);
                        custom.Add(addresssVendor.Cell);
                        custom.Add(txtEmail.Text);
                        custom.Add(txtWebsite.Text);
                        //send email to Admin
                        Mail.SendEmail(PortalSettings.Email,
                                       PortalSettings.Email,
                                       Localization.GetSystemMessage(PortalSettings, "EMAIL_VENDOR_REGISTRATION_ADMINISTRATOR_SUBJECT"),
                                       Localization.GetSystemMessage(PortalSettings, "EMAIL_VENDOR_REGISTRATION_ADMINISTRATOR_BODY", Localization.GlobalResourceFile, custom));


                        //send email to vendor
                        custom.Clear();
                        custom.Add(txtFirstName.Text);
                        custom.Add(txtLastName.Text);
                        custom.Add(txtVendorName.Text);

                        Mail.SendEmail(PortalSettings.Email,
                                       txtEmail.Text,
                                       Localization.GetSystemMessage(PortalSettings, "EMAIL_VENDOR_REGISTRATION_SUBJECT"),
                                       Localization.GetSystemMessage(PortalSettings, "EMAIL_VENDOR_REGISTRATION_BODY", Localization.GlobalResourceFile, custom));


                        ReturnUrl(txtVendorName.Text.Substring(0, 1));
                    }
                    else
                    {
                        ReturnUrl(Convert.ToString(ViewState["filter"]));
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// cmdDelete_Click runs when the Delete button is clicked.
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <history>
 /// 	[cnurse]	9/17/2004	Updated to reflect design changes for Help, 508 support
 ///                       and localisation
 /// </history>
 /// -----------------------------------------------------------------------------
 protected void OnDeleteClick(object sender, EventArgs e)
 {
     try
     {
         if (VendorID != -1)
         {
             var objVendors = new VendorsController();
             objVendors.DeleteVendor(VendorID);
         }
         Response.Redirect(Globals.NavigateURL());
     }
     catch (Exception exc) //Module failed to load
     {
         Exceptions.ProcessModuleLoadException(this, exc);
     }
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/17/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;
            cmdDelete.Click += OnDeleteClick;
            cmdUpdate.Click += OnUpdateClick;

            try
            {
                var blnBanner = false;
                var blnSignup = false;

                if ((Request.QueryString["VendorID"] != null))
                {
                    VendorID = Int32.Parse(Request.QueryString["VendorID"]);
                }
                if (Request.QueryString["ctl"] != null && VendorID == -1)
                {
                    blnSignup = true;
                }
                if (Request.QueryString["banner"] != null)
                {
                    blnBanner = true;
                }
                if (Page.IsPostBack == false)
                {
                    ctlLogo.FileFilter = Globals.glbImageFileTypes;

                    addresssVendor.ModuleId = ModuleId;
                    addresssVendor.StartTabIndex = 4;

                    var objVendors = new VendorsController();
                    if (VendorID != -1)
                    {
                        VendorInfo objVendor;
						if (Globals.IsHostTab(PortalSettings.ActiveTab.TabID) && UserInfo.IsSuperUser)
                        {
							//Get Host Vendor
                            objVendor = objVendors.GetVendor(VendorID, Null.NullInteger);
                        }
                        else
                        {
							//Get Portal Vendor
                            objVendor = objVendors.GetVendor(VendorID, PortalId);
                        }
                        if (objVendor != null)
                        {
                            txtVendorName.Text = objVendor.VendorName;
                            txtFirstName.Text = objVendor.FirstName;
                            txtLastName.Text = objVendor.LastName;
                            ctlLogo.Url = objVendor.LogoFile;
                            addresssVendor.Unit = objVendor.Unit;
                            addresssVendor.Street = objVendor.Street;
                            addresssVendor.City = objVendor.City;
                            addresssVendor.Region = objVendor.Region;
                            addresssVendor.Country = objVendor.Country;
                            addresssVendor.Postal = objVendor.PostalCode;
                            addresssVendor.Telephone = objVendor.Telephone;
                            addresssVendor.Fax = objVendor.Fax;
                            addresssVendor.Cell = objVendor.Cell;
                            txtEmail.Text = objVendor.Email;
                            txtWebsite.Text = objVendor.Website;
                            chkAuthorized.Checked = objVendor.Authorized;
                            txtKeyWords.Text = objVendor.KeyWords;

                            ctlAudit.CreatedByUser = objVendor.CreatedByUser;
                            ctlAudit.CreatedDate = objVendor.CreatedDate.ToString();
                        }

                        //use dispatch method to load modules
                        var banners = ControlUtilities.LoadControl<Banners>(this, TemplateSourceDirectory.Remove(0, Globals.ApplicationPath.Length) + "/Banners.ascx");
                        banners.ID = "/Banners.ascx";
                        banners.VendorID = VendorID;
                        banners.ModuleConfiguration = ModuleConfiguration;
                        divBanners.Controls.Add(banners);


                        var affiliates = ControlUtilities.LoadControl<Affiliates>(this, TemplateSourceDirectory.Remove(0, Globals.ApplicationPath.Length) + "/Affiliates.ascx");
                        affiliates.ID = "/Affiliates.ascx";
                        affiliates.VendorID = VendorID;
                        affiliates.ModuleConfiguration = ModuleConfiguration;
                        divAffiliates.Controls.Add(affiliates);
                    }
                    else
                    {
                        chkAuthorized.Checked = true;
                        ctlAudit.Visible = false;
                        cmdDelete.Visible = false;
                        pnlBanners.Visible = false;
                        pnlAffiliates.Visible = false;
                    }
                    if (blnSignup || blnBanner)
                    {
                        rowVendor1.Visible = false;
                        rowVendor2.Visible = false;
                        pnlVendor.Visible = false;
                        cmdDelete.Visible = false;
                        ctlAudit.Visible = false;
                        if (blnBanner)
                        {
                            cmdUpdate.Visible = false;
                        }
                        else
                        {
                            cmdUpdate.Text = "Signup";
                        }
                    }
                    else
                    {
                        TabInfo objTab = TabController.Instance.GetTabByName("Vendors", Globals.IsHostTab(PortalSettings.ActiveTab.TabID) ? Null.NullInteger : PortalId);
                        if (objTab != null)
                        {
                            ViewState["filter"] = Request.QueryString["filter"];
                        }
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, 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 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);
            }
        }