<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="siteBoard.aspx.cs" Inherits="WebApp.Wpdcc.Dashboard" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>仪表盘</title>
    <meta name="description" content="overview &amp; stats" />

	<!--#include file = "../assets/head.htm" -->
	
	<!-- 仪表盘样式文件 -->
    <link rel="stylesheet" href="../assets/css/justgage.css" />
	
</head>
<body class="no-skin">
    
		<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 class="active">仪表盘</li>
						</ul><!-- /.breadcrumb -->

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

					<!-- /section:basics/content.breadcrumbs -->
					
					<div class="page-content">
						
						<!-- /section:settings.box -->
						<div class="page-header">
							<h1>
								仪表盘
								<small>
									<i class="ace-icon fa fa-angle-double-right"></i>
									概况 &amp; 统计
								</small>
							</h1>
						</div><!-- /.page-header -->

						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->

								<div class="row">
									<div class="space-6"></div>
									
									<div class="col-sm-3">
										<div class="well well-sm">
											<h5 class="blue">站群服务器</h5>
											<p>操作系统版本：<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></p>
											<p>.NET引擎版本：<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label></p>
											<p>IIS服务版本：<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label></p>
										</div>
									</div><!-- /.col -->
									
									<div class="vspace-12-sm"></div>
									
									<div class="col-sm-2 infobox-container">
										<!-- #section:pages/dashboard.infobox -->
										<div class="infobox infobox-green">
											<div class="infobox-icon">
												<i class="ace-icon fa fa-laptop"></i>
											</div>

											<div class="infobox-data">
												<span class="infobox-data-number"><% =WebServer %></span>
												<div class="infobox-content">WEB服务数量</div>
											</div>

										</div>
										
										<div class="infobox infobox-pink">
											<div class="infobox-icon">
												<i class="ace-icon fa fa-flag"></i>
											</div>

											<div class="infobox-data">
												<span class="infobox-data-number"><% =WebSite %></span>
												<div class="infobox-content">站点数</div>
											</div>
											
											<%--<div class="badge badge-success">
												正常
												<i class="ace-icon fa"></i>
											</div>--%>
										</div>
										
										<!-- /section:pages/dashboard.infobox -->
										<div class="space-6"></div>
									</div>
									
									<div class="vspace-12-sm"></div>
									
									<div class="col-sm-7 infobox-container">
										
										<div class="col-xs-2 center container">
                                            <div id="dcpu" class="gauge"></div>
                                        </div>
                                        
                                        <div class="col-xs-2 center container">
                                            <div id="dmemory" class="gauge"></div>
                                        </div>
                                        
                                        <div class="col-xs-2 center container">
                                            <div id="ddiskspace" class="gauge"></div>
                                        </div>
									    
									</div><!-- /.col -->
									
								</div><!-- /.row -->
								
								<!-- #section:custom/extra.hr -->
								<div class="hr hr22 hr-dotted"></div>
                                
								<!-- /section:custom/extra.hr -->
                                <div class="row">
                                <div class="col-xs-12">
                                <form id="Form1" method="post" runat="server">
                                    <asp:GridView ID="GridView1" runat="server" CssClass="table table-striped table-bordered table-hover" AutoGenerateColumns="false" PageSize="7" AllowPaging="True" CellSpacing="-1" GridLines="None" OnPreRender="GridView1_PreRender">
                                        <Columns>
                                            <asp:TemplateField HeaderText="序号" InsertVisible="False" HeaderStyle-CssClass="hidden-xs" ItemStyle-CssClass="hidden-xs">
                                                <ItemTemplate>
                                                    <%#Container.DataItemIndex+1%>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:HyperLinkField DataNavigateUrlFields="domainName" DataNavigateUrlFormatString="http://{0}" DataTextField="schoolName" HeaderText="站点名称" Target="_blank" />
                                            <asp:TemplateField HeaderText="发文量" HeaderStyle-CssClass="hidden-xs" ItemStyle-CssClass="hidden-xs col-xs-3"> 
                                                <ItemTemplate>
                                                    <div class="progress pos-rel progress-yellow" data-percent="NaN篇">
								                        <div class="progress-bar progress-bar-danger" style="width: 1%;"></div>
							                        </div>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="访问量" HeaderStyle-CssClass="hidden-480" ItemStyle-CssClass="hidden-480"> 
                                                <ItemTemplate>
                                                    <b class="blue">NaN</b>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="超管密码等级" HeaderStyle-CssClass="hidden-xs" ItemStyle-CssClass="hidden-xs"> 
                                                <ItemTemplate>
                                                    <span class="badge badge-success">N</span><span class="badge badge-warning">N</span><span class="badge badge-danger">N</span><span class="badge badge-light">N</span>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="用户密码等级" HeaderStyle-CssClass="hidden-xs" ItemStyle-CssClass="hidden-xs"> 
                                                <ItemTemplate>
                                                    <span class="badge badge-success">N</span><span class="badge badge-warning">N</span><span class="badge badge-danger">N</span><span class="badge badge-light">N</span>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="站点透视"> 
                                                <ItemTemplate>
                                                    <div class="action-buttons">
											            <a class="blue FBox" href='siteReview.aspx?pkId=<%# DataBinder.Eval(Container, "DataItem.pkId")%>' target="_blank" >
												            <i class="ace-icon fa fa-search-plus bigger-130"></i>
											            </a>
										            </div>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="ak" HeaderText="ak" HeaderStyle-CssClass="hidden" ItemStyle-CssClass="hidden" />
                                        </Columns>
                                        <PagerSettings Visible="False" />
                                    </asp:GridView>
                                    <asp:HiddenField ID="HfFWCycle" runat="server" />
                                    <asp:HiddenField ID="HfFWStandard" runat="server" />
                                    </form>
                                    <button class="btn btn-white btn-primary btn-block" id="sitelistboard" >查看更多</button>
                                </div>
                                </div><!-- /.row -->
                                
								<!-- PAGE CONTENT ENDS -->
							</div><!-- /.col -->
						</div><!-- /.row -->
					</div><!-- /.page-content -->
					
				</div>
	    
		<!-- basic scripts -->

		<!--[if !IE]> -->
		<script type="text/javascript">
			window.jQuery || document.write("<script src='../assets/js/jquery.js'>"+"<"+"/script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
        <script type="text/javascript">
         window.jQuery || document.write("<script src='../assets/js/jquery1x.js'>"+"<"+"/script>");
        </script>
        <![endif]-->
		<script type="text/javascript">
			if('ontouchstart' in document.documentElement) document.write("<script src='../assets/js/jquery.mobile.custom.js'>"+"<"+"/script>");
		</script>
		<script src="../assets/js/bootstrap.js"></script>
        <script src="../assets/fancybox/jquery.fancybox.js"></script>
	    <script src="../assets/js/raphael-2.1.4.min.js"></script>
        <script src="../assets/js/justgage.js"></script>
        <script type="text/javascript">
            var dcpu;
            var dmemory;
            var ddiskspace;
            document.addEventListener("DOMContentLoaded", function(event) {
            dcpu = new JustGage({
                id: "dcpu",
                value: 0,
                min: 0,
                max: 100,
                title: "CPU使用率"
            });
            
            dmemory = new JustGage({
                id: "dmemory",
                value: 0,
                min: 0,
                max: 100,
                title: "内存使用率"
            });
            
            ddiskspace = new JustGage({
                id: "ddiskspace",
                value: 0,
                min: 0,
                max: 100,
                title: "空间占用率"
            });
            
        });
        //获取服务器信息
        setInterval(function(){
        
            $.ajax({
                 type: "POST",
                 url: "siteBoard.aspx/serverCPU",
                 contentType: "application/json; charset=utf-8",
                 dataType: "json",
                 success: function(data){
                 data = JSON.parse(data);//返回的为字符串，需要进行json格式转换。
                             if(data.ret>0)
                             {
                                 dcpu.refresh(0);
                                 dmemory.refresh(0);
                                 ddiskspace.refresh(0);
                             }
                             else
                             {
                                dcpu.refresh(data.cpu);
                                dmemory.refresh(data.memory);
                                ddiskspace.refresh(data.diskspace);
                             }
                          },
                  error: function ()
                  {
                     dcpu.refresh(0);
                     dmemory.refresh(0);
                     ddiskspace.refresh(0);
                  }
             });
                
        },3000);
        
        function getNowFormatDate() {
            var date = new Date();
            var seperator1 = "/";
            
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = "0" + strDate;
            }
            var currentdate = year + seperator1 + month + seperator1 + strDate;
            return currentdate;
        }
        //根据当前的时间，获取某个周期之前的时间。
        function getCycleFormatDate(wcycle) {
            var today = new Date();
            var date = new Date(today.getTime()-wcycle * 24 * 3600 * 1000);
            var seperator1 = "/";
            
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = "0" + strDate;
            }
            var currentdate = year + seperator1 + month + seperator1 + strDate;
            return currentdate;
        }
        
        //加载运行监控图
        $('#GridView1 tr').each(function(){
            var t1 = $(this).find('td').eq(2);
            var t2 = $(this).find('td').eq(3);
            var t3 = $(this).find('td').eq(4);
            var t4 = $(this).find('td').eq(5);
            var t7 = $(this).find('td').eq(7);//ak码
            var a = $(this).find('td').eq(1).find('a').attr('href');
            if($(this).find('td').eq(1).find('a').attr('href') != undefined)
            {
            //加载访问量
            $.ajax({
                 type: "GET",
                 url: a+"/service/sitedataex.ashx",
                     data: {ak:t7.text(),code:"pv"},
                     dataType: "json",
                     success: function(data){
                     
                                 if(data.ret>0)
                                 {
                                    t2.html("<b class=\"blue\">"+data.msg+"</b>");
                                 }
                                 else
                                 {
                                    t2.html("<b class=\"blue\">"+data.pv[0].pv+"</b>");
                                 }
                                 
                              },
                      error: function ()
                      {
                         //t2.empty();   //清空
                         //t2.html("加载异常");
                      }
             });
            
            //获取发文量
            $.ajax({
                 type: "GET",
                 url: a+"/service/sitedataex.ashx",
                 data: {ak:t7.text(),code:"colpublish", dt1:getCycleFormatDate($('#HfFWCycle').val()), dt2:getNowFormatDate()},
                 dataType: "json",
                 success: function(data){
                             
                             if(data.ret>0)
                             {
                                t1.html(data.msg);
                             }
                             else
                             {
                                var fws = $('#HfFWStandard').val();//获取标准值。
                                var bfb = (Math.round(data.colpublish[0].colpublish / (fws * 2) * 10000) / 100.00);// 小数点后两位百分比，此处的“2”为长度系数。
                                
                                if(bfb >= 50)
                                {
                                    t1.html("<div class=\"progress pos-rel\" data-percent=\""+data.colpublish[0].colpublish+"篇\"><div class=\"progress-bar\" style=\"width:"+bfb+"%;\"></div></div>");
                                }
                                else
                                {
                                    t1.html("<div class=\"progress pos-rel progress-yellow\" data-percent=\""+data.colpublish[0].colpublish+"篇\"><div class=\"progress-bar progress-bar-yellow\" style=\"width:"+bfb+"%;\"></div></div>");
                                }
                             }
                          },
                  error: function ()
                  {
                     t1.empty();   //清空
                     //t1.html("加载异常");
                     t1.html("<div class=\"progress pos-rel progress-yellow\" data-percent=\"获取中\"><div class=\"progress-bar progress-bar-danger\" style=\"width:1%;\"></div></div>");
                  }
             });
            //获取密码强弱等级
            $.ajax({
                 type: "GET",
                 url: a+"/service/sitedataex.ashx",
                 data: {ak:t7.text(),code:"pwdlevel"},
                 dataType: "json",
                 success: function(data){
                             
                             if(data.ret>0)
                             {
                                t3.html(data.msg);
                                t4.html(data.msg);
                             }
                             else
                             {
                                t3.html("<span class=\"badge badge-success\" title=\"高强度\">"+data.pwdlevel[0].admin_high+"</span><span class=\"badge badge-warning\" title=\"中强度\">"+data.pwdlevel[0].admin_middle+"</span><span class=\"badge badge-danger\" title=\"低强度\">"+data.pwdlevel[0].admin_low+"</span><span class=\"badge badge-grey\" title=\"无强度\">"+data.pwdlevel[0].admin_unknown+"</span>");
                                t4.html("<span class=\"badge badge-success\" title=\"高强度\">"+data.pwdlevel[0].user_high+"</span><span class=\"badge badge-warning\" title=\"中强度\">"+data.pwdlevel[0].user_middle+"</span><span class=\"badge badge-danger\" title=\"低强度\">"+data.pwdlevel[0].user_low+"</span><span class=\"badge badge-grey\" title=\"无强度\">"+data.pwdlevel[0].user_unknown+"</span>");
                             }
                          },
                  error: function ()
                  {
//                     t3.empty();   //清空Div1里面的所有内容
//                     t3.html("加载异常");
//                     t4.empty();
//                     t4.html("加载异常");
                  }
             });
            }
            
        });
        
        //点击跳转到运行监控图页面
        $('#sitelistboard').click(function(){
            window.location.href="siteListBoard.aspx";
        });
        
        </script>
        <script lang="javascript" type="text/javascript">
        jQuery(function ($) {
            //编辑：打开弹出层
            $(".FBox").click().fancybox({
                autoSize:false,
                'width': 800,
                'height': 630,
                'hideOnOverlayClick': false,
                'type': 'iframe',
                'padding': '0'
            });

        });
    </script>
</body>
</html>
