예제 #1
0
        public static void InsertComment(long articleId, long article_id)
        {
            //int count = SelectComment(article_id);
            //if (count > 0)
            //{
            //    DelComment(article_id);
            //}
            try
            {
                DataTable      dt = new DataTable();
                DataConnection dc = new DataConnection();
                //获取Comment评论表的数据
                string sql = "select * from ra_pbComment where ParentID=" + articleId;
                dt = dc.FillDataTable(sql);
                foreach (DataRow dr in dt.Rows)
                {
                    int      parentID   = Convert.ToInt32(dr["ParentID"]);
                    string   body       = Convert.ToString(dr["Body"]);
                    string   authorName = Convert.ToString(dr["AuthorName"]);
                    DateTime addTime    = Convert.ToDateTime(dr["AddTime"]);
                    string   authorIP   = Convert.ToString(dr["AuthorIP"]);
                    DateTime updateTime = Convert.ToDateTime(dr["UpdateTime"]);

                    //将读取到的数据逐条插入postgresql数据库
                    Comment comment = new Comment();
                    comment.article_id     = article_id;
                    comment.comm_content   = body;
                    comment.comm_username  = authorName;
                    comment.comm_time      = addTime;
                    comment.ip             = authorIP;
                    comment.is_valid       = true;
                    comment.forum_topicid  = 0;
                    comment.forum_threadid = 0;
                    comment.modify_time    = updateTime;
                    Createcomment(comment);
                }
                //return result;
            }
            catch (Exception e)
            {
                Untils.WriteProgramLog("something wrong in A method: " + e.Message);
                throw;
            }
        }
예제 #2
0
        public static bool InsertUnit(int memberId, string loginName, string face)
        {
            //string msg = string.Empty;
            bool     result         = false;
            string   sql            = string.Empty;
            string   blogName       = string.Empty;
            int      blogId         = 0;
            string   blogTitle      = string.Empty;
            string   memberLogo     = string.Empty;
            DateTime blogAddTime    = DateTime.Now;
            DateTime blogUpdateTime = DateTime.Now;
            int      postCount      = 0;
            int      blogStatus     = 0;

            try
            {
                DataTable      dt = new DataTable();
                DataConnection dc = new DataConnection();
                //获取Blog博客表的数据
                sql = "select * from ra_bgBlog where MemberID=" + memberId;
                //dt = dc.FillDataTable(sql);
                DataRow dr = dc.FillDataRow(sql);
                //foreach (DataRow dr in dt.Rows)//?
                //{
                blogId         = Convert.ToInt32(dr["ID"]);
                blogStatus     = Convert.ToInt32(dr["status"]);
                blogName       = Convert.ToString(dr["Name"]);
                blogTitle      = Convert.ToString(dr["Title"]);
                blogAddTime    = Convert.ToDateTime(dr["AddTime"]);
                blogUpdateTime = Convert.ToDateTime(dr["UpdateTime"]);
                postCount      = Convert.ToInt32(dr["PostCount"]);//文章数量
                //}
                //if (blogStatus == 0)
                //{
                //  sql = "update ra_bgBlog set status=1";
                //   dc.ExeSql(sql);

                //获取Member表的数据
                //sql = "select * from ra_pbMember where LoginName='" + loginName + "'"; //?
                //dt = dc.FillDataTable(sql);
                //foreach (DataRow dr in dt.Rows)
                //{
                // memberId = Convert.ToInt32(dr["ID"]);
                // memberLogo = "http://blog.cnool.net" + Convert.ToString(dr["Face"]);
                //}

                var unitInfo = getUnitByBlogName(loginName);
                if (unitInfo != null)
                {
                    ArticleManage.InsertArticle(blogId, Convert.ToInt32(unitInfo["id"]), blogName, loginName);
                    result = true;
                }
                else
                {
                    Unit unit = new Unit();
                    unit.username = loginName;
                    unitInfo      = getUnitByName(loginName);
                    if (unitInfo != null)
                    {
                        unit.asmanagers = Untils.ConvertToSearchkey(loginName);
                        unit.username   = null;
                    }
                    unit.id          = GetId();
                    unit.unit_name   = loginName + "@博客";
                    unit.create_time = blogAddTime;
                    unit.isvalid     = true;
                    unit.creater     = "system";
                    unit.unit_type   = 1;
                    //unit.modifier = "system";
                    //unit.update_time = blogUpdateTime;
                    if (string.IsNullOrEmpty(face))
                    {
                        unit.unit_logo = null;
                    }
                    else
                    {
                        unit.unit_logo = Untils.GetHtmlImageUrl(face);
                    }
                    //unit.unit_remark = blogTitle;
                    unit.forum_id      = 0;
                    unit.industry_id   = 10040;
                    unit.status        = 0;
                    unit.article_count = postCount;
                    unit.unit_domain   = blogName + ".blog2.cnool.net";
                    result             = CreateUnit(unit);
                    if (result)
                    {
                        //导入Article表
                        ArticleManage.InsertArticle(blogId, unit.id, blogName, loginName);
                    }
                    else
                    {
                        Untils.WriteProgramLog(loginName + "  导入Blog数据失败!");
                    }
                }
            }
            catch (Exception e)
            {
                Untils.WriteProgramLog("something wrong in A method: " + e.Message);
                throw;
            }
            return(result);
        }