Ejemplo n.º 1
0
        public async Task <WorkflowDefinition?> PublishAsync(string workflowDefinitionId, CancellationToken cancellationToken = default)
        {
            var definition = await _workflowDefinitionStore.FindByDefinitionIdAsync(
                workflowDefinitionId,
                VersionOptions.Latest,
                cancellationToken);

            if (definition == null)
            {
                return(null);
            }

            return(await PublishAsync(definition, cancellationToken));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Handle(string workflowDefinitionId, string?context = default, VersionOptions?version = default, CancellationToken cancellationToken = default)
        {
            version ??= VersionOptions.Latest;
            var workflowDefinition = await _workflowDefinitionStore.FindByDefinitionIdAsync(workflowDefinitionId, version.Value, cancellationToken);

            var typeDefinitions = await _typeScriptDefinitionService.GenerateTypeScriptDefinitionsAsync(workflowDefinition, context, cancellationToken);

            var fileName = $"elsa.{workflowDefinitionId}.d.ts";
            var data     = Encoding.UTF8.GetBytes(typeDefinitions);

            return(File(data, "application/x-typescript", fileName));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <WorkflowDefinition> > Handle(string workflowDefinitionId, ApiVersion apiVersion, CancellationToken cancellationToken)
        {
            var workflowDefinition = await _workflowDefinitionStore.FindByDefinitionIdAsync(workflowDefinitionId, VersionOptions.Published, cancellationToken);

            if (workflowDefinition == null)
            {
                return(NotFound());
            }

            workflowDefinition = await _workflowPublisher.RetractAsync(workflowDefinition, cancellationToken);

            return(AcceptedAtAction("Handle", "GetByVersionId", new { versionId = workflowDefinition.Id, apiVersion = apiVersion.ToString() }, workflowDefinition));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Handle(string workflowDefinitionId, VersionOptions versionOptions, CancellationToken cancellationToken)
        {
            var workflowDefinition = await _workflowDefinitionStore.FindByDefinitionIdAsync(workflowDefinitionId, versionOptions, cancellationToken);

            if (workflowDefinition == null)
            {
                return(NotFound());
            }

            var json         = _contentSerializer.Serialize(workflowDefinition);
            var bytes        = Encoding.UTF8.GetBytes(json);
            var workflowName = workflowDefinition.Name is null or "" ? workflowDefinition.DefinitionId : workflowDefinition.Name.Trim();
            var fileName     = $"workflow-definition-{workflowName.Underscore().Dasherize().ToLowerInvariant()}.json";

            return(File(bytes, "application/json", fileName));
        }