Example #1
0
        private async ValueTask <WorkflowModel> CreateWorkflowModelAsync(WorkflowBlueprint workflowBlueprint)
        {
            var activities = await Task.WhenAll(workflowBlueprint.Activities.Select(async x => await CreateActivityModelAsync(x)));

            return(new()
            {
                Name = workflowBlueprint.Name,
                Activities = activities.ToImmutableList(),
                Connections = workflowBlueprint.Connections.Select(CreateConnectionModel).ToImmutableList()
            });
        }
        public async Task <IWorkflowBlueprint> CreateWorkflowBlueprintAsync(WorkflowDefinition workflowDefinition, CancellationToken cancellationToken)
        {
            var manyActivityBlueprints = await Task.WhenAll(workflowDefinition.Activities.Select(async x => await CreateBlueprintsAsync(x, cancellationToken)));

            var activityBlueprints          = manyActivityBlueprints.SelectMany(x => x).Distinct().ToDictionary(x => x.Id);
            var compositeActivityBlueprints = activityBlueprints.Values.Where(x => x is ICompositeActivityBlueprint).Cast <ICompositeActivityBlueprint>().ToList();
            var connections       = compositeActivityBlueprints.SelectMany(x => x.Connections).Distinct().ToList();
            var propertyProviders = compositeActivityBlueprints.SelectMany(x => x.ActivityPropertyProviders).ToList();

            connections.AddRange(workflowDefinition.Connections.Select(x => ResolveConnection(x, activityBlueprints)).Where(x => x != null).Select(x => x !));
            propertyProviders.AddRange(await CreatePropertyProviders(workflowDefinition, cancellationToken));

            var workflowBlueprint = new WorkflowBlueprint(
                workflowDefinition.DefinitionId,
                workflowDefinition.Version,
                workflowDefinition.VersionId,
                workflowDefinition.TenantId,
                workflowDefinition.IsSingleton,
                workflowDefinition.Name,
                workflowDefinition.DisplayName,
                workflowDefinition.Description,
                workflowDefinition.IsLatest,
                workflowDefinition.IsPublished,
                workflowDefinition.Tag,
                workflowDefinition.Channel,
                workflowDefinition.Variables,
                workflowDefinition.CustomAttributes,
                workflowDefinition.ContextOptions,
                workflowDefinition.PersistenceBehavior,
                workflowDefinition.DeleteCompletedInstances,
                activityBlueprints.Values,
                connections,
                new ActivityPropertyProviders(propertyProviders.ToDictionary(x => x.Key, x => x.Value))
                );

            foreach (var compositeActivityBlueprint in compositeActivityBlueprints)
            {
                ((CompositeActivityBlueprint)compositeActivityBlueprint).Parent = workflowBlueprint;
            }

            return(workflowBlueprint);
        }
Example #3
0
 public WorkflowBlueprintSurrogate(WorkflowBlueprint value)
 {
     Value = Serialize(value);
 }