Esempio n. 1
0
        private List <UserInfo> SyncGroupsUsers(List <UserInfo> uniqueLdapGroupUsers)
        {
            const double percents = 30;

            var step = percents / uniqueLdapGroupUsers.Count;

            var percentage = (double)GetProgress();

            var newUniqueLdapGroupUsers = new List <UserInfo>();

            var index = 0;
            var count = uniqueLdapGroupUsers.Count;

            int i, len;

            for (i = 0, len = uniqueLdapGroupUsers.Count; i < len; i++)
            {
                var ldapGroupUser = uniqueLdapGroupUsers[i];

                SetProgress(Convert.ToInt32(percentage),
                            currentSource:
                            string.Format("({0}/{1}): {2}", ++index, count,
                                          UserFormatter.GetUserName(ldapGroupUser, DisplayUserNameFormat.Default)));

                UserInfo user;
                switch (OperationType)
                {
                case LdapOperationType.Save:
                case LdapOperationType.Sync:
                    user = LDAPUserManager.SyncLDAPUser(ldapGroupUser, uniqueLdapGroupUsers);
                    if (!Equals(user, Constants.LostUser))
                    {
                        newUniqueLdapGroupUsers.Add(user);
                    }
                    break;

                case LdapOperationType.SaveTest:
                case LdapOperationType.SyncTest:
                    LdapChangeCollection changes;
                    user = LDAPUserManager.GetLDAPSyncUserChange(ldapGroupUser, uniqueLdapGroupUsers, out changes);
                    if (!Equals(user, Constants.LostUser))
                    {
                        newUniqueLdapGroupUsers.Add(user);
                    }
                    _ldapChanges.AddRange(changes);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                percentage += step;
            }

            return(newUniqueLdapGroupUsers);
        }
Esempio n. 2
0
        private void SyncDbUsers(List <UserInfo> ldapUsers)
        {
            const double percents = 35;

            var step = percents / ldapUsers.Count;

            var percentage = (double)GetProgress();

            if (!ldapUsers.Any())
            {
                return;
            }

            var index = 0;
            var count = ldapUsers.Count;

            foreach (var userInfo in ldapUsers)
            {
                SetProgress(Convert.ToInt32(percentage),
                            currentSource:
                            string.Format("({0}/{1}): {2}", ++index, count,
                                          UserFormatter.GetUserName(userInfo, DisplayUserNameFormat.Default)));

                switch (OperationType)
                {
                case LdapOperationType.Save:
                case LdapOperationType.Sync:
                    LDAPUserManager.SyncLDAPUser(userInfo, ldapUsers);
                    break;

                case LdapOperationType.SaveTest:
                case LdapOperationType.SyncTest:
                    LdapChangeCollection changes;
                    LDAPUserManager.GetLDAPSyncUserChange(userInfo, ldapUsers, out changes);
                    _ldapChanges.AddRange(changes);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                percentage += step;
            }
        }