예제 #1
0
        public bool TestPROJECTTEMPLET(string ID, out string Message)
        {
            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            string errors = string.Empty;
            var    m_BLL  = new SCHEMEBLL();
            var    entity = m_BLL.GetById(ID);

            if (entity != null)
            {
                if (entity.PROJECTTEMPLET != null &&
                    entity.PROJECTTEMPLET.Count > 0)
                {
                    foreach (var iEntity in entity.PROJECTTEMPLET)
                    {
                        if (!string.IsNullOrWhiteSpace(iEntity.HTMLVALUE))
                        {
                            doc.LoadHtml(iEntity.HTMLVALUE);
                            string data = AnalyticHTML.Getinput(doc);
                            AnalyticHTML.GetData(doc);
                            string data2 = AnalyticHTML.GetinputHead(doc);
                            if (!string.IsNullOrWhiteSpace(data2))
                            {
                                errors += "<br/><br/>thead标签中,name是不能相同的" + iEntity.ID + iEntity.RULE.ID + iEntity.RULE.NAMEOTHER + data2;
                            }
                            if (!string.IsNullOrWhiteSpace(data))
                            {
                                errors += iEntity.ID + iEntity.RULE.ID + iEntity.RULE.NAMEOTHER + data;
                            }
                        }
                    }
                }
            }
            Message = errors;
            return(false);
        }
예제 #2
0
        public bool Test(string ID, out string Message)
        {
            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            string errors = string.Empty;

            IBLL.IPREPARE_SCHEMEBLL m_BLL  = new PREPARE_SCHEMEBLL();
            PREPARE_SCHEME          entity = m_BLL.GetById(ID);
            string saveFileName            = "";

            if (entity != null)
            {
                ExportType type = GetExportType(entity, "ExportOriginal");

                if (entity.QUALIFIED_UNQUALIFIED_TEST_ITE != null &&
                    entity.QUALIFIED_UNQUALIFIED_TEST_ITE.Count > 0)
                {
                    TableTemplates    allTableTemplates    = GetTableTemplates(type);
                    SpecialCharacters allSpecialCharacters = GetSpecialCharacters();

                    entity.QUALIFIED_UNQUALIFIED_TEST_ITE = entity.QUALIFIED_UNQUALIFIED_TEST_ITE.OrderBy(p => p.SORT).ToList();
                    string xml = string.Empty;
                    foreach (QUALIFIED_UNQUALIFIED_TEST_ITE iEntity in entity.QUALIFIED_UNQUALIFIED_TEST_ITE)
                    {
                        //iEntity.RULEID;
                        if (!string.IsNullOrWhiteSpace(iEntity.HTMLVALUE))
                        {
                            doc.LoadHtml(iEntity.HTMLVALUE);


                            //测试的时候使用
                            string data = AnalyticHTML.Getinput(doc);
                            if (!string.IsNullOrWhiteSpace(data))
                            {
                                errors += iEntity.ID + iEntity.RULENJOINAME + data;
                            }
                        }
                    }
                    var da = xml;
                }
            }
            Message = errors;
            return(false);
        }
예제 #3
0
        /// <summary>
        /// 获取表头中的所有的input和select标签的数据
        /// </summary>
        /// <param name="doc"></param>
        /// <returns></returns>
        public static Dictionary <int, List <MYDataHead> > GetHeadData(HtmlAgilityPack.HtmlDocument doc)
        {
            var data = new Dictionary <int, List <MYDataHead> >();

            //表头
            Dictionary <int, HtmlAgilityPack.HtmlNodeCollection> theadOfInputAndSelect = AnalyticHTML.GetTheadOfInputAndSelect(doc);

            //遍历通道
            foreach (var item in theadOfInputAndSelect.Keys)
            {
                HtmlAgilityPack.HtmlNodeCollection body = theadOfInputAndSelect[item];
                List <MYDataHead> list = new List <MYDataHead>();
                foreach (var b in body)
                {
                    MYDataHead mydata = new MYDataHead();
                    mydata.id   = b.Attributes["id"].Value;
                    mydata.name = b.Attributes["name"].Value;

                    if (b.Name == "input")
                    {
                        if (b.Attributes["value"] != null)
                        {
                            mydata.value = b.Attributes["value"].Value;
                        }
                    }
                    else if (b.Name == "select")
                    {
                        var nodes = b.ChildNodes
                                    .Where(w => (w.Name == "option" && w.Attributes["selected"] != null))
                                    .Select(s => s.Attributes["value"].Value).FirstOrDefault();

                        if (null == (nodes))
                        {
                            mydata.value = b.ChildNodes
                                           .Where(w => (w.Name == "option"))
                                           .Select(s => s.Attributes["value"].Value).First();
                        }
                        else
                        {
                            mydata.value = nodes;
                        }
                    }

                    list.Add(mydata);
                }
                data.Add(item, list);
            }
            return(data);
        }
