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);
     }
 }
        /// <summary>
        /// 保存数据
        /// </summary>
        public virtual void SaveImportData(IEnumerable <Flow_FormContentStepCheckModel> list)
        {
            try
            {
                using (DBContainer db = new DBContainer())
                {
                    foreach (var model in list)
                    {
                        Flow_FormContentStepCheck entity = new Flow_FormContentStepCheck();
                        entity.Id         = ResultHelper.NewId;
                        entity.ContentId  = model.ContentId;
                        entity.StepId     = model.StepId;
                        entity.State      = model.State;
                        entity.StateFlag  = model.StateFlag;
                        entity.CreateTime = ResultHelper.NowTime;
                        entity.IsEnd      = model.IsEnd;
                        entity.IsCustom   = model.IsCustom;

                        db.Flow_FormContentStepCheck.Add(entity);
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
 public int Create(Flow_FormContentStepCheck entity)
 {
     using (AppsDBEntities db = new AppsDBEntities())
     {
         db.Flow_FormContentStepCheck.Add(entity);
         return(db.SaveChanges());
     }
 }
 public int Edit(Flow_FormContentStepCheck entity)
 {
     using (AppsDBEntities db = new AppsDBEntities())
     {
         db.Flow_FormContentStepCheck.Attach(entity);
         db.Entry <Flow_FormContentStepCheck>(entity).State = System.Data.Entity.EntityState.Modified;
         //db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);
         return(db.SaveChanges());
     }
 }
 public bool IsExist(string id)
 {
     using (AppsDBEntities db = new AppsDBEntities())
     {
         Flow_FormContentStepCheck entity = GetById(id);
         if (entity != null)
         {
             return(true);
         }
         return(false);
     }
 }
 public int Delete(string id)
 {
     using (AppsDBEntities db = new AppsDBEntities())
     {
         Flow_FormContentStepCheck entity = db.Flow_FormContentStepCheck.SingleOrDefault(a => a.Id == id);
         if (entity != null)
         {
             db.Flow_FormContentStepCheck.Remove(entity);
         }
         return(db.SaveChanges());
     }
 }
Пример #7
0
        //[SupportFilter]
        public ActionResult Edit(string formId, string id)
        {
            //获得当前步骤ID
            string currentStepId = formContentBLL.GetCurrentStepCheckId(formId, id);

            Flow_Form formModel = formBLL.m_Rep.Find(Convert.ToInt32(formId));

            //是否已经设置布局
            if (!string.IsNullOrEmpty(formModel.HtmlForm))
            {
                ViewBag.Html = formModel.HtmlForm;
            }
            else
            {
                ViewBag.Html = ExceHtmlJs(formId);
            }
            ViewBag.StepCheckMes   = formContentBLL.GetCurrentStepCheckMes(ref setNoPagerAscById, formId, id, GetUserId());
            ViewBag.StepCheckId    = currentStepId;
            ViewBag.IsCustomMember = false;

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

            return(View(model));
        }
 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);
     }
 }
Пример #9
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));
            }
        }
        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);
            }
        }
Пример #11
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);
            }
        }
