Ejemplo n.º 1
0
 /// <summary>
 /// 根据流程id删除对应可视范围
 /// </summary>
 /// <param name="SubjectId"></param>
 /// <returns></returns>
 public bool DeleteBySubjectId(int subjectId)
 {
     return(_repository.Delete(s => s.SubjectId == subjectId) > 0 ? true : false);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 修改流程管理
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public Result Edit(Subject model)
        {
            string msg    = string.Empty;
            bool   status = false;

            try
            {
                using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope())
                {
                    //主表
                    status = _repository.Update(s => s.Id == model.Id, s => new Subject
                    {
                        FlowTypeId    = model.FlowTypeId,
                        FormContent   = model.FormContent,
                        FormAttribute = model.FormAttribute,
                        IcoUrl        = model.IcoUrl,
                        PassInfo      = model.PassInfo,
                        SubjectName   = model.SubjectName,
                        UpdateTime    = DateTime.Now,
                        SubjectTypeId = model.SubjectTypeId
                    });
                    if (!status)
                    {
                        return new Result()
                               {
                                   Succeed = status, Message = "参数修改失败"
                               }
                    }
                    ;
                    //根据流程id删除对应可视范围
                    status = _rulerepository.Delete(s => s.SubjectId == model.Id && s.BusinessType == BusinessType.Transaction) > 0 ? true : false;
                    if (!status)
                    {
                        return new Result()
                               {
                                   Succeed = status, Message = "参数修改失败"
                               }
                    }
                    ;
                    //根据节点id删除对应节点人员表
                    var stepList   = _steprepository.Query(s => s.SubjectId == model.Id);
                    var SubjectIds = (from b in stepList select b.Id).ToArray();
                    status = _rulerepository.Delete(s => SubjectIds.Contains(s.SubjectStepId)) > 0 ? true : false;
                    if (!status)
                    {
                        return new Result()
                               {
                                   Succeed = status, Message = "参数修改失败"
                               }
                    }
                    ;
                    //根据流程id删除对应节点
                    status = _steprepository.Delete(s => s.SubjectId == model.Id) > 0 ? true : false;
                    if (!status)
                    {
                        return new Result()
                               {
                                   Succeed = status, Message = "参数修改失败"
                               }
                    }
                    ;
                    //添加可视范围
                    var subjectRuleList = model.SubjectRuleRangeList as List <SubjectRule>;
                    status = _rulerepository.AddRange(subjectRuleList) > 0 ? true : false;
                    if (!status)
                    {
                        return new Result()
                               {
                                   Succeed = status, Message = "参数修改失败"
                               }
                    }
                    ;
                    //添加流程节点
                    var subjectStepList = model.SubjectStepFlowList as List <SubjectStep>;
                    status = _steprepository.AddRange(subjectStepList) > 0 ? true : false;
                    if (!status)
                    {
                        return new Result()
                               {
                                   Succeed = status, Message = "参数修改失败"
                               }
                    }
                    ;

                    ts.Complete();//提交事务
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message.ToString();
            }
            return(new Result()
            {
                Succeed = status, Message = msg
            });
        }