public static void InsertArticle(int blogId, int parentId, string blogName, string loginName)
        {
            bool result = false;
            //int count = SelectArticle(parentId);
            //if (count > 0)
            //{
            //    DelArticle(parentId);
            //}
            DataTable dt = new DataTable();
            DataConnection dc = new DataConnection();
            string sql = "select EndArticleId from DataTransfer where UserName='******'";
            int endArticleId = Int32.Parse(dc.GetField(sql));
            try
            {
                sql = "select * from ra_bgArticle where BlogID=" + blogId + " and id>" + endArticleId + " order by ID";
                dt = dc.FillDataTable(sql);


                foreach (DataRow dr in dt.Rows)
                {
                    int articleId = Convert.ToInt32(dr["ID"]);
                    int bLogId = Convert.ToInt32(dr["BlogID"]);
                    string title = Convert.ToString(dr["Title"]);
                    string tags = Convert.ToString(dr["Tag"]);
                    string body = Convert.ToString(dr["Body"]);
                    int categoryId = Convert.ToInt32(dr["CategoryId"]);//分类
                    int channelId = Convert.ToInt32(dr["ChannelId"]);//频道 例如10006
                    string excerpt = Convert.ToString(dr["Excerpt"]);//摘要 summary 

                    string authorName = Convert.ToString(dr["AuthorName"]);
                    string sourceName = Convert.ToString(dr["SourceName"]);
                    string sourceUrl = Convert.ToString(dr["SourceUrl"]);
                    string coverUrl = Convert.ToString(dr["CoverUrl"]);
                    DateTime postTime = Convert.ToDateTime(dr["PostTime"]);
                    DateTime updateTime = Convert.ToDateTime(dr["UpdateTime"]);
                    string urlTime = updateTime.ToString("yyyy/MM/dd");


                    //将读取到的数据逐条插入postgresql数据库
                    Article article = new Article();//2147483729
                    //pgArticleId = ArticleManage.GetId();
                    article.Id = GetId();
                    //东方博客2012年度奖项名单
                    article.Title = title;
                    article.Content =Untils.GetHtml(body);
                    article.Publish_Time = postTime;
                    article.Create_Time = postTime;
                    //article.Source_Name = sourceName;

                    article.Modify_Time = updateTime;
                    if (Untils.GetHtmlImageUrlList(body).Length == 0)
                    {
                        article.Image_Url = Untils.GetHtmlImageUrl(coverUrl);
                    }
                    else
                    {
                        article.Image_Url = !string.IsNullOrEmpty(coverUrl) ? Untils.GetHtmlImageUrl(coverUrl) : Untils.GetHtmlImageUrlList(body)[0];
                    }
                    if (!string.IsNullOrEmpty(coverUrl) || Untils.GetHtmlImageUrlList(body).Length > 0)
                    {
                        article.Has_Picture = true;
                    }
                    else
                    {
                        article.Has_Picture = false;
                    }
                    article.Images = Untils.GetHtmlImageUrlList(body);
                    //article.Summary = Untils.NoHTML(body);
                    article.Summary = Untils.NoHTML(body).Length > 140 ? Untils.NoHTML(body).Substring(0, 140) : Untils.NoHTML(body);

                    //article.Source_Art_Id = parentId;
                    //article.Source_Url = "http://" + blogName + ".blog2.cnool.net/Article/" + urlTime + "/" + articleId + ".html";
                    article.Url = "http://blog.cnool.net/article/" + article.Id + ".html";

                    article.Industry_Id = 10040;
                    article.Industry_Name = "博客";

                    article.Unit_Id = parentId;
                    article.Comments = 0;
                    article.Status = 0;
                    article.Is_Publish = true;
                    article.Syn_Weixin = false;
                    article.Media_Id = null;
                    article.Creater_Id = 0;
                    article.Creater = authorName;

                    //article.Is_Del = false;
                    //article.Del_Time = DateTime.Parse("1970-1-1");
                    //article.Source_cate_id = 0;
                    string[] SearchkeyList = Untils.ConvertToSearchkey(tags); //每个tag不能超过20个字
                    article.Tags = SearchkeyList;
                    article.Search_Tags = SearchkeyList;
                    if (SearchkeyList != null)
                    {
                        //关键词转tag入库  0
                        foreach (string tag in SearchkeyList)
                        {
                            ArticleManage.CreateAticleTag(article.Id, tag, 0);
                        }
                    }
                    //获取Comment评论表的数据
                    sql = "select * from ra_pbComment where ParentID=" + articleId;
                    dt = dc.FillDataTable(sql);
                    if (dt!=null)
                    {
                        article.Comments = dt.Rows.Count;
                    }
                    List<Comment> list = new List<Comment>();
                    foreach (DataRow dr_comment in dt.Rows)
                    {
                        int parentID = Convert.ToInt32(dr_comment["ParentID"]);
                        string body_comment = Convert.ToString(dr_comment["Body"]);
                        string authorName_comment = Convert.ToString(dr_comment["AuthorName"]);
                        DateTime addTime = Convert.ToDateTime(dr_comment["AddTime"]);
                        string authorIP = Convert.ToString(dr_comment["AuthorIP"]);
                        DateTime updateTime_comment = Convert.ToDateTime(dr_comment["UpdateTime"]);

                        //将读取到的数据逐条插入postgresql数据库
                        Comment comment = new Comment();
                        comment.article_id = article.Id;
                        comment.comm_content = body_comment;
                        comment.comm_username = authorName_comment;
                        comment.comm_time = addTime;
                        comment.ip = authorIP;
                        comment.is_valid = true;
                        comment.forum_topicid = 0;
                        comment.forum_threadid = 0;
                        comment.modify_time = updateTime_comment;
                        list.Add(comment);
                    }
                    result = CreateArticle(article, list);
                    if (result)
                    {
                        //插入用户最后操作的Article的ID
                        sql = "update DataTransfer set EndArticleId=" + articleId + " where UserName='******'";
                        dc.ExeSql(sql);
                    }
                    else
                    {
                        Untils.WriteProgramLog(loginName + "  导入Article数据失败!");
                    }
                }
                //return result;
            }
            catch (Exception e)
            {
                Untils.WriteProgramLog("something wrong in A method: " + e.Message);
                throw;
            }

        }