overtakingaction.cs

来自「工作流的基本资料(文档资料」· CS 代码 · 共 45 行

CS
45
字号
using System;
using NetBpm.Workflow.Delegation;
using NetBpm.Workflow.Execution;
using NetBpm.Workflow.Execution.EComp;
using NetBpm.Workflow.Definition;
using NetBpm.Util.Client;

namespace NetBpm.Example.Delegate
{
	public class OvertakingAction : IActionHandler
	{
		private static readonly ServiceLocator serviceLocator = ServiceLocator.Instance;
		
		public void Run(IActionContext actionContext)
		{
			IFlow flow = actionContext.GetFlow();
			INode currentNode = flow.Node;
			
			if ("do bloody thing".Equals(currentNode.Name))
			//'do bloody thing' hasn't been performed
			{
				IExecutionSessionLocal executionComponent = (IExecutionSessionLocal) serviceLocator.GetService(typeof(IExecutionSessionLocal));
				try
				{
					//ae is a robot. Human (in) is incapable. Let robot replace him.
					executionComponent.DelegateActivity(flow.Id, "ae");
					
					//call external component (robot web service) to act on the flow
					System.Console.Out.WriteLine("calling robot web service to act on the flow... [ok]");
					
					//Now, revenge time: director fires originally assigned executor
					System.Console.Out.WriteLine("Isaac, you're fired!");
				}
				catch (ExecutionException e)
				{
					throw new System.SystemException("failed executing task: " + typeof(OvertakingAction) + " " + e.Message);
				}
				finally
				{
					serviceLocator.Release(executionComponent);
				}
			}
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?