public ActionResult Add(WF_Instance wfInstance, int id, int flowTo) { var currentUserId = 1; // 1. Add the new data into workflow-instance wfInstance.DelFlag = (short)DelFlagEnum.Normal; wfInstance.StartTime = DateTime.Now; wfInstance.FilePath = string.Empty; wfInstance.SenderId = currentUserId; wfInstance.Level = 0; wfInstance.Status = (short)WF_InstanceEnum.Processing; wfInstance.WFInstanceId = Guid.Empty; wfInstance.WF_TempId = id; WF_InstanceService.Add(wfInstance); // 2. Start the workflow var wfApp = WorkflowApplicationHelper.CreateWorkflowApp(new FinanceActivity(), null); wfInstance.WFInstanceId = wfApp.Id; // save the workflow id WF_InstanceService.Update(wfInstance); // 3. Add two new procedures to the workflow procedure // The first produce handler is self WF_Procedure startProcedure = new WF_Procedure(); startProcedure.WF_InstanceId = wfInstance.Id; startProcedure.SubTime = DateTime.Now; startProcedure.ProcedureName = "Submit the approval table"; startProcedure.IsEndProcedure = false; startProcedure.IsStartProcedure = true; startProcedure.HandleBy = currentUserId; startProcedure.ProcessComment = "submit approval"; startProcedure.ProcessResult = "pass"; startProcedure.ProcessStatus = (short)WF_InstanceEnum.Processing; WF_ProcedureService.Add(startProcedure); // Initial the next procedure handler WF_Procedure nextProcedure = new WF_Procedure(); nextProcedure.WF_InstanceId = wfInstance.Id; nextProcedure.SubTime = DateTime.Now; nextProcedure.ProcessTime = DateTime.Now; nextProcedure.ProcessComment = string.Empty; nextProcedure.IsEndProcedure = false; nextProcedure.IsStartProcedure = false; nextProcedure.HandleBy = flowTo; nextProcedure.ProcessResult = ""; nextProcedure.ProcessStatus = (short)WF_InstanceEnum.Unprocess; WF_ProcedureService.Add(nextProcedure); return(RedirectToAction("showMyCheck")); }
public ActionResult Add(WF_Instance instance, int id, int flowTo) { var currentUserId = LoginUser.Id; //在工作流实例表添加一条数据 instance.DelFlag = this.delFlagNormal; instance.StartTime = DateTime.Now; instance.FilePath = string.Empty; instance.StartBy = currentUserId; instance.Level = 0; instance.Status = (short)Wei.OA.Model.Enum.WF_InstanceEnum.Processing; instance.WFInstanceId = Guid.Empty; instance.WF_TempId = id; WF_InstanceService.Add(instance); //启动工作流 var wfApp = WorkflowApplictionHelper.CreateWorkflowApp(new FinancialActivity(), null); //可以通过反射,更灵活的添加不同的activity instance.WFInstanceId = wfApp.Id; WF_InstanceService.Update(instance); //在步骤表中添加两个步骤,一个当前已经处理完的步骤 WF_Step startStep = new WF_Step(); startStep.WF_InstanceId = instance.Id; startStep.SubTime = DateTime.Now; startStep.StepName = "提交审批表单"; startStep.IsEndStep = false; startStep.IsStartStep = true; startStep.ProcessBy = currentUserId; startStep.ProcessComment = "提交申请"; startStep.ProcessResult = "通过"; startStep.ProcessTime = DateTime.Now; startStep.StepStatus = (short)Wei.OA.Model.Enum.WFStepEnum.Processed; WF_StepService.Add(startStep); //下一步谁审批的步骤 WF_Step nextStep = new WF_Step(); nextStep.WF_InstanceId = instance.Id; nextStep.SubTime = DateTime.Now; nextStep.ProcessTime = DateTime.Now; nextStep.ProcessComment = String.Empty; nextStep.IsEndStep = false; nextStep.IsStartStep = false; nextStep.ProcessBy = flowTo; nextStep.ProcessResult = ""; nextStep.StepName = ""; nextStep.StepStatus = (short)Wei.OA.Model.Enum.WFStepEnum.UnProcess; WF_StepService.Add(nextStep); return(RedirectToAction("ShowMyCheck")); }
public ActionResult Add(WF_Instance instance, int id, int flowTo) { var currentUserId = LoginUser.ID; //在工作流实例表添加一条数据: instance.DelFlag = delflagNormal; instance.StartTime = DateTime.Now; instance.FilePath = string.Empty; instance.StartBy = currentUserId; instance.Level = 0; instance.Status = (short)Heima8.OA.Model.Enum.WF_InstanceEnum.Processing; instance.WFInstanceId = Guid.Empty; instance.WF_TempID = id; WF_InstanceService.Add(instance); //第二点:启动工作流 //1、获得工作流类型 var temp = GetWfTemp(instance); var activity = WorkflowFactory.GetActivity(temp.ActityType); WorkflowApplication wfApp = null; //2、家具产品对应的逻辑 if (activity is ProductFlow) { //家具逻辑中,设计之后数控和小锯是二选一 var designRole = RoleInfoService.GetEntities(r => r.DelFlag == delflagNormal && r.RoleName.Contains("设计")) .FirstOrDefault(); string flowToKeyWord = GetRoleHelper.GetFlowToRoleKeyWord(designRole, id); wfApp = WorkflowApplicationHelper.CreateWorkflowApp(activity, new Dictionary <string, object>() { { "AfterDesignFlowTo", flowToKeyWord } }); }//else if{ 其他工作流的逻辑} else {//没有对应的工作流提前结束 return(RedirectToAction("ShowMyCheck")); } instance.WFInstanceId = wfApp.Id; WF_InstanceService.Update(instance); //第三点:在步骤表里面添加两条步骤。一个当前已经处理的完成步骤。 WF_Step startStep = new WF_Step(); startStep.WF_InstanceID = instance.ID; startStep.SubTime = DateTime.Now; startStep.StepName = "提交审批表单"; startStep.IsEndStep = false; startStep.IsStartStep = true; startStep.ProcessBy = currentUserId; startStep.PorcessComment = "提交申请"; startStep.ProcessResult = "通过"; startStep.ProcessTime = DateTime.Now; // startStep.StepName = "提交审批表单"; startStep.StepStatus = (short)Heima8.OA.Model.Enum.WFStepEnum.Processed; WF_StepService.Add(startStep); //二个步骤:下一步谁审批的步骤。 项目经理审批 WF_Step nextStep = new WF_Step(); nextStep.WF_InstanceID = instance.ID; nextStep.SubTime = DateTime.Now; nextStep.ProcessTime = DateTime.Now; nextStep.PorcessComment = string.Empty; nextStep.IsEndStep = false; nextStep.IsStartStep = false; nextStep.ProcessBy = flowTo; nextStep.ProcessResult = ""; nextStep.StepName = ""; nextStep.StepStatus = (short)Heima8.OA.Model.Enum.WFStepEnum.UnProecess; WF_StepService.Add(nextStep); return(RedirectToAction("ShowMyCheck")); }