public override async ValueTask <IEnumerable <BookmarkResult> > GetBookmarksAsync(BookmarkProviderContext <HttpEndpoint> context, CancellationToken cancellationToken)
        {
            var path    = ToLower((await context.ReadActivityPropertyAsync(x => x.Path, cancellationToken)) !);
            var methods = (await context.ReadActivityPropertyAsync(x => x.Methods, cancellationToken))?.Select(ToLower) ?? Enumerable.Empty <string>();

            BookmarkResult CreateBookmark(string method) => Result(new(path, method));

            return(methods.Select(CreateBookmark));
        }
Esempio n. 2
0
 public override async ValueTask <IEnumerable <BookmarkResult> > GetBookmarksAsync(BookmarkProviderContext <EntityChanged> context, CancellationToken cancellationToken) =>
 new[]
 {
     Result(new EntityChangedBookmark(
                entityName: await context.ReadActivityPropertyAsync(x => x.EntityName, cancellationToken),
                action: await context.ReadActivityPropertyAsync(x => x.Action, cancellationToken),
                contextId: context.ActivityExecutionContext.WorkflowExecutionContext.WorkflowInstance.ContextId,
                correlationId: context.ActivityExecutionContext.WorkflowExecutionContext.WorkflowInstance.CorrelationId
                ))
 };
