Example #1
0
        /// <summary>
        /// Executes the Activity
        /// </summary>
        /// <param name="context"></param>
        protected override void Execute(NativeActivityContext context)
        {
            //
            //  We must enter a NoPersist zone because it looks like we're idle while our
            //  Task is executing but, we aren't really
            //
            NoPersistHandle noPersistHandle = NoPersistHandle.Get(context);

            noPersistHandle.Enter(context);

            //
            //  Set a bookmark that we will resume when our Task is done
            //
            m_Bookmark = context.CreateBookmark(BookmarkResumptionCallback);
            this.Bookmark.Set(context, m_Bookmark);
            m_BookmarkResumptionHelper = context.GetExtension <BookmarkResumptionHelper>();

            //
            //  Prepare to execute
            //
            PrepareToExecute(context);

            //
            //  Start a Task to do the actual execution of our activity
            //
            CancellationTokenSource tokenSource = new CancellationTokenSource();

            m_Task = Task.Factory.StartNew(ExecuteNonblocking, tokenSource.Token);
            m_Task.ContinueWith(TaskCompletionCallback);
        }
Example #2
0
        protected override void Execute(NativeActivityContext context)
        {
            // setup a no persist zone (don't want to be persisted while querying or mapping values)
            NoPersistHandle noPersistHandle = this.noPersistHandle.Get(context);

            noPersistHandle.Enter(context);

            // configure the helper object to access the database
            dbHelper = new DbHelper();
            dbHelper.ConnectionString = this.ConnectionString.Get(context);
            dbHelper.ProviderName     = this.ProviderName.Get(context);
            dbHelper.ConfigName       = this.ConfigName.Get(context);
            dbHelper.Sql         = this.Sql.Get(context);
            dbHelper.CommandType = this.CommandType;
            dbHelper.Parameters  = this.parameters;
            dbHelper.Init(context);

            // retrieve the data
            this.reader = dbHelper.ExecuteReader();

            // map the results
            if (this.Mapper != null)
            {
                // direct execution (invoke the Mapper function in a single pulse)
                DirectMapping(context);
            }
            else // execute in multiple pulses (each pulse invokes the MapperAction ActivityFunc)
            {
                // initialize results list
                this.Result.Set(context, new List <TResult>());

                // map a record
                InternalMapRecord(context);
            }
        }
Example #3
0
 protected override void Execute(NativeActivityContext context)
 {
     if (this.Body != null)
     {
         NoPersistHandle handle = this.noPersistHandle.Get(context);
         handle.Enter(context);
         context.ScheduleActivity(this.Body);
     }
 }
Example #4
0
        protected override void Execute(NativeActivityContext context)
        {
            TestTraceListenerExtension listenerExtension = context.GetExtension <TestTraceListenerExtension>();
            NoPersistHandle            handle            = _noPersistHandle.Get(context);

            handle.Enter(context);

            UserTrace.Trace(listenerExtension, context.WorkflowInstanceId, NoPersistenceBlockEntered);

            // Schedule all of the Sequence's Activities
            base.Execute(context);

            UserTrace.Trace(listenerExtension, context.WorkflowInstanceId, NoPersistenceBlockExited);
        }
        protected override void Execute(NativeActivityContext context)
        {
            string          bookmarkName           = BookmarkName.Get(context);
            NoPersistHandle noPersistHandleToEnter = noPersistHandle.Get(context);

            noPersistHandleToEnter.Enter(context);
            Bookmark bookmark = context.CreateBookmark(bookmarkName,
                                                       (NativeActivityContext _callbackContext, Bookmark _bookmark, object _state) =>
            {
                NoPersistHandle noPersistHandleToExit = noPersistHandle.Get(_callbackContext);
                noPersistHandleToExit.Exit(_callbackContext);
            });

            this.bookmark.Set(context, bookmark);
        }
        protected override void Execute(NativeActivityContext context)
        {
            // enter a no persist scope
            NoPersistHandle noPersistHandle = this.noPersistHandle.Get(context);

            noPersistHandle.Enter(context);

            // get the connection string
            string connectionString = this.ConnectionString.Get(context);

            // create the connection context
            this.efContext = new ObjectContext(connectionString);

            // use NorthwindEntities as the container name for this example until the default container feature is in
            this.efContext.DefaultContainerName = this.ContainerName.Get(context);

            // set the object context in the execution properties (to make it an ambient object context)
            context.Properties.Add(ObjectContextPropertyName, efContext);

            // schedule the body activity
            context.ScheduleActivity(this.Body, new CompletionCallback(OnBodyComplete));
        }
Example #7
0
        protected override void Execute(NativeActivityContext context)
        {
            NoPersistHandle noPersistHandle = this.NoPersistHandle.Get(context);

            noPersistHandle.Enter(context);
            Bookmark bookmark = context.CreateBookmark(new BookmarkCallback(this.BookmarkResumptionCallback));

            this.Bookmark.Set(context, bookmark);
            BookmarkResumptionHelper helper = context.GetExtension <BookmarkResumptionHelper>();

            System.Action <System.IAsyncResult> state = delegate(System.IAsyncResult result)
            {
                helper.ResumeBookmark(bookmark, result);
            };
            System.IAsyncResult asyncResult = this.BeginExecute(context, new System.AsyncCallback(this.AsyncCompletionCallback), state);
            if (asyncResult.CompletedSynchronously)
            {
                noPersistHandle.Exit(context);
                context.RemoveBookmark(bookmark);
                this.EndExecute(context, asyncResult);
            }
        }