Beispiel #1
0
        //根据主键获取模型
        public DEF_TestJobsDetailStepsModel GetModelById(string itemid, string vercode, string code)
        {
            var entity = repository.GetById(itemid, vercode, code);

            if (entity == null)
            {
                return(null);
            }
            DEF_TestJobsDetailStepsModel model = new DEF_TestJobsDetailStepsModel();

            //实现对象到模型转换
            model.ItemID          = entity.ItemID;
            model.VerCode         = entity.VerCode;
            model.Code            = entity.Code;
            model.Title           = entity.Title;
            model.TestContent     = entity.TestContent;
            model.Result          = entity.Result;
            model.Sort            = entity.Sort;
            model.ResultContent   = entity.ResultContent;
            model.ExSort          = entity.ExSort;
            model.StepType        = entity.StepType;
            model.Tester          = entity.Tester;
            model.TestDt          = entity.TestDt;
            model.Developer       = entity.Developer;
            model.PlanStartDt     = entity.PlanStartDt;
            model.PlanEndDt       = entity.PlanEndDt;
            model.FinDt           = entity.FinDt;
            model.DevFinFlag      = entity.DevFinFlag;
            model.TestRequestFlag = entity.TestRequestFlag;
            return(model);
        }
Beispiel #2
0
        public JsonResult Create(DEF_TestJobsDetailStepsModel model)
        {
            try
            {
                if (model == null || !ModelState.IsValid)
                {
                    return(Json(JsonHandler.CreateMessage(0, "数据验证不通过")));
                }


                //新增
                m_BLL.Create(ref validationErrors, model);
                //写日志
                if (validationErrors.Count > 0)
                {
                    //错误写入日志
                    LogHandler.WriteServiceLog(GetUserId(), Resource.InsertFail + ",新增测试步骤ID:" + model.ItemID, "失败", "新增", "测试步骤");
                    return(Json(JsonHandler.CreateMessage(0, validationErrors.Error)));
                }
                //成功写入日志
                LogHandler.WriteServiceLog(GetUserId(), Resource.InsertSucceed + ",新增测试步骤ID:" + model.ItemID, "成功", "新增", "测试步骤");
                return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed)));
            }
            catch
            {
                return(Json(JsonHandler.CreateMessage(1, Resource.InsertFail)));
            }
        }
