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); }