Пример #12
0
        //[SupportFilter]
        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_FormContentStepCheckState stepCheckStateModel = stepCheckStateBLL.m_Rep.Find(a => a.StepCheckId == stepCheckId);

            if (stepCheckStateModel.UserId != GetUserId())
            {
                return(Json(JsonHandler.CreateMessage(0, "越权操作!")));
            }
            stepCheckStateModel.Reamrk    = Remark;
            stepCheckStateModel.TheSeal   = TheSeal;
            stepCheckStateModel.CheckFlag = Flag.ToString();
            if (stepCheckStateBLL.m_Rep.Update(stepCheckStateModel))
            {
                //获取当前步骤
                Flow_FormContentStepCheck stepCheckModel = stepCheckBLL.m_Rep.Find(Convert.ToInt32(stepCheckStateModel.StepCheckId));
                //获得当前的步骤模板
                Flow_Step currentStepModel = stepBLL.m_Rep.Find(Convert.ToInt32(stepCheckModel.StepId));
                //驳回直接终止审核
                if (Flag == (int)FlowStateEnum.Reject)
                {
                    stepCheckModel.State     = Flag.ToString();
                    stepCheckModel.StateFlag = "false";
                    stepCheckBLL.m_Rep.Update(stepCheckModel);
                    //重置所有步骤的状态
                    stepCheckBLL.ResetCheckStateByFormCententId(stepCheckModel.Id.ToString(), 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 == "true")
                {
                    //启用会签
                    //获得同步骤的同批审核人
                    List <Flow_FormContentStepCheckState> stepCheckStateList = stepCheckStateBLL.m_Rep.FindPageList(ref setNoPagerAscById, a => a.StepCheckId == stepCheckStateModel.StepCheckId).ToList();
                    //查看自己是否是最后一个审核人
                    bool complete = stepCheckStateList.Where(a => a.CheckFlag == FlowStateEnum.Progress.ToString()).Count() == 1;
                    if (complete)
                    {
                        stepCheckModel.State     = Flag.ToString();
                        stepCheckModel.StateFlag = "true";
                        stepCheckBLL.m_Rep.Update(stepCheckModel);
                    }
                    else
                    {
                        //让审核人继续执行这个步骤直到完成
                        LogHandler.WriteServiceLog(GetUserId(), "Id" + stepCheckStateModel.Id + ",StepCheckId" + stepCheckStateModel.Reamrk, "成功", "修改", "Flow_FormContentStepCheckState");
                        return(Json(JsonHandler.CreateMessage(1, Resource.CheckSucceed)));
                    }
                }
                else
                {
                    //不是会签,任何一个审批都通过
                    stepCheckModel.State     = Flag.ToString();
                    stepCheckModel.StateFlag = "true";
                    stepCheckBLL.m_Rep.Update(stepCheckModel);
                }
                //查看下一步是否为自创建
                if (stepCheckModel.IsEnd != "true" && !string.IsNullOrEmpty(UserList))
                {
                    List <Flow_FormContentStepCheck> stepCheckList = stepCheckBLL.GetListByFormId(FormId, ContentId).ToList();
                    int j = 0;
                    for (int i = stepCheckList.Count() - 1; i >= 0; i--)
                    {
                        if (stepCheckId == stepCheckList[i].Id.ToString())
                        {
                            j = i;
                        }
                    }
                    //查看是否还有下一步步骤
                    if (j - 1 <= stepCheckList.Count())
                    {
                        //查有第二步骤,查看是否是自选
                        Flow_Step stepModel = stepBLL.m_Rep.Find(Convert.ToInt32(stepCheckList[j + 1].StepId));
                        if (stepModel.FlowRule == FlowRuleEnum.Customer.ToString())
                        {
                            foreach (string userId in UserList.Split(','))
                            {
                                //批量建立步骤审核人表
                                CreateCheckState(stepCheckList[j + 1].Id.ToString(), userId);
                            }
                        }
                        else
                        {
                            //批量建立审核人员表
                            foreach (string userId in GetStepCheckMemberList(stepCheckList[j + 1].StepId))
                            {
                                //批量建立步骤审核人表
                                CreateCheckState(stepCheckList[j + 1].Id.ToString(), 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)));
            }
        }
Пример #13
0
        //[SupportFilter]
        public JsonResult Create(Flow_FormContent model)
        {
            //当前的Form模版
            Flow_Form formModel = formBLL.m_Rep.Find(Convert.ToInt32(model.FormId));

            //初始化部分数据
            model.CreateTime = ResultHelper.NowTime.ToString("yyyy-MM-dd");
            model.UserId     = GetUserId();
            model.Title      = formModel.Name;
            model.TimeOut    = DateTime.Now.AddDays(30).ToString("yyyy-MM-dd");
            if (model != null)
            {
                if (formContentBLL.m_Rep.Create(model))
                {
                    //创建成功后把步骤取出
                    List <Flow_Step> stepModelList = stepBLL.m_Rep.FindPageList(ref setNoPagerAscBySort, a => a.FormId == model.FormId).ToList();
                    //查询步骤
                    int    listCount = stepModelList.Count();
                    string IsEnd     = "false";
                    for (int i = 0; i < listCount; i++)
                    {
                        string               nextStep          = "";
                        Flow_Step            stepModel         = stepModelList[i];
                        List <Flow_StepRule> stepRuleModelList = stepRuleBLL.m_Rep.FindList(a => a.StepId == stepModel.Id.ToString()).ToList();
                        //获取规则判断流转方向
                        foreach (Flow_StepRule 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.ToString() == nextStep)
                                        {
                                            i = j;//跳到分支后的下一步
                                        }
                                    }
                                }
                                else
                                {
                                    //nextStep=0流程结束
                                    IsEnd = "true";
                                }
                            }
                        }

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

                        stepCheckModel.IsCustom = stepModel.FlowRule == FlowRuleEnum.Customer.ToString() ? "true" : "false";
                        if (stepCheckBLL.m_Rep.Create(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_FormContentStepCheck();
                            stepCheckModel.ContentId  = model.Id.ToString();
                            stepCheckModel.StepId     = stepModel.Id.ToString();
                            stepCheckModel.State      = FlowStateEnum.Progress.ToString();
                            stepCheckModel.StateFlag  = "false"; //true此步骤审核完成
                            stepCheckModel.CreateTime = ResultHelper.NowTime.ToString("yyyy-MM-dd");
                            stepCheckModel.IsEnd      = IsEnd;   //是否流程的最后一步


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

                        if (IsEnd == "true")//如果是最后一步就无需要下面继续了
                        {
                            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)));
            }
        }
Пример #14
0
        private void InsertChecker(Flow_FormContent model, int i, Flow_Step stepModel, Flow_FormContentStepCheck stepCheckModel)
        {
            //获得流转规则下的审核人员
            List <string> userIdList = new List <string>();

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

            foreach (string userId in userIdList)
            {
                //批量建立步骤审核人表
                Flow_FormContentStepCheckState stepCheckModelState = new Flow_FormContentStepCheckState();
                stepCheckModelState.StepCheckId = stepCheckModel.Id.ToString();
                stepCheckModelState.UserId      = userId;
                stepCheckModelState.CheckFlag   = "2";
                stepCheckModelState.Reamrk      = "";
                stepCheckModelState.TheSeal     = "";
                stepCheckModelState.CreateTime  = ResultHelper.NowTime.ToString("yyyy-MM-dd");
                stepCheckStateBLL.m_Rep.Create(stepCheckModelState);
            }
        }