public IDictionary <String, String> Process(XDocument doc)
        {
            var users     = doc.Element("users").Elements();
            var idmap     = new ConcurrentDictionary <String, String>();
            var anonymous = new SimpleQAIdentity("", "dumpprocessor", "", 0);

            Parallel.ForEach(users, new ParallelOptions()
            {
                MaxDegreeOfParallelism = Environment.ProcessorCount
            }, user =>
            {
                var command = new AuthenticateCommand(user.Attribute("DisplayName").Value, "whatever");
                var result  = _mediator.ExecuteAsync <AuthenticateCommand, AuthenticateCommandResult>(command, anonymous, CancellationToken.None).Result;
                idmap.TryAdd(user.Attribute("Id").Value, _channel.Execute("HGET {user}:namemapping @Username", new { command.Username })[0].GetString());
                _channel.Execute("sadd {user}:builtin @user", new { user = command.Username }).ThrowErrorIfAny();
                Console.WriteLine("Added user: " + command.Username);
            });

            return(idmap);
        }
Exemple #2
0
 /// <summary>
 /// Executes synchronously the given command.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="channel"><see cref="IRedisChannel"/></param>
 /// <param name="command">The Redis command.</param>
 /// <param name="parameters">The object with properties will be used as parameters.</param>
 /// <returns><seealso cref="IRedisResults"/></returns>
 public static IRedisResults Execute <T>(this IRedisChannel channel, String command, T parameters) where T : class
 {
     return(channel.Execute(command, parameters, CancellationToken.None));
 }
Exemple #3
0
 /// <summary>
 /// Executes synchronously the given command.
 /// </summary>
 /// <param name="channel"><see cref="IRedisChannel"/></param>
 /// <param name="command">The Redis command.</param>
 /// <param name="cancel">A token that can cancel the execution.</param>
 /// <returns><seealso cref="IRedisResults"/></returns>
 public static IRedisResults Execute(this IRedisChannel channel, String command, CancellationToken cancel)
 {
     return(channel.Execute <Object>(command, null, cancel));
 }