コード例 #1
0
        public ActionResult Edit(string id)
        {
            ViewBag.Perm = GetPermission();
            Flow_FormContentStepCheckModel entity = m_BLL.GetById(id);

            return(View(entity));
        }
コード例 #2
0
        public ActionResult EditExternal(string formId, string id)
        {
            //获得当前步骤ID
            string currentStepId = formContentBLL.GetCurrentStepCheckId(formId, id);

            Flow_FormModel formModel = formBLL.GetById(formId);

            ViewBag.Html = formModel.ExternalURL.Split(',')[2];

            ViewBag.StepCheckMes = formContentBLL.GetCurrentStepCheckMes(ref setNoPagerAscById, formId, id, GetUserId());
            //获取可审核步骤的人
            List <Flow_FormContentStepCheckStateModel> stepCheckStateModel = stepCheckStateBLL.GetListByStepCheckId(ref setNoPagerAscById, currentStepId);
            //决定是否显示审核框
            string currentUser = GetUserId();

            if (stepCheckStateModel.Where(a => a.UserId == currentUser).Count() == 0)
            {
                ViewBag.StepCheckId = "";
            }
            else
            {
                ViewBag.StepCheckId = currentStepId;
            }


            ViewBag.IsCustomMember = false;

            if (!string.IsNullOrEmpty(currentStepId))
            {
                List <Flow_FormContentStepCheckModel> stepCheckModelList = stepCheckBLL.GetListByFormId(formId, id);
                int j = 0;//下一个步骤
                for (int i = 0; i < stepCheckModelList.Count(); i++)
                {
                    if (currentStepId == stepCheckModelList[i].Id)
                    {
                        j = i;
                    }
                }
                //获得下个步骤
                if (j + 1 < stepCheckModelList.Count())
                {
                    //查询第二步是否是自选
                    Flow_FormContentStepCheckModel stepModel = stepCheckModelList[j + 1];
                    if (stepModel.IsCustom)
                    {
                        ViewBag.IsCustomMember = true;
                    }
                }
            }
            Flow_FormContentModel model = formContentBLL.GetById(id);

            model.ExternalURL = formModel.ExternalURL;
            //来自外部,所有情况都需要枚举,每加一个,这里加一句,必须的,与前端相互对应
            if (formModel.ExternalURL.Contains("/External/"))
            {
                model.externalModel = externalBLL.GetById(id);
            }
            //////
            return(View(model));
        }
コード例 #3
0
 public bool Create(ref ValidationErrors errors, Flow_FormContentStepCheckModel model)
 {
     try
     {
         Flow_FormContentStepCheck entity = m_Rep.GetById(model.Id);
         if (entity != null)
         {
             errors.Add(Suggestion.PrimaryRepeat);
             return(false);
         }
         entity            = new Flow_FormContentStepCheck();
         entity.ContentId  = model.ContentId;
         entity.CreateTime = model.CreateTime;
         entity.Id         = model.Id;
         entity.IsEnd      = model.IsEnd;
         entity.State      = model.State;
         entity.StateFlag  = model.StateFlag;
         entity.StepId     = model.StepId;
         if (m_Rep.Create(entity) == 1)
         {
             return(true);
         }
         else
         {
             errors.Add(Suggestion.InsertFail);
             return(false);
         }
     }
     catch (Exception ex)
     {
         errors.Add(ex.Message);
         ExceptionHander.WriteException(ex);
         return(false);
     }
 }
