<%@Page Language="C#" Inherits="IWMS.Admin.GatherDb" MasterPageFile="admin.master"%>
<asp:Content ContentPlaceHolderId="cphHead" runat="server">
	<script type="text/javascript">
	<!--
		<asp:Literal id="sortArr" runat="server"/>
		
		function WriteProcess(full, part){
			var w = parseInt(part*200/full);
			var s = "<center style='font-size:12px;font-family:Arial;'><div style='width:200px; height:10px; border:1px #F7D4D4 solid;font-size:5px;' align='left'>";
				s += "<div style='width:"+ w +"px;height:10px;background:#4DADF4;'><\/div>";
				s += "<\/div>";
				s += parseInt(part*100/full) + "%<\/center>";
			return s;
		}
		
		function Refresh(){
			window.setTimeout("location.href=location.href;",4000);
		}
		//WriteProcess(308,20);
		
		function WriteState(){
			var s;
			if (<%=gState.Processing.ToString().ToLower()%>){
				s = "需采集 <%=gState.NeedAdd%> 条,";
				s += "已添加 <%=gState.AddNum%> 条,";
				s += WriteProcess(<%=gState.NeedAdd%>,<%=gState.AddNum%>);
				if (<%=gState.Error.Length>0 ? "true" : "false"%>){
					s += "　<a href=\"#\" title=\"<%=gState.Error.Replace("\"","&quot;").Replace("\r","&#10;").Replace("\n","&#13")%>\">错误<\/a>" ;
				}
				s += "　<a href=\"javascript:document.location=document.location.href\">刷新<\/a>";
				Refresh();
			}else{
				s = "上次添加 <%=gState.AddNum%> 条";
				if (<%=gState.Error.Length>0 ? "true" : "false"%>){
					s += "　<a href=\"#\" title=\"<%=gState.Error.Replace("\"","&quot;").Replace("\r","&#10;").Replace("\n","&#13")%>\">错误<\/a>" ;
				}
			}
			document.getElementById("<%=myLabel.ClientID%>").innerHTML = s;
		}
	-->
	</script>
