Esempio n. 1
0
        private void Action_ResendEmail()
        {
            string ErrorMessage;
            Label  TempPrimaryEmail = (Label)formView.FindControl("TempPrimaryEmail");

            //When the Email verification for Change email is resent, need to reset EmailChangeRequestDate to getdate()
            if (UserBLL.ResetEmailChangeRequestDate(ViewData.UserId, TempPrimaryEmail.Text))
            {
                bool mailSent = VerifyEmail.SendEmailVerificationNotificationforEmailChange(false, ViewData.UserId, ViewData.CreatedBy, TempPrimaryEmail.Text, out ErrorMessage);
                if (mailSent)
                {
                    DisplayMessage("The email has been sent successfully. <br />", false);
                }
                else
                {
                    DisplayMessage("The email attempt failed with the following error message:" + "<br />" + ErrorMessage, true);
                }
            }
        }
Esempio n. 2
0
        protected void ChangeEmailCommand(object sender, EventArgs e)
        {
            //TODO: Validation to be replaced with ProxyValidator
            Page.Validate("ChangeEmail");
            if (Page.IsValid)
            {
                //using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                //{
                bool   DoCommit = false;
                string ErrorMessage;
                string NewEmail = Email.Text.Trim();

                //Check if the Username already exists
                if (RegisterUserBLL.DoesUserNameExist(NewEmail))
                {
                    DisplayMessage("The Primary Email address is already registered. Duplicates are not allowed.", true);
                    return;
                }
                else
                {
                    if (UserBLL.ChangeEmail(ShiptalkPrincipal.UserId, ShiptalkPrincipal.Username, NewEmail, ShiptalkPrincipal.UserId, out ErrorMessage))
                    {
                        if (VerifyEmail.SendEmailVerificationNotificationforEmailChange(false, ShiptalkPrincipal.UserId, ShiptalkPrincipal.UserId, NewEmail, out ErrorMessage))
                        {
                            DoCommit = true;
                        }
                    }

                    if (DoCommit)
                    {
                        //scope.Complete();
                        DisplayMessage("Your request has been submitted. You will receive this Change Email request information email at your old Email address and  'Email verification' email at your new Email address shortly. Please follow the instruction to complete the Email verification process . If you do not receive an email after a while, please contact the help desk.", false);
                    }
                    else
                    {
                        DisplayMessage("Sorry. Unable to change your email. Please contact support for assistance.", false);
                    }
                    //}
                }
            }
        }
