示例#1
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdUpdate_Click runs when the Update 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 OnUpdateClick(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                var objAffiliate = new AffiliateInfo
                {
                    AffiliateId = AffiliateId,
                    VendorId    = VendorId,
                    StartDate   = StartDatePicker.SelectedDate.HasValue ? StartDatePicker.SelectedDate.Value : Null.NullDate,
                    EndDate     = EndDatePicker.SelectedDate.HasValue ? EndDatePicker.SelectedDate.Value : Null.NullDate,
                    CPC         = double.Parse(txtCPC.Text),
                    CPA         = double.Parse(txtCPA.Text)
                };
                var objAffiliates = new AffiliateController();

                if (AffiliateId == -1)
                {
                    objAffiliates.AddAffiliate(objAffiliate);
                }
                else
                {
                    objAffiliates.UpdateAffiliate(objAffiliate);
                }

                //Redirect back to the portal home page
                Response.Redirect(EditUrl("VendorId", VendorId.ToString()), true);
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <remarks>
        /// - manage affiliates
        /// - log visit to site
        /// </remarks>
        /// <history>
        ///     [sun1]	1/19/2004	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void ManageRequest()
        {
            //affiliate processing
            int affiliateId = -1;

            if (Request.QueryString["AffiliateId"] != null)
            {
                if (Regex.IsMatch(Request.QueryString["AffiliateId"], "^\\d+$"))
                {
                    affiliateId = Int32.Parse(Request.QueryString["AffiliateId"]);
                    var objAffiliates = new AffiliateController();
                    objAffiliates.UpdateAffiliateStats(affiliateId, 1, 0);

                    //save the affiliateid for acquisitions
                    if (Request.Cookies["AffiliateId"] == null) //do not overwrite
                    {
                        var objCookie = new HttpCookie("AffiliateId", affiliateId.ToString("D"))
                        {
                            Expires = DateTime.Now.AddYears(1),
                            Path    = (!string.IsNullOrEmpty(Globals.ApplicationPath) ? Globals.ApplicationPath : "/")
                        };
                        Response.Cookies.Add(objCookie);
                    }
                }
            }

            //site logging
            if (PortalSettings.SiteLogHistory != 0)
            {
                //get User ID

                //URL Referrer
                string urlReferrer = "";
                try
                {
                    if (Request.UrlReferrer != null)
                    {
                        urlReferrer = Request.UrlReferrer.ToString();
                    }
                }
                catch (Exception exc)
                {
                    Logger.Error(exc);
                }
                string strSiteLogStorage = Host.SiteLogStorage;
                int    intSiteLogBuffer  = Host.SiteLogBuffer;

                //log visit
                var objSiteLogs = new SiteLogController();

                UserInfo objUserInfo = UserController.Instance.GetCurrentUserInfo();
                objSiteLogs.AddSiteLog(PortalSettings.PortalId, objUserInfo.UserID, urlReferrer, Request.Url.ToString(),
                                       Request.UserAgent, Request.UserHostAddress, Request.UserHostName,
                                       PortalSettings.ActiveTab.TabID, affiliateId, intSiteLogBuffer,
                                       strSiteLogStorage);
            }
        }
        /// -----------------------------------------------------------------------------
        /// <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;
            cmdDelete.Click += OnDeleteClick;
            cmdSend.Click   += OnSendClick;
            cmdUpdate.Click += OnUpdateClick;

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

            if ((Request.QueryString["AffilId"] != null))
            {
                AffiliateId = Int32.Parse(Request.QueryString["AffilId"]);
            }

            //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)
            {
                var objAffiliates = new AffiliateController();
                if (AffiliateId != Null.NullInteger)
                {
                    //Obtain a single row of banner information
                    var objAffiliate = objAffiliates.GetAffiliate(AffiliateId, VendorId, PortalId);
                    if (objAffiliate != null)
                    {
                        if (!Null.IsNull(objAffiliate.StartDate))
                        {
                            txtStartDate.Text = objAffiliate.StartDate.ToShortDateString();
                        }
                        if (!Null.IsNull(objAffiliate.EndDate))
                        {
                            txtEndDate.Text = objAffiliate.EndDate.ToShortDateString();
                        }
                        txtCPC.Text = objAffiliate.CPC.ToString("#0.0####");
                        txtCPA.Text = objAffiliate.CPA.ToString("#0.0####");
                    }
                    else //security violation attempt to access item not related to this Module
                    {
                        Response.Redirect(EditUrl("VendorId", VendorId.ToString()), true);
                    }
                }
                else
                {
                    txtCPC.Text = 0.ToString("#0.0####");
                    txtCPA.Text = 0.ToString("#0.0####");

                    cmdDelete.Visible = false;
                }
            }
        }
