using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Fm.Tags;
using Fm.Bussiness;

public partial class admin_htm_index : BasePage
{
    //创建一个DT
   
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //ATL.IO.IOStream stream = new ATL.IO.IOStream();
            Xml_work xml = new Xml_work();
            //读取首页模板文件
            DataTable dt = xml.Xml_Reader(Server.MapPath("../config/templates.xml"),"templates");
            temp_index.Text = dt.Rows[0]["index"].ToString();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        ATL.IO.IOStream stream = new ATL.IO.IOStream();
        ////实例化模板解析类
        Temp_Index index = new Temp_Index();
        string temp = Server.MapPath("../templates/");
        string content = index.Get_Index(temp,temp_index.Text.Trim());
        //Lab_info.Text = "系统提示:首页生成成功!";
        //生成模板
        if (stream.WriteFile(Server.MapPath("../index.html"), content))
        {
            Lab_info.Text = "首页生成成功!<a href='/index.html' target='_blank'>预览</a>";
        }
        Xml_work xml = new Xml_work();
        //生成后保存新选择首页模板
        DataTable dt = xml.Xml_Reader(Server.MapPath("../config/templates.xml"), "templates");
        if (dt != null)
        {
            dt.Rows[0]["index"] = temp_index.Text;

            xml.Xml_Update(Server.MapPath("../config/templates.xml"), "templates", dt);
        }
    }
}
