public void AddNew(M_testDemand newTC)
 {
     using (QCTESTEntities QC_DB = new QCTESTEntities())
     {
         QC_DB.M_testDemand.Add(newTC);
         QC_DB.SaveChanges();
     }
 }
        public ActionResult EditDemand(int ID)
        {
            using (QCTESTEntities QC_DB = new QCTESTEntities())
            {
                M_testDemand mt = QC_DB.M_testDemand.First(t => t.ID == ID);

                return(PartialView("_addNew", mt));//未做错误处理
            }
        }
        public ActionResult AddNew(int?baseID, int?PID, int type)
        {
            ViewData["AddNew"] = true;
            M_testDemand td = new M_testDemand();

            td.baseID = baseID;
            td.PID    = PID;
            td.type   = type;
            return(PartialView("_addNew", td));
        }
 public bool EditDemand(M_testDemand td)
 {
     using (QCTESTEntities QC_DB = new QCTESTEntities())
     {
         M_testDemand mtc = QC_DB.M_testDemand.FirstOrDefault(t => t.ID == td.ID);
         mtc.name = td.name;
         mtc.mark = td.mark;
         QC_DB.SaveChanges();
         return(true);
     }
 }
        public string runDemand(int ID)
        {
            QCTESTEntities QC_DB = new QCTESTEntities();
            int            cnt   = QC_DB.M_runScene.Where(t => t.DemandID == ID && t.deviceID == null).Count();

            if (cnt == 0)
            {
                M_testDemand td = QC_DB.M_testDemand.Where(t => t.ID == ID).First();
                td.isRun = true;
                QC_DB.SaveChanges();
                //开始执行咯

                var machines = from t in QC_DB.M_deviceConfig.Distinct()
                               join t1 in QC_DB.M_runScene on t.ID equals t1.deviceID
                               join t2 in QC_DB.M_testDemand on t1.DemandID equals t2.ID
                               where t2.ID == ID
                               select t.IP + ":" + t.Port;

                List <string> urls = machines.Distinct().ToList();
                string        msg  = null;
                foreach (var url in urls)
                {
                    if (!Call_Client.startRun(url))
                    {
                        msg += (url + ",");
                    }
                }
                if (msg != null)
                {
                    return("执行机:" + msg + "发生错误!");
                }
                else
                {
                    return("True");
                }
            }
            else
            {
                return("有场景未选择执行设备");
            }
        }
Exemple #6
0
        public testDemandTree(M_testDemand td)
        {
            QCTESTEntities QC_DB = new QCTESTEntities();

            id       = td.ID;
            DemandID = td.ID;
            text     = td.name;
            state    = td.type == 0 ? "closed" : "open";
            iconCls  = td.type == 0 ? null : "icon-application_windows";
            type     = td.type == null ? 0 : td.type.Value;

            if (td.type != 1)
            {
                return;
            }

            if (td.isRun == true)//需优化
            {
                var TotalCase = new ObjectParameter("Out1", DbType.Int32);
                var sucess    = new ObjectParameter("Out2", DbType.Int32);
                var error     = new ObjectParameter("Out3", DbType.Int32);
                var noRun     = new ObjectParameter("Out4", DbType.Int32);
                var Untreated = new ObjectParameter("Out5", DbType.Int32);

                QC_DB.M_testDemand_result(td.ID, TotalCase, sucess, error, noRun, Untreated);

                if (Convert.ToInt32(noRun.Value) == 0)
                {
                    iconCls = "icon-application_windows_okay";
                    if (Convert.ToInt32(Untreated.Value) > 0)//未处理>0
                    {
                        iconCls = "icon-application_windows_edit";
                    }
                }
                else if (Convert.ToInt32(noRun.Value) > 0)
                {
                    iconCls = "icon-application_windows_right";
                }
            }
        }
        public string DeleteDemand(int ID)
        {
            using (QCTESTEntities QC_DB = new QCTESTEntities())
            {
                M_testDemand md = QC_DB.M_testDemand.First(t => t.ID == ID);

                if (md.type == 0 && md.M_testDemand1.Count > 0)
                {
                    return("无法直接删除文件夹,请连续管理员");
                }
                else if (md.isRun == true)
                {
                    return("无法删除已执行的测试计划");
                }
                else
                {
                    md.visable = false;
                    md.isRun   = false;

                    QC_DB.SaveChanges();
                    return("True");
                }
            }
        }