<!--#include file="../ACT.Function.asp"-->
<!--#include file="../../ACT_inc/ACT.Code.asp"-->
<% 		With Response
		Dim ACTCode,ModeID,Table
		Set ACTCode =New ACT_Code
		Dim StartRefreshTime,RefreshFlag
		Dim FsoHtmlList,ItemName
		RefreshFlag = Request("RefreshFlag")
		StartRefreshTime = Request("StartRefreshTime")
		If StartRefreshTime = "" Then StartRefreshTime = Timer()
	ModeID =ACTCMS.ChkNumeric(request("ModeID"))
	IF ModeID = 0 Then ModeID = 1
	If ACTCMS.ACT_C(ModeID,3) = 0 Then Call ACTCMS.Alert("ACTCMS系统提醒您：\n\n1、此模型没有启用生成静态HTML功能\n\n2、请进入该模型->系统参数设置 >启用生成静态Html功能","../Mode/ACT.MX.asp?A=E&ModeID="&ModeID&"")
	Server.ScriptTimeOut=9999999
	Table=actcms.ACT_C(ModeID,2)
	Application(AcTCMSN&"ModeID")=ModeID
	Call MakeContent
	End With
	 Set ACTCode=Nothing:Set ACTCMS=Nothing
		Sub Main()
		Dim ReturnInfo
		  With Response
		  .Write ("<html>")
		  .Write ("<head>")
		  .Write ("<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">")
		  .Write ("<title>系统信息</title>")
		  .Write ("</head>")
		  .Write ("<body>")
		  If RefreshFlag="ID" Then
              .Write "<div style=""display:none"">"
				.Write "<br><br><br><table style=""display:none"" id=""BarShowArea"" width=""400"" border=""0"" align=""center"" cellspacing=""1"" cellpadding=""1"">"
		 Else
				.Write "<br><br><br><table id=""BarShowArea"" width=""400"" border=""0"" align=""center"" cellspacing=""1"" cellpadding=""1"">"
		 End iF
				.Write "<tr> "
				.Write "<td bgcolor=000000>"
				.Write " <table width=""400"" border=""0"" cellspacing=""0"" cellpadding=""1"">"
				.Write "<tr> "
				.Write "<td bgcolor=ffffff height=20><img src=""../images/bar9.gif"" width=0 height=19 id=img2 name=img2 align=absmiddle></td></tr></table>"
				.Write "</td></tr></table>"
				.Write "<table width=""550"" border=""0"" align=""center"" cellspacing=""1"" cellpadding=""1""><tr> "
				.Write "<td align=center> <span id=txt2 name=txt2 style=""font-size:9pt"">0</span><span id=txt4 style=""font-size:9pt"">%</span></td></tr> "
				.Write "<tr><td align=center><span id=txt3 name=txt3 style=""font-size:9pt"">0</span></td></tr>"
				.Write "</table>"
		 .Write ("   <div id=""fsohtml"">")
		 .Write (FsoHtmlList)
		  .Write ("   </div>")
		 .Write ("</body>")
		 .Write ("</html>")
		 End With
		End Sub
		Sub MakeContent()
		Dim AlreadyRefreshByID,MaxNum,NowNum,TotalNum,StartDate,EndDate,ClassID,StartID,EndID
		Dim r_sql,R_RS,ID
		AlreadyRefreshByID = Request.QueryString("AlreadyRefreshByID")
		MaxNum = Request.QueryString("MaxNum")
		NowNum = Request.QueryString("NowNum") '正在刷新第几篇文章
		if request("ismake")="1" then
			R_Sql=" Where ismake=0 and isAccept=0 and delif=0"
		Else 
			R_Sql=" Where isAccept=0 and delif=0"
		End  If 
			If NowNum = "" Then NowNum = 0
			With Response
		Select Case RefreshFlag
		   Case "ID"
				ID =ACTCMS.S("ID")
				R_Sql="Select Top 2 * From " & Table & R_SQL&" and ID IN(Select top 2 id from " & Table & R_Sql & " And ID<=" & id & " Order By ID Desc) Order By ID"
				MaxNum=conn.execute("select count(id) from " & Table  &" where isAccept=0 and ID<=" & ID)(0)
				If MaxNum>2 Then MaxNum=2
			Case "New"
			  TotalNum = ACTCMS.ChkNumeric(Request("TotalNum"))
			  If TotalNum >conn.execute("select count(id) from "& Table )(0) Then TotalNum = conn.execute("select count(id) from "& Table )(0)
			  MaxNum = TotalNum
			  If TotalNum=0 Then TotalNum=1
			  R_Sql="Select Top " & TotalNum & " * from " & Table  & " Order By ID Desc"
		 Case "InfoID"
				 StartID = ACTCMS.ChkNumeric(Request("StartID"))
				 EndID = ACTCMS.ChkNumeric(Request("EndID"))
				 MaxNum=conn.execute("select count(id) from " & Table  & R_Sql & " and ID>= " & StartID & " And  ID <=" & EndID)(0)
				 R_Sql = "Select * from " & Table  & R_Sql & " and ID>= " & StartID & " And  ID <=" & EndID & " order by ID desc"
		   Case "Date"
			  StartDate = Request("StartDate"):EndDate = DateAdd("d", 1, Request("EndDate"))
				 MaxNum=conn.execute("select count(id) from " & Table  & R_Sql & " and UpdateTime>= #" & StartDate & "# And  UpdateTime <=#" & EndDate & "#")(0)
				 R_Sql = "Select * from " & Table  & R_Sql & " and UpdateTime>= #" & StartDate & "# And  UpdateTime <=#" & EndDate & "# order by ID desc"
		  Case "Folder"
			 ClassID = Trim(Replace(Request("ClassID")," ",""))
			 MaxNum=conn.execute("select count(id) from " & Table  & R_Sql& " And ClassID IN(" & ClassID & ")")(0)
			 R_Sql = "Select * from " & Table  & R_Sql & " And ClassID IN(" & ClassID & ") order by ID desc"
		  Case "All"
		      MaxNum=conn.execute("select count(id) from " & Table  & R_Sql)(0)
			  R_Sql = "Select * from " & Table  & R_Sql & " order by ID desc"
		 Case Else
				R_Sql = ""
				MaxNum = 0
		End Select
		Call Main
		If R_Sql <> "" Then
			Set R_RS = Server.CreateObject("ADODB.RecordSet")
			R_RS.Open R_Sql, Conn, 1, 1
			If R_RS.EOF And R_RS.BOF Then
				.Write "<script>img2.width=""0"";" & vbCrLf
				.Write "txt2.innerHTML=""没有可生成的内容页！<br><br><input name='button1' type='button' onclick=javascript:location='ACT.Make.asp?ModeID=" & ModeID  &"'; class='button' value=' 返 回 '>"";" & vbCrLf
				.Write "txt3.innerHTML="""";" & vbCrLf
				.Write "txt4.innerHTML="""";" & vbCrLf
				.Write "document.all.BarShowArea.style.display='none';" & vbCrLf
				.Write "</script>" & vbCrLf
				.Flush
				R_RS.Close:Set R_RS=Nothing
				Exit Sub
			Else
				For NowNum=1 To MaxNum
				If R_RS("Score_ACT")>0  Or R_RS("GroupID_ACT")<>""  Or ACTCMS.ACT_L(R_RS("ClassID"),6)<>"" Then
					FsoHtmlList="<div align=center><li>标题为<font color=red><b>"  & R_RS("Title") & "</b></font>的没有生成</div>"
				Else 
				   FsoHtmlList="<div align=center><li>标题为<font color=red>"  & R_RS("Title") & "</font>已生成</div>"
				   conn.execute("update " & Table & " set ismake=1 where id=" & R_RS("id"))
				End If 
				 Call ACTCode.ArticleContent(ModeID,R_RS)
				If Err.Number <> 0 Then
				 FsoHtmlList = "操作失败!<br><font color=red>" & Err.Description & "</font>"
				 Call TypeJS(NowNum,MaxNum,ACTCMS.ACT_C(ModeID,5))
				 R_RS.Close:Set R_RS=Nothing
				 Exit Sub
				End If
				If RefreshFlag="ID" and NowNum=2 Then
				 Call TypeJS(NowNum,MaxNum,ACTCMS.ACT_C(ModeID,5)):R_RS.Close:Set R_RS=Nothing:.End
				Else
				 Call TypeJS(NowNum,MaxNum,ACTCMS.ACT_C(ModeID,5))
				End If
				if Not Response.IsClientConnected then Exit FOR
			  r_rs.movenext
			Next
				.Write "<script>"
				.Write "fsohtml.innerHTML='';" & vbCrLf
				.Write "img2.width=400;" & vbCrLf
				.Write "txt2.innerHTML=""生成内容页结束！100"";" & vbCrLf
				.Write "txt3.innerHTML=""总共生成了 <font color=red><b>" & MaxNum & "</b></font> 条,总费时:<font color=red>" & Left((Timer() - StartRefreshTime), 4) & "</font> 秒<br><br><input name='button1' type='button' onclick=javascript:location='ACT.Make.asp?ModeID=" & ModeID & "'; class='button' value=' 返 回 '>"";" & vbCrLf
				.Write "img2.title=""(" & NowNum & ")"";</script>" & vbCrLf
			
			End If
		Else
				.Write "<script>img2.width=""0"";" & vbCrLf
				.Write "txt2.innerHTML=""没有可生成的内容页！<br><br><input name='button1' type='button' onclick=javascript:location='ACT.Make.asp?ModeID=" & ModeID & "'; class='button' value=' 返 回 '>"";" & vbCrLf
				.Write "txt3.innerHTML="""";" & vbCrLf
				.Write "txt4.innerHTML="""";" & vbCrLf
				.Write "document.all.BarShowArea.style.display='none';" & vbCrLf
				.Write "</script>" & vbCrLf
		End If
		End With
		End Sub
		Sub TypeJS(NowNum,TotalNum,itemname)
		  With Response
				.Write "<script>"
				.Write "fsohtml.innerHTML='" & FsoHtmlList & "';" & vbCrLf
				.Write "img2.width=" & Fix((NowNum / TotalNum) * 400) & ";" & vbCrLf
				.Write "txt2.innerHTML=""生成进度:" & FormatNumber(NowNum / TotalNum * 100, 2, -1) & """;" & vbCrLf
				.Write "txt3.innerHTML=""总共需要生成 <font color=red><b>" & TotalNum & "</b></font> " & itemname & ",<font color=red><b>在此过程中请勿刷新此页面！！！</b></font> 系统正在生成第 <font color=red><b>" & NowNum & "</b></font> " & itemname & """;" & vbCrLf
				.Write "img2.title=""(" & NowNum & ")"";</script>" & vbCrLf
				.Flush
		  End With
		End Sub
 %>
