<%Server.ScriptTimeOut=99999%>
<!--#include file="tgzcm_Conn.asp"-->
<!--#include file="tgzcm_Check.asp"-->
<!--#include file="../tgzcm.Include/tgzcm.Lable.All.asp"-->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<TITLE>网站生成管理</TITLE>
<style type="text/css">
<!--
body {background-color:#E4EDF9; line-height:20px; font-size:12px; color:#135294; padding:2px;}
-->
</style>
</head>
<body>
<%

Dim Action,ii,ppage,tpage
Action=Trim(Request("action"))
Classid=Trim(Request("Classid"))
Classid=Replace(Classid,", ",",")
Ranks=PE_CLng(Request.QueryString("Ranks"))
tgzcmPath = Left(tgzcmpath,instrrev(tgzcmpath, "/")-1)'获取安装目录
tgzcmPath = Left(tgzcmpath,instrrev(tgzcmpath, "/"))'获取安装目录
ppage=PE_CLng(Request("PPage"))
If ppage<1 Then ppage=1'初始化分页参数

If action="classall" Then
    Sql="select class_id,class_name,class_orderid from tgzcm_class order by class_orderid asc"
Else
    If Classid="" Then
	    Call tgzcm_err_c("数据不能为空！")
	    Response.End
	End if
    Sql="select class_id,class_name,class_bigid,class_orderid from tgzcm_class where class_id in("&Classid&") order by class_orderid asc"
End If

Set Crs = Server.CreateObject("adodb.recordset")
'sql=
Crs.Open sql, Conn, 1, 1
If Not (Crs.bof And Crs.eof) Then   
    Response.Write("<b>总共需要生成<font color='red'>"&Crs.recordcount&"</font>个栏目！<font color='red'>在此过程中请勿刷新此页面！！！</font></b><br>")
	ii=0
	Crs.pagesize=1            '每页数量
	tpage=Crs.PageCount       '总页数
	Crs.AbsolutePage=ppage    '当前页
	Do while not Crs.eof and ii<Crs.pagesize
		Response.Write("正在生成第<font color='red'>"&ppage&"</font>个栏目<font color='red'>"&Crs("class_name")&"</font>的列表页面……请稍候！<br>")
	    Response.flush
		Call Classpage(Crs("class_id"),PPage)'
		'Response.Write Crs("class_id")&ppage
		jcid=Crs("class_id")
        'Response.End()
	    ii=ii+1	
    Crs.movenext
    Loop
Else
    Response.Write("暂时没有数据无需生成！")	
End If
Crs.Close
Set Crs=nothing

If ppage>=tpage Then
    Response.Write("<p align='center' style='font-size:14px; color:#FF0000'>已经生成所有页面！</p>")
Else
    Response.Write("<p align='center' style='font-size:14px; color:#FF0000'>"&tgzcmId(11)&"秒后将自动继续生成下一个栏目！</p><meta http-equiv='refresh' content="&tgzcmId(11)&";url='tgzcm_CreateClass.asp?Action="&action&"&Classid="&Classid&"&PPage="&PPage+1&"'>")
End If

Sub Classpage(listid,pageid)
    list_id=listid
    Set rs_c = Server.CreateObject("adodb.recordset")
	'Sql=" Select class_id from tgzcm_name where class_id="&listid&" "
	Sql=" Select class_id from tgzcm_name where (class_id="&listid&" or class_id in (select class_id from tgzcm_class where class_bigid="&listid&"))"
	rs_c.Open sql, Conn, 1, 1
	Set bigrs=Conn.Execute("Select class_bigid From tgzcm_class Where class_bigid="&listid&"")
	If Not(rs_c.bof And rs_c.eof) Then
		rs_c.pagesize=tgzcm(11)'每页数据
		m=rs_c.recordcount     '总记录
		n=rs_c.PageCount       '总页数
		z=rs_c.pagesize        '每页数量 
		For jj=1 To rs_c.PageCount
		    page=jj
			Call tgzcm_Lable_Head(tgzcm_Lable_Html("../skin/"&tgzcm(12)&"/"&tgzcmId(21)&"tgzcm_type.html"))
			Call tgzcm_Lable_List(moban)
			Call tgzcm_Lable_Product(moban)
			tgzcm_title=GetClassName(list_id)
			moban=Replace(moban,"@ClassId@",list_id)
			moban=Replace(moban,"@Ranks@",Ranks_Css(Ranks))
			moban=Replace(moban,"@ClassName@",GetClassName(list_id))
			Call tgzcm_Lable_All(moban)
			'取该栏目的路径
		    If HtmlId(3)="2" Then
			ListUrl=GetClassEn(list_id)&"/"&GetListFileName(0, rs_c("class_id"), page, n)&"."&HtmlId(7)'Xj/index.html
			Else
			ListUrl="List/"&GetListFileName(1, list_id, page, n)&"."&HtmlId(7)        'List/List_2_5.html
			End If
	        Call MakeHtml("../"&ListUrl,moban)
		    Response.Write"&nbsp;&nbsp;&nbsp;成功生成第 <font color='red'><b>"&pageid&"</b> </font>个栏目的第 <font color='blue'>"&jj&"</font> 页列表："&ListUrl&"<br>"
			Response.flush
		Next
		
	ElseIf Not (bigrs.bof And bigrs.eof) Then
            Call tgzcm_Lable_Head(tgzcm_Lable_Html("../skin/"&tgzcm(12)&"/"&tgzcmId(21)&"tgzcm_type_big.html"))
			Call tgzcm_Lable_Listfor(moban)
			tgzcm_title=GetClassName(list_id)
			Call tgzcm_Lable_List(moban)
			Call tgzcm_Lable_Product(moban)
			moban=Replace(moban,"@ClassId@",list_id)
			moban=Replace(moban,"@Ranks@",Ranks_Css(Ranks))
			moban=Replace(moban,"@ClassName@",GetClassName(list_id))
			Call tgzcm_Lable_All(moban)
			'取该栏目的路径
			ListUrl=GetClassEn(list_id)&"/index."&HtmlId(7)'Xj/index.html
	        Call MakeHtml("../"&ListUrl,moban)
		    Response.Write"&nbsp;&nbsp;&nbsp;成功生成第 <font color='red'><b>"&pageid&"</b> </font>个栏目的第 <font color='blue'>"&jj&"</font> 页列表："&ListUrl&"<br>"
	Else
	    Response.Write "&nbsp;&nbsp;&nbsp;第 <font color='red'><b>"&pageid&"</b> </font>个栏目下暂无影片信息,</font>不需要生成!</font><br>"
	End If
	rs_c.Close
    Set rs_c=nothing
	Set bigrs=nothing
	Set conn=nothing
End Sub

'**************************************************
'函数名：GetListFileName
'作  用：获得列表文件名称(栏目有分页时)
'参  数：iListFileType ----列表文件方式
'        iClassID ---- 栏目ID
'        iCurrentPage ---- 列表当前页数
'返回值：列表文件名称
'**************************************************
Public Function GetListFileName(iListFileType, iType_Id, iCurrentPage, iPages)
    Select Case iListFileType
    Case 0
        If iCurrentPage = 1 Then
            GetListFileName = "index"
        Else
            GetListFileName = "List_" & iPages - iCurrentPage + 1
        End If
    Case 1, 2
        If iCurrentPage = 1 Then
            GetListFileName = "List_" & iType_Id
        Else
            GetListFileName = "List_" & iType_Id & "_" & iPages - iCurrentPage + 1
        End If
    End Select
End Function
%>
</body>
</html>