Exemple #1
0
        /// <summary>
        /// Performs the password validation rules. If validation fails an exception is raised from the
        /// ValidateUserPassword method. If validation succeeds, but the password was changed
        /// to an empty string that result is returned, which will be displayed to the UI.
        /// </summary>
        /// <param name="form">The change password form.</param>
        /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public static void btnSave_OnClick(IUserChangePassword form, EventArgs args)
        {
            string newPassword = form.txtNewPassword.Text;

            if (newPassword.Equals(form.txtConfirmPassword.Text))
            {
                IUser user = (IUser)form.usrUser.LookupResultValue;
                if (user.ValidateUserPassword(newPassword))
                {
                    Sage.Platform.WebPortal.Services.IWebDialogService ds = form.Services.Get <Sage.Platform.WebPortal.Services.IWebDialogService>();
                    user.SavePassword(newPassword);
                    form.lblInvalidPassword.Text = newPassword.Length == 0 ? form.GetResource("PasswordBlank").ToString() : String.Empty;
                    if (newPassword.Length == 0)
                    {
                        ds.ShowMessage(form.GetResource("PasswordBlank").ToString());
                    }
                    else
                    {
                        ds.ShowMessage(form.GetResource("PasswordChanged").ToString());
                    }
                    ds.CloseEventHappened(form, null);
                    Sage.Platform.WebPortal.Services.IPanelRefreshService refresher = form.Services.Get <Sage.Platform.WebPortal.Services.IPanelRefreshService>();
                    if (refresher != null)
                    {
                        refresher.RefreshAll();
                    }
                }
            }
            else
            {
                throw new Sage.Platform.Application.ValidationException(form.GetResource("Error_PasswordsDontMatch").ToString());
            }
        }
        public static void btnOK_OnClickStep(IQuickInsertAccountContact form, EventArgs args)
        {
            IUser    currentUser = Sage.SalesLogix.API.MySlx.Security.CurrentSalesLogixUser;
            IContact contact     = form.CurrentEntity as IContact;
            IAccount account     = Sage.Platform.EntityFactory.Create <IAccount>();

            IAddress ad = Sage.Platform.EntityFactory.Create <IAddress>();

            ad.Description = contact.Address.Description;
            ad.Address1    = contact.Address.Address1;
            ad.Address2    = contact.Address.Address2;
            ad.Address3    = contact.Address.Address3;
            ad.Address4    = contact.Address.Address4;
            ad.City        = contact.Address.City;
            ad.State       = contact.Address.State;
            ad.PostalCode  = contact.Address.PostalCode;
            ad.Country     = contact.Address.Country;
            ad.County      = contact.Address.County;
            ad.Salutation  = contact.Address.Salutation;

            account.Address        = ad;
            account.AccountName    = form.txtAccount.Text;
            account.AccountManager = currentUser;
            account.Owner          = currentUser.DefaultOwner;
            account.Type           = form.pklType.PickListValue;
            account.MainPhone      = form.phAccountMain.Text;
            //if ((string.IsNullOrEmpty(contact.LastName)&&(string.IsNullOrEmpty(contact.FirstName))))
            //{
            //   contact.LastName = string.Format("New Contact for {0}",currentUser.UserInfo.UserName );
            //}
            contact.Account        = account;
            contact.AccountManager = currentUser;
            contact.Owner          = currentUser.DefaultOwner;
            contact.SaveContactAccount(account);

            ISelectionService srv     = ApplicationContext.Current.Services.Get <ISelectionService>(true);
            ISelectionContext sc      = new SimpleSelectionContext();
            SelectionInfo     selInfo = new SelectionInfo();
            SelectionItem     item    = new SelectionItem();

            item.Id = contact.Id.ToString();
            selInfo.Selections.Add(item);
            sc.Key           = "QuickInsertAccountContact";
            sc.SelectionInfo = selInfo;
            srv.SetSelectionContext(sc.Key, sc);

            Sage.Platform.WebPortal.Services.IPanelRefreshService refresher = form.Services.Get <Sage.Platform.WebPortal.Services.IPanelRefreshService>();
            if (refresher != null)
            {
                refresher.RefreshAll();
            }
        }
Exemple #3
0
        /// <summary>
        /// Performs the password validation rules. If validation fails an exception is raised from the
        /// ValidateUserPassword method. If validation succeeds, but the password was changed
        /// to an empty string that result is returned, which will be displayed to the UI.
        /// </summary>
        /// <param name="form">The change password form.</param>
        /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public static void btnSave_OnClick(IUserChangePassword form, EventArgs args)
        {
            string newPassword = form.txtNewPassword.Text;

            if (newPassword.Equals(form.txtConfirmPassword.Text))
            {
                IUser user = (IUser)form.CurrentEntity;

                if (user.ValidateUserPassword(newPassword))
                {
                    Sage.Platform.WebPortal.Services.IWebDialogService ds = form.Services.Get <Sage.Platform.WebPortal.Services.IWebDialogService>();
                    user.SavePassword(newPassword);
                    var slxUserService = (ISlxUserService)ApplicationContext.Current.Services.Get <Sage.Platform.Security.IUserService>(true);
                    var currentUser    = slxUserService.GetUser();
                    if (user.UserName == currentUser.UserName)
                    {
                        var data = (Sage.SalesLogix.SLXDataService)ApplicationContext.Current.Services.Get <IDataService>(true);
                        var auth = (Sage.SalesLogix.Web.SLXWebAuthenticationProvider)data.AuthenticationProvider;
                        auth.AuthenticateWithContext(currentUser.UserName, newPassword);
                    }

                    form.lblInvalidPassword.Text = newPassword.Length == 0 ? form.GetResource("PasswordBlank").ToString() : String.Empty;
                    if (newPassword.Length == 0)
                    {
                        ds.ShowMessage(form.GetResource("PasswordBlank").ToString());
                    }
                    else
                    {
                        ds.ShowMessage(form.GetResource("PasswordChanged").ToString());
                    }
                    ds.CloseEventHappened(form, null);
                    Sage.Platform.WebPortal.Services.IPanelRefreshService refresher = form.Services.Get <Sage.Platform.WebPortal.Services.IPanelRefreshService>();
                    if (refresher != null)
                    {
                        refresher.RefreshAll();
                    }
                }
            }
            else
            {
                throw new Sage.Platform.Application.ValidationException(form.GetResource("Error_PasswordsDontMatch").ToString());
            }
        }