<%@ Page Language="C#" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Web.UI.WebControls.WebParts" %>
<%@ Import Namespace="System.Web.UI.HtmlControls" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.IO" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connstr"].ToString());
            con.Open();
            SqlCommand com = new SqlCommand("alter table qth8_mess add comment int default 0", con);
            com.ExecuteNonQuery();
            com = new SqlCommand("update qth8_mess set comment=0", con);
            com.ExecuteNonQuery();
            con.Close();
            con.Dispose();
            Response.Write("v4.4升级成功！");
        }
        catch (Exception err)
        {
            Response.Write("v4.4不需要升级！");
        }
        finally
        {
            
        }

        Response.Write("<br />");
        
        try
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connstr"].ToString());
            con.Open();
            SqlCommand com = new SqlCommand("alter table qth8_webconfig add qth8s1 int default 0,qth8s2 int default 0,qth8s3 int default 0,qth8s4 int default 0,qth8s5 int default 0,qth8s6 int default 0,qth8s7 int default 0,qth8s8 int default 0,qth8s9 int default 0,qth8s10 int default 0", con);
            com.ExecuteNonQuery();
            com = new SqlCommand("update qth8_webconfig set qth8s1=48,qth8s2=10,qth8s3=0,qth8s4=30,qth8s5=0,qth8s6=0,qth8s7=0,qth8s8=0,qth8s9=0,qth8s10=0", con);
            com.ExecuteNonQuery();
            con.Close();
            con.Dispose();
            Response.Write("v5.0升级成功！");
        }
        catch (Exception err)
        {
            Response.Write("v5.0不需要升级！");
        }
        finally
        {

        }

        Response.Write("<br />");

        try
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connstr"].ToString());
            con.Open();
            SqlCommand com = new SqlCommand("alter table qth8_webconfig add qth8Link1 text", con);
            com.ExecuteNonQuery();
            com = new SqlCommand("update qth8_webconfig set qth8Link1=''", con);
            com.ExecuteNonQuery();
            com = new SqlCommand("alter table qth8_review add power int default 0", con);
            com.ExecuteNonQuery();
            com = new SqlCommand("update qth8_review set power=0", con);
            com.ExecuteNonQuery();
            com = new SqlCommand("alter table qth8_bizreview add power int default 0", con);
            com.ExecuteNonQuery();
            com = new SqlCommand("update qth8_bizreview set power=0", con);
            com.ExecuteNonQuery();
            com = new SqlCommand("update qth8_webconfig set qth8s6=1024", con);
            com.ExecuteNonQuery();
            con.Close();
            con.Dispose();
            Response.Write("v6.0升级成功！");
        }
        catch (Exception err)
        {
            Response.Write("v6.0不需要升级！");
        }
        finally
        {

        }

        Response.Write("<br />");

        try
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connstr"].ToString());
            con.Open();
            SqlCommand com = new SqlCommand("alter table qth8_webconfig add qth8ad9 text", con);
            com.ExecuteNonQuery();
            com = new SqlCommand("update qth8_webconfig set qth8ad9=''", con);
            com.ExecuteNonQuery();
            com = new SqlCommand("alter table qth8_mess drop column searchText", con);
            com.ExecuteNonQuery();
            com = new SqlCommand("alter table qth8_mess add searchText nvarchar(400)", con);
            com.ExecuteNonQuery();
            com = new SqlCommand("create index i_top on qth8_mess(id,topstate)", con);
            com.ExecuteNonQuery();
            com = new SqlCommand("create index i_search on qth8_mess(searchText)", con);
            com.ExecuteNonQuery();
            con.Close();
            con.Dispose();
            Response.Write("v6.1升级成功！");

            try
            {
                con = new SqlConnection(ConfigurationManager.ConnectionStrings["connstr"].ToString());
                con.Open();
                com = new SqlCommand("update qth8_mess set searchText=left(title+Convert(nvarchar(2000),content),400)", con);
                com.ExecuteNonQuery();

                con.Close();
                con.Dispose();
                Response.Write("更新搜索索引成功！");
            }
            catch (Exception err)
            {
                Response.Write("更新搜索索引失败！");
            }
            finally
            {

            }
        }
        catch (Exception err)
        {
            Response.Write("v6.1不需要升级！");
        }
        finally
        {

        }
        
       

        
    }
    
</script>
