Esempio n. 1
0
        /// <summary>
        /// ²éÕÒ²»´æÔÚµÄͼƬ²¢É¾³ýÒÑɾ³ýµÄͼƬ¼°Êý¾Ý
        /// </summary>
        public void DeleteList(SqlConnection conn, SqlTransaction trans, List <Model.article_albums> models, int article_id)
        {
            StringBuilder idList = new StringBuilder();

            if (models != null)
            {
                foreach (Model.article_albums modelt in models)
                {
                    if (modelt.id > 0)
                    {
                        idList.Append(modelt.id + ",");
                    }
                }
            }
            string        id_list = SFUtils.DelLastChar(idList.ToString(), ",");
            StringBuilder strSql  = new StringBuilder();

            strSql.Append("select id,thumb_path,original_path from " + databaseprefix + "article_albums where article_id=" + article_id);
            if (!string.IsNullOrEmpty(id_list))
            {
                strSql.Append(" and id not in(" + id_list + ")");
            }
            DataSet ds = DbHelperSQL.Query(conn, trans, strSql.ToString());

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                int rows = DbHelperSQL.ExecuteSql(conn, trans, "delete from " + databaseprefix + "article_albums where id=" + dr["id"].ToString()); //ɾ³ýÊý¾Ý¿â
                if (rows > 0)
                {
                    SFUtils.DeleteFile(dr["thumb_path"].ToString());    //ɾ³ýËõÂÔͼ
                    SFUtils.DeleteFile(dr["original_path"].ToString()); //ɾ³ýԭͼ
                }
            }
        }
Esempio n. 2
0
 //删除更新的旧文件
 public void DeleteFile(int id, string filePath)
 {
     Model.article_attach model = GetModel(id);
     if (model != null && model.file_path != filePath)
     {
         SFUtils.DeleteFile(model.file_path);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// 删除附件文件
 /// </summary>
 public void DeleteFile(List <Model.article_attach> models)
 {
     if (models != null)
     {
         foreach (Model.article_attach modelt in models)
         {
             SFUtils.DeleteFile(modelt.file_path);
         }
     }
 }
Esempio n. 4
0
 /// <summary>
 /// ɾ³ýÏà²áͼƬ
 /// </summary>
 public void DeleteFile(List <Model.article_albums> models)
 {
     if (models != null)
     {
         foreach (Model.article_albums modelt in models)
         {
             SFUtils.DeleteFile(modelt.thumb_path);
             SFUtils.DeleteFile(modelt.original_path);
         }
     }
 }