コード例 #4
0
        public ActionResult Edit(string formId, string id)
        {
            //获得当前步骤ID
            string currentStepId = formContentBLL.GetCurrentStepCheckId(formId, id);

            Flow_FormModel formModel = formBLL.GetById(formId);

            //是否已经设置布局
            if (!string.IsNullOrEmpty(formModel.HtmlForm))
            {
                ViewBag.Html = formModel.HtmlForm;
            }
            else
            {
                ViewBag.Html = ExceHtmlJs(formId);
            }
            ViewBag.StepCheckMes = formContentBLL.GetCurrentStepCheckMes(ref setNoPagerAscById, formId, id, GetUserId());
            //获取可审核步骤的人
            List <Flow_FormContentStepCheckStateModel> stepCheckStateModel = stepCheckStateBLL.GetListByStepCheckId(ref setNoPagerAscById, currentStepId);
            //决定是否显示审核框
            string currentUser = GetUserId();

            if (stepCheckStateModel.Where(a => a.UserId == currentUser).Count() == 0)
            {
                ViewBag.StepCheckId = "";
            }
            else
            {
                ViewBag.StepCheckId = currentStepId;
            }


            ViewBag.IsCustomMember = false;

            if (!string.IsNullOrEmpty(currentStepId))
            {
                List <Flow_FormContentStepCheckModel> stepCheckModelList = stepCheckBLL.GetListByFormId(formId, id);
                int j = 0;//下一个步骤
                for (int i = 0; i < stepCheckModelList.Count(); i++)
                {
                    if (currentStepId == stepCheckModelList[i].Id)
                    {
                        j = i;
                    }
                }
                //获得下个步骤
                if (j + 1 < stepCheckModelList.Count())
                {
                    //查询第二步是否是自选
                    Flow_FormContentStepCheckModel stepModel = stepCheckModelList[j + 1];
                    if (stepModel.IsCustom)
                    {
                        ViewBag.IsCustomMember = true;
                    }
                }
            }
            Flow_FormContentModel model = formContentBLL.GetById(id);

            return(View(model));
        }
