//删除
 public int Delete(string itemid, string vercode, string code)
 {
     using (DBContainer db = new DBContainer())
     {
         DEF_TestJobsDetailSteps deleteItem = db.DEF_TestJobsDetailSteps.SingleOrDefault(a => a.ItemID == itemid && a.VerCode == vercode && a.Code == code);
         if (deleteItem != null)
         {
             db.DEF_TestJobsDetailSteps.Remove(deleteItem);
             return(db.SaveChanges());
         }
         return(0);
     }
 }
Esempio n. 2
0
        //新增
        public override bool Create(ref ValidationErrors errors, DEF_TestJobsDetailStepsModel model)
        {
            try
            {
                //测试关键数值是否有效
                DEF_TestJobsDetailItem testItem = testItemRep.GetById(model.VerCode, model.Code);
                if (testItem == null)
                {
                    errors.Add("测试项目不存在");
                    return(false);
                }
                //新建对象
                DEF_TestJobsDetailSteps entity = new DEF_TestJobsDetailSteps();

                //实现从模型到对象设置值
                entity.ItemID        = model.ItemID;
                entity.VerCode       = model.VerCode;
                entity.Code          = model.Code;
                entity.Title         = model.Title;
                entity.TestContent   = model.TestContent;
                entity.Result        = model.Result;
                entity.Sort          = model.Sort;
                entity.ResultContent = model.ResultContent;
                entity.StepType      = model.StepType;
                entity.TestDt        = model.TestDt;
                entity.Tester        = model.Tester;

                entity.Developer       = model.Developer;
                entity.PlanStartDt     = model.PlanStartDt;
                entity.PlanEndDt       = model.PlanEndDt;
                entity.FinDt           = model.FinDt;
                entity.DevFinFlag      = model.DevFinFlag;
                entity.TestRequestFlag = model.TestRequestFlag;

                if (repository.Create(entity))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
            }
            return(false);
        }
