public UpFileEntity() { BaseConfigInfo config = BaseConfigs.GetConfig(); this.ftpEnable = config.FTPEnable; this.distributeFileSystem = config.DistributeFileSystem; IsClose = true; }
public void DeleteComment(int commentid) { DbParameter[] dbparams = { DbHelper.MakeInParam("?commentid", (DbType)MySqlDbType.Int32, 4, commentid), }; DbHelper.ExecuteNonQuery(CommandType.Text, string.Format("DELETE FROM {0}comments WHERE commentid=?commentid", BaseConfigs.GetConfig().Tableprefix), dbparams); }
public void CreateComment(CommentInfo commentinfo) { DbParameter[] dbparams = { DbHelper.MakeInParam("?articleid", (DbType)MySqlDbType.Int32, 4, commentinfo.Articleid), DbHelper.MakeInParam("?uid", (DbType)MySqlDbType.Int32, 4, commentinfo.Uid), DbHelper.MakeInParam("?username", (DbType)MySqlDbType.String, 50, commentinfo.Username), DbHelper.MakeInParam("?postdate", (DbType)MySqlDbType.Datetime, 8, commentinfo.Postdate), DbHelper.MakeInParam("?del", (DbType)MySqlDbType.Int32, 4, commentinfo.Del), DbHelper.MakeInParam("?content", (DbType)MySqlDbType.String, 1000, commentinfo.Content), DbHelper.MakeInParam("?goodcount", (DbType)MySqlDbType.Int32, 4, commentinfo.Goodcount), DbHelper.MakeInParam("?badcount", (DbType)MySqlDbType.Int32, 4, commentinfo.Badcount), DbHelper.MakeInParam("?articletitle", (DbType)MySqlDbType.String, 100, commentinfo.Articletitle) }; DbHelper.ExecuteNonQuery(CommandType.Text, string.Format("INSERT INTO {0}comments(articleid,uid,username,postdate,del,content,goodcount,badcount,articletitle) VALUES(?articleid,?uid,?username,?postdate,?del,?content,?goodcount,?badcount,?articletitle)", BaseConfigs.GetConfig().Tableprefix), dbparams); }
public IDataReader GetCommentInfo(int commentid) { IDataReader dr; DbParameter[] dbparams = { DbHelper.MakeInParam("?commentid", (DbType)MySqlDbType.Int32, 4, commentid) }; dr = DbHelper.ExecuteReader(CommandType.Text, string.Format("SELECT * FROM {0}comments WHERE commentid=?commentid", BaseConfigs.GetConfig().Tableprefix), dbparams); return(dr); }
public int GetMostGradCommentsPageCount(int pagesize) { int recordcount; string sql; sql = string.Format("SELECT COUNT(commentid) FROM {0}comments WHERE del=0", BaseConfigs.GetConfig().Tableprefix); recordcount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql)); return(recordcount % pagesize == 0 ? recordcount / pagesize : recordcount / pagesize + 1); }
public void ChangeCommentCount(int articleid, int changevalue, int type) { string sql; if (type == 1) { sql = string.Format("UPDATE {0}articles SET commentcount=commentcount+@increasevalue WHERE articleid=@articleid", BaseConfigs.GetConfig().Tableprefix); } else { sql = string.Format("UPDATE {0}articles SET commentcount=commentcount-@increasevalue WHERE articleid=@articleid", BaseConfigs.GetConfig().Tableprefix); } DbParameter[] prams = { DbHelper.MakeInParam("@articleid", DbType.Int32, 4, articleid), DbHelper.MakeInParam("@increasevalue", DbType.Int32, 4, changevalue) }; DbHelper.ExecuteReader(CommandType.Text, sql, prams); }
public IDataReader GetAdminInfo(string name, string password) { IDataReader dr; DbParameter[] prams = { DbHelper.MakeInParam("@name", DbType.String, 50, name), DbHelper.MakeInParam("@password", DbType.String, 32, password) }; dr = DbHelper.ExecuteReader(CommandType.Text, string.Format("SELECT * FROM {0}admins WHERE name=@name AND password=@password", BaseConfigs.GetConfig().Tableprefix), prams); return(dr); }
public int GetUserCommentsPageCount(int uid, int pagesize) { int recordcount; string sql; DbParameter[] prams = { DbHelper.MakeInParam("?uid", (DbType)MySqlDbType.Int32, 4, uid) }; sql = string.Format("SELECT COUNT(commentid) FROM {0}comments WHERE del=0 AND uid=?uid", BaseConfigs.GetConfig().Tableprefix); recordcount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, prams)); return(recordcount % pagesize == 0 ? recordcount / pagesize : recordcount / pagesize + 1); }
public IDataReader GetSearchArticles(string searchkey, int pagesize, int currentpage) { if (!Natsuhime.Common.Utils.IsSafeSqlString(searchkey)) { return(null); } IDataReader dr; int recordoffset = (currentpage - 1) * pagesize; DbParameter[] prams = { DbHelper.MakeInParam("@recordoffset", DbType.Int32, 4, recordoffset), DbHelper.MakeInParam("@pagesize", DbType.Int32, 4, pagesize) }; dr = DbHelper.ExecuteReader(CommandType.Text, string.Format("SELECT * FROM {0}articles WHERE del=0 AND title LIKE '%{1}%' ORDER BY articleid DESC LIMIT @recordoffset,@pagesize", BaseConfigs.GetConfig().Tableprefix, searchkey), prams); return(dr); }
public int GetHotArticleCollectionPageCount(int pagesize) { int recordcount; recordcount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, string.Format("SELECT COUNT(articleid) FROM {0}articles WHERE del=0", BaseConfigs.GetConfig().Tableprefix))); return(recordcount % pagesize == 0 ? recordcount / pagesize : recordcount / pagesize + 1); }
public IDataReader GetHotArticles(int pagesize, int currentpage) { IDataReader dr; int recordoffset = (currentpage - 1) * pagesize; DbParameter[] prams = { DbHelper.MakeInParam("@recordoffset", DbType.Int32, 4, recordoffset), DbHelper.MakeInParam("@pagesize", DbType.Int32, 4, pagesize) }; dr = DbHelper.ExecuteReader(CommandType.Text, string.Format("SELECT * FROM {0}articles WHERE del=0 ORDER BY commentcount DESC,articleid DESC LIMIT @recordoffset,@pagesize", BaseConfigs.GetConfig().Tableprefix), prams); return(dr); }
public IDataReader GetAdminInfo(int adminid, string password) { IDataReader dr; DbParameter[] prams = { DbHelper.MakeInParam("?adminid", (DbType)MySqlDbType.Int32, 4, adminid), DbHelper.MakeInParam("?password", (DbType)MySqlDbType.String, 32, password) }; dr = DbHelper.ExecuteReader(CommandType.Text, string.Format("SELECT * FROM {0}admins WHERE adminid=?adminid AND password=?password", BaseConfigs.GetConfig().Tableprefix), prams); return(dr); }
public IDataReader GetUserInfo(int uid, string password) { IDataReader dr; DbParameter[] prams = { DbHelper.MakeInParam("@uid", DbType.String, 100, uid), DbHelper.MakeInParam("@password", DbType.String, 32, password) }; dr = DbHelper.ExecuteReader(CommandType.Text, string.Format("SELECT * FROM {0}users WHERE uid=@uid AND password=@password", BaseConfigs.GetConfig().Tableprefix), prams); return(dr); }
public int GetCommentsPageCount(int articleid, int pagesize) { int recordcount; string sql; DbParameter[] prams = { DbHelper.MakeInParam("@articleid", DbType.Int32, 4, articleid) }; if (articleid > 0) { sql = string.Format("SELECT COUNT(commentid) FROM {0}comments WHERE del=0 AND articleid=@articleid", BaseConfigs.GetConfig().Tableprefix); } else { sql = string.Format("SELECT COUNT(commentid) FROM {0}comments WHERE del=0", BaseConfigs.GetConfig().Tableprefix); } recordcount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, prams)); return(recordcount % pagesize == 0 ? recordcount / pagesize : recordcount / pagesize + 1); }
private static void SaveThumb(Image img, string newFileName, ImageFormat imgFormat, UpFileEntity upFileEntity) { BaseConfigInfo config = BaseConfigs.GetConfig(); string fileName = Path.GetFileName(newFileName); if (config.DistributeFileSystem == 1 && upFileEntity.DistributeFileSystem == 1) { if (!string.IsNullOrEmpty(upFileEntity.GroupName)) { byte[] contentBytes = GetByteImage(img, imgFormat); DFSProvider.CurrentDFS.UploadSlaveFile(contentBytes, upFileEntity.Mast_File_Name, upFileEntity.Prefix_Name, upFileEntity.File_Ext.Replace(".", "")); } } else { if (config.FTPEnable == 1 && upFileEntity.FTPEnable == 1) { if (FTPs.IsLocalhost(upFileEntity.FTPIdent))//区分本地或FTP { img.Save(newFileName, imgFormat); } else { string fileExt = Path.GetExtension(newFileName); string dir = Path.GetDirectoryName(config.FTPTempPath + GetFtpPath("", fileExt, config.FTPPathFormat, upFileEntity)); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } string savePath = dir + "/" + fileName; System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); img.Save(savePath, imgFormat); //存入临时文件夹 FTPs.UpLoadFile(Path.GetDirectoryName(newFileName), savePath, upFileEntity, upFileEntity.FTPIdent); //-FTP不需要传入文件名 stopwatch.Stop(); long minsecond = stopwatch.ElapsedMilliseconds; } } else { img.Save(newFileName, imgFormat); } } img.Dispose(); #region 写入备份记录-通过接口 if (upFileEntity.AttachID > 0) { fileName = fileName.ToLower().Replace(upFileEntity.File_Ext.ToLower(), ""); string[] fileNameArr = fileName.Split('!'); string[] sites; if (fileNameArr.Length > 1) { sites = fileNameArr[1].Split('_'); } else { sites = fileName.Split('_'); } if (sites.Length == 3) { if (!string.IsNullOrEmpty(config.BakClassName)) { UploadBakProvider.GetInstance(config.BakClassName).Update(upFileEntity.AttachID, sites[1] + "_" + sites[2]); } } } #endregion }
public void GradeComment(int commentid, int type) { string sql; DbParameter[] dbparams = { DbHelper.MakeInParam("?commentid", (DbType)MySqlDbType.Int32, 4, commentid), }; if (type == 1) { sql = string.Format("UPDATE {0}comments SET goodcount=goodcount+1 WHERE commentid=?commentid", BaseConfigs.GetConfig().Tableprefix); } else { sql = string.Format("UPDATE {0}comments SET badcount=badcount+1 WHERE commentid=?commentid", BaseConfigs.GetConfig().Tableprefix); } DbHelper.ExecuteNonQuery(CommandType.Text, sql, dbparams); }
public IDataReader GetUserComments(int uid, int pagesize, int currentpage) { IDataReader dr; int recordoffset = (currentpage - 1) * pagesize; DbParameter[] prams = { DbHelper.MakeInParam("?uid", (DbType)MySqlDbType.Int32, 4, uid), DbHelper.MakeInParam("?recordoffset", (DbType)MySqlDbType.Int32, 4, recordoffset), DbHelper.MakeInParam("?pagesize", (DbType)MySqlDbType.Int32, 4, pagesize) }; dr = DbHelper.ExecuteReader(CommandType.Text, string.Format("SELECT * FROM {0}comments WHERE del=0 AND uid=?uid ORDER BY commentid DESC LIMIT ?recordoffset,?pagesize", BaseConfigs.GetConfig().Tableprefix), prams); return(dr); }
/// <summary> /// 取得文章列表. /// </summary> /// <param name="cid">栏目id(如果为0表示取得所有栏目)</param> /// <param name="pagesize">分页大小</param> /// <param name="currentpage">当前页</param> /// <returns>列表</returns> public System.Data.IDataReader GetArticles(int cid, int pagesize, int currentpage) { string sql; IDataReader dr; int recordoffset = (currentpage - 1) * pagesize; DbParameter[] prams = { DbHelper.MakeInParam("@columnid", DbType.Int32, 4, cid), DbHelper.MakeInParam("@recordoffset", DbType.Int32, 4, recordoffset), DbHelper.MakeInParam("@pagesize", DbType.Int32, 4, pagesize) }; if (cid > 0) { sql = string.Format("SELECT * FROM {0}articles WHERE del=0 AND columnid=@columnid ORDER BY articleid DESC LIMIT @recordoffset,@pagesize", BaseConfigs.GetConfig().Tableprefix); } else { sql = string.Format("SELECT * FROM {0}articles WHERE del=0 ORDER BY articleid DESC LIMIT @recordoffset,@pagesize", BaseConfigs.GetConfig().Tableprefix); } dr = DbHelper.ExecuteReader(CommandType.Text, sql, prams); return(dr); }
public IDataReader GetMostGradComments(int pagesize, int currentpage) { IDataReader dr; string sql; int recordoffset = (currentpage - 1) * pagesize; DbParameter[] prams = { DbHelper.MakeInParam("?recordoffset", (DbType)MySqlDbType.Int32, 4, recordoffset), DbHelper.MakeInParam("?pagesize", (DbType)MySqlDbType.Int32, 4, pagesize) }; sql = string.Format("SELECT * FROM {0}comments WHERE del=0 ORDER BY goodcount DESC, badcount DESC, commentid DESC LIMIT ?recordoffset,?pagesize", BaseConfigs.GetConfig().Tableprefix); dr = DbHelper.ExecuteReader(CommandType.Text, sql, prams); return(dr); }
public int GetSearchArticleCollectionPageCount(string searchkey, int pagesize) { if (!Natsuhime.Common.Utils.IsSafeSqlString(searchkey)) { return(0); } int recordcount = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, string.Format("SELECT COUNT(articleid) FROM {0}articles WHERE del=0 AND title LIKE '%{1}%'", BaseConfigs.GetConfig().Tableprefix, searchkey))); return(recordcount % pagesize == 0 ? recordcount / pagesize : recordcount / pagesize + 1); }