예제 #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));
        }
예제 #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));
        }
예제 #3
0
파일: Retract.cs 프로젝트: tle5/elsa-core
        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));
        }
예제 #4
0
파일: Export.cs 프로젝트: tle5/elsa-core
        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));
        }