<%@ Reference Page="~/admin/backup/operate.aspx" %>

<%@ Page Language="c#" Inherits="WebApp.SchoolBackup" EnableEventValidation="false"
    CodeBehind="SchoolBackup.aspx.cs" %>

<!DOCTYPE html>
<!--[if lt IE 9]><html class="lte-ie8"><![endif]-->
<!--[if gt IE 8]><!-->
<html>
<!--<![endif]-->
<head>
    <title>子站数据备份</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!--#include file = "../Css/adminCssEdit.htm" -->
</head>
<body>
    <div class="edit-func-box func-box">
        <div class="hd">
            子站数据备份</div>
        <form id="frmBackup" method="post" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div class="bd">
            <div class="function-hd">
                <div class="search-box fr">
                </div>
                <!--/search-box-->
                <div class="action-field">
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            子站服务器：<asp:DropDownList ID="ddlWeb" runat="server" Width="180px" AutoPostBack="True"
                                OnSelectedIndexChanged="ddlWeb_SelectedIndexChanged">
                            </asp:DropDownList>
                            &nbsp;子站名称：
                            <asp:DropDownList ID="ddlUnit" runat="server">
                            </asp:DropDownList>
                            &nbsp;<asp:Button ID="btnQuery" CssClass="btn" runat="server" Text="查看" OnClick="btnQuery_Click" />
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="ddlWeb" EventName="SelectedIndexChanged" />
                        </Triggers>
                    </asp:UpdatePanel>
                </div>
                <!--/action-field-->
            </div>
            <asp:DataGrid ID="backupList" CssClass="list-table" runat="server" AutoGenerateColumns="False"
                OnItemCommand="backupList_ItemCommand" OnItemDataBound="backupList_ItemDataBound">
                <Columns>
                    <asp:BoundColumn DataField="pkId" HeaderText="ID" HeaderStyle-CssClass="title"></asp:BoundColumn>
                    <asp:TemplateColumn HeaderText="子站名称" HeaderStyle-CssClass="title">
                        <ItemTemplate>
                            <asp:Label ID="lblSchoolName" runat="server" Text='<%# GetSchoolName(DataBinder.Eval(Container, "DataItem.applyID").ToString())%>'>
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:BoundColumn DataField="name" HeaderText="备份包名称" Visible="false" HeaderStyle-CssClass="title">
                    </asp:BoundColumn>
                    <asp:TemplateColumn HeaderText="备份包信息" HeaderStyle-CssClass="title">
                        <ItemTemplate>
                            <asp:Label ID="lblInfo" Style="cursor: default" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.name") %>'>
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:BoundColumn DataField="updatetime" HeaderText="备份时间" Visible="true" HeaderStyle-CssClass="title">
                    </asp:BoundColumn>
                    <asp:TemplateColumn HeaderText="文件大小" HeaderStyle-CssClass="title">
                        <ItemTemplate>
                            <asp:Label ID="lblSize" runat="server" Text='<%# Convert.ToDouble(DataBinder.Eval(Container, "DataItem.fileSize")).ToString("f3") + "M"%>'>
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:BoundColumn DataField="state" HeaderText="备份进程" HeaderStyle-CssClass="title">
                    </asp:BoundColumn>
                    <asp:BoundColumn DataField="remark" HeaderText="备注" HeaderStyle-CssClass="title">
                    </asp:BoundColumn>
                    <asp:BoundColumn DataField="type" HeaderText="备份类型" HeaderStyle-CssClass="title">
                    </asp:BoundColumn>
                    <asp:TemplateColumn HeaderText="执    行" HeaderStyle-CssClass="title">
                        <ItemTemplate>
                            <asp:LinkButton ID="btnUpdate" runat="server" CommandName="update">修改备注</asp:LinkButton>
                            <asp:LinkButton ID="btnDelete" runat="server" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.name") %>'
                                CausesValidation="False" CommandName="delete">删 除</asp:LinkButton>
                            <asp:HyperLink ID="downBackup" runat="server" NavigateUrl='<%# "./down.aspx?pkId="+DataBinder.Eval(Container, "DataItem.pkId") %>'
                                Target="_blank" Visible="False">下  载</asp:HyperLink>
                            <asp:LinkButton ID="btnView" runat="server" CommandName="view" Visible="False">查看信息</asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:BoundColumn Visible="False" DataField="zipName" HeaderText="zipName" HeaderStyle-CssClass="title">
                    </asp:BoundColumn>
                    <asp:BoundColumn DataField="applyID" HeaderText="applyID" Visible="False"></asp:BoundColumn>
                    <asp:BoundColumn DataField="fileSize" HeaderText="fileSize" Visible="False"></asp:BoundColumn>
                </Columns>
            </asp:DataGrid>
            <table class="border" id="Table1" cellspacing="0" cellpadding="4" width="760" align="center">
                <tr class="tdbg">
                    <td valign="top">
                        名称：<asp:TextBox ID="txtName" runat="server" Enabled="False"></asp:TextBox>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;备注：
                        <asp:TextBox ID="txtRemark" CssClass="input-txt input-txt1" runat="server" Rows="1" Font-Names="宋体" Font-Size="9pt"
                            TextMode="MultiLine"></asp:TextBox>&nbsp;<asp:Button ID="btnSave" CssClass="btn"
                                runat="server" Text="修改" OnClick="btnSave_Click"></asp:Button>&nbsp;&nbsp;<asp:Button
                                    ID="btnCancel" CssClass="btn" runat="server" OnClick="btnCancel_Click" Text="取消" />&nbsp;&nbsp;<asp:Button
                                        ID="btnRefresh" CssClass="btn" runat="server" OnClick="btnRefresh_Click" Text="刷新列表" />
                    </td>
                </tr>
            </table>
            <div class="ft">
                <div class="pagination">
                    <asp:Label ID="lblPage" runat="server"></asp:Label>
                </div>
            </div>
        </div>
        <div class="hd">
            子站数据备份</div>
        <div class="bd">
            <table class="border" cellspacing="0" cellpadding="4" width="760" align="center">
                <tr>
                    <td class="tdbg" align="left" width="50%" style="height: 281px">
                        <asp:ListBox ID="schoolList" Width="100%" Rows="10" Height="272px" runat="server">
                        </asp:ListBox>
                    </td>
                    <td style="height: 281px">
                        <table height="100%" cellspacing="0" cellpadding="4" border="0">
                            <tr>
                                <td valign="top" style="width: 357px">
                                    <asp:Button ID="btnSelSchools" CssClass="btn" runat="server" Text="选择子站"></asp:Button>
                                </td>
                            </tr>
                            <tr>
                                <td valign="bottom" style="width: 357px">
                                    <asp:Button ID="btnMulti" CssClass="btn" Text="备份" runat="server" OnClick="btnMulti_Click">
                                    </asp:Button>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 357px">
                                    <asp:DropDownList ID="backupType" runat="server">
                                        <asp:ListItem Selected="True" Value="-1">选择备份类型</asp:ListItem>
                                        <asp:ListItem Value="1">完整备份</asp:ListItem>
                                        <asp:ListItem Value="0">数据备份</asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 357px">
                                    说明：<br />
                                    1、为了考虑到空间大小的问题，特引入备份类型的概念。<br />
                                    2、完整备份：备份包较大，备份Images下面的内容和数据，只需在平台操作即可。<br />
                                    3、数据备份：备份包较小，只备份数据库，需要Asp管理员手工备份对应子站的Images。<br />
                                    4、采用数据备份时，建议备份包名称和手动备份的Images包名称一致，方便管理和查找。
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr class="tdbg">
                    <td align="center" colspan="2">
                        <font face="宋体">
                        <input id="d_name" style="width: 80px; height: 21px" type="hidden" size="8" name="Hidden1"
                            runat="server"><input id="d_value" style="width: 88px; height: 21px" type="hidden"
                                size="9" name="Hidden2" runat="server">
                        <asp:TextBox ID="txtID" runat="server" Visible="False"></asp:TextBox><asp:TextBox
                            ID="txtSchoolName" runat="server" Visible="False"></asp:TextBox></font>
                    </td>
                </tr>
            </table>
        </div>
        </form>
        </div>
