<%@ Page Language="c#" Inherits="Web.Wpdcc.operate" CodeBehind="operate.aspx.cs" %>

<!DOCTYPE html>
<!--[if lt IE 9]><html class="lte-ie8"><![endif]-->
<!--[if gt IE 8]><!-->
<html>
<!--<![endif]-->
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Backup and Restore</title>
    <!--#include file="../Css/head.htm"-->
</head>
<body>
    <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-desktop"></i>
                    <a href="../welcome.aspx">主页</a>
                </li>
                <li>网站数据分析
                </li>
                <li class="active">网站备份</li>
            </ul>
            <!-- /.breadcrumb -->

            <!-- /section:basics/content.searchbox -->
        </div>
        <!-- /section:basics/content.breadcrumbs -->
        <div class="page-content">
            <div class="row">
                <div class="col-xs-12">
                    <!-- PAGE CONTENT BEGINS -->
                    <div class="list-func-box func-box">
                        <form id="system" method="post" runat="server">
                            <div class="bd">
                                <asp:DataGrid ID="pageGrid" runat="server" class="table table-striped table-bordered table-hover" AutoGenerateColumns="False"
                                    OnItemCommand="pageGrid_ItemCommand">
                                    <Columns>
                                        <asp:BoundColumn DataField="pkId" HeaderText="ID" HeaderStyle-CssClass="title"></asp:BoundColumn>
                                        <asp:BoundColumn DataField="name" HeaderText="名称" HeaderStyle-CssClass="title"></asp:BoundColumn>
                                        <asp:TemplateColumn HeaderText="说明" HeaderStyle-CssClass="title">
                                            <HeaderStyle Width="154px"></HeaderStyle>
                                            <ItemTemplate>
                                                <asp:LinkButton ID="AddInfoLinkButton" runat="server" Visible='<%#DataBinder.Eval(Container, "DataItem.remark").ToString().Trim() == "" ? false : false%>'
                                                    CommandName="addInfo">添加说明</asp:LinkButton>
                                                <asp:Label ID="InfoLabel" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.remark") %>'
                                                    Visible='<%# DataBinder.Eval(Container, "DataItem.remark").ToString().Trim() == "" ? false : true %>'
                                                    ToolTip='<%# DataBinder.Eval(Container, "DataItem.remark") %>'>
                                                </asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateColumn>
                                        <asp:BoundColumn DataField="updatetime" HeaderText="备份时间" HeaderStyle-CssClass="title"></asp:BoundColumn>
                                        <asp:BoundColumn HeaderText="文件大小" HeaderStyle-CssClass="title">
                                            <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                                                Font-Underline="False" HorizontalAlign="Left" />
                                        </asp:BoundColumn>
                                        <asp:BoundColumn DataField="type" HeaderText="备份类型" HeaderStyle-CssClass="title"></asp:BoundColumn>
                                        <asp:BoundColumn Visible="False" DataField="zipName" HeaderText="zipName" HeaderStyle-CssClass="title"></asp:BoundColumn>
                                        <asp:BoundColumn Visible="False" DataField="isSystem" HeaderText="是否默认" HeaderStyle-CssClass="title"></asp:BoundColumn>
                                        <asp:BoundColumn Visible="False" DataField="isSystem" HeaderText="isSystem" HeaderStyle-CssClass="title"></asp:BoundColumn>
                                        <asp:TemplateColumn HeaderText="执行" HeaderStyle-CssClass="title">
                                            <ItemTemplate>
                                                <div class="action-buttons">
                                                <asp:LinkButton ID="editt" runat="server" CommandName="edit"  CssClass="blue" data-toggle="tooltip" data-placement="bottom" title="编辑"><i class="ace-icon fa fa-pencil bigger-120" ></i></asp:LinkButton>
                            <asp:LinkButton ID="copyy" runat="server" CommandName="copy1" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.name") %>' data-toggle="tooltip" data-placement="bottom" title="恢复" ><i class="ace-icon fa fa-reply bigger-120 grey " ></i></asp:LinkButton>
                            <asp:HyperLink ID="downBackup" runat="server" Target="_blank" NavigateUrl='<%# "./down.aspx?pkId="+DataBinder.Eval(Container, "DataItem.pkId") %>' data-toggle="tooltip" data-placement="bottom" title="下载"><i class="ace-icon fa fa-download bigger-120 " ></i></asp:HyperLink>
                                                <a rel="Index" href="showinfo.aspx?pkID=<%#Eval("pkID") %>" target="_blank" data-toggle="tooltip" data-placement="bottom" title="查看信息" ><i class="ace-icon fa fa-search bigger-120 light-grey" ></i></a>
                                                <asp:LinkButton ID="previewTemplate" runat="server" CommandName="previewTemplate1" data-toggle="tooltip" data-placement="bottom" title="预览模板" style="display:none;"><i class="ace-icon fa fa-eye bigger-120 green" ></i></asp:LinkButton>
                            <asp:LinkButton ID="dell" runat="server" CommandName="del1" CausesValidation="False" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.name") %>' data-toggle="tooltip" data-placement="bottom" title="删除" ><i class="ace-icon fa fa-trash-o bigger-120 red " ></i></asp:LinkButton>
                                                    </div>
                                            </ItemTemplate>
                                        </asp:TemplateColumn>
                                        <asp:BoundColumn DataField="type" HeaderText="backuptype" Visible="False" HeaderStyle-CssClass="title"></asp:BoundColumn>
                                    </Columns>
                                </asp:DataGrid>
                            </div>
                            <div class="hd">
                                网站备份管理
                            </div>
                            <table class="edit-table">
                                <tr>
                                    <th>备份名称：
                                    </th>
                                    <td>
                                        <asp:TextBox ID="bannerName" runat="server" CssClass="input-md" MaxLength="40"></asp:TextBox>
                                        &emsp;
                    备份模式：
                    <asp:DropDownList ID="backupType" runat="server" CssClass="input-md">
                        <asp:ListItem Value="1">完整备份</asp:ListItem>
                        <asp:ListItem Value="0" Selected="True">数据备份</asp:ListItem>
                        <asp:ListItem Value="2">快捷备份</asp:ListItem>
                    </asp:DropDownList>&emsp;
                    <asp:Button ID="add" runat="server" Text="备 份" CssClass="btn btn-sm btn-primary" OnClientClick="return checkBackup();" OnClick="add_Click"></asp:Button>
                                        <span data-rel="popover" data-trigger="hover" data-placement="right" data-content="网站图片量较大时，推荐用【数据备份】或【快捷备份】模式"   style="display: inline-block;"> 
                                                                <i class="fa fa-question-circle bigger-120 blue" ></i>
                                                            </span>
                                    </td>
                                </tr>
                            </table>
                            <br />
                            <div class="hd">
                                上传备份管理
                            </div>
                            <table class="edit-table">
                                <tr>
                                    <th>备份名称：
                                    </th>
                                    <td>
                                        <asp:Panel ID="Panel2" runat="server" Width="100%">
                                            <asp:TextBox ID="uploadName" runat="server" CssClass="input-md" MaxLength="40"></asp:TextBox>
                                        </asp:Panel>
                                    </td>
                                </tr>
                                <tr>
                                    <th>上传备份文件：</th>
                                    <td><div class="col-xs-8" style="padding-left:0px;"><div class="col-xs-5" style="padding-left:0px;"><input id="uploadfile" type="file" runat="server"  /></div><div class="col-xs-3"><asp:Button ID="upload" runat="server" Text="上传备份文件" OnClick="upload_Click" CssClass="btn btn-sm btn-primary"></asp:Button></div></div></td>
                                </tr>
                                <tr>
                                    <th>备份说明(公用)：
                                    </th>
                                    <td>
                                        <asp:TextBox ID="InfoTextBox" runat="server" CssClass="input-md w3" MaxLength="100"></asp:TextBox>
                                        &emsp;
                                        <asp:Button ID="EditButton" runat="server" CssClass="btn btn-sm btn-primary" Text="修改" Visible="False" OnClick="EditButton_Click"></asp:Button>
                                    </td>
                                </tr>
                            </table>
                            <asp:Panel ID="Panel1" runat="server" Visible="False" Width="100%">
                                <table class="edit-table">
                                    <tr>
                                        <th>(暂留待用功能)
                                        </th>
                                        <td>备份名称：
                        <asp:TextBox ID="urlName" runat="server" CssClass="input-md"></asp:TextBox>
                                            远程抓取备份URL：
                        <asp:TextBox ID="url" runat="server" Width="296px"></asp:TextBox>
                                            <asp:Button ID="downLoad" runat="server" Text="上传备份文件" OnClick="downLoad_Click"></asp:Button>
                                        </td>
                                    </tr>
                                </table>
                            </asp:Panel>
                            <asp:Panel ID="Panel3" runat="server">
                                <br />
                                <div class="hd">
                                    备份提醒
                                </div>
                                <table class="edit-table">
                                    <tr>
                                        <th>备份提醒周期：
                                        </th>
                                        <td height="30">
                                            <asp:TextBox ID="txtTipCycle" runat="server" CssClass="input-md" Text="30" notNull="true" dataType="integer" minvalue="1" maxvalue="999" MaxLength="3" msgname="备份提示周期天数"></asp:TextBox>
                                            （天）&emsp;
                        <asp:RadioButtonList ID="rbnAllowTipOpen" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
                            <asp:ListItem Value="1" Selected="True">开启</asp:ListItem>
                            <asp:ListItem Value="0">关闭</asp:ListItem>
                        </asp:RadioButtonList>
                                            &emsp;
                        <asp:Button ID="btnTipSave" runat="server" CssClass="btn btn-sm btn-primary" Text="更新提醒参数" OnClientClick="return checkAllValidate();" OnClick="btnTipSave_Click" />
                                            &emsp; 
                                            <span data-rel="popover" data-trigger="hover" data-placement="right" data-content="为了您的网站安全，请开启备份提示"   style="display: inline-block;"> 
                                                                <i class="fa fa-info-circle bigger-120 blue" ></i>
                                                            </span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>本地备份目录检测：
                                        </th>
                                        <td height="30">
                                            <asp:Label ID="explain" runat="server" Visible="False" ForeColor="Red">Label</asp:Label>
                                            <asp:Button ID="auto" runat="server" Text="自动添加" CssClass="btn btn-sm btn-primary" Visible="False" OnClick="auto_Click"></asp:Button>
                                        </td>
                                    </tr>
                                </table>
                            </asp:Panel>
                        </form>
                    </div>
                    <!-- PAGE CONTENT ENDS -->
                </div>
            </div>
        </div>
        <!-- /.page-content -->
    </div>
    <!--#include file = "../Css/foot.htm" -->
    <script src="../../assets/js/ace/elements.fileinput.js" type="text/javascript"></script>            <!--文件上传-->
    <script language="javascript">

        jQuery(function ($) {

            $("a[rel=Index]").fancybox({
                'width': 480,
                'height': 430,
                'hideOnOverlayClick': false,
                'transitionIn': 'elastic',
                'transitionOut': 'elastic',
                'type': 'iframe',
                'padding': '0'
            });

            $('[data-rel=popover]').popover();

            $('#uploadfile').ace_file_input({
                no_file: '没有文件 ...',
                btn_choose: '请选择',
                btn_change: '选好了',
                droppable: false,
                onchange: null,
                thumbnail: false 
            });
        });
    </script>
        <script language="javascript">
            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, "");
            }
            function checkLastBackup(type, lastBackupType, backupName, v1, v2) {
                if (type == "2") {
                    if (type != lastBackupType && lastBackupType != -1) {
                        if (confirm("您所要恢复的备份包与该站点最后备份的备份包类型不一致！\r\n您确定要恢复“" + backupName + "”的数据吗？(您选择恢复的是【快捷备份】,恢复后请手动恢复Image/uploadfiles文件夹)") == true) {
                            if (v1 < v2) {
                                switch (v2) {
                                    case 2:
                                        return confirm("对不起，您要恢复的数据包包含专业版栏目。\r\n恢复后，您无法对专业版特有栏目进行栏目和数据的维护！\r\n您确定要执行恢复操作吗？");
                                        break;
                                    case 3:
                                        return confirm("对不起，您要恢复的数据包包含豪华版栏目。\r\n恢复后，您无法对豪华版特有栏目进行栏目和数据的维护！\r\n您确定要执行恢复操作吗？");
                                        break;
                                }
                            }
                            else
                                return true;
                        }
                        else
                            return false;
                    }
                    else {
                        if (confirm("您确定要恢复“" + backupName + "”的数据吗？(您选择恢复的是【快捷备份】,恢复后请手动恢复Image/uploadfiles文件夹)") == true) {
                            if (v1 < v2) {
                                switch (v2) {
                                    case 2:
                                        return confirm("对不起，您要恢复的数据包包含专业版栏目。\r\n恢复后，您无法对专业版特有栏目进行栏目和数据的维护！\r\n您确定要执行恢复操作吗？");
                                        break;
                                    case 3:
                                        return confirm("对不起，您要恢复的数据包包含豪华版栏目。\r\n恢复后，您无法对豪华版特有栏目进行栏目和数据的维护！\r\n您确定要执行恢复操作吗？");
                                        break;
                                }
                            }
                            else
                                return true;
                        }
                        else
                            return false;
                    }
                }
                else {
                    if (type != lastBackupType && lastBackupType != -1) {
                        if (confirm("您所要恢复的备份包与该站点最后备份的备份包类型不一致！\r\n您确定要恢复“" + backupName + "”的数据吗？") == true) {
                            if (v1 < v2) {
                                switch (v2) {
                                    case 2:
                                        return confirm("对不起，您要恢复的数据包包含专业版栏目。\r\n恢复后，您无法对专业版特有栏目进行栏目和数据的维护！\r\n您确定要执行恢复操作吗？");
                                        break;
                                    case 3:
                                        return confirm("对不起，您要恢复的数据包包含豪华版栏目。\r\n恢复后，您无法对豪华版特有栏目进行栏目和数据的维护！\r\n您确定要执行恢复操作吗？");
                                        break;
                                }
                            }
                            else
                                return true;
                        }
                        else
                            return false;
                    }
                    else {
                        if (confirm("您确定要恢复“" + backupName + "”的数据吗？") == true) {
                            if (v1 < v2) {
                                switch (v2) {
                                    case 2:
                                        return confirm("对不起，您要恢复的数据包包含专业版栏目。\r\n恢复后，您无法对专业版特有栏目进行栏目和数据的维护！\r\n您确定要执行恢复操作吗？");
                                        break;
                                    case 3:
                                        return confirm("对不起，您要恢复的数据包包含豪华版栏目。\r\n恢复后，您无法对豪华版特有栏目进行栏目和数据的维护！\r\n您确定要执行恢复操作吗？");
                                        break;
                                }
                            }
                            else
                                return true;
                        }
                        else
                            return false;
                    }
                }

            }



            function showInfoZip(pkId) {
                arr = showModalDialog("showInfo.aspx?pkId=" + pkId, window, "dialogWidth:25.5em; dialogHeight:22.5em; status:0");
            }

            function showRemark(pkId, isEdit) {
                w = 400;
                h = 240;
                LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
                TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
                settings = 'height=' + h + ',width=' + w + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no';
                window.open("ShowRemark.aspx?pkId=" + pkId + "&isEdit=" + isEdit, "", settings);

            }

            function previewTemplate(pkId) {
                w = 800;
                h = 500;
                LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
                TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
                settings = 'height=' + h + ',width=' + w + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no';

                window.open("showTemplatePreview.aspx?pkId=" + pkId, "", settings);
            }

            function checkBackup() {
                if (document.all.bannerName.value.Trim() == "") {
                    alert("请输入备份名称！");
                    return false;
                }
                var backtype = document.all.backupType.options[document.all.backupType.selectedIndex].value;
                if (backtype == "0") {
                    return confirm("【数据备份】速度快、备份包小，但仅备份网站新闻数据，不含新闻附件和网站模版！\r\n备份成功后，需手动备份Images文件夹（若是子站用户则联系主站管理员备份该文件夹），以保证数据完整！您确定要执行数据备份吗？");
                }
                else if (backtype == "1") {
                    return confirm("您选择的是【完整备份】，如果网站images文件夹超过2G，推荐使用【快捷备份】，您确定要执行本操作吗？");
                }
                else if (backtype = "2") {
                    return confirm("【快捷备份】会备份数据和网站模版，不备份新闻中的图片等附件！\r\n备份成功后再手动备份images/uploadfiles文件夹便达到【完整备份】的效果，您确定要执行本操作吗？");
                }
            }

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