Esempio n. 1
0
    public async Task <IEnumerable <UserAction> > GetUserActionsAsync(string workflowInstanceId, CancellationToken cancellationToken = default)
    {
        var specification = BookmarkTypeAndWorkflowInstanceSpecification.For <UserTaskBookmark>(workflowInstanceId);
        var bookmarks     = await _bookmarkStore.FindManyAsync(specification, cancellationToken : cancellationToken);

        var userTaskBookmarks = bookmarks.Select(bookmark => _bookmarkSerializer.Deserialize <UserTaskBookmark>(bookmark.Model)).ToList();

        return(userTaskBookmarks.Select(x => new UserAction(workflowInstanceId, x.Action)));
    }
Esempio n. 2
0
    public async Task Handle(ScheduleTemporalBookmark message)
    {
        var bookmark         = message.Bookmark;
        var bookmarkTypeName = bookmark.ModelType;
        var bookmarkType     = Type.GetType(bookmarkTypeName) !;
        var model            = _bookmarkSerializer.Deserialize(bookmark.Model, bookmarkType);

        _logger.LogDebug("Scheduling bookmark {@Bookmark}", model);

        switch (model)
        {
        case TimerBookmark timerBookmark:
            await _workflowInstanceScheduler.ScheduleAsync(bookmark.WorkflowInstanceId, bookmark.ActivityId, timerBookmark.ExecuteAt, null);

            break;

        case StartAtBookmark startAtBookmark:
            await _workflowInstanceScheduler.ScheduleAsync(bookmark.WorkflowInstanceId, bookmark.ActivityId, startAtBookmark.ExecuteAt, null);

            break;

        case CronBookmark cronBookmark:
            await _workflowInstanceScheduler.ScheduleAsync(bookmark.WorkflowInstanceId !, bookmark.ActivityId, cronBookmark.CronExpression);

            break;
        }
    }
Esempio n. 3
0
    public async Task Handle(ScheduleTemporalTrigger message)
    {
        var trigger          = message.Trigger;
        var bookmarkTypeName = trigger.ModelType;
        var bookmarkType     = Type.GetType(bookmarkTypeName) !;
        var model            = _bookmarkSerializer.Deserialize(trigger.Model, bookmarkType);

        _logger.LogDebug("Scheduling trigger {@Trigger}", model);

        switch (model)
        {
        case TimerBookmark timerBookmark:
            await _workflowDefinitionScheduler.ScheduleAsync(trigger.WorkflowDefinitionId, trigger.ActivityId, timerBookmark.ExecuteAt, timerBookmark.Interval);

            break;

        case StartAtBookmark startAtBookmark:
            await _workflowDefinitionScheduler.ScheduleAsync(trigger.WorkflowDefinitionId, trigger.ActivityId, startAtBookmark.ExecuteAt, null);

            break;

        case CronBookmark cronBookmark:
            await _workflowDefinitionScheduler.ScheduleAsync(trigger.WorkflowDefinitionId !, trigger.ActivityId, cronBookmark.CronExpression);

            break;
        }
    }
Esempio n. 4
0
        public async Task Handle(TriggerIndexingFinished notification, CancellationToken cancellationToken)
        {
            var startAtTriggers = notification.Triggers.FilterByBookmarkType <StartAtBookmark>();
            var timerTriggers   = notification.Triggers.FilterByBookmarkType <TimerBookmark>();
            var cronTriggers    = notification.Triggers.FilterByBookmarkType <CronBookmark>();

            await _workflowDefinitionScheduler.UnscheduleAsync(notification.WorkflowDefinitionId, cancellationToken);

            foreach (var trigger in startAtTriggers)
            {
                var bookmark = _bookmarkSerializer.Deserialize <StartAtBookmark>(trigger.Model);
                await Try(() => _workflowDefinitionScheduler.ScheduleAsync(trigger.WorkflowDefinitionId, trigger.ActivityId, bookmark.ExecuteAt, null, cancellationToken));
            }

            foreach (var trigger in timerTriggers)
            {
                var bookmark = _bookmarkSerializer.Deserialize <TimerBookmark>(trigger.Model);
                await Try(() => _workflowDefinitionScheduler.ScheduleAsync(trigger.WorkflowDefinitionId, trigger.ActivityId, bookmark.ExecuteAt, bookmark.Interval, cancellationToken));
            }

            foreach (var trigger in cronTriggers)
            {
                var bookmark = _bookmarkSerializer.Deserialize <CronBookmark>(trigger.Model);
                await Try(() => _workflowDefinitionScheduler.ScheduleAsync(trigger.WorkflowDefinitionId, trigger.ActivityId, bookmark.CronExpression, cancellationToken));
            }
        }
Esempio n. 5
0
 private IEnumerable <BookmarkFinderResult> SelectResults(IEnumerable <Bookmark> bookmarks) =>
 from bookmark in bookmarks
 let bookmarkType                         = Type.GetType(bookmark.ModelType)
                                let model = _serializer.Deserialize(bookmark.Model, bookmarkType)
                                            select new BookmarkFinderResult(bookmark.WorkflowInstanceId, bookmark.ActivityId, model, bookmark.CorrelationId);
Esempio n. 6
0
 public static T Deserialize <T>(this IBookmarkSerializer serializer, string json) where T : IBookmark => (T)serializer.Deserialize(json, typeof(T));