コード例 #1
0
        protected virtual void Users_OverrideADRoles_FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e)
        {
            Users user   = (Users)e.Row;
            bool  oldval = user.OverrideADRoles == true;
            bool  newval = e.NewValue != null?Convert.ToBoolean(e.NewValue) : false;

            if (oldval != newval && !newval &&
                user.Source == PXUsersSourceListAttribute.ActiveDirectory &&
                RolesByUser.SelectSingle() != null)
            {
                if (UserList.Ask(PX.Objects.CR.Messages.Confirmation,
                                 PXMessages.LocalizeFormatNoPrefixNLA(PX.Objects.CR.Messages.DeleteLocalRoles, user.Username),
                                 MessageButtons.YesNo, MessageIcon.Warning) != WebDialogResult.Yes)
                {
                    e.NewValue = true;
                    e.Cancel   = true;
                }
                else
                {
                    //delete UsersInRoles records if overridead is disabled.
                    foreach (UsersInRoles role in RolesByUser.Select())
                    {
                        RolesByUser.Delete(role);
                    }
                }
            }
        }
コード例 #2
0
        public override void Persist()
        {
            foreach (Users user in UserList.Cache.Deleted)
            {
                Contact cnt = (Contact)contact.View.SelectSingleBound(new object[] { user });
                if (cnt != null)
                {
                    cnt.UserID = null;
                    contact.Update(cnt);

                    EPEmployee emp = Employee.Select(cnt.ContactID);
                    if (emp != null)
                    {
                        emp = PXCache <EPEmployee> .CreateCopy(emp);

                        emp.UserID = null;
                        Employee.Update(emp);
                    }
                }
            }

            if (UserList.Current != null && UserList.Current.OverrideADRoles != true && UserList.Current.Source == PXUsersSourceListAttribute.ActiveDirectory)
            {
                //notice that this select returns nothing if called on AccessUsers. AccessUsers::roleList() returns empty list;
                foreach (UsersInRoles userrole in RoleList.Select())
                {
                    RoleList.Delete(userrole);
                }
            }

            //if no local roles selected - disable override.
            if (UserList.Current != null && UserList.Current.OverrideADRoles == true && UserList.Current.Source == PXUsersSourceListAttribute.ActiveDirectory)
            {
                if (RolesByUser.SelectSingle() == null)
                {
                    UserListCurrent.Current.OverrideADRoles = false;
                }
            }

            base.Persist();
        }
コード例 #3
0
        public override void Persist()
        {
            Contact    cnt             = contact.SelectSingle();
            EPEmployee currentEmployee = (cnt != null) ? Employee.Select(cnt.ContactID) : null;

            cnt = (Contact)contact.Cache.CreateCopy(cnt);
            if (UserList.Current != null)
            {
                UserList.Current.IsAssigned = cnt != null;

                foreach (Contact existing in PXSelect <Contact, Where <Contact.userID, Equal <Current <Users.pKID> > > > .Select(this))
                {
                    existing.UserID = null;
                    contact.Update(existing);

                    EPEmployee emp = Employee.Select(existing.ContactID);
                    if (emp != null)
                    {
                        emp = PXCache <EPEmployee> .CreateCopy(emp);

                        emp.UserID = null;
                        Employee.Update(emp);
                    }
                }

                if (cnt != null)
                {
                    cnt.UserID = UserList.Current.PKID;
                    contact.Update(cnt);

                    if (currentEmployee != null)
                    {
                        currentEmployee = PXCache <EPEmployee> .CreateCopy(currentEmployee);

                        currentEmployee.UserID = UserList.Current.PKID;
                        Employee.Update(currentEmployee);
                    }
                }
            }

            foreach (Users user in UserList.Cache.Deleted)
            {
                cnt = (Contact)contact.View.SelectSingleBound(new object[] { user });
                if (cnt != null)
                {
                    cnt.UserID = null;
                    contact.Update(cnt);

                    EPEmployee emp = Employee.Select(cnt.ContactID);
                    if (emp != null)
                    {
                        emp = PXCache <EPEmployee> .CreateCopy(emp);

                        emp.UserID = null;
                        Employee.Update(emp);
                    }
                }
            }

            if (UserList.Current != null && UserList.Current.OverrideADRoles != true && UserList.Current.Source == PXUsersSourceListAttribute.ActiveDirectory)
            {
                //notice that this select returns nothing if called on AccessUsers. AccessUsers::roleList() returns empty list;
                foreach (UsersInRoles userrole in RoleList.Select())
                {
                    RoleList.Delete(userrole);
                }
            }

            //if no local roles selected - disable override.
            if (UserList.Current != null && UserList.Current.OverrideADRoles == true && UserList.Current.Source == PXUsersSourceListAttribute.ActiveDirectory)
            {
                if (RolesByUser.SelectSingle() == null)
                {
                    UserListCurrent.Current.OverrideADRoles = false;
                }
            }

            base.Persist();
        }