コード例 #5
0
        /// <summary>
        /// 校验Excel数据,这个方法一般用于重写校验逻辑
        /// </summary>
        public virtual bool CheckImportData(string fileName, List <Flow_FormContentStepCheckModel> list, ref ValidationErrors errors)
        {
            var targetFile = new FileInfo(fileName);

            if (!targetFile.Exists)
            {
                errors.Add("导入的数据文件不存在");
                return(false);
            }

            var excelFile = new ExcelQueryFactory(fileName);

            //对应列头
            excelFile.AddMapping <Flow_FormContentStepCheckModel>(x => x.ContentId, "所属公文");
            excelFile.AddMapping <Flow_FormContentStepCheckModel>(x => x.StepId, "所属步骤");
            excelFile.AddMapping <Flow_FormContentStepCheckModel>(x => x.State, "0不通过1通过2审核中");
            excelFile.AddMapping <Flow_FormContentStepCheckModel>(x => x.StateFlag, "状态(是否完成)");
            excelFile.AddMapping <Flow_FormContentStepCheckModel>(x => x.CreateTime, "创建时间");
            excelFile.AddMapping <Flow_FormContentStepCheckModel>(x => x.IsEnd, "是否结束");
            excelFile.AddMapping <Flow_FormContentStepCheckModel>(x => x.IsCustom, "是否自选审核人默认为false");

            //SheetName
            var excelContent = excelFile.Worksheet <Flow_FormContentStepCheckModel>(0);
            int rowIndex     = 1;

            //检查数据正确性
            foreach (var row in excelContent)
            {
                var errorMessage = new StringBuilder();
                var entity       = new Flow_FormContentStepCheckModel();
                entity.Id         = row.Id;
                entity.ContentId  = row.ContentId;
                entity.StepId     = row.StepId;
                entity.State      = row.State;
                entity.StateFlag  = row.StateFlag;
                entity.CreateTime = row.CreateTime;
                entity.IsEnd      = row.IsEnd;
                entity.IsCustom   = row.IsCustom;

                //=============================================================================
                if (errorMessage.Length > 0)
                {
                    errors.Add(string.Format(
                                   "第 {0} 列发现错误:{1}{2}",
                                   rowIndex,
                                   errorMessage,
                                   "<br/>"));
                }
                list.Add(entity);
                rowIndex += 1;
            }
            if (errors.Count > 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #6
0
 public Flow_FormContentStepCheckModel GetById(string id)
 {
     if (IsExist(id))
     {
         Flow_FormContentStepCheck      entity = m_Rep.GetById(id);
         Flow_FormContentStepCheckModel model  = new Flow_FormContentStepCheckModel();
         model.ContentId  = entity.ContentId;
         model.CreateTime = entity.CreateTime;
         model.Id         = entity.Id;
         model.IsEnd      = entity.IsEnd;
         model.State      = entity.State;
         model.StateFlag  = entity.StateFlag;
         model.StepId     = entity.StepId;
         return(model);
     }
     else
     {
         return(null);
     }
 }
コード例 #7
0
        public virtual async Task <Tuple <ValidationErrors, bool> > CreateAsync(Flow_FormContentStepCheckModel model)
        {
            ValidationErrors errors = new ValidationErrors();

            try
            {
                Flow_FormContentStepCheck entity = await m_Rep.GetByIdAsync(model.Id);

                if (entity != null)
                {
                    errors.Add(Resource.PrimaryRepeat);
                    return(new Tuple <ValidationErrors, bool>(errors, false));
                }
                entity            = new Flow_FormContentStepCheck();
                entity.Id         = model.Id;
                entity.ContentId  = model.ContentId;
                entity.StepId     = model.StepId;
                entity.State      = model.State;
                entity.StateFlag  = model.StateFlag;
                entity.CreateTime = model.CreateTime;
                entity.IsEnd      = model.IsEnd;
                entity.IsCustom   = model.IsCustom;


                if (await m_Rep.CreateAsync(entity))
                {
                    return(new Tuple <ValidationErrors, bool>(errors, true));
                }
                else
                {
                    errors.Add(Resource.InsertFail);
                    return(new Tuple <ValidationErrors, bool>(errors, false));
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(new Tuple <ValidationErrors, bool>(errors, false));
            }
        }
コード例 #8
0
 public JsonResult Edit(Flow_FormContentStepCheckModel model)
 {
     if (model != null && ModelState.IsValid)
     {
         if (m_BLL.Edit(ref errors, model))
         {
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",ContentId" + model.ContentId, "成功", "修改", "Flow_FormContentStepCheck");
             return(Json(JsonHandler.CreateMessage(1, Suggestion.EditSucceed)));
         }
         else
         {
             string ErrorCol = errors.Error;
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",ContentId" + model.ContentId + "," + ErrorCol, "失败", "修改", "Flow_FormContentStepCheck");
             return(Json(JsonHandler.CreateMessage(0, Suggestion.EditFail + ErrorCol)));
         }
     }
     else
     {
         return(Json(JsonHandler.CreateMessage(0, Suggestion.EditFail)));
     }
 }
コード例 #9
0
        public virtual Flow_FormContentStepCheckModel GetById(object id)
        {
            if (IsExists(id))
            {
                Flow_FormContentStepCheck      entity = m_Rep.GetById(id);
                Flow_FormContentStepCheckModel model  = new Flow_FormContentStepCheckModel();
                model.Id         = entity.Id;
                model.ContentId  = entity.ContentId;
                model.StepId     = entity.StepId;
                model.State      = entity.State;
                model.StateFlag  = entity.StateFlag;
                model.CreateTime = entity.CreateTime;
                model.IsEnd      = entity.IsEnd;
                model.IsCustom   = entity.IsCustom;

                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #10
0
        public virtual bool Edit(ref ValidationErrors errors, Flow_FormContentStepCheckModel model)
        {
            try
            {
                Flow_FormContentStepCheck entity = m_Rep.GetById(model.Id);
                if (entity == null)
                {
                    errors.Add(Resource.Disable);
                    return(false);
                }
                entity.Id         = model.Id;
                entity.ContentId  = model.ContentId;
                entity.StepId     = model.StepId;
                entity.State      = model.State;
                entity.StateFlag  = model.StateFlag;
                entity.CreateTime = model.CreateTime;
                entity.IsEnd      = model.IsEnd;
                entity.IsCustom   = model.IsCustom;



                if (m_Rep.Edit(entity))
                {
                    return(true);
                }
                else
                {
                    errors.Add(Resource.NoDataChange);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(false);
            }
        }
コード例 #11
0
ファイル: DrafController.cs プロジェクト: zqs99/XDWMS-Ymnets
        public JsonResult Create(Flow_FormContentModel model)
        {
            //当前的Form模版
            Flow_FormModel formModel = formBLL.GetById(model.FormId);

            //初始化部分数据
            model.Id         = ResultHelper.NewId;
            model.CreateTime = ResultHelper.NowTime;
            model.UserId     = GetUserId();
            model.Title      = formModel.Name;
            model.TimeOut    = DateTime.Now.AddDays(30);
            if (model != null && ModelState.IsValid)
            {
                //内容提交数据库
                if (formContentBLL.Create(ref errors, model))
                {
                    try
                    {
                        List <Flow_StepModel> stepModelList = stepBLL.GetList(ref setNoPagerAscBySort, model.FormId);
                        //查询步骤
                        int  listCount = stepModelList.Count();
                        bool IsEnd     = false;
                        //循环表单的所有步骤
                        for (int i = 0; i < listCount; i++)
                        {
                            string         nextStep  = "";
                            Flow_StepModel stepModel = stepModelList[i];
                            //获得步骤对应的规则
                            List <Flow_StepRuleModel> stepRuleModelList = stepRuleBLL.GetList(stepModel.Id);
                            //获取规则判断流转方向
                            foreach (Flow_StepRuleModel stepRuleModel in stepRuleModelList)
                            {
                                //获取需要判断的数值,比如请假天数
                                string val = new FlowHelper().GetFormAttrVal(stepRuleModel.AttrId, formModel, model);
                                //有满足流程结束的条件,判断请假天数是否处于这个规则内
                                if (!JudgeVal(stepRuleModel.AttrId, val, stepRuleModel.Operator, stepRuleModel.Result))
                                {
                                    //如果符合规则,判断是否还有下一步
                                    if (stepRuleModel.NextStep != "0")
                                    {
                                        //跳转后的下一步
                                        for (int j = 0; j < listCount; j++)
                                        {
                                            //看看当前步骤是哪一步
                                            if (stepModelList[j].Id == nextStep)
                                            {
                                                i = j;//跳到分支后的下一步,从这一步开始循环
                                                continue;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        IsEnd = true;
                                        continue;
                                    }
                                }
                            }
                            #region 插入步骤
                            //插入步骤审核表
                            Flow_FormContentStepCheckModel stepCheckModel = new Flow_FormContentStepCheckModel();
                            stepCheckModel.Id         = ResultHelper.NewId;
                            stepCheckModel.ContentId  = model.Id;
                            stepCheckModel.StepId     = stepModel.Id;
                            stepCheckModel.State      = (int)FlowStateEnum.Progress;
                            stepCheckModel.StateFlag  = false;//true此步骤审核完成
                            stepCheckModel.CreateTime = ResultHelper.NowTime;
                            stepCheckModel.IsEnd      = IsEnd;
                            stepCheckModel.IsCustom   = stepModel.FlowRule == (int)FlowRuleEnum.Customer ? true : false;

                            if (stepCheckBLL.Create(ref errors, stepCheckModel))//新建步骤成功
                            {
                                InsertChecker(model, i, stepModel, stepCheckModel);
                            }

                            if (IsEnd)//如果是最后一步就无需要下面继续了
                            {
                                break;
                            }
                            #endregion
                        }



                        LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",AttrA" + model.AttrA, "成功", "创建", "Flow_FormContent");
                        return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed)));
                    }
                    catch (Exception ex)
                    {
                        //创建失败,删除表单
                        formContentBLL.Delete(ref errors, model.Id);
                        return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + "流程发生异常,请联系管理员")));
                    }
                }
                else
                {
                    string ErrorCol = errors.Error;
                    LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",AttrA" + model.AttrA + "," + ErrorCol, "失败", "创建", "Flow_FormContent");
                    return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol)));
                }
            }
            else
            {
                return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail)));
            }
        }
