Windows Workflow Foundation (WF4) - Workflow Services and Auto-Start

This sample application demonstrates how you can create a Workflow Service that will automatically start and periodically wake up to do some work. The sample also demonstrates a UI that shows the progress of the work and provides control and query capabilities.

C# (249.0 KB)
 
 
 
 
 
4 Star
(6)
4,298 times
Add to favorites
4/28/2011
E-mail Twitter del.icio.us Digg Facebook
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TrackBatchRequest.cs" company="Microsoft">
//   Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
// <summary>
//   The track batch request.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace BatchWeb
{
    using System.Activities;
    using System.Activities.Tracking;
    using System.Diagnostics;

    using BatchWorker.Contracts;

    /// <summary>
    /// The track batch request.
    /// </summary>
    public sealed class TrackBatchRequest : CodeActivity
    {
        // Define an activity input argument of type string
        #region Properties

        /// <summary>
        /// Gets or sets Request.
        /// </summary>
        [RequiredArgument]
        public InArgument<BatchRequest> Request { get; set; }

        #endregion

        // If your activity returns a value, derive from CodeActivity<TResult>
        // and return the value from the Execute method.
        #region Methods

        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        protected override void Execute(CodeActivityContext context)
        {
            // Obtain the runtime value of the Text input argument
            var request = this.Request.Get(context);
            var message = string.Format(
                "SubmitJob CountTo:{0}, StartAt: {1} Delay: {2} AutoStart:{3}", request.CountTo, request.StartAt, request.Delay, request.AutoStart);
            Trace.WriteLine(message);
            context.Track(new CustomTrackingRecord(message));
        }

        #endregion
    }
}