コード例 #1
0
ファイル: OldHandler.cs プロジェクト: john123951/sweetfly.net
        private ExamItem BuildEntity(int moduleId, IHtmlElement item)
        {
            try
            {
                var id_element = item.FindFirst(@"tr[valign]>td");

                var match = Regex.Match(id_element.InnerText(), @"\d+");

                int id = Convert.ToInt32(match.Value.Trim());
                string title = id_element.NextElement().InnerText().Trim().RemoveHtml().RemoveHtmlEncode();
                string answer = item.FindFirst("div[id]").InnerText().Trim().RemoveHtmlEncode();
                string examType = item.PreviousElement().Descendants("td")
                                                        .ElementAt(1)
                                                        .InnerText().Trim().RemoveHtml().RemoveHtmlEncode();

                if (answer.StartsWith("答案:"))
                {
                    answer = answer.Substring(3).Trim();
                }

                var itemType = ItemTypeService.GetByText(examType);
                if (itemType == null)
                {
                    logger.Info(string.Format("未匹配的题目类别[{0}],ExamId=[{1}]", examType, id));
                }

                var model = new ExamItem()
                {
                    Id = id,
                    Title = title,
                    Answer = answer,
                    OriginalHtml = item.InnerHtml(),
                    Module_Id = moduleId,
                    ItemType = itemType != null ? itemType.Id : 0,
                    CreateTime = DateTime.Now,
                    DelFlag = false
                };
                return model;
            }
            catch (Exception ex)
            {
                WriteLog(item.ToString(), ex.Message);
                throw;
            }
        }
コード例 #2
0
        private ExamItem BuildEntity(int moduleId, IHtmlElement item)
        {
            try
            {
                var id_element = item.FindFirst(@"tr[valign]>td");

                var match = Regex.Match(id_element.InnerText(), @"\d+");

                int    id       = Convert.ToInt32(match.Value.Trim());
                string title    = id_element.NextElement().InnerText().Trim().RemoveHtml().RemoveHtmlEncode();
                string answer   = item.FindFirst("div[id]").InnerText().Trim().RemoveHtmlEncode();
                string examType = item.PreviousElement().Descendants("td")
                                  .ElementAt(1)
                                  .InnerText().Trim().RemoveHtml().RemoveHtmlEncode();

                if (answer.StartsWith("答案:"))
                {
                    answer = answer.Substring(3).Trim();
                }

                var itemType = ItemTypeService.GetByText(examType);
                if (itemType == null)
                {
                    logger.Info(string.Format("未匹配的题目类别[{0}],ExamId=[{1}]", examType, id));
                }

                var model = new ExamItem()
                {
                    Id           = id,
                    Title        = title,
                    Answer       = answer,
                    OriginalHtml = item.InnerHtml(),
                    Module_Id    = moduleId,
                    ItemType     = itemType != null ? itemType.Id : 0,
                    CreateTime   = DateTime.Now,
                    DelFlag      = false
                };
                return(model);
            }
            catch (Exception ex)
            {
                WriteLog(item.ToString(), ex.Message);
                throw;
            }
        }
コード例 #3
0
ファイル: CssRelativeSelector.cs プロジェクト: zpzgone/Jumony
        protected override bool IsEligible(ISelector leftSelector, IHtmlElement element)
        {
            var previous = element.PreviousElement();

            return(leftSelector.IsEligibleBuffered(previous) || this.IsEligibleBuffered(previous));
        }
コード例 #4
0
ファイル: CssRelativeSelector.cs プロジェクト: zpzgone/Jumony
 protected override bool IsEligible(ISelector leftSelector, IHtmlElement element)
 {
     return(leftSelector.IsEligibleBuffered(element.PreviousElement()));
 }
コード例 #5
0
        protected override bool IsEligible( ISelector leftSelector, IHtmlElement element )
        {
            var previous = element.PreviousElement();

              return leftSelector.IsEligibleBuffered( previous ) || this.IsEligibleBuffered( previous );
        }
コード例 #6
0
 protected override bool IsEligible( ISelector leftSelector, IHtmlElement element )
 {
     return leftSelector.IsEligibleBuffered( element.PreviousElement() );
 }