Exemple #1
0
        private void validateStart(AuditFlowStartParam startParam)
        {
            if (startParam.DefSteps.Count < 2)
            {
                throw new Exception("未能指定正确的设校审步骤,无法启动校审");
            }
            var designStep = startParam.DefSteps.FirstOrDefault(d => d.StepKey == ActivityType.Design);

            if (designStep == null)
            {
                throw new Exception("校审步骤必须包含设计步骤");
            }
            if (String.IsNullOrEmpty(designStep.UserID) || String.IsNullOrEmpty(designStep.UserName))
            {
                throw new Exception("设计环节必须指定设计人才能启动校审");
            }
            if (String.IsNullOrEmpty(startParam.AuditFormUrl))
            {
                throw new Exception("请指定校审单的URL链接地址");
            }
            if (String.IsNullOrEmpty(startParam.AuditFormID))
            {
                throw new Exception("启动设校审时,必须指定校审单ID,请先创建校审单对象");
            }
        }
Exemple #2
0
        /// <summary>
        /// 启动校审
        /// </summary>
        /// <param name="startParam">启动参数</param>
        /// <param name="execNext">是否执行到下一环节</param>
        /// <returns>当前环节的活动</returns>
        public virtual List <S_W_Activity> StartAuditFlow(AuditFlowStartParam startParam)
        {
            var wbs = instanceEnitites.S_W_WBS.FirstOrDefault(d => d.ID == startParam.WBSID);

            if (wbs == null)
            {
                throw new Exception("未能找到ID为【" + startParam.WBSID + "】的WBS对象,无法启动校审");
            }
            this.validateStart(startParam);
            var designStep     = startParam.DefSteps.FirstOrDefault(d => d.StepKey == ActivityType.Design);
            var designActivity = wbs.ActivityList.FirstOrDefault(d => d.OwnerUserID == designStep.UserID &&
                                                                 d.State == ProjectCommoneState.Create.ToString() && d.AuditPatchID == startParam.AuditFormID);

            if (designActivity == null)
            {
                designActivity               = new S_W_Activity();
                designActivity.ActvityName   = EnumBaseHelper.GetEnumDescription(typeof(ActivityType), ActivityType.Design.ToString());
                designActivity.ActivityKey   = ActivityType.Design.ToString();
                designActivity.OwnerUserID   = designStep.UserID;
                designActivity.OwnerUserName = designStep.UserName;
                wbs.AddActivity(designActivity);
            }
            designActivity.DisplayName  = startParam.DisplayName;
            designActivity.LinkUrl      = startParam.AuditFormUrl;
            designActivity.DefSteps     = JsonHelper.ToJson(startParam.DefStepsToCollection());
            designActivity.AuditPatchID = startParam.AuditFormID;
            designActivity.BusniessID   = startParam.AuditFormID;
            designActivity.SetParam("ID", startParam.AuditFormID);

            List <S_W_Activity> rtnList = new List <S_W_Activity>();

            if (startParam.ExecNext)
            {
                designActivity.Finish();

                var nextStep  = startParam.DefSteps.Where(d => d.StepIndex > designStep.StepIndex).OrderBy(d => d.StepIndex).FirstOrDefault();
                var execParam = new AuditFlowExecuteParam();
                execParam.DisplayName   = designActivity.DisplayName.Replace(designActivity.DisplayName.Split('(').FirstOrDefault(), nextStep.StepName);;
                execParam.NextStep      = nextStep;
                execParam.WBSID         = wbs.ID;
                execParam.ExecuteOption = AuditOption.Pass;
                designActivity.NextStep = JsonHelper.ToJson(nextStep.ToDic());
                var exeResult = this.Execute(designActivity, execParam);
                rtnList = exeResult.Activities;
            }
            else
            {
                rtnList.Add(designActivity);
            }

            return(rtnList);
        }
Exemple #3
0
        /// <summary>
        /// 获取校审流程启动参数
        /// </summary>
        /// <param name="auditForm"></param>
        /// <param name="auditFormUrl"></param>
        /// <param name="stepList"></param>
        /// <returns></returns>
        public virtual AuditFlowStartParam GetAuditFlowStartParam(T_AE_Audit auditForm, string auditFormUrl, List <S_E_Product> productList, S_W_WBS wbs, S_I_ProjectInfo projectInfo)
        {
            var startParam = new AuditFlowStartParam();

            startParam.DisplayName  = EnumBaseHelper.GetEnumDescription(typeof(ActivityType), ActivityType.Design.ToString()) + "(" + auditForm.Name + ")";
            startParam.AuditFormUrl = auditFormUrl;
            startParam.AuditFormID  = auditForm.ID;
            startParam.WBSID        = auditForm.WBSID;

            //参与校审的人员
            var userInfo = GetAuditRoleUser(auditForm.WBSID);
            //本次校审的环节
            var stepList = GetAuditSteps(userInfo, productList, wbs, projectInfo);

            foreach (var auditStep in stepList)
            {
                startParam.AddStep(auditStep);
            }
            return(startParam);
        }