Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Navigational Workflows Unleashed in WWF/ASP.NET 3.5

, 21 Oct 2008 CPOL
Case-study on the internals of a Navigational Workflow engine for a fictional dating website called “World Wide Dating”.
datesite.zip
DateSite
App_Data
bin
database setup procedure
DateSite.csproj.user
Global.asax
images
complete.png
critical.png
logo2.png
warning.png
Profile.dbml
Profile.dbml.layout
Properties
Service References
NavigationWorkflow
bin
NavigationWorkflow.layout
Properties
Settings.settings
using System;

namespace DateSite
{
    /// <summary>
    /// Page for entering personal lifestyle information.
    /// </summary>
    public partial class lifestyle : System.Web.UI.Page
    {
        private WorkflowManager _workflowManager;
        private Profile _profile;

        /// <summary>
        /// Page initialization code.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Init(object sender, EventArgs e)
        {
            // create an instance of the navigational workflow manager
            _workflowManager = new WorkflowManager(Application, Session, Request, Response);

            // make sure the workflow is synchronized... meaning the page we are on is the page we should be on / can be on
            _workflowManager.SynchronizeWorkflow();

            // get the dating id from Session
            string datingId = Session["datingId"] as string;

            // retrieve the given users profile
            _profile = Database.SelectProfile(datingId);

            // populate the data on the page
            LoadData();
        }

        /// <summary>
        /// Navigate to the previous page in the navigational workflow.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnPrevious_Click(object sender, EventArgs e)
        {
            // navigate to the previous page
            string pageToGoTo = _workflowManager.Previous();
            _workflowManager.ManagedRedirect(pageToGoTo);
        }

        /// <summary>
        /// Navigate to the next page in the navigational workflow.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnNext_Click(object sender, EventArgs e)
        {
            // save data to database
            SaveData();

            // navigate to the next page
            string pageToGoTo = _workflowManager.Next();
            _workflowManager.ManagedRedirect(pageToGoTo);
        }

        /// <summary>
        /// Load lifestyle information from the database.
        /// </summary>
        private void LoadData()
        {
            if (_profile.ExerciseHabits != null)
                ddlExerciseHabits.SelectedValue = _profile.ExerciseHabits;

            if(_profile.Smoking != null)
                ddlSmoking.SelectedValue = _profile.Smoking;

            if (_profile.Drinking != null)
                ddlDrinking.SelectedValue = _profile.Drinking;
        }

        /// <summary>
        /// Save the lifestyle information to the database.
        /// </summary>
        private void SaveData()
        {
            _profile.ExerciseHabits = ddlExerciseHabits.SelectedValue;
            _profile.Smoking = ddlSmoking.SelectedValue;
            _profile.Drinking = ddlDrinking.SelectedValue;

            Database.UpdateProfile(_profile);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Pero Matić
Software Developer (Senior) Plan A Software
United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141223.1 | Last Updated 21 Oct 2008
Article Copyright 2008 by Pero Matić
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid