Exemplo n.º 1
0
 public async Task <WrappedResponse <bool> > RunByIdAsync([FromQuery] Guid projectId)
 {
     using (CallProxy)
     {
         return(await CallProxy.CallAsync(async() => await runner.RunAsync(projectId)));
     }
 }
Exemplo n.º 2
0
        internal override async Task <ExceptionDispatchInfo?> InvokeAsync(IRunner runner, CancellationToken cancellationToken)
        {
            ExceptionDispatchInfo?info = null;

            await runner.RunAsync(() =>
            {
                try
                {
                    return(this._stackFactory());
                }
                // because we are newing a generic, reflection comes in to
                // construct the instance. And if there is an exception in
                // the constructor of the user-provided TStack, it will be wrapped
                // in TargetInvocationException - which is not the exception
                // we want to throw to the consumer.
                catch (TargetInvocationException ex)
                {
                    info = ex.InnerException != null
                        ? ExceptionDispatchInfo.Capture(ex.InnerException)
                        : ExceptionDispatchInfo.Capture(ex);
                    throw;
                }
                catch (Exception ex)
                {
                    info = ExceptionDispatchInfo.Capture(ex);
                    throw;
                }
            }).ConfigureAwait(false);

            return(info);
        }
Exemplo n.º 3
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            notifier.Notify("Debug: Start program from ConsoleRunner.");
            await runner.RunAsync(stoppingToken);

            notifier.Notify("Program End.");
        }
        public async Task <IExecutionResult> ExecuteAsync()
        {
            var tasks = _runner.RunAsync(_script).ToList();

            var results = await Task.WhenAll(tasks).ConfigureAwait(false);

            return(new AggregateResult(results));
        }
        private async Task RunSingleTask(ITaskDefinition <TIdentifier> singleTaskDefinition, PreconditionEvaluator <TIdentifier> preconditionEvaluator, ImmutableList <ISchedule <TIdentifier> > schedules, ImmutableList <TaskPrecondition <TIdentifier> > preconditions, SessionRunResult <TIdentifier> sessionRunResult, DateTime startTime, Guid runId)
        {
            var taskSchedule = schedules.Single(candidateSchedule => EqualityComparer <TIdentifier> .Default.Equals(candidateSchedule.TaskDefinitionId, singleTaskDefinition.Id));
            var history      = historyReader.GetNew();

            history.StartTime        = startTime;
            history.TaskDefinitionId = singleTaskDefinition.Id;
            history.RunId            = runId;
            var runResult = default(SingleTaskRunResult);

            var failingPrecondition = await preconditionEvaluator.GetFailingPrecondition(singleTaskDefinition, preconditions);

            var allPreconditionsPassed = string.IsNullOrEmpty(failingPrecondition);

            if (allPreconditionsPassed)
            {
                try
                {
                    runResult = await runner.RunAsync(singleTaskDefinition);
                }
                catch (Exception e)
                {
                    await faultHandler.HandleAsync(singleTaskDefinition, e);

                    runResult = new SingleTaskRunResult
                    {
                        Succeeded = false,
                        Remarks   = e.Message,
                    };
                }
                finally
                {
                    if (taskSchedule.IsOnDemand)
                    {
                        onDemandQueueManager.DeQueue(taskSchedule.TaskDefinitionId);
                    }
                }
                history.Remarks = runResult.Remarks;
                history.Status  = runResult.Succeeded ? RunHistoryStatuses.CompletedSuccessfully : RunHistoryStatuses.Failed;
            }
            else
            {
                history.Remarks = $"Precondition '{failingPrecondition}' failed";
                history.Status  = RunHistoryStatuses.PreconditionPreventedRun;
            }
            history.EndTime = taskSchedule.LastRun = DateTime.Now;

            sessionRunResult.Histories = sessionRunResult.Histories.Add(history);
            sessionRunResult.Schedules = sessionRunResult.Schedules.Add(taskSchedule);
        }
Exemplo n.º 6
0
        internal override async Task <ExceptionDispatchInfo?> InvokeAsync(IRunner runner, CancellationToken cancellationToken)
        {
            ExceptionDispatchInfo?info = null;

            await runner.RunAsync(async() =>
            {
                try
                {
                    return(await this._program(cancellationToken).ConfigureAwait(false));
                }
                catch (Exception ex)
                {
                    info = ExceptionDispatchInfo.Capture(ex);
                    throw;
                }
            }, null).ConfigureAwait(false);

            return(info);
        }
Exemplo n.º 7
0
 /// <inheritdoc/>
 internal override Task <int> InvokeAsync(IRunner runner, CancellationToken cancellationToken)
 => runner.RunAsync(this._stackFactory);
Exemplo n.º 8
0
 /// <inheritdoc/>
 internal override Task <int> InvokeAsync(IRunner runner, CancellationToken cancellationToken)
 => runner.RunAsync(() => this._program(cancellationToken), null);