Esempio n. 3
0
        public virtual bool Create(ref ValidationErrors errors, DEF_TestJobsDetailStepsModel model)
        {
            try
            {
                DEF_TestJobsDetailSteps entity = m_Rep.GetById(model.ItemID);
                if (entity != null)
                {
                    errors.Add(Resource.PrimaryRepeat);
                    return(false);
                }
                entity                 = new DEF_TestJobsDetailSteps();
                entity.ItemID          = model.ItemID;
                entity.VerCode         = model.VerCode;
                entity.Code            = model.Code;
                entity.Title           = model.Title;
                entity.TestContent     = model.TestContent;
                entity.Result          = model.Result;
                entity.Sort            = model.Sort;
                entity.ResultContent   = model.ResultContent;
                entity.ExSort          = model.ExSort;
                entity.StepType        = model.StepType;
                entity.Tester          = model.Tester;
                entity.TestDt          = model.TestDt;
                entity.Developer       = model.Developer;
                entity.PlanStartDt     = model.PlanStartDt;
                entity.PlanEndDt       = model.PlanEndDt;
                entity.FinDt           = model.FinDt;
                entity.TestRequestFlag = model.TestRequestFlag;
                entity.DevFinFlag      = model.DevFinFlag;


                if (m_Rep.Create(entity))
                {
                    return(true);
                }
                else
                {
                    errors.Add(Resource.InsertFail);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(false);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 执行测试
        /// </summary>
        /// <param name="error"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool RunTest(ref ValidationErrors errors, DEF_TestJobsDetailStepsModel model)
        {
            try
            {
                //修改前检查关键字

                DEF_TestJobsDetailSteps stepsModel = GetById(model.ItemID, model.VerCode, model.Code);
                if (stepsModel == null)
                {
                    errors.Add("测试步骤不存在");
                    return(false);
                }
                stepsModel.ResultContent = model.ResultContent;
                stepsModel.Result        = model.Result;

                if (stepsModel.Result == null)
                {
                    stepsModel.TestDt = null;
                    stepsModel.Tester = null;
                }
                else
                {
                    stepsModel.TestDt = model.TestDt;
                    stepsModel.Tester = model.Tester;
                    //更新测试请求状态
                    stepsModel.TestRequestFlag = false;
                }

                //修改
                if (!repository.Edit(stepsModel))
                {
                    errors.Add("修改错误!");
                }
                //更新开发状态
                testItemRep.DevUpdateState(model.VerCode, model.Code);
                return(true);
            }
            catch (Exception ex)
            {
                ExceptionHander.WriteException(ex);
                errors.Add("修改异常!");
                return(false);
            }
        }
        //添加
        public override bool Create(DEF_TestJobsDetailItem entity)
        {
            Context.DEF_TestJobsDetailItem.Add(entity);

            //增加测试步骤
            var caseSteps = Context.DEF_TestCaseSteps.Where(a => a.Code == entity.Code);

            foreach (var caseStep in caseSteps)
            {
                var step = new DEF_TestJobsDetailSteps();
                step.ItemID      = caseStep.ItemID;
                step.VerCode     = entity.VerCode;
                step.Code        = caseStep.Code;
                step.Title       = caseStep.Title;
                step.TestContent = caseStep.TestContent;

                step.Sort            = caseStep.sort;
                step.StepType        = 0;
                step.TestRequestFlag = false;

                Context.DEF_TestJobsDetailSteps.Add(step);
            }
            return(this.SaveChanges() > 0);
        }
Esempio n. 6
0
        //批量设置
        public bool AllSet(ref ValidationErrors errors, string begintime, string endtime, string member, string ids)
        {
            try
            {
                if (string.IsNullOrEmpty(ids))
                {
                    errors.Add("记录不能为空!");
                    return(false);
                }
                string[] arrIds = ids.Split(',');

                for (int i = 0; i < arrIds.Length; i++)
                {
                    DEF_TestJobsDetailSteps model = repository.GetById(arrIds[i]);
                    if (model == null)
                    {
                        continue;
                    }
                    if (member != "")
                    {
                        model.Developer = member;
                    }
                    else
                    {
                        model.Developer = null;
                    }
                    if (begintime != "")
                    {
                        try
                        {
                            model.PlanStartDt = Convert.ToDateTime(begintime);
                        }
                        catch
                        {
                            errors.Add("日期不是正确的!格式为:2012-01-02");
                            return(false);
                        }
                    }
                    else
                    {
                        model.PlanStartDt = null;
                    }
                    if (endtime != "")
                    {
                        try
                        {
                            model.PlanEndDt = Convert.ToDateTime(endtime);
                        }
                        catch
                        {
                            errors.Add("日期不是正确的!格式为:2012-01-02");
                            return(false);
                        }
                    }
                    else
                    {
                        model.PlanEndDt = null;
                    }
                    if (!repository.Edit(model))
                    {
                        errors.Add("批量设置出错!");
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                ExceptionHander.WriteException(ex);
                errors.Add("分配执行人员异常");
                return(false);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 设置处理状态
        /// </summary>
        /// <param name="error"></param>
        /// <param name="state"></param>
        /// <param name="ids"></param>
        /// <param name="userid"></param>
        /// <returns></returns>
        public bool SetProcessState(ref ValidationErrors errors, bool state, string ids, string userid)
        {
            try
            {
                if (string.IsNullOrEmpty(ids))
                {
                    errors.Add("记录不能为空!");
                    return(false);
                }


                string[] arrIds = ids.Split(',');

                for (int i = 0; i < arrIds.Length; i++)
                {
                    DEF_DefectModel model = GetModelByComplexId(arrIds[i]);
                    if (model == null)
                    {
                        continue;
                    }
                    if (!CheckJobsIsClosed(ref errors, model.VerCode))
                    {
                        return(false);
                    }

                    if (state)
                    {
                        model.ProcessState = state;
                        model.Processor    = userid;
                        model.ProcessDt    = DateTime.Now;
                        model.CloseState   = true;//默认已审核
                        model.CloseDt      = DateTime.Now;
                        model.Closer       = userid;
                    }
                    else
                    {
                        model.ProcessState = state;
                        model.Processor    = null;
                        model.ProcessDt    = null;
                    }

                    if (m_Rep.Edit(model) != 1)
                    {
                        errors.Add("设置处理状态出错!");
                        return(false);
                    }
                    //处理成功,相应运行测试模块变更为测试请求为true
                    var entity = testJobsDetailStepRep.GetByComplexId(arrIds[i]);
                    if (entity != null)
                    {
                        DEF_TestJobsDetailSteps tjdsModel = testJobsDetailStepRep.GetById(entity.ItemID, entity.VerCode, entity.Code);
                        tjdsModel.TestRequestFlag = true;

                        testJobsDetailStepRep.Edit(tjdsModel);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                ExceptionHander.WriteException(ex);
                errors.Add("设置处理状态异常");
                return(false);
            }
        }