<%@ Page Language="c#" Inherits="WebApp.SpaceStat" EnableEventValidation="false" CodeBehind="SpaceStat.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">
    <div class="edit-func-box func-box">
        <form id="frmSpaceStat" method="post" runat="server">
    <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">
                    <asp:DropDownList ID="ddlServerList" runat="server">
                    </asp:DropDownList>
                    &nbsp;
                    <asp:Button ID="btnQuery" CssClass="btn btn-sm btn-primary" runat="server" Text="查看" OnClick="btnQuery_Click" />
                </div>

                <div class="row">
                    <div class="col-xs-12">
                <asp:DataGrid ID="webList" CssClass="table table-striped table-bordered" runat="server" AutoGenerateColumns="False" DataKeyField="pkID" OnItemCommand="webList_ItemCommand">
                <Columns>
                    <asp:BoundColumn DataField="pkID" HeaderText="ID" HeaderStyle-CssClass="title"></asp:BoundColumn>
                    <asp:BoundColumn DataField="schoolName" HeaderText="站点名称" HeaderStyle-CssClass="title">
                    </asp:BoundColumn>
                    <asp:BoundColumn DataField="regTime" HeaderText="开通时间" HeaderStyle-CssClass="title" DataFormatString="{0:yyyy-MM-dd}"></asp:BoundColumn>
                    <asp:TemplateColumn HeaderText="分配空间(MB)" HeaderStyle-CssClass="title">
                        <ItemTemplate>
                            <asp:Label ID="lblWebSpace" runat="server" Text='<%# GetWebSpace(DataBinder.Eval(Container, "DataItem.webSpace").ToString()) %>'>
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:TemplateColumn HeaderText="实用空间(MB)" HeaderStyle-CssClass="title">
                        <ItemTemplate>
                            <asp:Label ID="lblUsedSpace" runat="server" Text='<%# ((Convert.ToDouble(DataBinder.Eval(Container, "DataItem.usedSpace"))/1024)/1024).ToString("f2") %>'>
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:TemplateColumn HeaderText="上传空间(MB)" HeaderStyle-CssClass="title">
                        <ItemTemplate>
                            <asp:Label ID="lblUsedImageSpace" runat="server" Text='<%# ((Convert.ToDouble(DataBinder.Eval(Container, "DataItem.usedImageSpace"))/1024)/1024).ToString("f2") %>'>
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:TemplateColumn HeaderText="备份空间(MB)" HeaderStyle-CssClass="title">
                        <ItemTemplate>
                            <asp:Label ID="lblUsedBackupSpace" runat="server" Text='<%# ((Convert.ToDouble(DataBinder.Eval(Container, "DataItem.usedBackupSpace"))/1024)/1024).ToString("f2") %>'>
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:BoundColumn DataField="spaceStateTime" HeaderText="统计时间" HeaderStyle-CssClass="title">
                    </asp:BoundColumn>
                    <asp:TemplateColumn HeaderText="操作" HeaderStyle-CssClass="title">
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" CssClass="badge badge-success" Text="正常" Visible='<%# !IsOver(Convert.ToInt32(DataBinder.Eval(Container, "DataItem.applyID"))) %>'>
                            </asp:Label>
                            <asp:Label ID="lblOver" runat="server" CssClass="badge badge-danger" Text="空间过大" Visible='<%# IsOver(Convert.ToInt32(DataBinder.Eval(Container, "DataItem.applyID"))) %>'>
                            </asp:Label>
                            <asp:LinkButton ID="btnSendMail" runat="server" Visible='<%# IsOver(Convert.ToInt32(DataBinder.Eval(Container, "DataItem.applyID"))) %>' Text="发送邮件" CommandName="send">
                            </asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:BoundColumn DataField="applyID" HeaderText="站点ID" Visible="False" HeaderStyle-CssClass="title"></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" runat="server" Width="100%" Height="216px" Rows="10"></asp:ListBox>
                        </div>
                       <div class="col-sm-6">
                            <p>
                                <asp:Button ID="btnSelSchools" CssClass="btn btn-sm btn-primary" runat="server" Text="选择站点"></asp:Button></p>
                            <p>
                                <asp:Button ID="btnStat" CssClass="btn btn-sm btn-primary" runat="server" Text="开始统计" OnClientClick="javascript:queryform();return true;" OnClick="btnStat_Click"></asp:Button>
                                
                            </p>
                            <p>
                                <asp:Button ID="btnRefresh" CssClass="btn btn-sm btn-primary" runat="server" Text="刷新列表" OnClick="btnRefresh_Click"></asp:Button></p>
                                <input id="d_name" type="hidden" name="Hidden1" runat="server" />
                                <input id="d_value" type="hidden" name="Hidden2" runat="server" />
                        </div>
                </div>
            </div>
        </div>
            <input id="Hidden1" runat="server" type="hidden" />
            </div>
            
    </form>
    
    </div>
    <!--#include file = "../assets/foot.htm" -->
    <script type="text/javascript">

        jQuery(function ($) {
            //改用弹出层，因为201409发布的最新ghome开始不支持showModalDialog()
            $("#btnSelSchools").click(function () {
                return true;
            }).fancybox({
                autoSize: false,
                'type': 'iframe',
                'width': 600,
                'height': 450,
                'hideOnOverlayClick': false,
                'href': 'selectSchools.aspx'
            });
        })
    </script>
    <script language="javascript" type="text/javascript">
        //function selectSchools()
        //{	
        //	var arr = showModalDialog("selectSchools.aspx", window, "dialogWidth:500px;dialogHeight:326px;help:no;scroll:no;resizable:yes;status:no");
        //	if(arr!=null)
        //	  location.href="SpaceStat.aspx";
        //}
        function DelAll() {
            var selectTo = document.frmSpaceStat.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.frmSpaceStat.schoolList;
            selectFrom.add(new Option(text, value));
            //alert(text+","+value);
        }
        function queryform() {
            var sel = document.frmSpaceStat.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.frmSpaceStat.d_name.value = str1;
            document.frmSpaceStat.d_value.value = str2;
            //alert(str1+str2);
            return true;
        }
    </script>
</body>
</html>
