/// <summary> /// 项目可选设备 /// </summary> /// <param name="DemandID"></param> /// <returns></returns> private string getDeviceListJson(int DemandID) { QCTESTEntities QC_DB = new QCTESTEntities(); var PP = new ObjectParameter("Out1", DbType.Int32); QC_DB.M_testDemand_getProject(DemandID, PP);//获得属于哪个项目 int PID = Convert.ToInt32(PP.Value); var ll = from t in QC_DB.M_DevProMapping where t.PID == PID && t.usable == true select new { DeviceID = t.DeviceID, DeviceName = t.M_deviceConfig.mark }; string json = JsonConvert.SerializeObject(ll); return(json); }
public string ChangePassword(ChangePasswordModel req) { if (!ModelState.IsValid) { Response.Status = "400"; return("非法提交"); } QCTESTEntities QC_DB = new QCTESTEntities(); int id = userHelper.getUserID(); admin_user user = QC_DB.admin_user.First(t => t.ID == id); if (user.Password != req.Password) { Response.Status = "400"; return("旧密码错误"); } user.Password = req.Password; QC_DB.SaveChanges(); return(true.ToString()); }
public Boolean controlSave(int id, string name, string steps, string Param) { QCTESTEntities qctest = new QCTESTEntities(); var nmtc = qctest.M_testCaseSteps.First(t => t.ID == id); JObject ParamO = JObject.Parse(Param); XElement stepXML = testCaseHelper.json2StepList(steps); //nmtc.userID = userHelper.getUserID(); nmtc.name = name; nmtc.stepXML = stepXML.ToString(); XElement paramXml = new XElement("Step"); foreach (var p in ParamO) { XElement PB = new XElement("ParamBinding"); PB.SetAttributeValue("name", p.Key); PB.SetAttributeValue("value", p.Value); paramXml.Add(PB); } nmtc.paramXML = paramXml.ToString(); qctest.SaveChanges(); return(true); }
public ActionResult addProject() { QCTESTEntities QC_DB = new QCTESTEntities(); var deviceList = from t1 in QC_DB.M_deviceConfig select new checkListModel { Value = t1.ID.ToString(), Text = t1.mark }; var appList = from t1 in QC_DB.M_application select new checkListModel { Value = t1.ID.ToString(), Text = t1.name }; ViewData["deviceList"] = deviceList.ToList(); ViewData["appList"] = appList.ToList(); return(PartialView("_editProject", new project())); }
public string uploadApk(int id) { string originalName = ""; var stm = FileToStream(); if (stm != null) { string guid = System.Guid.NewGuid().ToString("N"); originalName = guid + "_" + Request["originalName"]; string filename = Server.MapPath("~/apkInstall/") + originalName; StreamWriter sw = new StreamWriter(filename); stm.CopyTo(sw.BaseStream); sw.Flush(); sw.Close(); QCTESTEntities QC_DB = new QCTESTEntities(); var Mtd = QC_DB.M_testDemand.Where(t => t.ID == id).First(); Mtd.apkName = originalName; QC_DB.SaveChanges(); } return(originalName); }
public ActionResult EditName(int id) { QCTESTEntities qx = new QCTESTEntities(); var mtc = qx.M_testCaseSteps.First(t => t.ID == id); return(PartialView("_EditName", mtc)); }
public void uploadCase(int?baseID, int?PID) { var stm = FileToStream(); if (stm != null) { StreamReader sr = new StreamReader(stm); XElement tp = XElement.Parse(sr.ReadToEnd()); //开始写入数据库 QCTESTEntities QC_DB = new QCTESTEntities(); M_testCase mtc = new M_testCase(); mtc.type = 1; mtc.testXML = tp.ToString(); if (PID == null) { mtc.baseID = Convert.ToInt32(baseID); } else { mtc.projectID = Convert.ToInt32(PID); } //mtc.Name = name.Remove(name.LastIndexOf(".")); mtc.Name = tp.Attribute("desc").Value; mtc.FID = Convert.ToInt32(tp.Attribute("FID").Value); QC_DB.M_testCase.Add(mtc); QC_DB.SaveChanges(); } }
public string userFramework() { /*******直接保存不可取 提取需要的信息再保存********/ var stm = FileToStream(); if (stm != null) { StreamReader sr = new StreamReader(stm); XElement fm = XElement.Parse(sr.ReadToEnd()); int userID = userHelper.getUserID(); QCTESTEntities QC_DB = new QCTESTEntities(); var cf = QC_DB.caseFramework.First(t => t.userID == userID); cf.controlXML = fm.ToString(); QC_DB.SaveChanges(); return(cf.controlXML); } else { Response.Status = "500"; return("文件上传失败"); } }
public application_res(int?id) { QCTESTEntities QC_DB = new QCTESTEntities(); M_application app; if (id == null) { app = QC_DB.M_application.First(); } else { app = QC_DB.M_application.First(t => t.ID == id); } this.id = app.ID; this.id = app.ID; this.name = app.name; this.robotiumApk = app.runApkName; this.androidPackeg = app.package; this.mainActivity = app.mainActiviy; this.iosPackeg = app.package2; this.clearCache = app.isClear == true?true:false; }
public string DemandErrorReset(int ID) { QCTESTEntities QC_DB = new QCTESTEntities(); int num = QC_DB.M_runTestCase_FailReset(ID); return("共重置" + num + "条案例."); }
public string getFileByProject(int ID) { using (QCTESTEntities QC_DB = new QCTESTEntities()) { var tcl = from t in QC_DB.M_testCase where t.projectID == ID && t.baseID == null orderby t.type select new testCaseTreeModel { id = t.ID, text = t.Name, mark = t.mark, state = t.type == 0 ? "closed" : "open", type = t.type == null ? 0 : t.type.Value }; var jSetting = new JsonSerializerSettings(); jSetting.NullValueHandling = NullValueHandling.Ignore; string json = JsonConvert.SerializeObject(tcl, jSetting); return(json); } }
public string getFileByProject(int ID) { using (QCTESTEntities QC_DB = new QCTESTEntities()) { var tcl = from t in QC_DB.M_testDemand where t.PID == ID && t.visable != false && t.baseID == null orderby t.type select new testDemandTree { DemandID = t.ID, text = t.name, //state = "closed",//在tree里显示场景 state = t.type == 0 ? "closed" : "open", iconCls = t.type == 0 ? null : "icon-application_windows", type = t.type == null ? 0 : t.type.Value }; var jSetting = new JsonSerializerSettings(); jSetting.NullValueHandling = NullValueHandling.Ignore; string json = JsonConvert.SerializeObject(tcl, jSetting); return(json); } }
public ActionResult DeviceView() { QCTESTEntities QC_DB = new QCTESTEntities(); var rtc = from t in QC_DB.M_runTestCase select t; var ss = (from t in QC_DB.M_deviceConfig select new DeviceViewModel { ID = t.ID, mark = t.mark, Model = t.Model, //img = t.img == null ? "default.jpg" : t.img, run = rtc.Where(r => r.M_runScene.deviceID == t.ID && r.state != null).Count(), runing = rtc.Where(r => r.M_runScene.deviceID == t.ID && r.M_runScene.M_testDemand.isRun == true && r.state == null).Count() }).ToList(); string json = JsonConvert.SerializeObject(ss); ViewBag.data = json; return(View()); }
public bool sortCaseList(int targetID, int sourceID, int type) { QCTESTEntities QC_DB = new QCTESTEntities(); if (type == 1) { int rtn = QC_DB.M_testCase_sort(sourceID, targetID);//存储过程返回最终目标节点ID if (rtn > 0) { return(true); } else { return(false); } } else { M_testCase mtc = QC_DB.M_testCase.Where(t => t.ID == sourceID).First();//要移动的数据 mtc.baseID = null; mtc.projectID = targetID; QC_DB.SaveChanges(); return(true); } }
public Boolean saveUserControl(string name, int PID, int FID, string steps, string Param) { JObject ParamO = JObject.Parse(Param); XElement stepXML = testCaseHelper.json2StepList(steps); M_testCaseSteps nmtc = new M_testCaseSteps(); nmtc.PID = PID; nmtc.FID = FID; nmtc.userID = userHelper.getUserID(); nmtc.name = name; nmtc.stepXML = stepXML.ToString(); XElement paramXml = new XElement("Step"); foreach (var p in ParamO) { XElement PB = new XElement("ParamBinding"); PB.SetAttributeValue("name", p.Key); PB.SetAttributeValue("value", p.Value); paramXml.Add(PB); } nmtc.paramXML = paramXml.ToString(); QCTESTEntities qctest = new QCTESTEntities(); qctest.M_testCaseSteps.Add(nmtc); qctest.SaveChanges(); return(true); }
public IHttpActionResult caseResult([FromBody] caseResult_req req) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } QCTESTEntities QC_DB = new QCTESTEntities(); //属于这台手机并已经开始的场景 var rtc = QC_DB.M_runTestCase.First(t => t.ID == req.ID); rtc.startDate = req.startDate; rtc.endDate = req.endDate; rtc.state = req.state; rtc.resultXML = req.resultXML.ToString(); rtc.resultPath = req.resultPath; QC_DB.SaveChanges(); return(Ok()); }
public IHttpActionResult registerDevice([FromBody] registerDevice_req req) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } QCTESTEntities QC_DB = new QCTESTEntities(); M_deviceConfig mdc = QC_DB.M_deviceConfig.Where(t => t.device == req.device).FirstOrDefault(); if (mdc != null) { mdc.IP = req.IP; } else { mdc = new M_deviceConfig(); mdc.IP = req.IP; mdc.device = req.device; mdc.Port = 8500; mdc.Model = req.model; mdc.mark = "新设备:" + req.model; QC_DB.M_deviceConfig.Add(mdc); } QC_DB.SaveChanges(); //string json = JsonConvert.SerializeObject(new { mdc.mark }); return(Ok(mdc.mark)); }
public void downloadCase(List <int> ids) { if (ids == null) { return; } MemoryStream MyStream = new MemoryStream(); ZipOutputStream zipedStream = new ZipOutputStream(MyStream); zipedStream.SetLevel(6); zipedStream.IsStreamOwner = false; QCTESTEntities QC_DB = new QCTESTEntities(); var cs = from t in QC_DB.M_testCase where ids.Contains(t.ID) select t; foreach (var c in cs) { creatCaseStream(c, zipedStream); } zipedStream.Finish(); zipedStream.Close(); DownLoad(MyStream, "案例.zip", "x - zip - compressed"); }
/// <summary> /// 初始化脚本model /// </summary> /// <param name="ID">脚本ID</param> public scriptViewModel(int ID) { using (QCTESTEntities QC_DB = new QCTESTEntities()) { this.ID = ID; var mtc = QC_DB.M_testCase.First(t => t.ID == ID); this.TreeJson = getScript2Json(mtc); this.FID = mtc.FID.Value; this.scriptName = mtc.Name; this.Fname = mtc.caseFramework.workName; var PP = new ObjectParameter("Out1", DbType.Int32); QC_DB.M_testCase_getProject(ID, PP); this.PID = Convert.ToInt32(PP.Value); //Fjson this.FJson = treeHelper.getFrameControl(FID); //获取Pjson 项目组件 this.PJson = treeHelper.getProjectControl(PID, FID); //获取Ujson 用户组件 this.UJson = treeHelper.getUserControl(FID, PID); } }
public string projectListInit() { using (QCTESTEntities QC_DB = new QCTESTEntities()) { var tcl = from t in QC_DB.project select new { PID = t.ID, text = t.Pname, state = "closed" }; if (!User.IsInRole("admin")) { int[] pp = userHelper.getUserPermission(); tcl = tcl.Where(t => pp.Contains(t.PID)); } var jSetting = new JsonSerializerSettings(); jSetting.NullValueHandling = NullValueHandling.Ignore; string json = JsonConvert.SerializeObject(tcl, jSetting); return(json); } }
public ActionResult debugSave(int id, string steps, string Param) { using (QCTESTEntities QC_DB = new QCTESTEntities()) { M_testCase mtc = QC_DB.M_testCase.First(t => t.ID == id); mtc.editScript(steps); QC_DB.SaveChanges();//先保存 XElement xe = XElement.Parse(mtc.testXML); var pbs = xe.ParamDictionary(Param); if (pbs.Count > 0) { return(PartialView("_DebugParam", pbs)); //有参数 } else { //没有参数 return(null); } } }
public HttpResponseMessage RunScript(int id) { QCTESTEntities QC_DB = new QCTESTEntities(); var rtc = QC_DB.M_runTestCase.First(t => t.ID == id); if (rtc.M_runScene.M_testDemand.isRun != true) { HttpResponseMessage responseMessage = new HttpResponseMessage { Content = new StringContent("null", Encoding.GetEncoding("UTF-8")) }; return(responseMessage); } else { HttpResponseMessage responseMessage = new HttpResponseMessage { Content = new StringContent(rtc.testXML, Encoding.GetEncoding("UTF-8"), "text/xml") }; return(responseMessage); } }
/// <summary> /// tree节点 /// </summary> /// <param name="ID"></param> /// <returns></returns> public string scriptData(int ID) { QCTESTEntities QC_DB = new QCTESTEntities(); var mtc = QC_DB.M_testCase.First(t => t.ID == ID); return(scriptViewModel.getScript2Json(mtc)); }
public userStepViewModel(int id) { using (QCTESTEntities QC_DB = new QCTESTEntities()) { int userID = userHelper.getUserID(); var us = QC_DB.M_testCaseSteps.FirstOrDefault(t => t.ID == id && t.userID == userID); } }
public ActionResult userCompleted(int ID) { QCTESTEntities QC_DB = new QCTESTEntities(); var pj = QC_DB.M_runTestCase.FirstOrDefault(t => t.ID == ID); return(PartialView("_userCompleted", pj)); }
public void AddNew(M_testDemand newTC) { using (QCTESTEntities QC_DB = new QCTESTEntities()) { QC_DB.M_testDemand.Add(newTC); QC_DB.SaveChanges(); } }
public void changeDevice(int id, int?DeviceID) { QCTESTEntities QC_DB = new QCTESTEntities(); var sc = QC_DB.M_runScene.First(t => t.ID == id); sc.deviceID = DeviceID; QC_DB.SaveChanges(); }
public void changeSceneName(int id, string name) { QCTESTEntities QC_DB = new QCTESTEntities(); var sc = QC_DB.M_runScene.First(t => t.ID == id); sc.name = name; 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 editDevice(int id) { QCTESTEntities QC_DB = new QCTESTEntities(); var p = QC_DB.M_deviceConfig.First(t => t.ID == id); return(PartialView("_editDevice", p)); }