public virtual async Task HandleAsync(IExternalTaskContext context) { IExecutionResult executionResult; try { ParseDefaultContext(context.Task); ParseContext(context.Task); await Process(); try { executionResult = await this.GetExecutionResult(); } catch (Exception e) { executionResult = new BpmnErrorResult("11", e.ToString()); } } catch (Exception ex) { executionResult = (IExecutionResult) new FailureResult(ex); } await executionResult.ExecuteResultAsync(context); }
private static Task HandlerDelegate <T>(IExternalTaskContext context) where T : class, IExternalTaskHandler { var handler = context.ServiceProvider.GetRequiredService <T>(); return(handler.HandleAsync(context)); }
public async Task RouteAsync(IExternalTaskContext context) { Guard.NotNull(context, nameof(context)); var externalTaskDelegate = _endpointProvider.GetEndpointDelegate(context.Task); var externalTask = context.Task; _logger.LogInformation("Started processing of task {TaskId}", externalTask.Id); await externalTaskDelegate(context); _logger.LogInformation("Finished processing of task {TaskId}", externalTask.Id); }
private async Task ExecuteInContext(IExternalTaskContext context) { using (context) { try { await _pipelineDescriptor.ExternalTaskDelegate(context); } catch (Exception e) { _logger.LogWarning(e, "Failed execution of task {Id}", context.Task.Id); } } }
public async Task ExecuteResultAsync(IExternalTaskContext context) { try { await context.CompleteAsync(Variables, LocalVariables); } catch (ClientException e) when(e.StatusCode == HttpStatusCode.InternalServerError) { context.LogWarning <CompleteResult>( "Failed completion of task {TaskId}. Reason: {Reason}", context.Task.Id, e.Message ); await context.ReportFailureAsync(e.ErrorType, e.ErrorMessage); } }
public async Task HandleAsync(IExternalTaskContext context) { IExecutionResult executionResult; try { executionResult = await Process(context.Task); } catch (Exception e) { executionResult = new FailureResult(e); } await executionResult.ExecuteResultAsync(context); }
internal static async Task RouteAsync(IExternalTaskContext context) { var router = context.ServiceProvider.GetRequiredService <IExternalTaskRouter>(); await router.RouteAsync(context); }
public Task ExecuteResultAsync(IExternalTaskContext context) => Task.CompletedTask;
internal static void LogWarning <T>(this IExternalTaskContext context, string message, params object[] args) { var logger = context.ServiceProvider.GetService <ILogger <T> >(); logger?.LogWarning(message, args); }
public Task ExecuteResultAsync(IExternalTaskContext context) { return(context.ReportFailureAsync(ErrorMessage, ErrorDetails, Retries, RetryTimeout)); }