Example #1
0
        /// <inheritdoc/>
        public virtual async Task HandleAsync(V1WorkflowActivityCompletedDomainEvent e, CancellationToken cancellationToken = default)
        {
            var activity = await this.GetOrReconcileProjectionAsync(e.AggregateId, cancellationToken);

            activity.LastModified = e.CreatedAt.UtcDateTime;
            activity.ExecutedAt   = e.CreatedAt.UtcDateTime;
            activity.Status       = V1WorkflowActivityStatus.Completed;
            var outputValue = e.Output as Dynamic;

            if (outputValue == null &&
                e.Output != null)
            {
                outputValue = Dynamic.FromObject(e.Output);
            }
            activity.Output = outputValue;
            await this.Projections.UpdateAsync(activity, cancellationToken);

            await this.Projections.SaveChangesAsync(cancellationToken);

            await this.UpdateParentWorkflowInstanceAsync(activity, cancellationToken);

            await this.PublishIntegrationEventAsync(e, cancellationToken);
        }
 /// <summary>
 /// Handles the specified <see cref="V1WorkflowActivityCompletedDomainEvent"/>
 /// </summary>
 /// <param name="e">The <see cref="V1WorkflowActivityCompletedDomainEvent"/> to handle</param>
 protected virtual void On(V1WorkflowActivityCompletedDomainEvent e)
 {
     this.Status = V1WorkflowActivityStatus.Completed;
     this.Output = e.Output;
     this.On(this.RegisterEvent(new V1WorkflowActivityExecutedDomainEvent(this.Id, this.Status, this.Output)));
 }