<%@ Page Inherits="Dvbbs.bbs.UI.Admin.admin_batch_delete" %>
<%@ Register tagPrefix="Dvbbs" namespace="Dvbbs.Controls" assembly="Dvbbs.Web"%>
<%@ Register tagPrefix="bbs" tagName="AdminHeader" src="controls/admin_header.ascx"%>
<%@ Register tagPrefix="bbs" tagName="AdminFooter" src="controls/admin_footer.ascx"%>
<bbs:AdminHeader title='批量删除主题和回帖' runat='server' ID="Adminheader1" />
<script language="javascript" src="scripts/calendar.js"></script>
<script type="text/javascript" language="javascript">
<!--
 var AjaxRequest=new Object();
 AjaxRequest.Send=function(method,url,callback,data)
 {
   var ajaxobj;
   if(window.ActiveXObject)
   {
     var objlist=['Microsoft.XMLHTTP','Msxml2.XMLHTTP'];
     for(var i=0;i<objlist.length;i++)
     {
       try
       {
          ajaxobj=new ActiveXObject(objlist[i]);
       }
       catch($e)
       {
       
       }
     }
   }
   else if(window.XMLHttpRequest)
   {
      ajaxobj=new XMLHttpRequest();
   }
   ajaxobj.onreadystatechange=function()
   {
      if(ajaxobj.readyState==4)
      {
        if(ajaxobj.status==200)
        {
           callback(ajaxobj);
        }
      }
   }
   if(method.toLowerCase()=="get")
   {
     ajaxobj.open("GET",url,true);
     ajaxobj.send(null);
   }
   else if(method.toLowerCase()=="post")
   {
     ajaxobj.open("POST",url,true);
     ajaxobj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
     ajaxobj.send(data);
   }
 }
 AjaxRequest.SendGet=function(url,data,callback)
 {   
    AjaxRequest.Send('GET',url,callback,data);
 }
 AjaxRequest.SendPost=function(url,data,callback)
 {
   AjaxRequest.Send('Post',url,callback,data);
 }
 var time=0; //已用时
 function ReceiveServerData(response)
 {
    var _data_ = response.responseText;
	_data_ = _data_.split(',');
	if(_data_[0] == 'OK'){
		document.getElementById('SetBar').innerHTML='成功重建帖子索引。';
		document.getElementById('StartRebuild').disabled=false;
		response.Abort();
		return;
	}if(_data_[0] == 'ERR'){
	    document.getElementById('SetBar').innerHTML='重建过程中发生错误，请检查您的数据库或网络连接。';
		document.getElementById('StartRebuild').disabled = false;
		response.Abort();
		return;
	}else{
	    time=time+parseFloat(_data_[3]); //已用时
	    var speed=Math.round(_data_[3]/300*1000000)/1000000; //单位 秒/条
	    var leftime=0;
	    var totaltime=Math.round(speed * parseFloat(_data_[2])*1000)/1000;  //估计需要的时间
	    var leftime=Math.round((_data_[2]*speed-time)*1000)/1000; //估计剩余时间
	    if(leftime<0)
	    {
	      leftime=Math.round(Math.random()*1000)/1000;
	    }
	    var timetips='处理速度约为:<font color=black>'+speed+'秒/条</font><br />共需耗费时间约为：<font color=black>'+totaltime+'秒</font><br />当前已用时：<font color=black>'+time+'秒</font><br />估计剩余时间：<font color=black>'+leftime+'秒</font>';
	    document.getElementById('SetBar').innerHTML= _data_[0]+'<br />'+timetips;
	    response.Abort();
		AjaxRequest.SendGet('admin_batch_delete.aspx?Next='+ _data_[1]+'&Total='+ _data_[2] +'&HtmlAction=RebuildIndex','' ,ReceiveServerData);
	}   
 }
 function RebuildTopicIndex()
 {
    document.getElementById('SetBar').innerHTML='开始重建帖子索引,过程可能会耗费一段时间，请耐心等待。';
    AjaxRequest.SendGet('admin_batch_delete.aspx?HtmlAction=RebuildIndex','',ReceiveServerData);
    document.getElementById('StartRebuild').disabled=true;
 }
