private async Task AddActivityOutputAsync(Engine engine, ActivityExecutionContext activityExecutionContext, CancellationToken cancellationToken)
        {
            var workflowExecutionContext = activityExecutionContext.WorkflowExecutionContext;
            var workflowInstance         = activityExecutionContext.WorkflowInstance;
            var workflowBlueprint        = workflowExecutionContext.WorkflowBlueprint;
            var activities = new Dictionary <string, object>();

            foreach (var activity in workflowBlueprint.Activities.Where(x => !string.IsNullOrWhiteSpace(x.Name)))
            {
                var activityType = await _activityTypeService.GetActivityTypeAsync(activity.Type, cancellationToken);

                var activityDescriptor = await _activityTypeService.DescribeActivityType(activityType, cancellationToken);

                var outputProperties      = activityDescriptor.OutputProperties;
                var storageProviderLookup = activity.PropertyStorageProviders;
                var activityModel         = new Dictionary <string, object?>();
                var storageContext        = new WorkflowStorageContext(workflowInstance, activity.Id);

                foreach (var property in outputProperties)
                {
                    var propertyName        = property.Name;
                    var storageProviderName = storageProviderLookup.GetItem(propertyName) ?? property.DefaultWorkflowStorageProvider;

                    activityModel[propertyName] = (Func <object?>)(() => _workflowStorageService.LoadAsync(storageProviderName, storageContext, propertyName, cancellationToken).Result);
                }

                activities[activity.Name !] = activityModel;
Beispiel #2
0
        private async ValueTask <(Variables InputProperties, Variables OutputProperties)> GetActivityPropertiesAsync(IWorkflowBlueprintWrapper workflowBlueprintWrapper, IActivityBlueprintWrapper activityBlueprintWrapper, CancellationToken cancellationToken)
        {
            var activityBlueprint = activityBlueprintWrapper.ActivityBlueprint;
            var activityType      = await _activityTypeService.GetActivityTypeAsync(activityBlueprint.Type, cancellationToken);

            var activityDescriptor = await _activityTypeService.DescribeActivityType(activityType, cancellationToken);

            var activityId       = activityBlueprint.Id;
            var activityWrapper  = workflowBlueprintWrapper.GetActivity(activityId) !;
            var inputProperties  = new Variables();
            var outputProperties = new Variables();

            foreach (var property in activityDescriptor.InputProperties)
            {
                var value = await GetPropertyValueAsync(workflowBlueprintWrapper.WorkflowBlueprint, activityWrapper, property, cancellationToken);

                inputProperties.Set(property.Name, value);
            }

            foreach (var property in activityDescriptor.OutputProperties)
            {
                // Declare output properties to have at least a complete schema.
                outputProperties.Set(property.Name, null);
            }

            return(inputProperties, outputProperties);
        }
Beispiel #3
0
        private async Task <ActivityDescriptor> DescribeActivity(ActivityType activityType, CancellationToken cancellationToken)
        {
            var activityDescriptor = await _activityTypeService.DescribeActivityType(activityType, cancellationToken);

            // Filter out any non-browsable properties.
            activityDescriptor.InputProperties = activityDescriptor.InputProperties.Where(x => x.IsBrowsable == true).ToArray();

            return(activityDescriptor);
        }
Beispiel #4
0
 private async Task <ActivityDescriptor> DescribeActivity(ActivityType activityType, CancellationToken cancellationToken) => await _activityTypeService.DescribeActivityType(activityType, cancellationToken);