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(FormCollection fm) { //int setupValue = Convert.ToInt32(fm["SetUpValue"]); //CommonWFInstance wfInstance = new CommonWFInstance(); //wfInstance.WFInstanceId = Guid.Empty; //wfInstance.MaxValue = Convert.ToInt32(fm["MaxValue"]); //wfInstance.SubTime = DateTime.Now; //wfInstance.status = (short)Enum.WF_InstanceEnum.Processing; //wfInstance.TempId = Convert.ToInt32(fm["FID"]); //wfInstance.UserId = Convert.ToInt32(fm["ID"]); //commonWFInstanceBll.Add(wfInstance); var wfApp = WorkflowApplicationHelper.CreateWorkflowApp(new ActivityLibraryFinancial.Activity1(), new Dictionary <string, object> { { "SetUpValue", Convert.ToInt32(fm["SetUpValue"]) }, { "InputValue", Convert.ToInt32(fm["MaxValue"]) }, { "StartBy", Convert.ToInt32(fm["ID"]) }, { "ManagerId", 8 }, //暂时写成固定的 userId=8 test2 { "SupervisorId", 1 }, //暂时写成固定的 userId=1 admin { "TempId", Convert.ToInt32(fm["FID"]) }, { "FinacialId", 9 }, //暂时写成固定的 userId=9 test3 }); //创建wf实例 //wfInstance.WFInstanceId = wfApp.Id; //commonWFInstanceBll.Update(wfInstance); ////申请人的步骤 //CommonWFStep wfStep = new CommonWFStep(); //wfStep.IsStartStep = true; //wfStep.IsEndStep = false; //wfStep.StepName = "提交审批"; //wfStep.CommonWFInstanceId = wfInstance.Id; //wfStep.ProcessBy = Convert.ToInt32(fm["Process"]); //wfStep.SubTime = DateTime.Now; //wfStep.ProcessBy = Convert.ToInt32(fm["ID"]); //wfStep.StepStatus = (short)Enum.WFStepEnum.Processed; //wfStep.ProcessResult = "通过"; //commonWFStepBll.Add(wfStep); return(RedirectToAction("/index")); }
public ActionResult Add(WF_Instance instance, int id, int flowTo) { var CurrentUserId = LoginUser.ID; //1->在工作流实例表中添加一条数据 instance.DelFlag = DelFlag; instance.StartTime = DateTime.Now; instance.FilePath = string.Empty; instance.StartBy = CurrentUserId; //当前用户 也就是发起人 instance.Level = 0; //紧急程度 instance.Status = (short)WF_InstanceEnum.Processing; instance.WF_TempID = id; //WF_TempBLL.Add(instance); WF_InstanceBLL.Add(instance); //2->在步骤表里面添加两条步骤 //2->1 一个当前已处理的步骤 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.ProcessContent = "提交申请"; startStep.ProcessResult = "通过"; startStep.ProcessTime = DateTime.Now; startStep.StepStaus = (short)WFStepEnum.Processed; WF_StepBLL.Add(startStep); //2->2 下一步谁审批的步骤 。项目经理审批 WF_Step nextStep = new WF_Step(); nextStep.WF_InstanceID = instance.ID; nextStep.SubTime = DateTime.Now; nextStep.ProcessTime = DateTime.Now; nextStep.ProcessContent = string.Empty; nextStep.IsStartStep = false; nextStep.IsEndStep = false; nextStep.ProcessBy = flowTo; nextStep.ProcessResult = ""; nextStep.StepName = ""; nextStep.StepStaus = (short)WFStepEnum.UnProecess; WF_StepBLL.Add(nextStep); //3->启动工作流 //根据流程类型 来初始化对应流程 spring 实现 //通过容器创建一个对象 依赖注入只能在子类中实现 // IApplicationContext ctx = ContextRegistry.GetContext(); var wftemp = WF_TempBLL.GetEntities(u => u.ID == id).FirstOrDefault(); //Activity activityType = ctx.GetObject(wftemp.ActityType.Split('.')[3]) as Activity; var wfApp = WorkflowApplicationHelper.CreateWorkflowApp( //new FincallActivity(), Assembly.Load("HeiMa8.OA.WorkFlow").CreateInstance(wftemp.ActityType) as Activity, null); instance.WFInstanceId = wfApp.Id; WF_InstanceBLL.Update(instance); return(Content("ok")); }
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")); }