コード例 #1
0
        /// <summary>
        /// 审批
        /// </summary>
        /// <param name="stepId">当前审批步骤id</param>
        /// <param name="isPass">是否通过</param>
        /// <param name="Comment">审批意见</param>
        /// <param name="flowTo">流转到谁</param>
        /// <returns></returns>
        public ActionResult DoCheck(int stepId, bool isPass, string Comment, int flowTo)
        {
            //stepId:id, isPass: pass, Comment: $("#Comment").val() }

            //1、更新当前步骤
            var step = WF_StepService.GetEntities(s => s.ID == stepId).FirstOrDefault();

            step.ProcessResult = isPass ? "通过" : "不通过";
            step.StepStatus    = (short)Heima8.OA.Model.Enum.WFStepEnum.Processed;
            step.ProcessTime   = DateTime.Now;

            step.PorcessComment = Comment;
            WF_StepService.Update(step);


            //初始化下一个步骤
            WF_Step nextStep = new WF_Step();

            nextStep.IsEndStep     = false;
            nextStep.IsStartStep   = false;
            nextStep.ProcessBy     = flowTo;//下一个步骤处理人
            nextStep.SubTime       = DateTime.Now;
            nextStep.ProcessResult = string.Empty;

            nextStep.StepStatus     = (short)Heima8.OA.Model.Enum.WFStepEnum.UnProecess;
            nextStep.StepName       = string.Empty;
            nextStep.WF_InstanceID  = step.WF_InstanceID;
            nextStep.ProcessTime    = DateTime.Now;
            nextStep.PorcessComment = string.Empty;

            WF_StepService.Add(nextStep);

            //让书签继续往下执行。
            var Value    = isPass ? 1 : 0;
            var instance = GetWfInstance(step);
            var temp     = GetWfTemp(instance);
            var activity = WorkflowFactory.GetActivity(temp.ActityType);

            Heima8.OA.Workflow.WorkflowApplicationHelper.ResumeBookMark(
                activity,
                step.WF_Instance.WFInstanceId,
                step.StepName,
                Value);
            return(Content("ok"));
        }
コード例 #2
0
        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"));
        }