/// <summary>
 /// Executes the specified activity.
 /// </summary>
 /// <param name="activity">The activity.</param>
 protected override void ExecuteActivity(Activity activity)
 {
     activity.OnInitialize(this);
     //执行当前动作
     activity.OnExecute(this);
     //如果工作流动作完成,那么移动到下一步状态
     if (activity.ExecutionStatus == ActivityExecutionStatus.Closed)
     {
         //添加当前动作到动作列表中
         executedActivities.Add(activity);
         if (activity is IBranchAction)
         {
             //分支动作,需要获取分支执行后选定的状态
             IBranchAction branch = (IBranchAction)activity;
             MoveOn(branch.GetSelectedState());
         }
         else
         {
             //顺序动作,从动作针对的事件名称中获取状态
             ApprovalEvent currentEvent = CurrentState.GetEventByName(activity.EventName);
             MoveOn(currentEvent.NextStateNames[0]);
         }
     }
     //保存
     Save();
     if (this.stateRecordNames.Count > 0)
     {
         WorkflowRuntime.Current.OnWorkflowExecuted(new StateChangedEventArgs(this, this.stateRecordNames[stateRecordNames.Count - 1], stateName));
     }
     //如果是子流程的执行完成,那么还有判断其父流程是否也已经执行完毕,如果执行完毕,那么设置其父流程的下一步状态
     if (this.CurrentStatus == WorkflowExecutionStatus.Closed && parentId != null && parentId != Guid.Empty)
     {
         StateMachineWorkflowInstance parentInstance = (StateMachineWorkflowInstance)WorkflowRuntime.Current.GetInstance(parentId);
         parentInstance.OnChildFinished(this);
     }
     else if (this.CurrentStatus == WorkflowExecutionStatus.Aborted)
     {
         WorkflowRuntime.Current.OnWorkflowTerminated(new StateChangedEventArgs(this, this.stateRecordNames[stateRecordNames.Count - 1], stateName));
     }
     if (IsEnd())
     {
         WorkflowRuntime.Current.OnWorkflowCompleted(new StateChangedEventArgs(this, this.stateRecordNames[stateRecordNames.Count - 1], stateName));
     }
 }