public override void Persist() { Contact cnt = contact.SelectSingle(); 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); } if (cnt != null) { cnt.UserID = UserList.Current.PKID; contact.Update(cnt); } } foreach (Users user in UserList.Cache.Deleted) { cnt = (Contact)contact.View.SelectSingleBound(new object[] { user }); if (cnt != null) { cnt.UserID = null; contact.Update(cnt); } } if (UserList.Current != null && UserList.Current.OverrideADRoles != true && UserList.Current.Source == PXUsersSourceListAttribute.ActiveDirectory) { foreach (UsersInRoles userrole in RoleList.Select()) { RoleList.Delete(userrole); } } base.Persist(); }
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(); }
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(); }