Example #1
0
        public virtual void Process(UnicornReserializeCompletePipelineArgs args)
        {
            var userPredicate = args.Configuration.Resolve <IUserPredicate>();

            // no predicate = configuration doesn't include any users
            if (userPredicate == null)
            {
                return;
            }

            var dataStore = args.Configuration.Resolve <IUserDataStore>();
            var logger    = args.Configuration.Resolve <ILogger>();

            Assert.IsNotNull(dataStore, $"The IUserDataStore was not registered for the {args.Configuration.Name} configuration.");
            Assert.IsNotNull(logger, $"The ILogger was not registered for the {args.Configuration.Name} configuration.");

            logger.Info(string.Empty);
            logger.Info($"{args.Configuration.Name} users are being reserialized.");

            dataStore.Clear();

            var users = UserManager.GetUsers().Where(user => userPredicate.Includes(user).IsIncluded);

            int userCount = 0;

            foreach (var user in users)
            {
                dataStore.Save(UserSynchronization.BuildSyncUser(Membership.GetUser(user.Name)));
                userCount++;
            }

            logger.Info($"{args.Configuration.Name} users reserialize complete. {userCount} users were reserialized.");
            logger.Info(string.Empty);
        }
Example #2
0
        public void Process(UnicornReserializeCompletePipelineArgs args)
        {
            var rolePredicate = args.Configuration.Resolve <IRolePredicate>();

            // no predicate = configuration doesn't include any roles
            if (rolePredicate == null)
            {
                return;
            }

            var dataStore = args.Configuration.Resolve <IRoleDataStore>();
            var logger    = args.Configuration.Resolve <ILogger>();

            logger.Info(string.Empty);
            logger.Info($"{args.Configuration.Name} roles are being reserialized.");

            dataStore.Clear();

            var roles = RolesInRolesManager.GetAllRoles()
                        .Select(role => new SitecoreRoleData(role))
                        .Where(role => rolePredicate.Includes(role).IsIncluded);

            int roleCount = 0;

            foreach (var role in roles)
            {
                dataStore.Save(role);
                roleCount++;
            }

            logger.Info($"{args.Configuration.Name} role reserialize complete. {roleCount} roles were reserialized.");
            logger.Info(string.Empty);
        }