Ejemplo n.º 1
0
        public TaskActivityWatcher Execute(MazeTask mazeTask, ICommandDescription commandDescription)
        {
            var task = TasksResource.Execute(mazeTask, _taskComponentResolver, _xmlSerializerCache, _restClient);

            var watcher = _serviceProvider.GetRequiredService <TaskActivityWatcher>();

            watcher.InitializeWatch(mazeTask.Id);

            PendingCommands.Insert(0, new PendingCommandViewModel(commandDescription, task, mazeTask, watcher));
            return(watcher);
        }
        public static string GetHelp(this ICommandDescription cd)
        {
            var helper = new StringBuilder(cd.Name);

            if (cd.AlternativeNames.Any())
            {
                helper.AppendFormat(" [ {0} ]", cd.AlternativeNames.Aggregate((x, y) => x + ", " + y));
            }
            helper.AppendFormat("\r\n{0}", cd.Description);
            return(helper.ToString());
        }
Ejemplo n.º 3
0
        public PendingCommandViewModel(ICommandDescription commandDescription, Task <TaskSessionsInfo> task, MazeTask mazeTask, TaskActivityWatcher taskActivityWatcher)
        {
            CommandDescription = commandDescription;
            Task                = task;
            MazeTask            = mazeTask;
            TaskActivityWatcher = taskActivityWatcher;

            Task.ContinueWith(x =>
            {
                RaisePropertyChanged(nameof(IsCompleted));
                TaskActivityWatcher.Dispose();
            });
        }
Ejemplo n.º 4
0
        private IDictionary<string, object> ParseArguments(string cmd, ICommandDescription description)
        {
            string[] tokens =
                ArgumentParser.SplitCommandLine(cmd).Skip(1).ToArray();

            ArgumentValue[] arguments =
                description.Arguments.Select(x => new ArgumentValue(x.Name, x.Type, x.Aliases, x.IsOptional, x.IsDefault))
                           .ToArray();

            ArgumentParser.Parse(tokens, arguments);

            return arguments.Where(x => x.HasValue)
                            .ToDictionary(x => x.Name, x => x.Value);
        }
Ejemplo n.º 5
0
        private void ExecuteCommand(IEnumerable <ClientViewModel> obj, ICommandDescription commandDescription)
        {
            var audienceCollection = new AudienceCollection();

            audienceCollection.AddRange(obj.Select(x => new CommandTarget(CommandTargetType.Client, x.ClientId)));

            if (_windowService.ShowDialog <ExecuteCommandViewModel>(vm => vm.Initialize(commandDescription, audienceCollection), out var viewModel) ==
                true)
            {
                var watcher = _commandExecutionManager.Execute(viewModel.MazeTask, commandDescription);

                _windowService.ShowDialog <TaskOverviewViewModel>(vm => vm.Initialize(watcher, commandDescription.Name));
            }
        }
Ejemplo n.º 6
0
        public static CommandDescription CreateCommandDescription(ICommandDescription original)
        {
            if (original is CommandDescription descr)
            {
                return(descr);
            }

            return(new CommandDescription(original.Commands)
            {
                Help = original.Help,
                Subcommand = original.Subcommand,
                RequiredPermissions = original.RequiredPermissions,
                Scope = original.Scope,
            });
        }
Ejemplo n.º 7
0
 public Task ExecuteCommand(ICommandDescription command)
 {
     return(null);
 }