Esempio n. 3
0
        public override async ValueTask <IEnumerable <BookmarkResult> > GetBookmarksAsync(BookmarkProviderContext context, CancellationToken cancellationToken)
        {
            var activityType = context.ActivityExecutionContext.ActivityBlueprint.Type;

            var queueOrTopic = activityType == nameof(AzureServiceBusQueueMessageReceived)
                ? await context.ReadActivityPropertyAsync <AzureServiceBusQueueMessageReceived, string>(x => x.QueueName, cancellationToken)
                : await context.ReadActivityPropertyAsync <AzureServiceBusTopicMessageReceived, string>(x => x.TopicName, cancellationToken);

            var subscription = activityType == nameof(AzureServiceBusTopicMessageReceived)
                ? await context.ReadActivityPropertyAsync <AzureServiceBusTopicMessageReceived, string>(x => x.SubscriptionName, cancellationToken)
                : default;

            return(new[] { Result(new MessageReceivedBookmark(queueOrTopic !, subscription)) });
Esempio n. 4
0
        public override async ValueTask <IEnumerable <BookmarkResult> > GetBookmarksAsync(BookmarkProviderContext <EntityChanged> context, CancellationToken cancellationToken)
        {
            var entityName = await context.ReadActivityPropertyAsync(x => x.EntityName, cancellationToken);

            var action = await context.ReadActivityPropertyAsync(x => x.Action, cancellationToken);

            var bookmark = new EntityChangedBookmark(
                entityName,
                action
                );

            return(new[] { Result(bookmark) });
        }
        public override async ValueTask <IEnumerable <BookmarkResult> > GetBookmarksAsync(BookmarkProviderContext <WatchDirectory> context, CancellationToken cancellationToken)
        {
            var changeTypes = await context.ReadActivityPropertyAsync(a => a.ChangeTypes, cancellationToken);

            var notifyFilters = await context.ReadActivityPropertyAsync(a => a.NotifyFilters, cancellationToken);

            var path = await context.ReadActivityPropertyAsync(a => a.Path, cancellationToken);

            var pattern = NormalizeWildcard(await context.ReadActivityPropertyAsync(a => a.Pattern, cancellationToken));
            var result  = Result(new FileSystemEventBookmark(path, pattern, changeTypes, notifyFilters));

            return(new[] { result });
        }
Esempio n. 6
0
        private async IAsyncEnumerable <FilteredCallInitiatedBookmark> CreateBookmarksAsync(BookmarkProviderContext <FilteredCallInitiated> context, [EnumeratorCancellation] CancellationToken cancellationToken)
        {
            var to   = (await context.ReadActivityPropertyAsync(x => x.To, cancellationToken) ?? Array.Empty <string>()).Where(x => !string.IsNullOrWhiteSpace(x));
            var from = (await context.ReadActivityPropertyAsync(x => x.From, cancellationToken) ?? Array.Empty <string>()).Where(x => !string.IsNullOrWhiteSpace(x));

            foreach (var number in to)
            {
                yield return(new FilteredCallInitiatedToBookmark(number));
            }

            foreach (var number in from)
            {
                yield return(new FilteredCallInitiatedFromBookmark(number));
            }
        }
Esempio n. 7
0
        public override async ValueTask <IEnumerable <BookmarkResult> > GetBookmarksAsync(BookmarkProviderContext context, CancellationToken cancellationToken)
        {
            var path    = ToLower((string)context.ActivityType.Attributes["Path"]) !;
            var methods = (await context.ReadActivityPropertyAsync <HttpEndpoint, HashSet <string> >(x => x.Methods, cancellationToken))?.Select(ToLower) ?? Enumerable.Empty <string>();

            BookmarkResult CreateBookmark(string method) => Result(new(path, method), nameof(HttpEndpoint));

            return(methods.Select(CreateBookmark));
        }
Esempio n. 8
0
        private async IAsyncEnumerable <BookmarkResult> GetBookmarksInternalAsync(BookmarkProviderContext <SignalReceived> context, [EnumeratorCancellation] CancellationToken cancellationToken)
        {
            var signalName = (await context.ReadActivityPropertyAsync(x => x.Signal, cancellationToken)) !.ToLowerInvariant();

            yield return(Result(new SignalReceivedBookmark
            {
                Signal = signalName
            }));
        }
Esempio n. 9
0
        public override async ValueTask <IEnumerable <BookmarkResult> > GetBookmarksAsync(BookmarkProviderContext <Cron> context, CancellationToken cancellationToken)
        {
            var cronExpression = await context.ReadActivityPropertyAsync(x => x.CronExpression, cancellationToken);

            if (context.Mode == BookmarkIndexingMode.WorkflowInstance)
            {
                var executeAt = GetExecuteAt(context);

                if (executeAt == null)
                {
                    return(Enumerable.Empty <BookmarkResult>());
                }

                return(new[]
        private async IAsyncEnumerable <BookmarkResult> GetBookmarksInternalAsync(BookmarkProviderContext <SignalReceived> context, [EnumeratorCancellation] CancellationToken cancellationToken)
        {
            var signalName = (await context.ReadActivityPropertyAsync(x => x.Signal, cancellationToken))?.ToLowerInvariant().Trim();

            // Can't do anything with an empty signal name.
            if (string.IsNullOrEmpty(signalName))
            {
                yield break;
            }

            yield return(Result(new SignalReceivedBookmark
            {
                Signal = signalName
            }));
        }
        private async IAsyncEnumerable <BookmarkResult> GetBookmarksInternalAsync(BookmarkProviderContext <SignalReceived> context, [EnumeratorCancellation] CancellationToken cancellationToken)
        {
            var signalName  = (await context.ReadActivityPropertyAsync(x => x.Signal, cancellationToken)) !.ToLowerInvariant();
            var signalScope = (await context.ReadActivityPropertyAsync(x => x.Scope, cancellationToken)) !;

            if (context.Mode == BookmarkIndexingMode.WorkflowBlueprint || signalScope == SignalScope.Global)
            {
                yield return(Result(new SignalReceivedBookmark
                {
                    Signal = signalName
                }));

                yield break;
            }

            if (signalScope == SignalScope.Instance)
            {
                yield return(Result(new SignalReceivedBookmark
                {
                    Signal = signalName,
                    WorkflowInstanceId = context.ActivityExecutionContext.WorkflowInstance.Id
                }));
            }
        }
        public override async ValueTask <IEnumerable <BookmarkResult> > GetBookmarksAsync(BookmarkProviderContext <RebusMessageReceived> context, CancellationToken cancellationToken)
        {
            var messageType = await context.ReadActivityPropertyAsync(x => x.MessageType, cancellationToken);

            if (messageType == null)
            {
                return(Enumerable.Empty <BookmarkResult>());
            }

            return(new[]
            {
                Result(new MessageReceivedBookmark
                {
                    MessageType = messageType.Name
                })
            });
        }
Esempio n. 13
0
        public override async ValueTask <IEnumerable <BookmarkResult> > GetBookmarksAsync(BookmarkProviderContext <Timer> context, CancellationToken cancellationToken)
        {
            var interval = await context.ReadActivityPropertyAsync(x => x.Timeout, cancellationToken);

            var executeAt = GetExecuteAt(context, interval);

            if (executeAt != null)
            {
                return new[]
                       {
                           Result(new TimerBookmark
                    {
                        ExecuteAt = executeAt.Value,
                        Interval  = interval
                    })
                       }
            }
            ;

            return(Enumerable.Empty <BookmarkResult>());
        }
Esempio n. 14
0
        private async IAsyncEnumerable <BookmarkResult> GetBookmarksInternalAsync(BookmarkProviderContext <RunTask> context, [EnumeratorCancellation] CancellationToken cancellationToken)
        {
            var taskName = ToLower(await context.ReadActivityPropertyAsync(x => x.TaskName, cancellationToken)) !;

            yield return(Result(new TaskBookmark(taskName), nameof(RunTask)));
        }
Esempio n. 15
0
        public override async ValueTask <IEnumerable <BookmarkResult> > GetBookmarksAsync(BookmarkProviderContext <UserTask> context, CancellationToken cancellationToken)
        {
            var actions = (await context.ReadActivityPropertyAsync(x => x.Actions, cancellationToken)) !;

            return(actions.Select(x => Result(new UserTaskBookmark(x))).ToList());
        }
Esempio n. 16
0
        private async IAsyncEnumerable <BookmarkResult> GetBookmarksInternalAsync(BookmarkProviderContext <EventReceived> context, [EnumeratorCancellation] CancellationToken cancellationToken)
        {
            var eventName = ToLower(await context.ReadActivityPropertyAsync(x => x.EventName, cancellationToken)) !;

            yield return(Result(new EventBookmark(eventName), nameof(EventReceived)));
        }
Esempio n. 17
0
 private static async Task <Instant?> GetExecuteAtAsync(BookmarkProviderContext <StartAt> context, CancellationToken cancellationToken) =>
 context.Mode == BookmarkIndexingMode.WorkflowInstance
         ? context.Activity.GetPropertyValue(x => x.ExecuteAt)
         : await context.ReadActivityPropertyAsync(x => x.Instant, cancellationToken);