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

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>子站数据备份</title>
    <meta name="description" content="overview &amp; stats" />
    <!--#include file = "../assets/head.htm" -->
    
</head>
<body class="no-skin">
    <form id="frmBackup" method="post" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <div class="breadcrumbs" id="breadcrumbs">
                <script type="text/javascript">
                    try { ace.settings.check('breadcrumbs', 'fixed') } catch (e) { }
                </script>

 			<ul class="breadcrumb">
					<li>
						<i class="ace-icon fa fa-home home-icon"></i>
						主页
					</li>
					<li>站点管理</li>
					<li class="active">站点备份</li>
			</ul><!-- /.breadcrumb -->

                <!-- /section:basics/content.searchbox -->
            </div>
            <!-- /section:basics/content.breadcrumbs -->

            <div class="page-content">
                <!-- PAGE CONTENT BEGINS -->

                <div class="page-header">
                    <div class="row">
					    <div class="col-xs-5">
                            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                                <ContentTemplate>
                                    <asp:DropDownList ID="ddlWeb" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlWeb_SelectedIndexChanged">
                                    </asp:DropDownList>
                                    &nbsp;
                                    <asp:DropDownList ID="ddlUnit" runat="server">
                                    </asp:DropDownList>
                                    &nbsp;<asp:Button ID="btnQuery" CssClass="btn btn-sm btn-primary" runat="server" Text="查看" OnClick="btnQuery_Click" />
                                </ContentTemplate>
                                <Triggers>
                                    <asp:AsyncPostBackTrigger ControlID="ddlWeb" EventName="SelectedIndexChanged" />
                                </Triggers>
                            </asp:UpdatePanel>
                        </div>
                        
                        <div class="form-horizontal col-xs-7" runat="server" id="editRemark" visible="false">
                            
                                <label class="col-sm-1 control-label no-padding-right" for="txtName">名称：</label>
                                <div class="col-sm-3">
                                    <asp:TextBox ID="txtName" runat="server" Enabled="False" CssClass="col-xs-3 col-sm-12"></asp:TextBox>
                                </div>
                                <label class="col-sm-1 control-label no-padding-right" for="txtRemark">备注：</label>
                                <div class="col-sm-3">
                                    <asp:TextBox ID="txtRemark" CssClass="col-xs-3 col-sm-12" runat="server" Rows="1" TextMode="MultiLine"></asp:TextBox>
                                </div>
                                <div class="col-md-offset-1">
                                    <asp:Button ID="btnSave" CssClass="btn btn-sm btn-primary" runat="server" Text="修改" OnClick="btnSave_Click"></asp:Button>
                                    &nbsp;&nbsp;
                                    <asp:Button ID="btnCancel" CssClass="btn btn-sm btn-primary" runat="server" OnClick="btnCancel_Click" Text="取消" />
                                    <%--<asp:Button ID="btnRefresh" CssClass="btn btn-sm btn-primary" runat="server" OnClick="btnRefresh_Click" Text="刷新列表" />--%>
                                </div>
                            
                        </div>
                        
                    </div>
                </div>

                <div class="row">
                    <div class="col-xs-12">
                        <asp:DataGrid ID="backupList" CssClass="table table-striped table-bordered" 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>
                                        <div class="action-buttons">
                                        <asp:LinkButton ID="btnUpdate" runat="server" CommandName="update"><i class="ace-icon fa fa-pencil bigger-130 green" title="修改备注"></i></asp:LinkButton>
                                        &nbsp;
                                        <asp:LinkButton ID="btnDelete" runat="server" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.name") %>' CausesValidation="False" CommandName="delete"><i class="ace-icon fa fa-trash-o bigger-130 red" title="删除"></i></asp:LinkButton>
                                        &nbsp;
                                        <asp:HyperLink ID="downBackup" runat="server" NavigateUrl='<%# "./down.aspx?pkId="+DataBinder.Eval(Container, "DataItem.pkId") %>' Target="_blank" ><i class="ace-icon fa fa-download grey" title="下载"></i></asp:HyperLink>
                                        
                                        <%--<asp:LinkButton ID="btnView" runat="server" CommandName="view" Visible="False">查看信息</asp:LinkButton>--%>
                                    </div>
                                            </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>
                        
                        <div class="clearfix">
                            <div class="col-xs-12">
                                <asp:Label ID="lblPage" runat="server"></asp:Label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row form-horizontal">
                    <div class="col-xs-12">
                        <div class="hr hr-16 hr-dotted"></div>
                        <div class="col-sm-4 col-sm-offset-2">
                            <asp:ListBox ID="schoolList" Width="100%" Rows="10" Height="270px" runat="server"></asp:ListBox>
                        </div>
                        <div class="col-sm-6">
                            <p>
                                <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>
                            </p>
                            <p>
                                <asp:Button ID="btnSelSchools" CssClass="btn btn-sm btn-primary" runat="server" Text="选择站点"></asp:Button>
                            </p>
                            <p>
                                <asp:Button ID="btnMulti" CssClass="btn btn-sm btn-primary" Text="开始备份" runat="server" OnClientClick="javascript:return queryform();" OnClick="btnMulti_Click"></asp:Button>
                            </p>
                            <p>说明：</p>
                            <p>1、为了考虑到空间大小的问题，特引入备份类型的概念。</p>
                            <p>2、完整备份：备份包较大，备份Images下面的内容和数据，只需在平台操作即可。</p>
                            <p>3、数据备份：备份包较小，只备份数据库，需要Asp管理员手工备份对应子站的Images。</p>
                            <p>4、采用数据备份时，建议备份包名称和手动备份的Images包名称一致，方便管理和查找。</p>
                            
                        <input id="d_name" type="hidden" name="Hidden1" runat="server" />
                        <input id="d_value" type="hidden" name="Hidden2" runat="server" />
                        <asp:TextBox ID="txtID" runat="server" Visible="False"></asp:TextBox>
                        <asp:TextBox ID="txtSchoolName" runat="server" Visible="False"></asp:TextBox>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <!--#include file = "../assets/foot.htm" -->
    <script type="text/javascript">

        jQuery(function ($) {
            $("#btnSelSchools").click(function () {
                return true;
            }).fancybox({
                autoSize: false,
                'type': 'iframe',
                'width': 600,
                'height': 450,
                'hideOnOverlayClick': false,
                'href': 'selectSchools.aspx'
            });
        })
    </script>
    <script language="javascript">
        function showInfoZip(pkId) {
            arr = showModalDialog("showInfo.aspx?pkId=" + pkId, window, "dialogWidth:25.5em; dialogHeight:20.5em; status:0");
        }

        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>
</body>
</html>