예제 #4
0
        public static string Create(HtmlAgilityPack.HtmlDocument doc, string RuleID)
        {
            try
            {
                //表头
                Dictionary <int, HtmlAgilityPack.HtmlNodeCollection> theadOfInputAndSelect = AnalyticHTML.GetTheadOfInputAndSelect(doc);
                //表身
                Dictionary <int, HtmlAgilityPack.HtmlNodeCollection> tbodyOfInputAndSelect = AnalyticHTML.GetTBodyOfInputAndSelect(doc);
                //表尾巴
                Dictionary <int, HtmlAgilityPack.HtmlNodeCollection> tfootOfInputAndSelect = AnalyticHTML.GetTfootOfInputAndSelect(doc);
                //表头的xml字符串
                string outHead = "";

                //只遍历通道1
                if (theadOfInputAndSelect != null && theadOfInputAndSelect.Count > 0)
                {
                    var tongdao1 = theadOfInputAndSelect[1];
                    for (int i = 0; i < tongdao1.Count; i++)
                    {
                        outHead += string.Format(tempCell, tongdao1[i].Attributes["name"].Value, i);
                    }
                }
                outHead = string.Format(tempCellList, outHead);

                outHead = string.Format(tempRowNumber, outHead, AnalyticHTML.GetTheadOfTR(doc));

                //表体的xml字符串
                string outBody = "";
                if (tbodyOfInputAndSelect != null && tbodyOfInputAndSelect.Count > 0)
                {
                    //只遍历通道1
                    var tongdao1OfBodyOfInputAndSelect = tbodyOfInputAndSelect[1];
                    //将name去重
                    var tongdao1OfBodyOfInputAndSelectAttributes = (from b in tongdao1OfBodyOfInputAndSelect
                                                                    // where b.Attributes["name"] != null//hidden标签会为空
                                                                    select b.Attributes["name"].Value).Distinct().ToList();

                    for (int i = 0; i < tongdao1OfBodyOfInputAndSelectAttributes.Count; i++)
                    {
                        outBody += string.Format(tempCell, tongdao1OfBodyOfInputAndSelectAttributes[i], i);
                    }
                    outBody = string.Format(tempCellList, outBody);
                }

                //表体的xml字符串
                string outFoot = "";

                //只遍历通道1
                if (tfootOfInputAndSelect != null && tfootOfInputAndSelect.Count > 0)
                {
                    var tongdao1OfFootOfInputAndSelect = tfootOfInputAndSelect[1];
                    //将name去重
                    var tongdao1OfFootOfInputAndSelectAttributes = (from b in tongdao1OfFootOfInputAndSelect
                                                                    // where b.Attributes["name"] != null//hidden标签会为空
                                                                    select b.Attributes["name"].Value).Distinct().ToList();

                    for (int i = 0; i < tongdao1OfFootOfInputAndSelectAttributes.Count; i++)
                    {
                        outFoot += string.Format(tempCell, tongdao1OfFootOfInputAndSelectAttributes[i], i);
                    }
                    outFoot = string.Format(tempCellList, outFoot);
                }

                //表格xml
                string outXML = "";
                return(outXML = string.Format(temp,
                                              RuleID,
                                              "-1" /*数据模板开始行号*/,
                                              "-1" /*备注模板行号*/,
                                              "-1" /*结论模板行号*/,
                                              "-1" /*表格表头行号*/,
                                              outHead,
                                              outFoot,/*尾巴行号*/
                                              outBody
                                              ));
            }
            catch (System.Exception ex)
            {
                throw;
            }
        }