/// <summary> /// 保存流程数据,会删除原有的所有参与者,再保存 /// </summary> /// <param name="workFlowEntity">流程</param> /// <param name="participants">所有参与者</param> /// <returns></returns> /// <remarks></remarks> public int Usp_Flow_Insert(CharityPlatform.Entity.WorkFlowEntity workFlowEntity, List <CharityPlatform.Entity.ParticipantEntity> participants) { this.ExecuteNonQuery("Usp_Flow_Insert", workFlowEntity); foreach (var entity in participants) { entity.I_WorkFlow = workFlowEntity.Id; this.ExecuteNonQuery("Usp_Participant_Insert", entity); } return(workFlowEntity.Id); }
/// <summary> /// 保存流程数据 /// </summary> /// <param name="flowEngine">流程</param> /// <param name="category">分类</param> /// <param name="owner">具体业务数据对应的PK</param> public void FlowSave(Eastday.WorkFlowEngine.FlowEngine flowEngine) { using (WorkFlowBLL workFlowBLL = new WorkFlowBLL()) { workFlowBLL.DbContext = workFlowBLL.CreateDbContext(true); WorkFlowEntity workFlowEntity = workFlowBLL.Usp_Flow_ByOwner(flowEngine.Attachment.Owner); if (workFlowEntity == null) workFlowEntity = new WorkFlowEntity(); workFlowEntity.I_Owner = flowEngine.Attachment.Owner; workFlowEntity.I_State = (int)flowEngine.FlowState; workFlowEntity.I_Flag = 1; //ParticipantEntity var aCurrent = flowEngine.GetCurrent(); var steps = from step in flowEngine.FlowSteps where !(step is StepEnd) select step; List<ParticipantEntity> participants = new List<ParticipantEntity>(); foreach (var step in steps) { foreach (var node in step.Nodes) { ParticipantEntity participantEntity = new ParticipantEntity(); participantEntity.I_Reference = node.Participant.Reference; participantEntity.I_WorkFlow = workFlowEntity.Id; participantEntity.C_Step = step.Identification; participantEntity.C_Node = node.Identification; participantEntity.I_Auditer = node.Conclusion.Auditer; participantEntity.D_Audit = node.Conclusion.AuditDate; participantEntity.I_Bind = node.Participant.Category; participantEntity.I_Current = step == aCurrent && node.AuditType == AuditType.UnAudit ? 1 : (int)node.Conclusion.AuditType; participants.Add(participantEntity); } } if (workFlowBLL.Usp_Flow_Insert(workFlowEntity, participants) > 0) { workFlowBLL.DbContext.CommitTransaction(); this.Save(flowEngine); } } }