Esempio n. 1
0
        private async Task Handle(RunMaintenanceScript r, IContext context)
        {
            using (var scope = new ContextualScope(_services, context)) {
                scope.Context.Set(new RequestTimeContext(DateTime.Now), true);
                QueueCommandResult result = await scope.Enqueue(ID.NewID(), new RunScript(r.Script));

                if (result.Type == QueueCommandResultType.Rejected)
                {
                    throw new InvalidOperationException("TODO: Better handling...");
                }

                await result.Completion;
            }
        }
Esempio n. 2
0
        public async Task RunScript(MaintenanceScript script)
        {
            ScriptCommand[] commands = script
                                       .Build()
                                       .ToArray();

            var message = new RunMaintenanceScript(
                new Script(script.Name, commands));

            using (var scope = new ContextualScope(_services)) {
                scope.Context.Set(new RequestTimeContext(DateTime.Now), true);
                var result = scope
                             .Enqueue(script.ScriptID, message)
                             .Result;

                if (result.Type == QueueCommandResultType.Rejected)
                {
                    throw new InvalidOperationException("TODO: Better handling...");
                }

                await result.Completion;
            }
        }