Beispiel #3
0
        /// <summary>
        /// 执行开发
        /// </summary>
        /// <param name="error"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool RunDev(ref ValidationErrors errors, DEF_TestJobsDetailStepsModel model)
        {
            DEF_TestJobsDetailSteps entity = repository.GetById(model.ItemID);

            if (entity == null)
            {
                errors.Add(Resource.Disable);
                return(false);
            }
            entity.ResultContent   = model.ResultContent;
            entity.Result          = null;//默认未测试通过
            entity.TestDt          = null;
            entity.Tester          = null;
            entity.Developer       = model.Developer;
            entity.DevFinFlag      = model.Result; //完成标识:未完成=false,完成=true
            entity.FinDt           = DateTime.Now;
            entity.TestRequestFlag = true;         //测试请求标识:不要求测试=false,要求测试=true

            if (repository.Edit(entity))
            {
                return(true);
            }
            else
            {
                errors.Add(Resource.NoDataChange);
                return(false);
            }
        }
        //新增
        public ActionResult Create(string vercode, string code)
        {
            if (!ModelState.IsValid)
            {
                return(View("数据验证不通过", true));
            }
            if (string.IsNullOrEmpty(vercode))
            {
                return(View("没有选择测试任务", true));
            }
            if (string.IsNullOrEmpty(code))
            {
                return(View("没有选择测试项目", true));
            }
            DEF_TestJobsDetailItemModel model = m_testItemBLL.GetModelById(vercode, code);

            if (model == null)
            {
                return(View("测试项目不存在"));
            }

            DEF_TestJobsDetailStepsModel stepsModel = new DEF_TestJobsDetailStepsModel()
            {
                VerCode  = vercode,
                Code     = code,
                ItemID   = "0",
                Sort     = 0,
                StepType = 0
            };

            return(View(stepsModel));
        }
 public ActionResult RunTest(DEF_TestJobsDetailStepsModel model)
 {
     try
     {
         model.Tester = GetUserId();
         model.TestDt = DateTime.Now;
         if (m_BLL.RunTest(ref validationErrors, model))
         {
             //生成缺陷报告
             m_defectBLL.CreateDefectReport(ref validationErrors, model.VerCode, GetUserId());
         }
         //写日志
         if (validationErrors.Count > 0)
         {
             //错误写入日志
             LogHandler.WriteServiceLog(GetUserId(), Resource.UpdateFail + ",编辑测试步骤ID:" + model.ItemID, "失败", "编辑", "测试步骤");
             return(Json(JsonHandler.CreateMessage(0, validationErrors.Error)));
         }
         //成功写入日志
         LogHandler.WriteServiceLog(GetUserId(), Resource.UpdateSucceed + ",编辑测试步骤ID:" + model.ItemID, "成功", "编辑", "测试步骤");
         return(Json(JsonHandler.CreateMessage(1, Resource.UpdateSucceed)));
     }
     catch
     {
         return(Json(JsonHandler.CreateMessage(0, Resource.UpdateFail)));
     }
 }
 public ActionResult RunDev(DEF_TestJobsDetailStepsModel model)
 {
     try
     {
         model.Developer = GetUserId();
         model.FinDt     = DateTime.Now;
         if (m_BLL.RunDev(ref validationErrors, model))
         {
             //生成缺陷报告
             m_testItemBLL.DevUpdateState(ref validationErrors, model.VerCode, model.Code);
         }
         //写日志
         if (validationErrors.Count > 0)
         {
             //错误写入日志
             LogHandler.WriteServiceLog(GetUserId(), Resource.UpdateFail + ",新增测试步骤ID:" + model.ItemID, "失败", "新增", "测试步骤");
             return(Json(JsonHandler.CreateMessage(0, validationErrors.Error)));
         }
         //成功写入日志
         LogHandler.WriteServiceLog(GetUserId(), Resource.UpdateFail + ",新增测试步骤ID:" + model.ItemID, "成功", "新增", "测试步骤");
         return(Json(JsonHandler.CreateMessage(1, Resource.UpdateSucceed)));
     }
     catch
     {
         return(Json(JsonHandler.CreateMessage(0, Resource.UpdateFail)));
     }
 }
Beispiel #7
0
        public virtual DEF_TestJobsDetailStepsModel GetById(string id)
        {
            if (IsExists(id))
            {
                DEF_TestJobsDetailSteps      entity = m_Rep.GetById(id);
                DEF_TestJobsDetailStepsModel model  = new DEF_TestJobsDetailStepsModel();
                model.ItemID          = entity.ItemID;
                model.VerCode         = entity.VerCode;
                model.Code            = entity.Code;
                model.Title           = entity.Title;
                model.TestContent     = entity.TestContent;
                model.Result          = entity.Result;
                model.Sort            = entity.Sort;
                model.ResultContent   = entity.ResultContent;
                model.ExSort          = entity.ExSort;
                model.StepType        = entity.StepType;
                model.Tester          = entity.Tester;
                model.TestDt          = entity.TestDt;
                model.Developer       = entity.Developer;
                model.PlanStartDt     = entity.PlanStartDt;
                model.PlanEndDt       = entity.PlanEndDt;
                model.FinDt           = entity.FinDt;
                model.TestRequestFlag = entity.TestRequestFlag;
                model.DevFinFlag      = entity.DevFinFlag;

                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #8
0
        //详细
        public ActionResult Details(string itemid, string vercode, string code)
        {
            if (!ModelState.IsValid)
            {
                return(View("数据验证不通过", true));
            }
            DEF_TestJobsDetailStepsModel model = m_BLL.GetModelById(itemid, vercode, code);

            return(View(model));
        }
Beispiel #9
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);
        }
Beispiel #10
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);
            }
        }