//-->
</script>
<form runat='server' ID="Form1">
	<input id="topicids" type="hidden" runat="server" NAME="topicids" /> <input id="replyids" type="hidden" runat="server" NAME="replyids" />
	
	<table width="100%" class="maintable" cellpadding="0" cellspacing="1" border="0">
	      <tr>
	         <td class="title" colspan="2">重建帖子索引</td>
	      </tr>
	      <tr>
	        <td colspan="2"><br />
	          <Button id="StartRebuild" type="button" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)" onMouseOver="IEvent('mouseover',this)"
						onMouseOut="IEvent('mouseout',this)" onclick="RebuildTopicIndex()" class="button_off">点此开始重建</button>
			&nbsp;&nbsp;<div style="border:1px solid #ddd; background-color:#CC9933;height:20px;width:auto;color:blue;text-align:center"
						id="SetBar" name="SetBar">&nbsp;重建帖子索引进度提示条</div>
						<br />
	        </td>
	      </tr>
	    <tr>
	    <td class="title" colspan="2">说明：如果您的主题分页等不正常的话，可以重建帖子索引，但这个过程耗费时间可能会比较长，建议您在空余时间执行此操作。</td>
	    </tr>
	</table>
	<br />
	<br />
	<table width="100%" class="maintable" cellpadding="0" cellspacing="1" border="0" ID="Table3">
		<asp:Panel id="searchPanel" runat="server">
			<tr>
				<td class='title' colspan="2">删除符合条件的主题和回帖（搜索）</td>
			</tr>
			<tr>
				<td class="left" width="30%">发表时间范围(格式 yyyy-mm-dd):</td>
				<td class="right" width="70%"><input id='time1' name='time1' readonly='readonly' onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)"
						onMouseOver="IEvent('mouseover',this)" onMouseOut="IEvent('mouseout',this)" title='点击打开日期控件' onclick='calendar.setHook(this)'
						runat='server' /> - <input id='time2' name='time2' readonly='readonly' onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)"
						onMouseOver="IEvent('mouseover',this)" onMouseOut="IEvent('mouseout',this)" title='点击打开日期控件' onclick='calendar.setHook(this)'
						runat='server' /></td>
			</tr>
			<tr>
				<td class="left">发帖用户名</td>
				<td class="right"><asp:TextBox ID='users' MaxLength='250' onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)"
						onMouseOver="IEvent('mouseover',this)" onMouseOut="IEvent('mouseout',this)" runat='server' />
					<br />
					<span>多用户名中间请用半角逗号 "," 分割</span>
				</td>
			</tr>
			<tr>
				<td class="left">内容关键字</td>
				<td class="right"><asp:TextBox ID='keywords' MaxLength='250' onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)"
						onMouseOver="IEvent('mouseover',this)" onMouseOut="IEvent('mouseout',this)" runat='server' />
					<br />
					<span>多关键字中间请用半角逗号 "," 分割</span>
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center"><asp:button text=" 开始检索 " onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)" onMouseOver="IEvent('mouseover',this)"
						onMouseOut="IEvent('mouseout',this)" onclick="ondelete" class="button_off" runat="server" ID="Button1" /></td>
			</tr>
		</asp:Panel>
	</table>
	<table width="100%" class="maintable" cellpadding="0" cellspacing="1" border="0" ID="Table1">
		<asp:Panel id="confirmPanel" runat="server" visible="false">
			<tr>
				<td class='title' colspan="2">删除符合条件的主题和回帖（删除）</td>
			</tr>
			<tr>
				<td colspan="2"><Dvbbs:Span id="confirmMessage" runat="server" />
					<br />
				是否确定要删除符合条件的主题和回帖？
			</tr>
			<tr>
				<td colspan="2">
					<input class='smallbox' type='checkbox' value='1' name='deduct' /> 是否同时扣除积分及相关扩展积分？</td>
			</tr>
			<tr>
				<td align="center" colspan="2" class="bottom"><asp:button text="  确定  " onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)" onMouseOver="IEvent('mouseover',this)"
						onMouseOut="IEvent('mouseout',this)" onclick="onok" runat="server" class="button_off" ID="Button2" />
					<asp:button text="  取消  " onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)" onMouseOver="IEvent('mouseover',this)"
						onMouseOut="IEvent('mouseout',this)" onclick="oncancel" runat="server" class="button_off" ID="Button3" /></td>
			</tr>
		</asp:Panel>
	</table>
</form>
<bbs:AdminFooter runat='server' ID="Adminfooter1" />