示例#4
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdDelete_Click runs when the Delete 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 OnDeleteClick(object sender, EventArgs e)
        {
            if (AffiliateId != -1)
            {
                var objAffiliates = new AffiliateController();
                objAffiliates.DeleteAffiliate(AffiliateId);

                //Redirect back to the portal home page
                Response.Redirect(EditUrl("VendorId", VendorId.ToString()), true);
            }
        }
示例#5
0
        /// <remarks>
        /// - manage affiliates
        /// - log visit to site
        /// </remarks>
        /// <history>
        ///     [sun1]	1/19/2004	Created
        /// </history>
        private void ManageRequest()
        {
            // affiliate processing
            int AffiliateId = -1;

            if (Request.QueryString["AffiliateId"] != null)
            {
                if (Int32.TryParse(Request.QueryString["AffiliateId"], out AffiliateId))
                {
                    AffiliateId = int.Parse(Request.QueryString["AffiliateId"]);
                    AffiliateController objAffiliates = new AffiliateController();
                    objAffiliates.UpdateAffiliateStats(AffiliateId, 1, 0);

                    // save the affiliateid for acquisitions
                    if (Request.Cookies["AffiliateId"] == null)  // do not overwrite
                    {
                        HttpCookie objCookie = new HttpCookie("AffiliateId");
                        objCookie.Value   = AffiliateId.ToString();
                        objCookie.Expires = DateTime.Now.AddYears(1);   // persist cookie for one year
                        Response.Cookies.Add(objCookie);
                    }
                }
            }

            // site logging
            if (PortalSettings.SiteLogHistory != 0)
            {
                // get User ID

                // URL Referrer
                string URLReferrer = "";
                if (Request.UrlReferrer != null)
                {
                    URLReferrer = Request.UrlReferrer.ToString();
                }

                string strSiteLogStorage = "D";
                if (Convert.ToString(Globals.HostSettings["SiteLogStorage"]) != "")
                {
                    strSiteLogStorage = Convert.ToString(Globals.HostSettings["SiteLogStorage"]);
                }
                int intSiteLogBuffer = 1;
                if (Convert.ToString(Globals.HostSettings["SiteLogBuffer"]) != "")
                {
                    intSiteLogBuffer = int.Parse(Convert.ToString(Globals.HostSettings["SiteLogBuffer"]));
                }

                // log visit
                SiteLogController objSiteLogs = new SiteLogController();

                UserInfo objUserInfo = UserController.GetCurrentUserInfo();
                objSiteLogs.AddSiteLog(PortalSettings.PortalId, objUserInfo.UserID, URLReferrer, Request.Url.ToString(), Request.UserAgent, Request.UserHostAddress, Request.UserHostName, PortalSettings.ActiveTab.TabID, AffiliateId, intSiteLogBuffer, strSiteLogStorage);
            }
        }