コード例 #12
0
ファイル: DrafController.cs プロジェクト: zqs99/XDWMS-Ymnets
        private void InsertChecker(Flow_FormContentModel model, int i, Flow_StepModel stepModel, Flow_FormContentStepCheckModel stepCheckModel)
        {
            //获得流转规则下的审核人员
            List <string> userIdList = new List <string>();

            if (stepModel.FlowRule == (int)FlowRuleEnum.Customer)
            {
                string[] arrUserList = model.CustomMember.Split(',');
                foreach (string s in arrUserList)
                {
                    userIdList.Add(s);
                }
            }
            else
            {
                userIdList = GetStepCheckMemberList(stepModel.Id, model.Id);
            }

            for (int j = 0; j < userIdList.Count(); j++)
            {
                //只有第一条记录 或者是非自选人才会插入
                if (j == i || !stepCheckModel.IsCustom)
                {
                    //批量建立步骤审核人表
                    Flow_FormContentStepCheckStateModel stepCheckModelState = new Flow_FormContentStepCheckStateModel();
                    stepCheckModelState.Id          = ResultHelper.NewId;
                    stepCheckModelState.StepCheckId = stepCheckModel.Id;
                    stepCheckModelState.UserId      = userIdList[j];
                    stepCheckModelState.CheckFlag   = 2;
                    stepCheckModelState.Reamrk      = "";
                    stepCheckModelState.TheSeal     = "";
                    stepCheckModelState.CreateTime  = ResultHelper.NowTime;
                    stepCheckStateBLL.Create(ref errors, stepCheckModelState);
                }
            }
        }
