public void Setup()
        {
            _builder = new EventGraphBuilder();
            var scheduledActivityEventGraph = _builder.ActivityStartedGraph(Identity.New(ActivityName, ActivityVersion, PositionalName).ScheduleId(), WorkerId);

            _activityStartedEvent = new ActivityStartedEvent(scheduledActivityEventGraph.First(), scheduledActivityEventGraph);
        }
示例#2
0
        public void Setup()
        {
            _builder = new HistoryEventsBuilder();
            var scheduledActivityEventGraph = _builder.ActivityStartedGraph(Identity.New(_activityName, _activityVersion, _positionalName), _workerId);

            _activityStartedEvent = new ActivityStartedEvent(scheduledActivityEventGraph.First(), scheduledActivityEventGraph);
        }
        /// <summary>
        /// This should only be called when restoring an existing workflow. This is a short blocking operation. It only waits a short amount of time. It if exits too early the workflow does not come back.
        /// </summary>
        /// <param name="id"></param>
        /// <exception cref="System.Runtime.DurableInstancing.InstanceLockedException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        public void ReloadAndRun(Guid id)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            _log.Info("Attempting to readload activity. Id=" + id.ToString());

            _application.Load(id);
            _application.Run(_timeOut);

            ActivityStartedEvent?.Invoke(id, _application.WorkflowDefinition);

            //Give it time to startup before exiting.
            _reloadWaitHandler.WaitOne(new TimeSpan(0, 0, 5));
        }
        /// <summary>
        /// Reloads the workflow starting from a bookmark.
        /// </summary>
        /// <param name="id">Workflow Id</param>
        /// <param name="bookmarkName">The name of the bookmark to be resumed.</param>
        /// <param name="value">An object passed as a parameter to the method that is invoked when the bookmark resumes.</param>
        /// <returns>NotFound | NotReady | Success</returns>
        /// <exception cref="System.Runtime.DurableInstancing.InstanceLockedException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        public BookmarkResumptionResult ReloadAndRun(Guid id, string bookmarkName, object value)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            if (string.IsNullOrEmpty(bookmarkName))
            {
                throw new ArgumentNullException(nameof(bookmarkName));
            }

            _log.Info("Attempting to readload bookmark=" + bookmarkName);


            ActivityStartedEvent?.Invoke(id, _application.WorkflowDefinition);
            _application.Run(_timeOut);

            return(_application.ResumeBookmark(bookmarkName, value, _timeOut));
        }
        /// <summary>
        /// Runs the workflow.
        /// </summary>
        public void Run()
        {
            _application.Run(_timeOut);

            ActivityStartedEvent?.Invoke(_application.Id, _application.WorkflowDefinition);
        }