public async Task <int> DeleteManyAsync(ISpecification <WorkflowDefinition> specification, CancellationToken cancellationToken = default) { var workflowDefinitions = await FindManyAsync(specification, cancellationToken : cancellationToken).ToList(); if (!workflowDefinitions.Any()) { return(0); } foreach (var workflowDefinition in workflowDefinitions) { await _mediator.Publish(new WorkflowDefinitionDeleting(workflowDefinition), cancellationToken); } await _mediator.Publish(new ManyWorkflowDefinitionsDeleting(workflowDefinitions), cancellationToken); var count = await _store.DeleteManyAsync(specification, cancellationToken); foreach (var instance in workflowDefinitions) { await _mediator.Publish(new WorkflowDefinitionDeleted(instance), cancellationToken); } await _mediator.Publish(new ManyWorkflowDefinitionsDeleted(workflowDefinitions), cancellationToken); return(count); }
public async Task DeleteAsync(string workflowDefinitionId, VersionOptions versionOptions, CancellationToken cancellationToken = default) { if (versionOptions.AllVersions) { await _workflowInstanceStore.DeleteManyAsync(new WorkflowDefinitionIdSpecification(workflowDefinitionId), cancellationToken); await _workflowDefinitionStore.DeleteManyAsync(new Persistence.Specifications.WorkflowDefinitions.WorkflowDefinitionIdSpecification(workflowDefinitionId), cancellationToken); } else { var definition = await _workflowDefinitionStore.FindByDefinitionIdAsync(workflowDefinitionId, versionOptions, cancellationToken); if (definition != null) { await DeleteAsync(definition, cancellationToken); } } }
public async Task DeleteAsync(string workflowDefinitionId, CancellationToken cancellationToken = default) { await _workflowInstanceStore.DeleteManyAsync(new WorkflowDefinitionIdSpecification(workflowDefinitionId), cancellationToken); await _workflowDefinitionStore.DeleteManyAsync(new Persistence.Specifications.WorkflowDefinitions.WorkflowDefinitionIdSpecification(workflowDefinitionId), cancellationToken); }
public Task <int> DeleteManyAsync(ISpecification <WorkflowDefinition> specification, CancellationToken cancellationToken) => _store.DeleteManyAsync(specification, cancellationToken);