コード例 #13
0
        public JsonResult Create(Flow_FormContentModel model)
        {
            model.Id         = ResultHelper.NewId;
            model.CreateTime = ResultHelper.NowTime;
            model.UserId     = GetUserId();

            if (model != null && ModelState.IsValid)
            {
                if (formContentBLL.Create(ref errors, model))
                {
                    //当前的Form模版
                    Flow_FormModel formModel = formBLL.GetById(model.FormId);

                    //创建成功后把步骤取出
                    List <Flow_StepModel> stepModelList = stepBLL.GetList(ref setNoPagerAscBySort, model.FormId);

                    //查询步骤
                    bool IsEnd = false;
                    foreach (Flow_StepModel stepModel in stepModelList)
                    {
                        List <Flow_StepRuleModel> stepRuleModelList = stepRuleBLL.GetList(stepModel.Id);
                        //获取规则判断流转方向
                        foreach (Flow_StepRuleModel stepRuleModel in stepRuleModelList)
                        {
                            string val = new FlowHelper().GetFormAttrVal(stepRuleModel.AttrId, formModel, model);

                            //有满足不流程结束的条件
                            if (!JudgeVal(stepRuleModel.AttrId, val, stepRuleModel.Operator, stepRuleModel.Result))
                            {
                                if (stepRuleModel.NextStep != "0")
                                {
                                    IsEnd = false;
                                }
                            }
                        }

                        //插入步骤审核表
                        Flow_FormContentStepCheckModel stepCheckModel = new Flow_FormContentStepCheckModel();
                        stepCheckModel.Id         = ResultHelper.NewId;
                        stepCheckModel.ContentId  = model.Id;
                        stepCheckModel.StepId     = stepModel.Id;
                        stepCheckModel.State      = 2;                                  //0不通过1通过2审核中
                        stepCheckModel.StateFlag  = false;                              //true此步骤审核完成
                        stepCheckModel.CreateTime = ResultHelper.NowTime;
                        stepCheckModel.IsEnd      = IsEnd;                              //是否流程的最后一步

                        if (formContentStepCheckBLL.Create(ref errors, stepCheckModel)) //新建步骤成功
                        {
                            //获得流转规则下的审核人员
                            List <string> userIdList = GetStepCheckMemberList(stepModel.Id, model.Id);
                            if (userIdList.Count > 0)
                            {
                                foreach (string userId in userIdList)
                                {
                                    //批量建立步骤审核人表
                                    Flow_FormContentStepCheckStateModel stepCheckStateModel = new Flow_FormContentStepCheckStateModel();
                                    stepCheckStateModel.Id          = ResultHelper.NewId;
                                    stepCheckStateModel.StepCheckId = stepCheckModel.Id;
                                    stepCheckStateModel.UserId      = userId;
                                    stepCheckStateModel.CheckFlag   = 2;
                                    stepCheckStateModel.Reamrk      = "";
                                    stepCheckStateModel.TheSeal     = "";
                                    stepCheckStateModel.CreateTime  = ResultHelper.NowTime;
                                    stepCheckStateBLL.Create(ref errors, stepCheckStateModel);
                                }
                            }
                        }

                        if (IsEnd)//如果是最后一步就无需要下面继续了
                        {
                            break;
                        }
                        IsEnd = true;
                    }

                    LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",AttrA" + model.AttrA, "成功", "创建", "Flow_FormContent");
                    return(Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed)));
                }
                else
                {
                    string ErrorCol = errors.Error;
                    LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",AttrA" + model.AttrA + "," + ErrorCol, "失败", "创建", "Flow_FormContent");
                    return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + ErrorCol)));
                }
            }
            else
            {
                return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail)));
            }
        }