示例#6
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 void Page_Load(Object sender, EventArgs e)
        {
            if ((Request.QueryString["VendorId"] != null))
            {
                VendorId = int.Parse(Request.QueryString["VendorId"]);
            }

            if ((Request.QueryString["AffilId"] != null))
            {
                AffiliateId = int.Parse(Request.QueryString["AffilId"]);
            }

            //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)
            {
                ClientAPI.AddButtonConfirm(cmdDelete, Localization.GetString("DeleteItem"));

                AffiliateController objAffiliates = new AffiliateController();
                if (AffiliateId != Null.NullInteger)
                {
                    // Obtain a single row of banner information
                    AffiliateInfo objAffiliate = objAffiliates.GetAffiliate(AffiliateId, VendorId, PortalId);

                    if (objAffiliate != null)
                    {
                        if (!Null.IsNull(objAffiliate.StartDate))
                        {
                            txtStartDate.Text = objAffiliate.StartDate.ToShortDateString();
                        }
                        if (!Null.IsNull(objAffiliate.EndDate))
                        {
                            txtEndDate.Text = objAffiliate.EndDate.ToShortDateString();
                        }
                        txtCPC.Text = objAffiliate.CPC.ToString("#0.#####");
                        txtCPA.Text = objAffiliate.CPA.ToString("#0.#####");
                    }
                    else // security violation attempt to access item not related to this Module
                    {
                        Response.Redirect(EditUrl("VendorId", VendorId.ToString()), true);
                    }
                }
                else
                {
                    txtCPC.Text = "0.00";
                    txtCPA.Text = "0.00";

                    cmdDelete.Visible = false;
                }
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// BindData gets the affiliates from the Database and binds them to the DataGrid
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	9/17/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        private void BindData()
        {
            var objAffiliates = new AffiliateController();

            //Localize the Grid
            Localization.LocalizeDataGrid(ref grdAffiliates, LocalResourceFile);

            grdAffiliates.DataSource = objAffiliates.GetAffiliates(VendorID);
            grdAffiliates.DataBind();

            cmdAdd.NavigateUrl = FormatURL("AffilId", "-1");
        }
示例#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;
            cmdDelete.Click += OnDeleteClick;
            cmdSend.Click   += OnSendClick;
            cmdUpdate.Click += OnUpdateClick;

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

            if ((Request.QueryString["AffilId"] != null))
            {
                AffiliateId = Int32.Parse(Request.QueryString["AffilId"]);
            }

            if (Page.IsPostBack == false)
            {
                var affiliateController = new AffiliateController();
                if (AffiliateId != Null.NullInteger)
                {
                    //Obtain a single row of banner information
                    var affiliate = affiliateController.GetAffiliate(AffiliateId, VendorId, PortalId);
                    if (affiliate != null)
                    {
                        StartDatePicker.SelectedDate = Null.IsNull(affiliate.StartDate) ? (DateTime?)null : affiliate.StartDate;
                        EndDatePicker.SelectedDate   = Null.IsNull(affiliate.EndDate) ? (DateTime?)null : affiliate.EndDate;

                        txtCPC.Text = affiliate.CPC.ToString("#0.0####");
                        txtCPA.Text = affiliate.CPA.ToString("#0.0####");
                    }
                    else //security violation attempt to access item not related to this Module
                    {
                        Response.Redirect(EditUrl("VendorId", VendorId.ToString()), true);
                    }
                }
                else
                {
                    txtCPC.Text = 0.ToString("#0.0####");
                    txtCPA.Text = 0.ToString("#0.0####");

                    cmdDelete.Visible = false;
                }
            }
        }
示例#9
0
        /// <summary>
        /// cmdUpdate_Click runs when the Update 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 cmdUpdate_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                AffiliateInfo objAffiliate = new AffiliateInfo();

                objAffiliate.AffiliateId = AffiliateId;
                objAffiliate.VendorId    = VendorId;
                if (!String.IsNullOrEmpty(txtStartDate.Text))
                {
                    objAffiliate.StartDate = DateTime.Parse(txtStartDate.Text);
                }
                else
                {
                    objAffiliate.StartDate = Null.NullDate;
                }
                if (!String.IsNullOrEmpty(txtEndDate.Text))
                {
                    objAffiliate.EndDate = DateTime.Parse(txtEndDate.Text);
                }
                else
                {
                    objAffiliate.EndDate = Null.NullDate;
                }
                objAffiliate.CPC = double.Parse(txtCPC.Text);
                objAffiliate.CPA = double.Parse(txtCPA.Text);

                AffiliateController objAffiliates = new AffiliateController();

                if (AffiliateId == -1)
                {
                    objAffiliates.AddAffiliate(objAffiliate);
                }
                else
                {
                    objAffiliates.UpdateAffiliate(objAffiliate);
                }

                // Redirect back to the portal home page
                Response.Redirect(EditUrl("VendorId", VendorId.ToString()), true);
            }
        }