Esempio n. 3
0
        protected void dataSourceUserView_Updated(object sender, ObjectContainerDataSourceStatusEventArgs e)
        {
            Page.Validate("UserProfile");
            if (!Page.IsValid)
            {
                return;
            }

            UserViewData ChangedUserData = (UserViewData)e.Instance;

            try
            {
                if (IsCMSOrStateScope)
                {
                    UserBLL.UpdateIsAdminStatus(ChangedUserData.UserId, ChangedUserData.IsAdmin);
                }
            }
            catch (Exception UpdateAccountEx)
            {
                DisplayMessage("Failed while saving administrator status. Please try later or contact support for assistance.", true);
                return;
            }

            //Update IsActive of UserData with what we got from Updating method.
            //ChangedUserData.IsActive = IsActiveUser;
            //using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
            //{
            if (UserBLL.UpdateUserProfile(CreateUserProfile(ChangedUserData), this.AccountInfo.UserId))
            {
                if (!UserData.IsShipDirector && UserData.IsUserStateScope)
                {
                    string ErrorMessage;
                    if (!UserBLL.SaveDescriptors(ChangedUserData.UserId, GetDescriptorsSelectedByAdmin(), ShiptalkLogic.Constants.Defaults.DefaultValues.AgencyIdForNonAgencyUsers, this.AccountInfo.UserId, out ErrorMessage))
                    {
                        DisplayMessage(ErrorMessage, true);
                        return;
                    }

                    if (!UserBLL.UpdateStateSuperDataEditor(ChangedUserData.UserId, ChangedUserData.IsStateSuperDataEditor, this.AccountInfo.UserId))
                    {
                        DisplayMessage("An error occured while updating the super data editor status", true);
                        return;
                    }
                }

                //Update the Is Approver Designate status for CMS/State scope Admins alone.
                //Ignore Ship directors and CMS Admins.
                if (UserData.IsAdmin)
                {
                    if ((!UserData.IsCMSAdmin && UserData.IsUserCMSScope) || (!UserData.IsShipDirector && UserData.IsUserStateScope))
                    {
                        if (!UserBLL.UpdateApproverDesignate(UserData.UserId, GetApproverDesignateSelection(), this.AccountInfo.UserId))
                        {
                            DisplayMessage("Failed while updating approver designate status. Please try later or contact support for assistance.", true);
                            return;
                        }
                    }
                }

                bool ReviewerUpdateFailed = false;
                if (ScopeIdOfUser == Scope.State.EnumValue <int>())
                {
                    if (NewSupervisorId == -1)
                    {
                        NewSupervisorId = 0;
                    }

                    if (NewSupervisorId != UserIdOfOldReviewer)
                    {
                        //Save the new ReviewerID as Supervisor
                        if (!UserBLL.SaveSupervisorForUser(ChangedUserData.UserId, NewSupervisorId, null, this.AccountInfo.UserId))
                        {
                            //If update failed, then
                            ReviewerUpdateFailed = true;
                        }
                    }
                }
                //Lavnaya: Included Change Email process : 09/02/2012
                //If Primary Email is changed, then the email should be sent to user's old email id and as well as to new email id to notify them.
                // Email verification link will be sen to the user's new email id. Users can login using their old email id till they vefy the new email. this process is same as "Edit my Email" functionality.
                //If the Primary EMail id is not changed, then we dont change it in database.

                bool   DoCommit = false;
                string ErrorMsg;
                string NewEmail = string.Empty;

                TextBox Email = formView.FindControl("Email") as TextBox;

                NewEmail = Email.Text;

                if (NewEmail != UserData.PrimaryEmail)
                {
                    if (NewEmail != "" && NewEmail != null)
                    {
                        //Check if the Username already exists
                        if (RegisterUserBLL.DoesUserNameExist(NewEmail))
                        {
                            DisplayMessage("The Primary Email address is already registered. Duplicates are not allowed.", true);
                            return;
                        }
                        else
                        {
                            if (UserBLL.ChangeEmail(ChangedUserData.UserId, UserData.PrimaryEmail, NewEmail, this.AccountInfo.UserId, out ErrorMsg))
                            {
                                if (VerifyEmail.SendEmailVerificationNotificationforEmailChange(false, ChangedUserData.UserId, ChangedUserData.UserId, NewEmail, out ErrorMsg))
                                {
                                    DoCommit = true;
                                }
                            }

                            //if (DoCommit)
                            //{
                            //    //scope.Complete();
                            //    DisplayMessage("Your request has been submitted. You will receive this Change Email request information email at your old Email address and  'Email verification' email at your new Email address shortly. Please follow the instruction to complete the Email verification process . If you do not receive an email after a while, please contact the help desk.", false);
                            //}

                            //}
                        }
                    }
                }


                //Lavnaya: Included Change Email process : 09/02/2012 -- End

                if (ReviewerUpdateFailed)
                {
                    DisplayMessage("Unable to save new supervisor. Please try later or contact support for assistance.", true);
                }


                //else if (!DoCommit)Pbattineni: If (!DoCommit) & and New email is not equal to Primary email then Throw error Message- 10/08/12
                else if (!DoCommit && NewEmail != UserData.PrimaryEmail)
                {
                    DisplayMessage("Sorry. Unable to change your email. Please contact support for assistance.", true);
                }
                else
                {
                    //scope.Complete();
                    DisplayMessage("The submitted information has been saved successfully.", false);
                }
                //formView.DataBind();
                //listViewUserRegionalProfiles.DataBind();
                //Page.DataBind();
            }
            else
            {
                DisplayMessage("Sorry. We were unable to save the information. Please contact support for assistance.", true);
            }
            //}

            //Get Fresh data for rebind.
            FetchUserData();
        }