コード例 #14
0
ファイル: ExamineController.cs プロジェクト: anbylau2130/App
        public JsonResult Edit(string Remark, string TheSeal, string FormId, int Flag, string ContentId, string UserList)
        {
            string stepCheckId = formContentBLL.GetCurrentStepCheckId(FormId, ContentId);

            if (stepCheckId == "")
            {
                return(Json(JsonHandler.CreateMessage(0, Resource.EditFail)));
            }
            Flow_FormContentStepCheckStateModel stepCheckStateModel = stepCheckStateBLL.GetByStepCheckId(stepCheckId);

            if (stepCheckStateModel.UserId != GetUserId())
            {
                return(Json(JsonHandler.CreateMessage(0, "越权操作!")));
            }
            stepCheckStateModel.Reamrk    = Remark;
            stepCheckStateModel.TheSeal   = TheSeal;
            stepCheckStateModel.CheckFlag = Flag;
            if (stepCheckStateBLL.Edit(ref errors, stepCheckStateModel))
            {
                //获取当前步骤
                Flow_FormContentStepCheckModel stepCheckModel = stepCheckBLL.GetById(stepCheckStateModel.StepCheckId);
                //获得当前的步骤模板
                Flow_StepModel currentStepModel = stepBLL.GetById(stepCheckModel.StepId);
                //驳回直接终止审核
                if (Flag == (int)FlowStateEnum.Reject)
                {
                    stepCheckModel.State     = Flag;
                    stepCheckModel.StateFlag = false;
                    stepCheckBLL.Edit(ref errors, stepCheckModel);
                    //重置所有步骤的状态
                    stepCheckBLL.ResetCheckStateByFormCententId(stepCheckModel.Id, ContentId, (int)FlowStateEnum.Progress, (int)FlowStateEnum.Progress);
                    LogHandler.WriteServiceLog(GetUserId(), "Id" + stepCheckStateModel.Id + ",StepCheckId" + stepCheckStateModel.Reamrk, "成功", "修改", "Flow_FormContentStepCheckState");
                    return(Json(JsonHandler.CreateMessage(1, Resource.CheckSucceed)));
                }
                else if (currentStepModel.IsAllCheck)
                {
                    //启用会签
                    //获得同步骤的同批审核人
                    List <Flow_FormContentStepCheckStateModel> stepCheckStateList = stepCheckStateBLL.GetListByStepCheckId(ref setNoPagerAscById, stepCheckStateModel.StepCheckId);
                    //查看自己是否是最后一个审核人
                    bool complete = stepCheckStateList.Where(a => a.CheckFlag == (int)FlowStateEnum.Progress).Count() == 1;
                    if (complete)
                    {
                        stepCheckModel.State     = Flag;
                        stepCheckModel.StateFlag = true;
                        stepCheckBLL.Edit(ref errors, stepCheckModel);
                    }
                    else
                    {
                        //让审核人继续执行这个步骤直到完成
                        LogHandler.WriteServiceLog(GetUserId(), "Id" + stepCheckStateModel.Id + ",StepCheckId" + stepCheckStateModel.Reamrk, "成功", "修改", "Flow_FormContentStepCheckState");
                        return(Json(JsonHandler.CreateMessage(1, Resource.CheckSucceed)));
                    }
                }
                else
                {
                    //不是会签,任何一个审批都通过
                    stepCheckModel.State     = Flag;
                    stepCheckModel.StateFlag = true;
                    stepCheckBLL.Edit(ref errors, stepCheckModel);
                }
                //查看下一步是否为自创建
                if (!stepCheckModel.IsEnd && !string.IsNullOrEmpty(UserList))
                {
                    List <Flow_FormContentStepCheckModel> stepCheckList = stepCheckBLL.GetListByFormId(FormId, ContentId);
                    int j = 0;
                    for (int i = stepCheckList.Count() - 1; i >= 0; i--)
                    {
                        if (stepCheckId == stepCheckList[i].Id)
                        {
                            j = i;
                        }
                    }
                    //查看是否还有下一步步骤
                    if (j - 1 <= stepCheckList.Count())
                    {
                        //查有第二步骤,查看是否是自选
                        Flow_StepModel stepModel = stepBLL.GetById(stepCheckList[j + 1].StepId);
                        if (stepModel.FlowRule == (int)FlowRuleEnum.Customer)
                        {
                            foreach (string userId in UserList.Split(','))
                            {
                                //批量建立步骤审核人表
                                CreateCheckState(stepCheckList[j + 1].Id, userId);
                            }
                        }
                        else
                        {
                            //批量建立审核人员表
                            foreach (string userId in GetStepCheckMemberList(stepCheckList[j + 1].StepId))
                            {
                                //批量建立步骤审核人表
                                CreateCheckState(stepCheckList[j + 1].Id, userId);
                            }
                        }
                    }
                }


                LogHandler.WriteServiceLog(GetUserId(), "Id" + stepCheckStateModel.Id + ",StepCheckId" + stepCheckStateModel.Reamrk, "成功", "修改", "Flow_FormContentStepCheckState");
                return(Json(JsonHandler.CreateMessage(1, Resource.CheckSucceed)));
            }
            else
            {
                string ErrorCol = errors.Error;
                LogHandler.WriteServiceLog(GetUserId(), "Id" + stepCheckStateModel.Id + ",StepCheckId" + stepCheckStateModel.Reamrk + "," + ErrorCol, "失败", "修改", "Flow_FormContentStepCheckState");
                return(Json(JsonHandler.CreateMessage(0, Resource.CheckFail + ErrorCol)));
            }
        }
