예제 #1
0
        public async Task <WorkflowDefinitionVersion> PublishAsync(
            WorkflowDefinitionVersion workflowDefinition,
            CancellationToken cancellationToken)
        {
            var definition = mapper.Map <WorkflowDefinitionVersion>(workflowDefinition);

            var publishedDefinition = await store.GetByIdAsync(
                definition.DefinitionId,
                VersionOptions.Published,
                cancellationToken);

            if (publishedDefinition != null)
            {
                publishedDefinition.IsPublished = false;
                publishedDefinition.IsLatest    = false;
                await store.UpdateAsync(publishedDefinition, cancellationToken);
            }

            if (definition.IsPublished)
            {
                definition.Id = idGenerator.Generate();
                definition.Version++;
            }
            else
            {
                definition.IsPublished = true;
            }

            definition.IsLatest = true;
            definition          = Initialize(definition);

            await store.SaveAsync(definition, cancellationToken);

            return(definition);
        }
        public async Task <WorkflowDefinitionVersion> UpdateAsync(WorkflowDefinitionVersion definition, CancellationToken cancellationToken = default)
        {
            var updatedDefinition = await decoratedStore.UpdateAsync(definition, cancellationToken);

            await PublishUpdateEventAsync(cancellationToken);

            return(updatedDefinition);
        }
예제 #3
0
        public async Task UpdateAsync(WorkflowDefinition entity, CancellationToken cancellationToken = default)
        {
            await _mediator.Publish(new WorkflowDefinitionSaving(entity), cancellationToken);

            await _store.UpdateAsync(entity, cancellationToken);

            await _mediator.Publish(new WorkflowDefinitionSaved(entity), cancellationToken);
        }
예제 #4
0
 public async Task UpdateAsync(WorkflowDefinition entity, CancellationToken cancellationToken)
 {
     entity = Initialize(entity);
     await _store.UpdateAsync(entity, cancellationToken);
 }