Esempio n. 1
0
        public async Task <CommandResult> Process(ICommand command, object parameters, bool overrideAuth = false)
        {
            var stopWatch = Stopwatch.StartNew();

            Logger.Trace("Hydrating command");
            hydrator.Hydrate(ref command, parameters);
            Logger.Trace("Hydrated command", command);
            Logger.Trace("Validating command");
            var result = await ValidateCommand(command);

            Logger.Trace("Validated command", result);

            if (result == null && !overrideAuth)
            {
                Logger.Trace("Authorizing command");
                result = await AuthorizeCommand(command);

                Logger.Trace("Authorized command", result);
            }
            Logger.Trace("Result", result);

            if (result == null)
            {
                Logger.Trace("Executing Command");
                result = await ExecuteCommand(command);

                Logger.Trace("Executed Command", result);
            }

            result.Elapsed = stopWatch.ElapsedMilliseconds;
            return(result);
        }
Esempio n. 2
0
        public override async Task <bool> IsValid()
        {
            var command          = commandLocator.Locate(CommandName);
            var validCommandName = command != null;

            commandHydrator.Hydrate(ref command, Parameters);
            var validParameters = await command.IsValid();

            var validSchedule = Schedule != null &&
                                Schedule.start != default(DateTime) &&
                                (Schedule.repeat_count == null || Schedule.repeat_count > 0);

            return(validCommandName && validParameters && validSchedule);
        }