コード例 #15
0
        public JsonResult Create(Flow_FormContentModel model)
        {
            //当前的Form模版
            Flow_FormModel formModel = formBLL.GetById(model.FormId);

            //初始化部分数据
            model.Id         = ResultHelper.NewId;
            model.CreateTime = ResultHelper.NowTime;
            model.UserId     = GetUserId();
            model.Title      = formModel.Name;
            model.TimeOut    = DateTime.Now.AddDays(30);
            if (model != null && ModelState.IsValid)
            {
                if (formContentBLL.Create(ref errors, model))
                {
                    //创建成功后把步骤取出
                    List <Flow_StepModel> stepModelList = stepBLL.GetList(ref setNoPagerAscBySort, model.FormId);
                    //查询步骤
                    int  listCount = stepModelList.Count();
                    bool IsEnd     = false;
                    for (int i = 0; i < listCount; i++)
                    {
                        string                    nextStep          = "";
                        Flow_StepModel            stepModel         = stepModelList[i];
                        List <Flow_StepRuleModel> stepRuleModelList = stepRuleBLL.GetList(stepModel.Id);
                        //获取规则判断流转方向
                        foreach (Flow_StepRuleModel stepRuleModel in stepRuleModelList)
                        {
                            string val = new FlowHelper().GetFormAttrVal(stepRuleModel.AttrId, formModel, model);
                            //有满足流程结束的条件
                            if (!JudgeVal(stepRuleModel.AttrId, val, stepRuleModel.Operator, stepRuleModel.Result))
                            {
                                if (stepRuleModel.NextStep != "0")
                                {
                                    //获得跳转的步骤
                                    nextStep = stepRuleModel.NextStep;
                                    //跳到跳转后的下一步
                                    for (int j = 0; j < listCount; j++)
                                    {
                                        if (stepModelList[j].Id == nextStep)
                                        {
                                            i = j;//跳到分支后的下一步
                                        }
                                    }
                                }
                                else
                                {
                                    //nextStep=0流程结束
                                    IsEnd = true;
                                }
                            }
                        }

                        #region 插入步骤
                        //插入步骤审核表
                        Flow_FormContentStepCheckModel stepCheckModel = new Flow_FormContentStepCheckModel();
                        stepCheckModel.Id         = ResultHelper.NewId;
                        stepCheckModel.ContentId  = model.Id;
                        stepCheckModel.StepId     = stepModel.Id;
                        stepCheckModel.State      = (int)FlowStateEnum.Progress;
                        stepCheckModel.StateFlag  = false;//true此步骤审核完成
                        stepCheckModel.CreateTime = ResultHelper.NowTime;
                        if (nextStep != "" && nextStep != "0")
                        {
                            stepCheckModel.IsEnd = (i == listCount) ? true : IsEnd;//是否流程的最后一步
                        }
                        else
                        {
                            stepCheckModel.IsEnd = (i == listCount - 1) ? true : IsEnd;//是否流程的最后一步
                        }

                        stepCheckModel.IsCustom = stepModel.FlowRule == (int)FlowRuleEnum.Customer ? true : false;
                        if (stepCheckBLL.Create(ref errors, stepCheckModel))//新建步骤成功
                        {
                            InsertChecker(model, i, stepModel, stepCheckModel);
                        }
                        #endregion
                        #region 插入分支步骤
                        if (nextStep != "" && nextStep != "0")
                        {
                            //不是最后一个审核人
                            if (listCount < 1 || i != listCount - 1)
                            {
                                IsEnd = false;
                            }
                            else
                            {
                                IsEnd = true;
                            }

                            stepCheckModel            = new Flow_FormContentStepCheckModel();
                            stepCheckModel.Id         = ResultHelper.NewId;
                            stepCheckModel.ContentId  = model.Id;
                            stepCheckModel.StepId     = stepModel.Id;
                            stepCheckModel.State      = (int)FlowStateEnum.Progress;
                            stepCheckModel.StateFlag  = false; //true此步骤审核完成
                            stepCheckModel.CreateTime = ResultHelper.NowTime;
                            stepCheckModel.IsEnd      = IsEnd; //是否流程的最后一步


                            stepCheckModel.IsCustom = stepModel.FlowRule == (int)FlowRuleEnum.Customer ? true : false;
                            if (stepCheckBLL.Create(ref errors, stepCheckModel))//新建步骤成功
                            {
                                InsertChecker(model, i, stepModel, stepCheckModel);
                            }
                        }
                        #endregion

                        if (IsEnd)//如果是最后一步就无需要下面继续了
                        {
                            break;
                        }
                        IsEnd = true;
                    }



                    LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",AttrA" + model.AttrA, "成功", "创建", "Flow_FormContent");
                    return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed)));
                }
                else
                {
                    string ErrorCol = errors.Error;
                    LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",AttrA" + model.AttrA + "," + ErrorCol, "失败", "创建", "Flow_FormContent");
                    return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol)));
                }
            }
            else
            {
                return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail)));
            }
        }