<%@ page language="C#" autoeventwireup="true" inherits="V5Shop.Admin.Data_Database_Restore, V5Shop.Shop.Database" enableviewstatemac="false" enableEventValidation="false" viewStateEncryptionMode="Never" %>

<%@ Register Src="control/ManageHeader.ascx" TagName="ManageHeader" TagPrefix="uc3" %>
<%@ Register Src="control/PageBottom.ascx" TagName="PageBottom" TagPrefix="uc2" %>
<%@ Register Src="control/HiddenField.ascx" TagName="HiddenField" TagPrefix="uc1" %>
<%@ Register TagPrefix="V5Shop" Namespace="V5Shop.Control" Assembly="V5Shop.Control" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="css/css.css" rel="stylesheet" type="text/css" />
    <link href="css/css_list.css" rel="stylesheet" type="text/css" />
    <link href="css/control.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript" language="javascript" src="js/Common.js"></script>
    <script language="javascript" src="js/prototype.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript" src="js/Control_Calendar.js"></script>
    <style>
.xingmu {
    line-height: 20px;
	font-family: "Verdana, ";
	color:#333333;
	font-size:12px;
	font-weight:bolder;
	background:#A8CFEB;
}
.processline,textarea{
    FONT-SIZE: 12px;
	COLOR:#333333;
    text-decoration: none;
    background:#F5FAFF;
	border:2px #9DB3C5 solid;
}
body{
    FONT-FAMILY: "";
    FONT-SIZE: 12px;
    text-decoration: none;
    line-height: 150%;
    /*background:#EBEBEB;*/
    SCROLLBAR-FACE-COLOR: #D5D5D5;
    SCROLLBAR-HIGHLIGHT-COLOR: #9A9A9A;
    SCROLLBAR-SHADOW-COLOR: #9A9A9A;
    SCROLLBAR-3DLIGHT-COLOR: #E0E0E0;
    SCROLLBAR-ARROW-COLOR: #333333;
    SCROLLBAR-TRACK-COLOR: #C5C5C5;
    SCROLLBAR-DARKSHADOW-COLOR: #E8E8E8;
    padding:0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 0px;
}

</style>
</head>
<body>
    <form id="form1" runat="server">
        
        <div>
            <div id="search" runat="server">
                <div style="padding: 10px 20px; border: 1px #eeeeee solid; background: #f7f7f7">
                    &nbsp;
                    <input type="checkbox" id="CheckAllBox" onclick="CheckAll()" class="checkbox" />
                    全选
                    <asp:LinkButton ID="btnRestore" runat="server" ForeColor="#4B6888" 
                        OnClientClick="return CheckEdit()" OnClick="btnRestore_Click"><img src="images/icon/key_output.gif" /> 恢复</asp:LinkButton>
                    <asp:LinkButton ID="btnDel" runat="server" ForeColor="#4B6888" OnClick="btnDel_Click"
                        OnClientClick="return CheckDel()"><img src="images/icon/key_delete.gif" /> 删除</asp:LinkButton>
                </div>
            </div>
            <div class="listborder" runat="server" id="ShowBakFileList">
                <V5Shop:V5ShopGridView ID="GridViewShow" runat="server" AllowPaging="True" AllowSorting="True"
                    AutoGenerateColumns="False" BorderWidth="0px" CacheName="TableCache_" CssClass="datalist"
                    GridLines="None" LabelArray="" MultiEditMode="False" PageSize="15" TableName=""
                    Width="100%">
                    <PagerSettings Mode="NumericFirstLast" />
                    <Columns>
                        <asp:TemplateField>
                            <itemstyle horizontalalign="Center" width="3%" />
                            <itemtemplate>
                                <input runat="server" Value='<%# Eval("ID") %>' ID="CheckBoxID" type="checkbox" onmouseover="this.mouse='over'" onmouseout="this.mouse='out'" mouse="out" class="checkbox">
                            
</itemtemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="Name" HeaderText="文件名称" SortExpression="Name" />
                        <asp:BoundField DataField="Notice" HeaderText="分卷" SortExpression="Notice" />
                        <asp:BoundField DataField="Size" HeaderText="大小(KB)" SortExpression="Size" />
                        <asp:BoundField DataField="Date" HeaderText="创建日期" SortExpression="Date" />
                    </Columns>
                    <HeaderStyle CssClass="category" />
                </V5Shop:V5ShopGridView>
            </div>
            <div class="listborder" runat="server" visible="false" id="ShowRestore">
            <table id="OperateTable" width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                    <td align="center" colspan="2" style="padding:30px 0 20px">
                        <div id="RefreshSchedule">
                            <div class="processline" align="left" style="width: 400px;">
                                <div id="RefreshLen" class="xingmu" style="width: 0px;">
                                    <span class="xingmu">0%</span>
                                </div>
                            </div>
                            <span id="CheckBakFile" align="left" style="color:#009900">
                            正在检测当前备份卷是否完整</span>
                            <span id="schedule" align="left" style="display: none">
                                共有{$totalcount}卷需要恢复.</span>
                            <span id="wait1" style="display: none">.</span>                                
                             <span id="totalcount" align="center" style="display: none"></span>
                            <br />
                            <br />
                        </div>
                  </td>
                </tr>
                <tr>
                    <td height="30" align="center" colspan="2">
                        <input type="hidden" id="filename" value=''  runat="server"/>
                        <input type="button" id="btnBeginRestore" value="开始恢复" onclick="RestoreData()"  runat="server" class="button"/>
                        <input type="button" id="btnReturn" value="返回列表" onclick="window.location.href='Data_Database_Restore.aspx'" class="button"/>
                    </td>
                </tr>
            </table>            
            </div>
            <div id="hiddenfield">
                <asp:HiddenField ID="CheckedIDS" runat="server" Value="0" />
                <asp:HiddenField ID="PageIndex" runat="server" Value="0" />
                <asp:HiddenField ID="MaxPageIndex" runat="server" Value="0" />
                <uc1:HiddenField ID="Alert" runat="server" />
            </div>
            
        </div>
    </form>
    <script language="javascript" type="text/javascript">
    var isfirst=true;
