Exemplo n.º 1
0
        public ChapterInfo GetChapterInfo()
        {
            var chapterInfo = new ChapterInfo();
            var regex = new Regex(@"<div\s*id=""title""><h1>(.*?)<\/h1><\/div>\s*<div\s*id=""msg"">作者:(.*?) \| 类型:(.*?) \| 最新:<a href=""(.*?)"">(.*?)<\/a><\/div>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
            var matches = regex.Matches(_html);
            if (matches.Count > 0)
            {
                foreach (Match match in matches)
                {
                    chapterInfo = new ChapterInfo()
                    {
                        Novel = new NovelInfo()
                        {
                            NovelName = match.Groups[1].Value,
                            NovelAuthor = match.Groups[2].Value,
                            NovelCategory = new NovelCategoryInfo(match.Groups[3].Value),
                        },
                        ChapterUrl = match.Groups[4].Value,
                        ChapterName = match.Groups[5].Value,
                    };
                }
            }

            return chapterInfo;
        }
Exemplo n.º 2
0
        public ChapterInfo GetNovelContent()
        {
            var chapter = new ChapterInfo() { Novel = new NovelInfo() };
            Regex chapterRegex = new Regex(@"<td class=""tddh""><a href=""(.*?)"">.*?<\/a><\/td>", RegexOptions.IgnoreCase | RegexOptions.Singleline);

            var chapterMatch = chapterRegex.Match(_html);
            chapter.PreviousChapterUrl = chapterMatch.Groups[1].Value;
            chapter.Novel.NovelUrl = chapterMatch.NextMatch().Groups[1].Value;
            chapter.NextChapterUrl = chapterMatch.NextMatch().Groups[1].Value;

            Regex hiarachyRegex = new Regex(@"&nbsp;&raquo;&nbsp;<a href=""(.*?)"">(.*?)&nbsp;&raquo;&nbsp;<a href=""(.*?)"">(.*?)&nbsp;&raquo;&nbsp;(.*?)<\/div>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
            var hiarachyMatches = hiarachyRegex.Matches(_html);
            if (hiarachyMatches.Count > 0)
            {
                chapter.Novel.NovelCategory = new NovelCategoryInfo(hiarachyMatches[0].Groups[2].Value);
                chapter.Novel.NovelUrl = hiarachyMatches[0].Groups[3].Value;
                chapter.Novel.NovelName = hiarachyMatches[0].Groups[4].Value;
                chapter.ChapterName = hiarachyMatches[0].Groups[5].Value;
            }

            Regex contentRegex = new Regex(@"<script >content\(\);<\/script>(.*)<script >fyup\(\);<\/script><\/div>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
            var contentMatch = contentRegex.Match(_html);
            if (contentMatch.Success)
            {
                chapter.ChapterContent = contentMatch.Value;
            }

            return chapter;
        }
        /// <summary>
        /// �����
        /// </summary>
        /// <param name="mChapter">����ӵ��µĶ���</param>
        /// <returns>����Ƿ�ɹ�,�ɹ��򷵻�true,ʧ���򷵻�false</returns>
        public bool AddChapter(ChapterInfo mChapter, string courseName)
        {
            SqlParameter[] parms = {
                new SqlParameter("@chapterNO",mChapter.StrChapterNO),
                new SqlParameter("@name",mChapter.StrDescription),
                new SqlParameter("@courseName",courseName)
            };

            bool isSuccess = false;

            int affectedRows = SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStringQuesBase,
                CommandType.StoredProcedure, "Proc_AddChapter", parms);

            if (affectedRows > 0)
            {
                isSuccess = true;
            }
            return isSuccess;
        }
        /// <summary>
        /// �޸���
        /// </summary>
        /// <param name="mChapter">���޸ĵ��¶���,���б�������µ�Id���µ�������Ϣ</param>
        /// <returns>�޸��Ƿ�ɹ����ɹ��򷵻�true,ʧ���򷵻�false</returns>
        public bool EditChapter(ChapterInfo mChapter)
        {
            SqlParameter[] parms = {
                new SqlParameter ("@chapterID",mChapter.IChapterId),
                new SqlParameter("@name",mChapter.StrDescription)
            };

            bool isSuccess = false;
            int affectedRows = SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStringQuesBase,
                CommandType.StoredProcedure, "SP_EditChapterByID", parms);

            if (affectedRows > 0)
            {
                isSuccess = true;
            }
            return isSuccess;
        }
 /// <summary>
 /// �޸���
 /// </summary>
 /// <param name="mChapter">���޸ĵ��¶���,���б�������µ�Id���µ�������Ϣ</param>
 /// <returns>�޸��Ƿ�ɹ����ɹ��򷵻�true,ʧ���򷵻�false</returns>
 public bool EditChapter(ChapterInfo mChapter)
 {
     return dal.EditChapter(mChapter);
 }
 /// <summary>
 /// �����
 /// </summary>
 /// <param name="mChapter">����ӵ��µĶ���</param>
 /// <returns>����Ƿ�ɹ�,�ɹ��򷵻�true,ʧ���򷵻�false</returns>
 public bool AddChapter(ChapterInfo mChapter, string courseName)
 {
     return dal.AddChapter(mChapter, courseName);
 }