public ViewResult Create()
        {
            var workflowDefinition = publisher.New();

            var model = new WorkflowDefinitionEditModel
            {
                Name = workflowDefinition.Name,
                Json = serializer.Serialize(workflowDefinition, JsonTokenFormatter.FormatName),
                ActivityDefinitions = options.Value.ActivityDefinitions.ToArray(),
                IsSingleton         = workflowDefinition.IsSingleton,
                IsDisabled          = workflowDefinition.IsDisabled,
                Description         = workflowDefinition.Description
            };

            return(View(model));
        }
예제 #2
0
        public async Task <AWFDefinitionDetailResponse> GetDetailDefinitionAsync(string id, CancellationToken cancellationToken)
        {
            var workflowDefinition = await _publisher.GetDraftAsync(id, cancellationToken);

            if (workflowDefinition == null)
            {
                throw new ErrorException(StatusCodes.Status404NotFound, $"Can't not found workflow definition with {id}");
            }

            var workflowModel = new WorkflowModel
            {
                Activities  = workflowDefinition.Activities.Select(x => new ActivityModel(x)).ToList(),
                Connections = workflowDefinition.Connections.Select(x => new ConnectionModel(x)).ToList()
            };

            var model = new WorkflowDefinitionEditModel
            {
                Id                  = workflowDefinition.DefinitionId,
                Name                = workflowDefinition.Name,
                Json                = _serializer.Serialize(workflowModel, JsonTokenFormatter.FormatName),
                Description         = workflowDefinition.Description,
                IsSingleton         = workflowDefinition.IsSingleton,
                IsDisabled          = workflowDefinition.IsDisabled,
                ActivityDefinitions = _options.Value.ActivityDefinitions.ToArray(),
                WorkflowModel       = workflowModel
            };

            return(_mapper.Map <AWFDefinitionDetailResponse>(model));
        }
 public static string Serialize(this IWorkflowSerializer serializer, Workflow workflow, string format)
 {
     return(serializer.Serialize(workflow.ToInstance(), format));
 }