</body>
</html>

<script language="javascript">		
			function showInfoZip(pkId)
			{
			arr = showModalDialog("showInfo.aspx?pkId="+pkId , window,"dialogWidth:25.5em; dialogHeight:20.5em; status:0");
			}
			function selectSchools()
			{	
				var arr = showModalDialog("selectSchools.aspx", window, "dialogWidth:500px;dialogHeight:325px;help:no;scroll:no;resizable:yes;status:no");
		   		if(arr!=null)
		   		  location.href="Backup.aspx";
			}
			function DelAll() 
			{
				var selectTo=document.frmBackup.schoolList;
				var nLen = selectTo.length;
				if (nLen<1) return;
				for(var loop=nLen;loop>=0;loop--)
				{ 
               		selectTo.options[loop] = null;
               	}			  
			}
			function checkform(text,value) 
			{				
				var selectFrom=document.frmBackup.schoolList;
			    selectFrom.add(new Option(text,value));
			}
			function queryform() {
			    if (document.getElementById("backupType").value == "-1")
			    {
			        alert("请选择数据备份类型!");
			        return false;
			    }
			    else
			    {
				    var sel=document.frmBackup.schoolList;
				    var nLen = sel.length;
				    var str1="";
				    var str2="";
				    for (var i=0;i<nLen;i++) {
					    if (i>0) 
					    {str2+=",";str1+=",";}
					    str2+=sel.options[i].value;
					    str1+=sel.options[i].text;
				    }
				    document.frmBackup.d_name.value=str1;
				    document.frmBackup.d_value.value=str2;
				    //alert(str1+str2);
				    if(str1.LTrim().RTrim().length==0)
				    {
				        alert("请选择要备份的站点！")
				        return false;
				    }
				    else if(document.getElementById("backupType").value=="0")				    
				    {				
				        return confirm("您选择的是数据备份，该备份方式可以减小备份包大小，并缩短备份时间！\r\n备份数据后，需要马上备份对应子站的Images文件夹，保证数据完整！\r\n您确定要执行数据备份吗？");        
				    }
				    else
				    {
				        return true;
				    }
				    //return true;
				}
			}
		    String.prototype.Trim = function() 
            { 
            return this.replace(/(^\s*)|(\s*$)/g, ""); 
            } 

            String.prototype.LTrim = function() 
            { 
            return this.replace(/(^\s*)/g, ""); 
            } 

            String.prototype.RTrim = function() 
            { 
            return this.replace(/(\s*$)/g, ""); 
            } 		
</script>

