コード例 #1
0
ファイル: ScheduleTimers.cs プロジェクト: jruckert/elsa-core
        public async Task Handle(BookmarkIndexingFinished notification, CancellationToken cancellationToken)
        {
            var bookmarks          = notification.Bookmarks;
            var workflowInstanceId = notification.WorkflowInstanceId;
            var startAtBookmarks   = bookmarks.FilterByType <StartAtBookmark>();
            var timerBookmarks     = bookmarks.FilterByType <TimerBookmark>();
            var cronBookmarks      = bookmarks.FilterByType <CronBookmark>();

            await _workflowInstanceScheduler.UnscheduleAsync(workflowInstanceId, cancellationToken);

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

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

            foreach (var trigger in cronBookmarks)
            {
                var bookmark = _bookmarkSerializer.Deserialize <CronBookmark>(trigger.Model);
                await Try(() => _workflowInstanceScheduler.ScheduleAsync(workflowInstanceId, trigger.ActivityId, bookmark.CronExpression, cancellationToken));
            }
        }
コード例 #2
0
        public async Task Handle(BlockingActivityRemoved notification, CancellationToken cancellationToken)
        {
            // TODO: Consider introducing a "stereotype" field for activities to exit early in case they are not stereotyped as "temporal".

            await _workflowInstanceScheduler.UnscheduleAsync(
                notification.WorkflowExecutionContext.WorkflowInstance.Id,
                notification.BlockingActivity.ActivityId,
                cancellationToken);
        }
コード例 #3
0
ファイル: CancelTimer.cs プロジェクト: mhymhygi/elsa-core
        protected override async ValueTask <IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context)
        {
            await _workflowScheduler.UnscheduleAsync(context.WorkflowInstance.Id, ActivityId, context.CancellationToken);

            return(Done());
        }