示例#10
0
        /// <summary>
        /// UserCreateCompleted runs when a new user has been Created
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	3/06/2006	created
        /// </history>
        protected void UserCreateCompleted(object sender, User.UserCreatedEventArgs e)
        {
            string strMessage = "";

            try
            {
                if (e.CreateStatus == UserCreateStatus.Success)
                {
                    if (IsRegister)
                    {
                        // send notification to portal administrator of new user registration
                        Mail.SendMail(User, MessageType.UserRegistrationAdmin, PortalSettings);

                        // complete registration

                        switch (PortalSettings.UserRegistration)
                        {
                        case (int)Globals.PortalRegistrationType.PrivateRegistration:

                            Mail.SendMail(User, MessageType.UserRegistrationPrivate, PortalSettings);

                            //show a message that a portal administrator has to verify the user credentials
                            strMessage = string.Format(Localization.GetString("PrivateConfirmationMessage", this.LocalResourceFile), User.Email);
                            break;

                        case (int)Globals.PortalRegistrationType.PublicRegistration:

                            Mail.SendMail(User, MessageType.UserRegistrationPublic, PortalSettings);

                            UserLoginStatus loginStatus = 0;
                            UserController.UserLogin(PortalSettings.PortalId, User.Username, User.Membership.Password, "", PortalSettings.PortalName, "", ref loginStatus, false);
                            break;

                        case (int)Globals.PortalRegistrationType.VerifiedRegistration:

                            Mail.SendMail(User, MessageType.UserRegistrationVerified, PortalSettings);

                            //show a message that an email has been send with the registration details
                            strMessage = string.Format(Localization.GetString("VerifiedConfirmationMessage", this.LocalResourceFile), User.Email);
                            break;
                        }

                        // affiliate
                        if (!Null.IsNull(User.AffiliateID))
                        {
                            AffiliateController objAffiliates = new AffiliateController();
                            objAffiliates.UpdateAffiliateStats(User.AffiliateID, 0, 1);
                        }

                        //store preferredlocale in cookie
                        Localization.SetLanguage(User.Profile.PreferredLocale);

                        AddLocalizedModuleMessage(strMessage, ModuleMessageType.GreenSuccess, (strMessage.Length > 0));
                    }
                    else
                    {
                        if (e.Notify)
                        {
                            //Send Notification to User
                            if (PortalSettings.UserRegistration == (int)Globals.PortalRegistrationType.VerifiedRegistration)
                            {
                                Mail.SendMail(User, MessageType.UserRegistrationVerified, PortalSettings);
                            }
                            else
                            {
                                Mail.SendMail(User, MessageType.UserRegistrationPublic, PortalSettings);
                            }
                        }
                    }

                    //Log Event to Event Log
                    EventLogController objEventLog = new EventLogController();
                    objEventLog.AddLog(User, PortalSettings, UserId, User.Username, EventLogController.EventLogType.USER_CREATED);

                    if (IsRegister)
                    {
                        //Response.Redirect( RedirectURL, true );
                        if (string.IsNullOrEmpty(strMessage))
                        {
                            Response.Redirect(RedirectURL, true);
                        }
                        else
                        {
                            DisableForm();
                            pnlRegister.Visible = false;
                        }
                    }
                    else
                    {
                        Response.Redirect(ReturnUrl, true);
                    }
                }
                else
                {
                    AddLocalizedModuleMessage(UserController.GetUserCreateStatus(e.CreateStatus), ModuleMessageType.RedError, true);
                }
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
示例#11
0
        protected string CompleteUserCreation(UserCreateStatus createStatus, UserInfo newUser, bool notify, bool register)
        {
            var strMessage = "";
            var message    = ModuleMessage.ModuleMessageType.RedError;

            if (register)
            {
                //send notification to portal administrator of new user registration
                //check the receive notification setting first, but if register type is Private, we will always send the notification email.
                //because the user need administrators to do the approve action so that he can continue use the website.
                if (PortalSettings.EnableRegisterNotification || PortalSettings.UserRegistration == (int)Globals.PortalRegistrationType.PrivateRegistration)
                {
                    strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationAdmin, PortalSettings);
                    SendAdminNotification(newUser, PortalSettings);
                }

                var loginStatus = UserLoginStatus.LOGIN_FAILURE;

                //complete registration
                switch (PortalSettings.UserRegistration)
                {
                case (int)Globals.PortalRegistrationType.PrivateRegistration:
                    strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationPrivate, PortalSettings);

                    //show a message that a portal administrator has to verify the user credentials
                    if (string.IsNullOrEmpty(strMessage))
                    {
                        strMessage += string.Format(Localization.GetString("PrivateConfirmationMessage", Localization.SharedResourceFile), newUser.Email);
                        message     = ModuleMessage.ModuleMessageType.GreenSuccess;
                    }
                    break;

                case (int)Globals.PortalRegistrationType.PublicRegistration:
                    Mail.SendMail(newUser, MessageType.UserRegistrationPublic, PortalSettings);
                    UserController.UserLogin(PortalSettings.PortalId, newUser.Username, newUser.Membership.Password, "", PortalSettings.PortalName, "", ref loginStatus, false);
                    break;

                case (int)Globals.PortalRegistrationType.VerifiedRegistration:
                    Mail.SendMail(newUser, MessageType.UserRegistrationVerified, PortalSettings);
                    UserController.UserLogin(PortalSettings.PortalId, newUser.Username, newUser.Membership.Password, "", PortalSettings.PortalName, "", ref loginStatus, false);
                    break;
                }
                //affiliate
                if (!Null.IsNull(User.AffiliateID))
                {
                    var objAffiliates = new AffiliateController();
                    objAffiliates.UpdateAffiliateStats(newUser.AffiliateID, 0, 1);
                }
                //store preferredlocale in cookie
                Localization.SetLanguage(newUser.Profile.PreferredLocale);
                if (IsRegister && message == ModuleMessage.ModuleMessageType.RedError)
                {
                    AddLocalizedModuleMessage(string.Format(Localization.GetString("SendMail.Error", Localization.SharedResourceFile), strMessage), message, (!String.IsNullOrEmpty(strMessage)));
                }
                else
                {
                    AddLocalizedModuleMessage(strMessage, message, (!String.IsNullOrEmpty(strMessage)));
                }
            }
            else
            {
                if (notify)
                {
                    //Send Notification to User
                    if (PortalSettings.UserRegistration == (int)Globals.PortalRegistrationType.VerifiedRegistration)
                    {
                        strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationVerified, PortalSettings);
                    }
                    else
                    {
                        strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationPublic, PortalSettings);
                    }
                }
            }

            return(strMessage);
        }
