示例#1
0
        void GetTitleUrlsComplete(string sourceHtml, object userstate, bool cancelled)
        {
            List<PostInfo> posts = new List<PostInfo>();
            int pageCount = 0;

            string baseUrl = base.httper.Url.Substring(0, base.httper.Url.LastIndexOf('/') + 1);
            MatchCollection urlList = Natsuhime.Web.Plugin.Discuz.TextAnalyze.GetThreadsInBoard(sourceHtml);
            Exception error = null;
            if (urlList != null)
            {
                foreach (Match key in urlList)
                {
                    PostInfo pi = new PostInfo();
                    pi.Url = Utils.CompleteRelativeUrl(baseUrl, key.Groups[1].Value);
                    pi.Title = Utils.HtmlDecode(key.Groups[2].Value);
                    posts.Add(pi);
                }
                pageCount = Natsuhime.Web.Plugin.Discuz.TextAnalyze.GetBoardPageCount(sourceHtml);
            }
            else
            {
                error = new Exception(sourceHtml);
            }

            OnCompleted(new ReturnCompletedEventArgs(urlList, error, cancelled, userstate));//兼容测试方法用 以后移除
            OnFetchPostCompleted(new FetchTitleCompletedEventArgs(posts, pageCount, error, cancelled, userstate));

        }
示例#2
0
        void SaveTitle2DB(PostInfo pi)
        {
            string sqlPost = "INSERT INTO posts(`title`,`url`) VALUES(@title,@url);select last_insert_rowid()";

            DbParameter[] pramsPost = 
		            {
			            DbHelper.MakeInParam("@title", DbType.String, 100,pi.Title),
			            DbHelper.MakeInParam("@url", DbType.String, 500,pi.Url)
		            };
            try
            {
                pi.PostId = Convert.ToInt32(
                    DbHelper.ExecuteNonQuery(CommandType.Text, sqlPost, pramsPost)
                    );
                if (pi.PostId < 1)
                {
                    throw new Exception("postid<1");
                }
            }
            catch (Exception ex)
            {
                pi.PostId = -1;
                string message = string.Format("插入Post失败:{0},跳过当前Post文件列表!!!" + pi.Url + ex.Message);
                //this.PostFetchInfoChanged("插入Post失败", message, "", null);
                //continue;
            }
        }