using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.IO;

namespace Fm.Bussiness
{
    /// <summary>
    /// 静态文档处理类
    /// </summary>
    public class model_htm:System.Web.UI.Page
    {
        /// <summary>
        /// 根据文档删除静态文件
        /// </summary>
        /// <param name="docid"></param>
        /// <returns></returns>
        public bool Document_del(int docid)
        {
            //实例化AyongToolsLibrary类库
            ATL.IO.IOStream stream = new ATL.IO.IOStream();
            //查询出栏目目录
            public_select ps = new public_select();
            DataView dv = ps.Getps("Fm_model_view","cl_path","docid="+docid+"");

            //查询文档的静态文件
            DataView dw = ps.Getps("Fm_model_htm","*","docid="+docid+"");
            string path=Server.MapPath("../"+dv[0]["cl_path"].ToString()+"/");
          
            //循环删除
            foreach (DataRow row in dw.Table.Rows)
            {
                if (File.Exists(path + row["path"].ToString()))
                {
                    stream.DeleteFile(path+row["path"].ToString());
                }
            }
            //删除表中数据
            ps.Queryps("delete from Fm_model_htm where docid=" + docid + "");
            return true;
        }
    }
}
