コード例 #1
0
ファイル: ActivityInvoker.cs プロジェクト: randyammar/Elsa
        private Task <ActivityExecutionResult> InvokeAsync(
            WorkflowExecutionContext workflowContext,
            IActivity activity,
            Func <ActivityExecutionContext, IActivityDriver, Task <ActivityExecutionResult> > invokeAction)
        {
            var activityContext = workflowContext.CreateActivityExecutionContext(activity);
            var driver          = driverRegistry.GetDriver(activity.Name);

            return(invokeAction(activityContext, driver));
        }
コード例 #2
0
        private async Task <ActivityExecutionResult> InvokeAsync(
            WorkflowExecutionContext workflowContext,
            IActivity activity,
            Func <ActivityExecutionContext, IActivityDriver, Task <ActivityExecutionResult> > invokeAction)
        {
            var activityContext = workflowContext.CreateActivityExecutionContext(activity);
            var driver          = driverRegistry.GetDriver(activity.Name);

            try
            {
                if (driver == null)
                {
                    throw new WorkflowException($"No driver found for activity {activity.Name}");
                }

                return(await invokeAction(activityContext, driver));
            }
            catch (Exception e)
            {
                logger.LogError(e, "Error while invoking activity {ActivityId} of workflow {WorkflowId}", activity.Id, workflowContext.Workflow.Metadata.Id);
                workflowContext.Workflow.AddLogEntry(activity.Id, clock.GetCurrentInstant(), e.Message, true);
                return(new FaultWorkflowResult(e, clock.GetCurrentInstant()));
            }
        }