//public override object NewID() //{ // int max = DbInstance.GetInt("select max(articleID) from blog_tb_article"); // return base.NewID(); //} public int UpdateExtend(string articleID, string lastOpenIP, string lastOpenUserID) { string sql = "select * from blog_tb_article_extend where articleID=@articleID"; if (DbInstance.Exists(sql, DbInstance.CreateParameter("@articleID", articleID))) { sql = " update blog_tb_article_extend set lastOpenDatetime=GETDATE(),lastOpenIP=@ip,lastOpenUserID=@userID,UPDATE_DATE=GETDATE(),articleClickTimes=articleClickTimes+1 where articleID=@articleID"; DbInstance.ExecuteSql(sql , DbInstance.CreateParameter("@articleID", articleID) , DbInstance.CreateParameter("@ip", lastOpenIP) , DbInstance.CreateParameter("@userID", lastOpenUserID)); } else { blog_tb_article_extend entity = new blog_tb_article_extend(); entity.articleClickTimes = 1; entity.articleCommentTimes = 0; entity.articleID = Convert.ToInt32(articleID); entity.extendID = Guid.NewGuid().ToString("N"); entity.lastOpenDatetime = DateTime.Now; entity.UPDATE_DATE = DateTime.Now; entity.lastOpenIP = lastOpenIP; entity.lastOpenUserID = lastOpenUserID; FYJ.Data.Entity.EntityHelper <blog_tb_article_extend> .Insert(entity, "blog_tb_article_extend", "extendID", true, DbInstance); } return(1); }
public int UpdateExtend(string articleID, string lastOpenIP, string lastOpenUserID) { string sql = "select * from blog_tb_article_extend where articleID=@articleID"; IDbHelper db = IocFactory <IDbFactory> .Instance.GetDbInstance("Blogs-Write"); if (db.Exists(sql, db.CreateParameter("@articleID", articleID))) { sql = " update blog_tb_article_extend set lastOpenDatetime=@UPDATE_DATE,lastOpenIP=@ip,lastOpenUserID=@userID,UPDATE_DATE=@UPDATE_DATE,articleClickTimes=ifnull(articleClickTimes,0)+1 where articleID=@articleID"; db.ExecuteSql(sql , db.CreateParameter("@articleID", articleID) , db.CreateParameter("@ip", lastOpenIP) , db.CreateParameter("@userID", lastOpenUserID) , db.CreateParameter("@UPDATE_DATE", DateTime.Now)); } else { blog_tb_article_extend entity = new blog_tb_article_extend(); entity.articleClickTimes = 1; entity.articleCommentTimes = 0; entity.articleID = Convert.ToInt32(articleID); entity.lastOpenDatetime = DateTime.Now; entity.UPDATE_DATE = DateTime.Now; entity.lastOpenIP = lastOpenIP; entity.lastOpenUserID = lastOpenUserID; FYJ.Data.Entity.EntityHelper <blog_tb_article_extend> .Insert(entity, "blog_tb_article_extend", "articleID", true, db); } return(1); }