//成功发布一篇文章后,更新采集文章库中对应文章的信息 private bool updateCoArticle(long aid, long cmsAid) { bool isCorrectUpdated = true; mySqlDB myDB = new mySqlDB(_coConnString); string sResult = ""; int counts = 0; string sql = "update arc_contents set cms_aid='" + cmsAid.ToString() + "' where aid='" + aid.ToString() + "'"; counts = myDB.executeDMLSQL(sql, ref sResult); if (sResult != mySqlDB.SUCCESS || counts == 0) { isCorrectUpdated = false; Exception ex = new Exception(sResult); ex.Data.Add("错误信息", "发布文章后更新cms_aid字段信息错误"); ex.Data.Add("采集文章ID", aid); ex.Data.Add("发布文章ID", cmsAid); } sql = "update arc_contents set usedby_pc='yes' where aid='" + aid.ToString() + "'"; counts = myDB.executeDMLSQL(sql, ref sResult); if (sResult != mySqlDB.SUCCESS || counts == 0) { isCorrectUpdated = false; Exception ex = new Exception(sResult); ex.Data.Add("错误信息", "发布文章后更新usedby_pc字段信息错误"); ex.Data.Add("采集文章ID", aid); ex.Data.Add("发布文章ID", cmsAid); } return(isCorrectUpdated); }
//导出一篇文章到CMS中 private bool exportOneRecord(Dictionary <string, object> coArticle, ref long cmsAid) { cmsAid = -1; //news表中插入记录后的ID值 string typeid = "0"; string title = coArticle["title"].ToString(); string litpic = coArticle["litpic"].ToString(); string sourceSite = coArticle["source_site"].ToString(); string content = coArticle["content"].ToString(); string description = coArticle["description"].ToString(); string url = ""; string status = "99"; string sysadd = "1"; string username = "******"; long pubDateUnixtime = getRandomPubDate(); //将文章信息插入到news表中 mySqlDB pubMyDB = new mySqlDB(_pubConnString); string sResult = ""; int counts = 0; string sql = "insert into " + _pubTablePrename + "_news(catid,typeid,title,thumb,description,url,status,sysadd,username,inputtime,updatetime)"; sql = sql + " values ('" + _pubTypeid + "'"; sql = sql + ",'" + typeid + "'"; sql = sql + ",'" + mySqlDB.EscapeString(title) + "'"; sql = sql + ",'" + litpic + "'"; sql = sql + ",'" + mySqlDB.EscapeString(description) + "'"; sql = sql + ",'" + url + "'"; sql = sql + ",'" + status + "'"; sql = sql + ",'" + sysadd + "'"; sql = sql + ",'" + username + "'"; sql = sql + ",'" + pubDateUnixtime + "'"; sql = sql + ",'" + pubDateUnixtime + "')"; counts = pubMyDB.executeDMLSQL(sql, ref sResult); if (sResult == mySqlDB.SUCCESS && counts > 0) { cmsAid = pubMyDB.LastInsertedId; } else { Exception ex = new Exception(sResult); ex.Data.Add("错误信息", "发布文章至news表错误"); _pubExceptions.Add(ex); return(false); } //将相应的文章数据插入到news_data表中 string maxcharperpage = "3000"; //文章按多少字分页 string paginationtype = "1"; //表示文章自动分页 string groupids_view = ""; string template = ""; sql = "insert into " + _pubTablePrename + "_news_data(id,content,groupids_view,paginationtype,maxcharperpage,template,copyfrom)"; sql = sql + " values ('" + cmsAid.ToString() + "'"; sql = sql + ",'" + mySqlDB.EscapeString(content) + "'"; sql = sql + ",'" + groupids_view + "'"; sql = sql + ",'" + paginationtype + "'"; sql = sql + ",'" + maxcharperpage + "'"; sql = sql + ",'" + template + "'"; sql = sql + ",'" + mySqlDB.EscapeString(sourceSite) + "')"; counts = pubMyDB.executeDMLSQL(sql, ref sResult); if (sResult == mySqlDB.SUCCESS && counts > 0) { } else { Exception ex = new Exception(sResult); ex.Data.Add("错误信息", "发布文章至news_data表错误"); ex.Data.Add("发布文章ID", cmsAid); _pubExceptions.Add(ex); return(false); } //将相应的文章数据插入到hits表中 string hitsid = "c-1-" + cmsAid.ToString(); sql = "INSERT IGNORE INTO " + _pubTablePrename + "_hits(hitsid,catid) Values('" + hitsid + "','" + _pubTypeid + "')"; counts = pubMyDB.executeDMLSQL(sql, ref sResult); if (sResult == mySqlDB.SUCCESS && counts > 0) { return(true); } else { Exception ex = new Exception(sResult); ex.Data.Add("错误信息", "发布文章-添加点击数记录至hits表错误"); ex.Data.Add("发布文章ID", cmsAid); _pubExceptions.Add(ex); } return(true); }