Windows Server AppFabric / Workflow Services Demo - Contoso HR

This sample demonstrates how you can use a Windows Workflow Foundation (WF4) Workflow Service and Windows Server AppFabric to construct a long running business process.

C# (6.3 MB)
 
 
 
 
 
4.9 Star
(8)
6,156 times
Add to favorites
12/3/2011
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
//  ----------------------------------------------------------------------------------
//  Microsoft Developer & Platform Evangelism
//  
//  Copyright (c) Microsoft Corporation. All rights reserved.
//  
//  THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
//  EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
//  OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//  ----------------------------------------------------------------------------------
//  The example companies, organizations, products, domain names,
//  e-mail addresses, logos, people, places, and events depicted
//  herein are fictitious.  No association with any real company,
//  organization, product, domain name, email address, logo, person,
//  places, or events is intended or should be inferred.
//  ----------------------------------------------------------------------------------
using System.Activities;
using HRApplicationServices.Contracts;
using HRApplicationServices.Data;

namespace HRApplicationServices.Activities
{
    public class SaveJobApplication : CodeActivity<SubmitJobApplicationResponse>
    {
        public InArgument<SubmitJobApplicationRequest> AppRequest { get; set; }


        protected override SubmitJobApplicationResponse Execute(CodeActivityContext context)
        {
            using (var ctx = new HRApplicationDataEntities())
            {
                var request = AppRequest.Get(context);
                var app = ctx.Applicants.CreateObject();
                app.ApplicantName = request.Resume.Name;
                app.NumberOfReferences = request.Resume.NumReferences;
                app.Education = request.Resume.Education;
                app.RequestID = request.RequestID;

                ctx.Applicants.AddObject(app);
                ctx.SaveChanges();
                ctx.Connection.Close();

                return new SubmitJobApplicationResponse
                           {
                               ApplicationID = app.ApplicationID,
                               ApplicantName = request.Resume.Name,
                               ResponseText =
                                   string.Format(ServiceResources.JobApplicationProcessing, request.Resume.Name,
                                                 app.ApplicationID)
                           };
            }
        }
    }
}