<!--#include file="inc/conn.asp"-->
<!--#include file="inc/function.asp"-->
<%
Dim Rs,Sql,SqlItem,RsItem,Action,FoundErr,ErrMsg
Dim HistrolyID,ItemID,ChannelID,ClassID,SpecialID,ArticleID,Title,CollecDate,NewsUrl,Result
Dim  Arr_Histroly,Arr_ArticleID,i_Arr,Del,Flag
Dim MaxPerPage,CurrentPage,AllPage,HistrolyNum,i_His
MaxPerPage=20
FoundErr=False
Del=Trim(Request("Del"))
Action=Trim(Request("Action"))
If Del="Del" Then
   Call DelHistroly()
End If
If FoundErr<>True Then
   Call Main()
else
   Call WriteErrMsg(ErrMsg)
End If
'关闭数据库链接
Call CloseConn()
Call CloseConnItem()
%>

<%Sub Main%>
<html>
<head>
<title>信息采集系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../css/Admin_Style.css">
<style type="text/css">
.ButtonList {
	BORDER-RIGHT: #000000 2px solid; BORDER-TOP: #ffffff 2px solid; BORDER-LEFT: #ffffff 2px solid; CURSOR: default; BORDER-BOTTOM: #999999 2px solid; BACKGROUND-COLOR: #e6e6e6
}
</style>
<SCRIPT language=javascript>
function unselectall(thisform)
{
    if(thisform.chkAll.checked)
	{
		thisform.chkAll.checked = thisform.chkAll.checked&0;
    } 	
}

function CheckAll(thisform)
{
	for (var i=0;i<thisform.elements.length;i++)
    {
	var e = thisform.elements[i];
	if (e.Name != "chkAll"&&e.disabled!=true)
		e.checked = thisform.chkAll.checked;
    }
}
</script>
</head>
 


<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table cellpadding="0" cellspacing="1" border="0" width="100%" class="border" align=center>
  <tr class="topbg">
	<td height="22" colspan="2" align="center"><strong>采 集 系 统 历 史 记 录 管 理</strong></td>
  </tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border">
  <tr class="tdbg"> 
    <td height="30" width="65"><strong>管理导航：</strong></td>  
    <td height="30"><a href="Admin_ItemHistroly.asp">管理首页</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="Admin_ItemHistroly.asp?Action=Succeed">成功记录</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="Admin_ItemHistroly.asp?Action=Failure">失败记录</a></td>     
  </tr>         
</table>    
<br>   
<%                             
Set RsItem=server.createobject("adodb.recordset")         
SqlItem="select * from Websen_histroly"
If Action="Succeed"  Then
   SqlItem=SqlItem  &  " Where  Result=True"
   Flag="成 功 记 录"
ElseIf Action="Failure"  Then
   SqlItem=SqlItem  &  " Where  Result=False"
   Flag="失 败 记 录"
Else
   Flag="所 有 记 录"
End  If
%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border" >
    <tr> 
      <td height="22" colspan="2" class="title"> <div align="center"><strong>历  史  记  录 －　<%=Flag%></strong></div></td>
    </tr>
</table>
  <table class="border" border="0" cellspacing="1" width="100%" cellpadding="0">         
   <form name="form1" method="POST" action="Admin_ItemHistroly.asp">         
     <tr class="tdbg" style="padding: 0px 2px;">         
      <td width="49" height="22" align="center" class=ButtonList>选择</td>                 
      <td width="134" align="center" class=ButtonList>项目名称</td>         
      <td width="309" align="center" class=ButtonList>信息标题</td>
      <td width="115" height="22" align="center" class=ButtonList>频道</td> 
      <td width="156" height="22" align="center" class=ButtonList>栏目</td> 
      <td width="83" align="center" class=ButtonList>来源</td>        
      <td width="72" align="center" class=ButtonList>结果</td>
      <td width="80" height="22" align="center" class=ButtonList>操作</td>         
     </tr>         
<%
If Request("page")<>"" then
    CurrentPage=Cint(Request("Page"))
Else
    CurrentPage=1
End if 
SqlItem=SqlItem  &  " order by HistrolyID DESC"
RsItem.open SqlItem,ConnItem,1,1
If (Not RsItem.Eof) and (Not RsItem.Bof) then
   RsItem.PageSize=MaxPerPage
   Allpage=RsItem.PageCount
   If Currentpage>Allpage Then Currentpage=1
   HistrolyNum=RsItem.RecordCount
   RsItem.MoveFirst
   RsItem.AbsolutePage=CurrentPage
   i_His=0
   Do While not RsItem.Eof
%>
    <tr class="tdbg" onMouseOut="this.style.backgroundColor=''" onMouseOver="this.style.backgroundColor='#cccccc'" style="padding: 0px 2px;">          
      <td width="49" align="center">          
        <input type="checkbox" value="<%=RsItem("HistrolyID")%>" name="HistrolyID" onClick="unselectall(this.form)" style="border: 0px;background-color: #E1F4EE;">         
      </td>               
      <td width="134" align="center">          
        <%Call Admin_ShowItem_Name(RsItem("ItemID"))%>         
      </td>         
      <td width="309" align="left"><%=RsItem("Title")%>
      </td>  
      <td width="115" align="center"><%
if RsItem("ChannelID")=1 then
response.write"商业资讯"
elseif RsItem("ChannelID")=2 then
response.write"展会资讯"
else
response.write"未知"
end if
%></td>
      <td width="156" align="center"><%
