private XElement writePerformer(Participant participant)
 {
     if (participant == null) { return null; }
     XElement participantElement = new XElement(
         xN + PERFORMER,
         new XAttribute(NAME, participant.Name),
         new XAttribute(DISPLAY_NAME, participant.DisplayName),
         new XAttribute(ASSIGNMENT_TYPE, participant.AssignmentType.ToString()), //201004 add lwz 参与者通过业务接口实现默认获取用户
         new XElement(xN + DESCRIPTION, participant.Description),
         new XElement(xN + ASSIGNMENT_HANDLER, participant.AssignmentHandler)
         );
     return participantElement;
 }
        // throws EngineException, KernelException
        /// <summary>分配, 按照当前任务的参与者插入工单</summary>
        /// <param name="currentSession"></param>
        /// <param name="processInstance"></param>
        /// <param name="runtimeContext"></param>
        /// <param name="taskInstance"></param>
        /// <param name="formTask"></param>
        /// <param name="part"></param>
        /// <param name="dynamicAssignmentHandler"></param>
        protected void assign(IWorkflowSession currentSession, IProcessInstance processInstance, RuntimeContext runtimeContext, ITaskInstance taskInstance, FormTask formTask, Participant part, DynamicAssignmentHandler dynamicAssignmentHandler)
        {
            //如果有指定的Actor,则按照指定的Actor分配任务
            if (dynamicAssignmentHandler != null)
            {
                dynamicAssignmentHandler.assign((IAssignable)taskInstance, part.Name);
            }
            else
            {
                IPersistenceService persistenceService = runtimeContext.PersistenceService;
                List<ITaskInstance> taskInstanceList = persistenceService.FindTaskInstancesForProcessInstance(taskInstance.ProcessInstanceId, taskInstance.ActivityId);
                ITaskInstance theLastCompletedTaskInstance = null;

                for (int i = 0; taskInstanceList != null && i < taskInstanceList.Count; i++)
                {
                    ITaskInstance tmp = (ITaskInstance)taskInstanceList[i];
                    if (tmp.Id.Equals(taskInstance.Id)) continue;
                    if (!tmp.TaskId.Equals(taskInstance.TaskId)) continue;
                    if (tmp.State != TaskInstanceStateEnum.COMPLETED) continue;
                    if (theLastCompletedTaskInstance == null)
                    {
                        theLastCompletedTaskInstance = tmp;
                    }
                    else
                    {
                        if (theLastCompletedTaskInstance.StepNumber < tmp.StepNumber)
                        {
                            theLastCompletedTaskInstance = tmp;
                        }
                    }
                }

                //如果是循环且LoopStrategy==REDO,则分配个上次完成该工作的操作员
                if (theLastCompletedTaskInstance != null && (LoopStrategyEnum.REDO==formTask.LoopStrategy || currentSession.isInWithdrawOrRejectOperation()))
                {
                    List<IWorkItem> workItemList = persistenceService.FindCompletedWorkItemsForTaskInstance(theLastCompletedTaskInstance.Id);
                    ITaskInstanceManager taskInstanceMgr = runtimeContext.TaskInstanceManager;
                    for (int k = 0; k < workItemList.Count; k++)
                    {
                        IWorkItem completedWorkItem = (IWorkItem)workItemList[k];

                        IWorkItem newFromWorkItem = taskInstanceMgr.createWorkItem(currentSession, processInstance, taskInstance, completedWorkItem.ActorId);
                        newFromWorkItem.claim();//并自动签收
                    }
                }
                else
                {
                    IBeanFactory beanFactory = runtimeContext.BeanFactory;
                    //从spring中获取到对应任务的Performer,创建工单
                    //201004 add lwz 参与者通过业务接口实现默认获取用户
                    switch (part.AssignmentType)
                    {
                        case AssignmentTypeEnum.Current:
                            runtimeContext.AssignmentBusinessHandler.assignCurrent(
                                currentSession, processInstance, (IAssignable)taskInstance);
                            break;
                        case AssignmentTypeEnum.Role:
                            runtimeContext.AssignmentBusinessHandler.assignRole(
                                currentSession, processInstance, (IAssignable)taskInstance, part.PerformerValue);
                            break;
                        case AssignmentTypeEnum.Agency:
                            runtimeContext.AssignmentBusinessHandler.assignAgency(
                                currentSession, processInstance, (IAssignable)taskInstance, part.PerformerValue);
                            break;
                        case AssignmentTypeEnum.Fixed:
                            runtimeContext.AssignmentBusinessHandler.assignFixed(
                                currentSession, processInstance, (IAssignable)taskInstance, part.PerformerValue);
                            break;
                        case AssignmentTypeEnum.Superiors:
                            runtimeContext.AssignmentBusinessHandler.assignSuperiors(
                                currentSession, processInstance, (IAssignable)taskInstance);
                            break;
                        default:
                            IAssignmentHandler assignmentHandler = (IAssignmentHandler)beanFactory.GetBean(part.AssignmentHandler);
                            //modified by wangmj 20090904
                            ((IAssignmentHandler)assignmentHandler).assign((IAssignable)taskInstance, part.PerformerValue);
                            break;
                    }
                }
            }
        }