</asp:Content>
<asp:Content ContentPlaceHolderId="cphMain" runat="server">

	<asp:Label id="myLabel" class="msgBar" EnableViewState="false" runat="server"/>
	<form id="myForm" runat="server">
		<asp:ValidationSummary 
			 DisplayMode="BulletList" 
			 EnableClientScript="true"
			 ShowSummary="false"
			 ShowMessageBox="true"                        
			 HeaderText="请正确填写以下内容"
			 runat="server"/>
	
	<div class="mframe">
	<div class="tl"></div>
	<div class="rt"></div>
	<div class="tm">
		<span class="tt">数据库采集规则</span>
	　<asp:Button id="stop" Onclick="stop_OnClick" Text="停止采集" Visible="false" CausesValidation="false" runat="server"/>
	</div>
	<div class="wrapper">
	<div class="ml"></div>
	<div class="mr"></div>
	<div class="mm">
		<ASP:DataGrid id="MyDataGrid" runat="server"
				Width="100%"
				align="center"
				ShowHeader="true"
				ShowFooter="false"
				AllowPaging="true"
				AutoGenerateColumns="false"
				DataKeyField="id"
				OnDeleteCommand="MyDataGrid_Delete"
				OnPageIndexChanged="MyDataGrid_Page"
				CssClass="grid"
				BorderColor="#cccccc"
				HeaderStyle-CssClass="gridHead"
				ItemStyle-CssClass="tdbg"
				PageSize="10"
				CellPadding="6"
				CellSpacing="0" >
			
			<Columns>
				<asp:TemplateColumn>
					<ItemTemplate>
						<input type="radio" name="rid" value='<%#Eval("id")%>'/>
					</ItemTemplate>
					<ItemStyle Width="20" HorizontalAlign="center" />
				</asp:TemplateColumn>
				<asp:TemplateColumn
					HeaderText="采集名称"
					>
					<ItemTemplate>
						<a href="admin_gatherDbRuleAdd.aspx?id=<%#Eval("id")%>"><%#Eval("name")%></a>
					</ItemTemplate>
					<ItemStyle HorizontalAlign="left"/>
				</asp:TemplateColumn>
				<asp:BoundColumn
					HeaderText="采集数"
					DataField="gatherNum"
					>
					<ItemStyle Width="50" HorizontalAlign="center" />
				</asp:BoundColumn>
				<asp:TemplateColumn
					HeaderText="不审"
					>
					<ItemTemplate>
						<%#(bool)Eval("passed") ? "√" : "×"%>
					</ItemTemplate>
					<ItemStyle Width="35" HorizontalAlign="center" />
				</asp:TemplateColumn>
				<asp:ButtonColumn
					ButtonType="LinkButton"
					CommandName="Delete"
					Text="删除" >
					<ItemStyle Width="40" HorizontalAlign="center" />
				</asp:Buttoncolumn>
			</Columns>
		</ASP:DataGrid>
	</div>
	</div>
	<div class="bl"></div>
	<div class="br"></div>
	<div class="bm"></div>
	</div>
	
	<asp:PlaceHolder id="phGather" runat="server">
	<div class="mframe">
	<div class="tl"></div>
	<div class="rt"></div>
	<div class="tm">
		<span class="tt">开始采集</span>
	</div>
	<div class="wrapper">
	<div class="ml"></div>
	<div class="mr"></div>
	<div class="mm">
		<table width="100%">
		<tr><td>
			入库分类
			<asp:DropDownList id="sortID"
				runat="server"/>
			<asp:RequiredFieldValidator
				ControlToValidate="sortID"
				ErrorMessage="必须选择采集新闻入库分类"
				Display="None"
				runat="server"/>
			<script type="text/javascript">
			<!--
			function setOptionColor(){
				var obj=document.getElementById("<%=sortID.ClientID%>");
				var keepSelect=false;
				var dispChilds=0;	// 需显示下级数
				// 非可添加项变色
				for (var i=obj.options.length-1;i>=0;i-=1){
					var id = parseInt(obj.options[i].value);
					if (id==0){
						continue;
					}
					if (!sArr[id][2]){
						if (sArr[id][0]==0 || dispChilds==0){
							if (document.all){
								obj.options.remove(i);
							}else{
								obj.options[i]=null;
							}
						}else{
							obj.options[i].value="";
							obj.options[i].style.color="gray";
						}
					}else{
						// 深度大于0为子类
						if (sArr[id][3]>0) {
							dispChilds+=1;
						}
						if (obj.options[i].selected){
							keepSelect=true;
						}
					}
					if (sArr[id][3]==0) {
						dispChilds=0;
					}
				}
				// 选择第一个可添加项
				if (!keepSelect) {
					for (var i=0;i<obj.options.length;i++)
					{
						if ( obj.options[i].value != "") {
							obj.selectedIndex = i;
							break;
						}
					}
				}
			}
			setOptionColor();
			-->
			</script>
			
			采集新闻数 <asp:TextBox Columns="7" MaxLength="7" id="gatherNum" Style="text-align:right" runat="server"/>
			<asp:RegularExpressionValidator
				ControlToValidate="gatherNum"
				ValidationExpression="\d+"
				ErrorMessage="采集数只能是数字"
				Display="None"
				runat="server"/>
			
			&nbsp;
			<asp:CheckBox id="decodeContent" Text="内容HtmlDecode" runat="server"/>
	
			&nbsp; &nbsp;
			不经过审核
			<asp:RadioButtonList id="passed" RepeatDirection="Horizontal"
				RepeatLayout="Flow"
				runat="server">
				<asp:ListItem>是</asp:ListItem>
				<asp:ListItem>否</asp:ListItem>
			</asp:RadioButtonList>
			
		</td>
		</tr>
		<tr><td>
			<div style="position:relative; float:left; width:100px">
			sql条件语句：
			</div>
			<div style="position:relative;">
			<asp:TextBox id="filter" TextMode="MultiLine" Columns="50" rows="3" runat="server"/>
			</div>
		</td>
		</tr>
		<tr>
		<td>
			<asp:Button id="Submit" Onclick="Submit_OnClick" Text="开始采集" runat="server"/>
			&nbsp; <input type="button" onclick="document.location.href=document.location.href;" value="刷新"/>
		</td>
		<td>
		</td>
		</tr>
		</table>
	</div>
	</div>
	<div class="bl"></div>
	<div class="br"></div>
	<div class="bm"></div>
	</div>
	
	</asp:PlaceHolder>
	</form>

</asp:Content>