if RsItem("ChannelID")=1 then
set rs5=server.CreateObject("adodb.recordset")
sql5="select typeid,type from Websen_newstype where typeid="&RsItem("ClassID")
rs5.open sql5,conn,1,1
if not rs5.eof then
response.write"商业资讯 >> "&rs5("type")&""
end if
elseif RsItem("ChannelID")=2 then
set rs51=server.CreateObject("adodb.recordset")
sql51="select id,type from Websen_expoinfotype where id="&RsItem("ClassID")
rs51.open sql51,conn,1,1
if not rs51.eof then
response.write"展会资讯 >> "&rs51("type")&""
end if
else
response.write"未知"
end if
%></td>
      <td width="83" align="center"><a href="<%=RsItem("NewsUrl")%>" target=_blank title=<%=RsItem("NewsUrl")%>>点击访问</a></td>     
      <td width="72" align="center">
      <%If RsItem("Result")=True Then
           Response.write "成功"
        ElseIf RsItem("Result")=False Then
           Response.Write "<font color=red>失败</font>"
        Else
           Response.Write "<font color=red>异常</font>"
        End If
      %>
      </td>
      <td width="80" align="center">                           
      <a href="Admin_ItemHistroly.asp?Action=<%=Action%>&Del=Del&HistrolyID=<%=RsItem("HistrolyID")%>" onclick='return confirm("确定要删除此记录吗？");'>删除</a>                 
      </td>         
    </tr>         
<%         
           i_His=i_His+1
           If i_His > MaxPerPage Then
              Exit Do
           End If
        RsItem.Movenext         
   Loop         
%>         
    <tr class="tdbg">          
      <td colspan=8 height="30">       
        <input name="Del" type="hidden" id="Del" value="Del">   
        <input name="Action" type="hidden" id="Action" value="<%=Action%>"> 
        <input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox" style="border: 0px;background-color: #E1F4EE;">全选
      </td>         
    </tr> 
    <tr class="tdbg">          
      <td colspan=8 height="30" align=center>
        <input type="submit" value="清除选中记录" name="DelFlag" onclick='return confirm("确定要清除所选记录吗？");' style="cursor: hand;background-color: #cccccc;">&nbsp;&nbsp;       
        <input type="submit" value="清除失败记录" name="DelFlag" onclick='return confirm("确定要清除所有失败记录吗？");' style="cursor: hand;background-color: #cccccc;">
        &nbsp;
        <input type="submit" value="清空所有记录" name="DelFlag" onclick='return confirm("确定要清除所有记录吗？");' style="cursor: hand;background-color: #cccccc;">
      </td>         
    </tr> 
    <tr class="tdbg">          
      <td colspan=8 height="30">          
        
      </td>         
    </tr>       
<%Else%>
<tr class="tdbg">
        <td colspan='9' class="tdbg" align="center"><br>系统中暂无历史记录！</td>
</tr> 
<%End  If%>       
<%         
RsItem.Close         
Set RsItem=nothing           
%>         
</form>         
</table>  
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border" >
    <tr> 
      <td height="22" colspan="2" class="tdbg">
<%
Response.Write ShowPage("Admin_ItemHistroly.asp?Action="& Action,HistrolyNum,MaxPerPage,True,True," 个记录")
%>

      </td>
    </tr>
</table>
<!--#include file="Admin_ItemFoot.asp"-->           
</body>         
</html>
<%End Sub%>
<%Sub DelHistroly
Dim DelFlag
DelFlag=Trim(Request("DelFlag"))
HistrolyID=Trim(Request("HistrolyID"))
If HistrolyID<>"" Then
   HistrolyID=Replace(HistrolyID," ","")
End If
If DelFlag="清除选中记录" Then
   If HistrolyID="" Then
      FoundErr=True
      ErrMsg=ErrMsg & "<br><li>请选择要删除的记录</li>"
   Else
      HistrolyID=Replace(HistrolyID," ","")
      SqlItem="Delete From [Websen_histroly] Where HistrolyID in(" & HistrolyID & ")"
   End If
ElseIf DelFlag="清除失败记录" Then
   SqlItem="Delete From [Histroly] Where Result=False"
ElseIf DelFlag="清除失效记录" Then
   Set Rs=server.createobject("adodb.recordset")
   Sql="Select ArticleID From PE_Article Where Deleted=False"
   Rs.open Sql,Conn,1,1
   If (Not Rs.Eof) And (Not Rs.Bof) Then
      Do While not rs.eof
         Arr_ArticleID=Arr_ArticleID & "," & CStr(rs("ArticleID"))
      Rs.MoveNext
      Loop
   End  If
   Rs.Close
   Set Rs=Nothing
   If Arr_ArticleID<>"" Then
      Arr_ArticleID=0 & Arr_ArticleID
      SqlItem="Delete From [Websen_histroly] Where ArticleID Not In(" & Arr_ArticleID & ")"
   Else
      SqlItem="Delete From [Websen_histroly]"
   End If
ElseIf DelFlag="清空所有记录" Then
   SqlItem="Delete From [Websen_histroly]"
Else
   If HistrolyID="" Then
      FoundErr=True
      ErrMsg=ErrMsg & "<br><li>请选择要删除的记录</li>"
   Else
      HistrolyID=Replace(HistrolyID," ","")
      SqlItem="Delete From [Websen_histroly] Where HistrolyID In(" & HistrolyID & ")"
   End If
End if

If FoundErr<>True Then
   ConnItem.Execute(SqlItem)
End If
End Sub
%>