Exemplo n.º 1
0
        /// <inheritdoc/>
        public virtual async Task HandleAsync(V1WorkflowInstanceExecutedDomainEvent e, CancellationToken cancellationToken = default)
        {
            var workflowInstance = await this.Mediator.ExecuteAndUnwrapAsync(new V1FindByIdQuery <Integration.Models.V1WorkflowInstance, string>(e.AggregateId));

            var workflow = await this.GetOrReconcileProjectionAsync(workflowInstance.WorkflowId, cancellationToken);

            workflow.RunningInstanceCount--;
            workflow.ExecutedInstanceCount++;
            switch (e.Status)
            {
            case V1WorkflowInstanceStatus.Completed:
                workflow.CompletedInstanceCount++;
                break;

            case V1WorkflowInstanceStatus.Faulted:
                workflow.FaultedInstanceCount++;
                break;

            case V1WorkflowInstanceStatus.Cancelled:
                workflow.CancelledInstanceCount++;
                break;
            }
            if (!workflowInstance.ExecutedAt.HasValue)
            {
                workflowInstance.ExecutedAt = e.CreatedAt.DateTime;
            }
            workflow.TotalInstanceExecutionTime = workflow.TotalInstanceExecutionTime.Add(workflowInstance.Duration !.Value);
            if (!workflow.ShortestInstanceDuration.HasValue ||
                workflowInstance.Duration < workflow.ShortestInstanceDuration)
            {
                workflow.ShortestInstanceDuration = workflowInstance.Duration;
            }
            if (!workflow.LongestInstanceDuration.HasValue ||
                workflowInstance.Duration > workflow.LongestInstanceDuration)
            {
                workflow.LongestInstanceDuration = workflowInstance.Duration;
            }
            await this.Projections.UpdateAsync(workflow, cancellationToken);

            await this.Projections.SaveChangesAsync(cancellationToken);
        }
        /// <inheritdoc/>
        public virtual async Task HandleAsync(V1WorkflowInstanceExecutedDomainEvent e, CancellationToken cancellationToken = default)
        {
            var metrics = await this.GetOrCreateV1OperationalReportsForAsync(e.CreatedAt, cancellationToken);

            metrics.RunningInstances--;
            metrics.ExecutedInstances++;
            switch (e.Status)
            {
            case V1WorkflowInstanceStatus.Completed:
                metrics.CompletedInstances++;
                break;

            case V1WorkflowInstanceStatus.Faulted:
                metrics.FaultedInstances++;
                break;

            case V1WorkflowInstanceStatus.Cancelled:
                metrics.CancelledInstances++;
                break;
            }
            await this.OperationalReports.UpdateAsync(metrics, cancellationToken);

            await this.OperationalReports.SaveChangesAsync(cancellationToken);
        }
 /// <inheritdoc/>
 public virtual async Task HandleAsync(V1WorkflowInstanceExecutedDomainEvent e, CancellationToken cancellationToken = default)
 {
     await this.PublishIntegrationEventAsync(e, cancellationToken);
 }