Esempio n. 1
0
        /// <summary>
        /// 获取项目步骤
        /// </summary>
        /// <param name="PID"></param>
        /// <param name="FID"></param>
        /// <returns></returns>
        public static string getProjectControl(int PID, int FID)
        {
            QCTESTEntities QC_DB = new QCTESTEntities();

            var fps = (from t in QC_DB.Framework4Project
                       where t.PID == PID && t.FID == FID
                       select t).ToList();

            List <scriptStepTreeModel> lss = new List <scriptStepTreeModel>();

            scriptStepTreeModel rootnode = new scriptStepTreeModel();

            var p = QC_DB.project.First(t => t.ID == PID);

            rootnode.text  = p.Pname;
            rootnode.PID   = p.ID;
            rootnode.state = "open";

            rootnode.children = new List <treeViewModel>();
            foreach (var fp in fps)
            {
                rootnode.children.Add(fp.getControlJson4Tree());
            }
            if (rootnode.children.Count > 0)
            {
                lss.Add(rootnode);
            }

            JsonSerializerSettings jSetting = new JsonSerializerSettings();

            jSetting.NullValueHandling = NullValueHandling.Ignore;

            return(JsonConvert.SerializeObject(lss, jSetting));
        }
Esempio n. 2
0
        /// <summary>
        /// 返回给scriptTree使用的step数据
        /// </summary>
        /// <param name="xe"></param>
        /// <returns></returns>
        public static scriptStepTreeModel getScriptStep(this XElement xe)
        {
            /*
             * //改数据时修改了个别Step的大小写,为了OK加了容错,正式环境后期可以去掉这个逻辑
             * if (sms.Count() == 0)
             * {
             *  sms = xe.Descendants("step");
             * }*/

            scriptStepTreeModel tmp = new scriptStepTreeModel();


            tmp.name    = (string)xe.Attribute("name");
            tmp.state   = "closed";
            tmp.iconCls = "icon-view_outline_detail";
            tmp.desc    = (string)xe.Attribute("desc");

            var atts = from t in xe.Elements()
                       select new scriptStepAttrModel
            {
                Key      = (string)t.Attribute("name"),
                Value    = t.Attribute("value") == null ? "" : t.Attribute("value").Value,
                state    = "open",
                iconCls  = "icon-spanner_blue",
                checkbox = false
            };

            tmp.children = new List <treeViewModel>();
            tmp.children.AddRange(atts.ToList());



            return(tmp);
        }
        /// <summary>
        /// 获取添加到scriptView中的step步骤的 json(new)
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public string getStep(string name, int?FID, int?PID)
        {
            scriptStepTreeModel xe = testCaseHelper.autoStepParam(name, FID, PID).getScriptStep();

            xe.desc = "XXX new step XXX";

            var jSetting = new JsonSerializerSettings();

            jSetting.NullValueHandling = NullValueHandling.Ignore;

            string json = JsonConvert.SerializeObject(xe, jSetting);

            return(json);
        }
Esempio n. 4
0
        public static treeViewModel getControlJson4Tree(this Framework4Project cf)
        {
            XElement xe = XElement.Parse(cf.controlXML);


            scriptStepTreeModel tv = new scriptStepTreeModel();

            tv.FID   = cf.FID;
            tv.PID   = cf.PID;
            tv.state = "open";
            tv.name  = "prostep_" + cf.ID;

            tv.iconCls = "icon-view_outline_detail";

            if (xe.Attribute("desc") != null)
            {
                tv.desc = xe.Attribute("desc").Value;
            }


            return(tv);
        }
        /// <summary>
        /// 框架xml转换成前台显示的treeStep
        /// </summary>
        /// <param name="cf"></param>
        /// <returns></returns>
        public static treeViewModel getControlJson4Tree(this caseFramework cf)
        {
            XElement xe = XElement.Parse(cf.controlXML);


            var root = new frameTreeNode();

            root.text  = cf.workName;
            root.state = "open";
            root.FID   = cf.ID;

            root.children = new List <treeViewModel>();

            var sms = xe.Descendants("Step");

            foreach (var e in sms)
            {
                scriptStepTreeModel tv = new scriptStepTreeModel();

                tv.FID = cf.ID;
                //tv.PID = null;
                tv.state   = "open";
                tv.name    = e.Attribute("name").Value;//name肯定有把....
                tv.iconCls = "icon-view_outline_detail";

                if (e.Attribute("desc") != null)
                {
                    tv.desc = e.Attribute("desc").Value;
                }


                root.children.Add(tv);
            }



            return(root);
        }