Effect of running the program homepage:
First open the homecontroller. CS File
public ActionResult Index() { #region XAML //var activity = // ActivityXamlServices.Load( // Server.MapPath("~/workflows/GetDataForMainPage.xaml")); //var results = WorkflowInvoker.Invoke(activity); #endregion var results = WorkflowInvoker.Invoke( new CustomActivities.GetDataForMainPage()); ViewData["candidates"] = results["candidates"]; ViewData["workOrders"] = results["workOrders"]; return View(); }
The program uses workflowinvoker. invoke to call the getdataformainpage activity and save the returned results in viewdata.
Analyze the getdataformainpage Activity
A parallel workflow contains two getodata activities. The returned results of a generic activity, ienumerable <jobcandidate> and ienumerable <workorder>, are bound to the output parameters candidate and workorders.
Next, let's look at the implementation of getodata.
public sealed class GetOData<T> : AsyncCodeActivity<IEnumerable<T>> { [RequiredArgument] public InArgument<Uri> ServiceUrl { get; set; } public InArgument<string> EntitySetName { get; set; } protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { DataServiceContext ctx = new DataServiceContext(ServiceUrl.Get(context)); DataServiceQuery<T> query = ctx.CreateQuery<T>(EntitySetName.Get(context)); context.UserState = query; return query.BeginExecute(callback, state); } protected override IEnumerable<T> EndExecute(AsyncCodeActivityContext context, IAsyncResult result) { DataServiceQuery<T> query = context.UserState as DataServiceQuery<T>; return query.EndExecute(result); } }
The code in this section calls WCF data services through asynchronous dataservicequery.