Beispiel #11
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 ActionResult Edit(DEF_TestJobsDetailStepsModel model)
 {
     try
     {
         m_BLL.Edit(ref validationErrors, model);
         //写日志
         if (validationErrors.Count > 0)
         {
             //错误写入日志
             LogHandler.WriteServiceLog(GetUserId(), Resource.UpdateFail + ",编辑测试步骤ID:" + model.ItemID, "失败", "编辑", "测试步骤");
             return(Json(JsonHandler.CreateMessage(0, validationErrors.Error)));
         }
         //成功写入日志
         LogHandler.WriteServiceLog(GetUserId(), Resource.UpdateSucceed + ",编辑测试步骤ID:" + model.ItemID, "成功", "编辑", "测试步骤");
         return(Json(JsonHandler.CreateMessage(1, Resource.UpdateSucceed)));
     }
     catch
     {
         return(Json(JsonHandler.CreateMessage(0, Resource.UpdateFail)));
     }
 }
        public ActionResult CreateDefect(string vercode, string code)
        {
            if (!ModelState.IsValid)
            {
                return(View("数据验证不通过", true));
            }
            if (string.IsNullOrEmpty(vercode))
            {
                return(View("没有选择测试任务", true));
            }
            if (string.IsNullOrEmpty(code))
            {
                code = "";
            }
            //
            string codeName = "";
            var    testItem = m_testItemBLL.GetModelById(vercode, code);

            if (testItem != null)
            {
                codeName = testItem.Name;
            }
            else
            {
                codeName = "未选择测试用例";
            }
            DEF_TestJobsDetailStepsModel stepsModel = new DEF_TestJobsDetailStepsModel()
            {
                VerCode  = vercode,
                Code     = code,
                ItemID   = "0",
                Result   = false,
                Sort     = 100,
                StepType = 1
            };

            return(View(stepsModel));
        }
Beispiel #14
0
 public bool CreateDefect(ref ValidationErrors errors, DEF_TestJobsDetailStepsModel model, string creator)
 {
     try
     {
         //设置为测试未通过
         model.Result = false;
         if (Create(ref errors, model))
         {
             defectRep.CreateDefectReport(model.VerCode, creator);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         errors.Add(ex.Message);
         ExceptionHander.WriteException(ex);
     }
     return(false);
 }
        public JsonResult CreateDefect(DEF_TestJobsDetailStepsModel model)
        {
            try
            {
                if (string.IsNullOrEmpty(model.Code))
                {
                    return(Json(JsonHandler.CreateMessage(0, "测试用例不能为空,请选择一个")));
                }

                if (!ModelState.IsValid)
                {
                    return(Json(JsonHandler.CreateMessage(0, "数据验证不通过")));
                }

                //新增
                model.ItemID   = Guid.NewGuid().ToString();
                model.StepType = 1;
                model.Tester   = GetUserId();
                model.TestDt   = DateTime.Now;

                m_BLL.CreateDefect(ref validationErrors, model, GetUserId());
                //写日志
                if (validationErrors.Count > 0)
                {
                    //错误写入日志
                    LogHandler.WriteServiceLog(GetUserId(), Resource.InsertFail + ",新增测试步骤ID:" + model.ItemID, "失败", "新增", "测试步骤");
                    return(Json(JsonHandler.CreateMessage(0, validationErrors.Error)));
                }
                //成功写入日志
                LogHandler.WriteServiceLog(GetUserId(), Resource.InsertSucceed + ",新增测试步骤ID:" + model.ItemID, "成功", "新增", "测试步骤");
                return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed)));
            }
            catch
            {
                return(Json(JsonHandler.CreateMessage(1, Resource.InsertFail)));
            }
        }
 public JsonResult Create(DEF_TestJobsDetailStepsModel model)
 {
     try
     {
         //新增
         model.ItemID   = Guid.NewGuid().ToString();
         model.StepType = 0;
         m_BLL.Create(ref validationErrors, model);
         //写日志
         if (validationErrors.Count > 0)
         {
             //错误写入日志
             LogHandler.WriteServiceLog(GetUserId(), Resource.InsertFail + ",新增测试步骤ID:" + model.ItemID, "失败", "新增", "测试步骤");
             return(Json(JsonHandler.CreateMessage(0, validationErrors.Error)));
         }
         //成功写入日志
         LogHandler.WriteServiceLog(GetUserId(), Resource.InsertSucceed + ",新增测试步骤ID:" + model.ItemID, "成功", "新增", "测试步骤");
         return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed)));
     }
     catch
     {
         return(Json(JsonHandler.CreateMessage(1, Resource.InsertFail)));
     }
 }