/*以下检测当前是否发布*/
function CheckBakFile()
{
    $('wait1').style.display="";
    HiddenControl();
    var url = 'Data_Database_Restore.aspx?ChcekBakFile=true&d='+Date()+'&filename='+$('filename').value;
    var Action = '';
    setTimeout('WaitPreData()',1000);
    var wAjax = new Ajax.Request(url,{method:'get',parameters:Action,onComplete:ShowCheckTimeOut});
}

function ShowCheckTimeOut(OriginalRequest)
{
     var originalrequest = OriginalRequest.responseText;
     setTimeout("ShowCheck("+originalrequest+")",1000);
}

function ShowCheck(originalrequest)
{
    $("wait1").innerHTML="1";
    $("wait1").style.display="none";
    $("totalcount").value=originalrequest;
    if(originalrequest !="0")
    {
        $("CheckBakFile").innerHTML="备份卷检测完成，共有"+originalrequest+"卷备份卷。可以进行数据恢复。"
        ShowControl();
    }
    else
    {
        $("CheckBakFile").innerHTML="检测完毕，备份卷不完整，您无法恢复数据。"
        $('btnReturn').disabled=false;
    }
}
/*检测发布结束*/

/*控件状态改变*/
function ShowControl()
{
    $('btnBeginRestore').disabled=false;
    $('btnReturn').disabled=false;
}

function HiddenControl()
{
    $('btnBeginRestore').disabled=true;
    $('btnReturn').disabled=true;
}
/*控件状态改变*/

<%=startcheck %>

/*以下是进度条脚本.*/
    function ShowWaitStatus(index){
    var id = "wait" + index;
    $(id).innerHTML = $(id).innerHTML + ".";
    if($(id).innerHTML == "............"){
        $(id).innerHTML = ".";
    }
}
function WaitPreData(){
    if($("wait1").innerHTML=="1")
    {
        return;
    }
    ShowWaitStatus(1);
    setTimeout('WaitPreData()', 1000);
}

/*显示统计结果，开始发布页面*/
function RestoreData()
{
   HiddenControl();
   $('CheckBakFile').style.display="none";
   $('schedule').style.display="";
   $('wait1').style.display="";
   $("wait1").innerHTML=".";
   setTimeout('WaitPreData()',1000);   
   StartCount($('filename').value);
}

/*开始统计进度*/
function StartCount(filename)
{
    if(isfirst){
        $('schedule').innerHTML= " 共有" + $('totalcount').value + "备份卷需要恢复.正在恢复卷头";
    }

    var url = 'Data_Database_Restore.aspx?RestoreData=true&d='+Date()+'&filename='+filename;
    var Action = '';
    var wAjax = new Ajax.Request(url,{method:'get',parameters:Action,onComplete:IsOver});
 
}

/*进度计算并显示*/
function IsOver(OriginalRequest)
{
    isfirst=false;
    var strRefreshLen=OriginalRequest.responseText.split("$")[2];
    var strFileName=OriginalRequest.responseText.split("$")[1];
    var strErr=OriginalRequest.responseText.split("$")[0];
    if(strRefreshLen==$('totalcount').value)
    {
        $('wait1').style.display="none";
        $("wait1").innerHTML="1";
		$("RefreshLen").style.width ="100%";
		$("RefreshLen").innerHTML="&nbsp;<span class=\"xingmu\">100%</span>";
        $('schedule').innerHTML= " 共有" + $('totalcount').value + "备份卷需要恢复.已经恢复" + strRefreshLen + "个备份卷.恢复完成";
        $('btnReturn').disabled=false;
        return;
    }
    else if(strErr!="")
    {
        $('wait1').style.display="none";
        $("wait1").innerHTML="1";
        $('schedule').innerHTML= " 数据恢复失败，请与管理员联系。错误描述如下："+strErr;
        $('btnReturn').disabled=false;
        return;
    }
    else
    {
    	var percent=(strRefreshLen/$('totalcount').value)*100;
		percent=Math.round(percent);
		$("RefreshLen").style.width =percent+"%";
		$("RefreshLen").innerHTML="&nbsp;<span class=\"xingmu\">"+percent+"%</span>";
        $('schedule').innerHTML= " 共有" + $('totalcount').value + "备份卷需要恢复.正在恢复" + strRefreshLen + "个备份卷";
        StartCount(strFileName);
    }
}

</script>
</body>
</html>
