Saving data in sql server using state machine workflow in ASP.Net RRS feed

  • Question

  • I am new to workflow, I am working on the project where we decided to go for state machine workflow. The project is related to training process for the employees, here trainee select the employee who attends the training and then select the training dates for the employee. Employee attends the training offline and trainee will provide them rating based on the trainees performance. Employee can attend maximum 3 cycles of training before he is judged incompetent or competent in the training.

    I have decided to use state machine workflow and prepare the same for my project. The challenge is that I have to save the status of training in the database table. The entire training process duration may vary from 1 week to 1-2 months. And there could be n number of employees attending the training and 1 employee might be selected for 2 or more trainings.

    I think of creating the event handler that saves the data in database. But do I need to create separate workflows for each employee for each training. If so, then how to create such workflows. I am using 3 screens/pages in the entire training process.

    Hope my query is clear, if you need further clarity then ask me for further details.

    Warm Regards & Thanks in advance,


    Thursday, May 24, 2012 9:28 AM


  • Hi,

    There won’t be a straightforward solution, you need to mode the business. It sure that you don’t need to create separate workflows for each employee for each training. But you may create multiple workflows for different trainings based on employee’s decision. It also possible to place the training process in a single state machine which applies to all employees. You can draw a diagram to see how you can build the state machine.

    What features of workflow foundation you can leverage here are that you can use persistence automatically persist the workflow instance during the training duration, you can use message activities to communicate with you ASP.NET site, you can write the status into database directly in each state or prompt state related fields for query and etc. I’d suggest you check the following article and sample for more information about sate machine workflow:

    Windows Workflow Foundation (WF4) - Introduction to State Machine Hands On Lab

    WF4 Advanced State Machine Stuff

    Hope this information helps, thanks.

    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by LeoTang Friday, June 1, 2012 11:52 AM
    Friday, May 25, 2012 12:10 PM