示例#12
0
        protected string CompleteUserCreation(UserCreateStatus createStatus, UserInfo newUser, bool notify, bool register)
        {
            string strMessage = "";

            ModuleMessage.ModuleMessageType message = ModuleMessage.ModuleMessageType.RedError;
            if (register)
            {
                //send notification to portal administrator of new user registration
                strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationAdmin, PortalSettings);

                var loginStatus = UserLoginStatus.LOGIN_FAILURE;

                //complete registration
                switch (PortalSettings.UserRegistration)
                {
                case (int)Globals.PortalRegistrationType.PrivateRegistration:
                    strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationPrivate, PortalSettings);

                    //show a message that a portal administrator has to verify the user credentials
                    if (string.IsNullOrEmpty(strMessage))
                    {
                        strMessage += string.Format(Localization.GetString("PrivateConfirmationMessage", Localization.SharedResourceFile), newUser.Email);
                        message     = ModuleMessage.ModuleMessageType.GreenSuccess;
                    }
                    break;

                case (int)Globals.PortalRegistrationType.PublicRegistration:
                    Mail.SendMail(newUser, MessageType.UserRegistrationPublic, PortalSettings);
                    UserController.UserLogin(PortalSettings.PortalId, newUser.Username, newUser.Membership.Password, "", PortalSettings.PortalName, "", ref loginStatus, false);
                    break;

                case (int)Globals.PortalRegistrationType.VerifiedRegistration:
                    Mail.SendMail(newUser, MessageType.UserRegistrationVerified, PortalSettings);
                    UserController.UserLogin(PortalSettings.PortalId, newUser.Username, newUser.Membership.Password, "", PortalSettings.PortalName, "", ref loginStatus, false);
                    break;
                }
                //affiliate
                if (!Null.IsNull(User.AffiliateID))
                {
                    var objAffiliates = new AffiliateController();
                    objAffiliates.UpdateAffiliateStats(newUser.AffiliateID, 0, 1);
                }
                //store preferredlocale in cookie
                Localization.SetLanguage(newUser.Profile.PreferredLocale);
                if (IsRegister && message == ModuleMessage.ModuleMessageType.RedError)
                {
                    AddLocalizedModuleMessage(string.Format(Localization.GetString("SendMail.Error", Localization.SharedResourceFile), strMessage), message, (!String.IsNullOrEmpty(strMessage)));
                }
                else
                {
                    AddLocalizedModuleMessage(strMessage, message, (!String.IsNullOrEmpty(strMessage)));
                }
            }
            else
            {
                if (notify)
                {
                    //Send Notification to User
                    if (PortalSettings.UserRegistration == (int)Globals.PortalRegistrationType.VerifiedRegistration)
                    {
                        strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationVerified, PortalSettings);
                    }
                    else
                    {
                        strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationPublic, PortalSettings);
                    }
                }
            }
            //Log Event to Event Log
            var objEventLog = new EventLogController();

            objEventLog.AddLog(newUser, PortalSettings, UserId, newUser.Username, EventLogController.EventLogType.USER_CREATED);
            return(strMessage);
        }
        /// <summary>
        /// cmdRegister_Click runs when the Register Button is clicked
        /// </summary>
        /// <history>
        ///     [cnurse]	9/13/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        ///     [cnurse]    10/06/2004  System Messages now handled by Localization
        /// </history>
        protected void cmdRegister_Click(Object sender, EventArgs E)
        {
            try
            {
                // Only attempt a save/update if all form fields on the page are valid
                if (Page.IsValid)
                {
                    // Add New User to Portal User Database
                    UserInfo objUserInfo;

                    objUserInfo = UserController.GetUserByName(PortalId, userControl.UserName, false);

                    if (Request.IsAuthenticated)
                    {
                        if (!String.IsNullOrEmpty(userControl.Password) || !String.IsNullOrEmpty(userControl.Confirm))
                        {
                            if (userControl.Password != userControl.Confirm)
                            {
                                UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("PasswordMatchFailure", this.LocalResourceFile), ModuleMessageType.YellowWarning);
                            }
                            return;
                        }

                        string Username = null;

                        if (UserInfo.UserID >= 0)
                        {
                            Username = UserInfo.Username;
                        }

                        //if a user is found with that username and the username isn't our current user's username
                        if (objUserInfo != null && userControl.UserName != Username)
                        {
                            //username already exists in DB so show user an error
                            UI.Skins.Skin.AddModuleMessage(this, string.Format(Localization.GetString("RegistrationFailure", this.LocalResourceFile), userControl.UserName), ModuleMessageType.YellowWarning);
                        }
                        else
                        {
                            //update the user
                            if (objUserInfo != null)
                            {
                                objUserInfo.UserID = UserInfo.UserID;

                                objUserInfo.PortalID           = PortalId;
                                objUserInfo.Profile.FirstName  = userControl.FirstName;
                                objUserInfo.Profile.LastName   = userControl.LastName;
                                objUserInfo.Profile.Unit       = addressUser.Unit;
                                objUserInfo.Profile.Street     = addressUser.Street;
                                objUserInfo.Profile.City       = addressUser.City;
                                objUserInfo.Profile.Region     = addressUser.Region;
                                objUserInfo.Profile.PostalCode = addressUser.Postal;
                                objUserInfo.Profile.Country    = addressUser.Country;
                                objUserInfo.Profile.Telephone  = addressUser.Telephone;
                                objUserInfo.Email                   = userControl.Email;
                                objUserInfo.Username                = userControl.UserName;
                                objUserInfo.Profile.Cell            = addressUser.Cell;
                                objUserInfo.Profile.Fax             = addressUser.Fax;
                                objUserInfo.Profile.IM              = userControl.IM;
                                objUserInfo.Profile.Website         = userControl.Website;
                                objUserInfo.Profile.PreferredLocale = cboLocale.SelectedItem.Value;
                                objUserInfo.Profile.TimeZone        = Convert.ToInt32(cboTimeZone.SelectedItem.Value);

                                //Update the User
                                UserController.UpdateUser(PortalId, objUserInfo);

                                //store preferredlocale in cookie
                                Localization.SetLanguage(objUserInfo.Profile.PreferredLocale);
                            }
                            //clear the portal cache if current user is portal administrator (catch email adress changes)
                            if (UserInfo.UserID == PortalSettings.AdministratorId)
                            {
                                DataCache.ClearPortalCache(PortalId, true);
                            }
                            // Redirect browser back to home page
                            Response.Redirect(Convert.ToString(ViewState["UrlReferrer"]), true);
                        }
                    }
                    else
                    {
                        UserCreateStatus userCreateStatus;

                        //if a user is found with that username, error.
                        //this prevents you from adding a username
                        //with the same name as a superuser.
                        if (objUserInfo != null)
                        {
                            //username already exists in DB so show user an error
                            UI.Skins.Skin.AddModuleMessage(this, string.Format(Localization.GetString("RegistrationFailure", this.LocalResourceFile), userControl.UserName), ModuleMessageType.YellowWarning);
                            return;
                        }

                        int AffiliateId = Null.NullInteger;
                        if (Request.Cookies["AffiliateId"] != null)
                        {
                            AffiliateId = int.Parse(Request.Cookies["AffiliateId"].Value);
                        }

                        UserInfo objNewUser = new UserInfo();
                        objNewUser.PortalID           = PortalId;
                        objNewUser.Profile.FirstName  = userControl.FirstName;
                        objNewUser.Profile.LastName   = userControl.LastName;
                        objNewUser.Profile.Unit       = addressUser.Unit;
                        objNewUser.Profile.Street     = addressUser.Street;
                        objNewUser.Profile.City       = addressUser.City;
                        objNewUser.Profile.Region     = addressUser.Region;
                        objNewUser.Profile.PostalCode = addressUser.Postal;
                        objNewUser.Profile.Country    = addressUser.Country;
                        objNewUser.Profile.Telephone  = addressUser.Telephone;
                        objNewUser.Email                   = userControl.Email;
                        objNewUser.Username                = userControl.UserName;
                        objNewUser.Membership.Password     = userControl.Password;
                        objNewUser.Membership.Approved     = Convert.ToBoolean(PortalSettings.UserRegistration != (int)Globals.PortalRegistrationType.PublicRegistration ? false : true);
                        objNewUser.AffiliateID             = AffiliateId;
                        objNewUser.Profile.Cell            = addressUser.Cell;
                        objNewUser.Profile.Fax             = addressUser.Fax;
                        objNewUser.Profile.IM              = userControl.IM;
                        objNewUser.Profile.Website         = userControl.Website;
                        objNewUser.Profile.PreferredLocale = cboLocale.SelectedItem.Value;
                        objNewUser.Profile.TimeZone        = Convert.ToInt32(cboTimeZone.SelectedItem.Value);

                        userCreateStatus = UserController.CreateUser(ref objNewUser);

                        if (userCreateStatus == UserCreateStatus.Success)
                        {
                            EventLogController objEventLog = new EventLogController();
                            objEventLog.AddLog(objNewUser, PortalSettings, UserId, userControl.UserName, EventLogController.EventLogType.USER_CREATED);

                            // send notification to portal administrator of new user registration
                            Mail.SendMail(PortalSettings.Email, PortalSettings.Email, "", Localization.GetSystemMessage(PortalSettings.DefaultLanguage, PortalSettings, "EMAIL_USER_REGISTRATION_ADMINISTRATOR_SUBJECT", objNewUser), Localization.GetSystemMessage(PortalSettings.DefaultLanguage, PortalSettings, "EMAIL_USER_REGISTRATION_ADMINISTRATOR_BODY", objNewUser), "", "", "", "", "", "");

                            // complete registration
                            string strMessage = "";
                            if (PortalSettings.UserRegistration == (int)Globals.PortalRegistrationType.PrivateRegistration)
                            {
                                Mail.SendMail(PortalSettings.Email, userControl.Email, "", Localization.GetSystemMessage(objNewUser.Profile.PreferredLocale, PortalSettings, "EMAIL_USER_REGISTRATION_PRIVATE_SUBJECT", objNewUser), Localization.GetSystemMessage(objNewUser.Profile.PreferredLocale, PortalSettings, "EMAIL_USER_REGISTRATION_PRIVATE_BODY", objNewUser), "", "", "", "", "", "");
                                //show a message that a portal administrator has to verify the user credentials
                                strMessage = string.Format(Localization.GetString("PrivateConfirmationMessage", this.LocalResourceFile), userControl.Email);
                            }
                            else if (PortalSettings.UserRegistration == (int)Globals.PortalRegistrationType.PublicRegistration)
                            {
                                UserLoginStatus loginStatus = 0;
                                UserController.UserLogin(PortalSettings.PortalId, userControl.UserName, userControl.Password, "", PortalSettings.PortalName, "", ref loginStatus, false);
                            }
                            else if (PortalSettings.UserRegistration == (int)Globals.PortalRegistrationType.VerifiedRegistration)
                            {
                                Mail.SendMail(PortalSettings.Email, userControl.Email, "", Localization.GetSystemMessage(objNewUser.Profile.PreferredLocale, PortalSettings, "EMAIL_USER_REGISTRATION_PUBLIC_SUBJECT", objNewUser), Localization.GetSystemMessage(objNewUser.Profile.PreferredLocale, PortalSettings, "EMAIL_USER_REGISTRATION_PUBLIC_BODY", objNewUser), "", "", "", "", "", "");
                                //show a message that an email has been send with the registration details
                                strMessage = string.Format(Localization.GetString("VerifiedConfirmationMessage", this.LocalResourceFile), userControl.Email);
                            }

                            // affiliate
                            if (!Null.IsNull(AffiliateId))
                            {
                                AffiliateController objAffiliates = new AffiliateController();
                                objAffiliates.UpdateAffiliateStats(AffiliateId, 0, 1);
                            }

                            //store preferredlocale in cookie
                            Localization.SetLanguage(objNewUser.Profile.PreferredLocale);

                            if (strMessage.Length != 0)
                            {
                                UI.Skins.Skin.AddModuleMessage(this, strMessage, ModuleMessageType.GreenSuccess);
                                UserRow.Visible       = false;
                                cmdRegister.Visible   = false;
                                cmdUnregister.Visible = false;
                                cmdCancel.Visible     = false;
                            }
                            else
                            {
                                // Redirect browser back to home page
                                Response.Redirect(Convert.ToString(ViewState["UrlReferrer"]), true);
                            }
                        }
                        else // registration error
                        {
                            UI.Skins.Skin.AddModuleMessage(this, UserController.GetUserCreateStatus(userCreateStatus), ModuleMessageType.RedError);
                        }
                    }
                }
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }