<%@ Page Language="C#" AutoEventWireup="true" Inherits="WebApp.Wpdcc.ServiceList" CodeBehind="ServiceList.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="form1" 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>WEB服务</li>
					<li class="active"><asp:Label ID="lblTitle" runat="server"></asp:Label></li>
				</ul><!-- /.breadcrumb -->

				<!-- /section:basics/content.searchbox -->
			</div>
			<!-- /section:basics/content.breadcrumbs -->
			
			<div class="page-content">
			<!-- PAGE CONTENT BEGINS -->
			
			<div class="page-header">
			
			    <input id="Button2" type="button" value="返回服务器列表" class="btn btn-sm btn-primary" onclick="window.location.href='./ServerList.aspx'" />
				&nbsp;
                <asp:Button ID="btnSaveWeb" CssClass="btn btn-sm btn-primary" runat="server" CausesValidation="False" Text="保存" OnClick="btnSaveWeb_Click" />
				
			</div>
			
		<div class="row">
		<div class="col-xs-12">
        
        <asp:DataGrid ID="dgWebServer" runat="server" class="table table-striped table-bordered" AutoGenerateColumns="False" DataKeyField="pkID" OnItemCommand="dgWebServer_ItemCommand" OnItemDataBound="dgWebServer_ItemDataBound">
                <Columns>
                    <asp:BoundColumn DataField="pkID" HeaderText="ID" HeaderStyle-CssClass="title"></asp:BoundColumn>
                    <asp:BoundColumn DataField="serviceName" HeaderText="名称" HeaderStyle-CssClass="title">
                    </asp:BoundColumn>
                    <asp:BoundColumn DataField="ip" HeaderText="IP" HeaderStyle-CssClass="title"></asp:BoundColumn>
                    <asp:BoundColumn DataField="webPath" HeaderText="默认路径" HeaderStyle-CssClass="title">
                    </asp:BoundColumn>
                    <asp:BoundColumn DataField="webPort" HeaderText="端口" HeaderStyle-CssClass="title">
                    </asp:BoundColumn>
                    <asp:BoundColumn DataField="serverName" HeaderText="所在服务器" Visible="false" HeaderStyle-CssClass="title">
                    </asp:BoundColumn>
                    <asp:TemplateColumn HeaderText="是否在用" HeaderStyle-CssClass="title">
                        <ItemTemplate>
                            <asp:DropDownList ID="ddlWebOnUsing" runat="server" SelectedValue='<%# DataBinder.Eval(Container, "DataItem.OnUsing") %>'>
                                <asp:ListItem Value="0">禁用</asp:ListItem>
                                <asp:ListItem Value="1">使用</asp:ListItem>
                            </asp:DropDownList>
                        </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:TemplateColumn HeaderText="可用空间(MB)" HeaderStyle-CssClass="title">
                        <ItemTemplate>
                            <asp:Label ID="lblAvaiableSpace" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.availableSpace").ToString() == "0" ? "尚未统计" : (((double)Convert.ToDouble(DataBinder.Eval(Container, "DataItem.availableSpace"))/1024)/1024).ToString("f2") %>'>
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:TemplateColumn HeaderText="执行" HeaderStyle-CssClass="title">
                        <ItemTemplate>
                            <div class="action-buttons">
                            <asp:LinkButton ID="editWeb" runat="server" CausesValidation="false" CommandName="edit"><i class="ace-icon fa fa-pencil bigger-130 green" title="编辑"></i></asp:LinkButton>
                            &nbsp;
                            <asp:LinkButton ID="delWeb" runat="server" CommandName="delete" CausesValidation="false"
                                CommandArgument='<%# DataBinder.Eval(Container, "DataItem.serviceName") %>'><i class="ace-icon fa fa-trash-o bigger-130 red" title="删除"></i></asp:LinkButton>
                            &nbsp;
                            <asp:HyperLink ID="hplViewWebSite" runat="server" NavigateUrl='<%# "WebSiteList.aspx?webId="+Eval("pkId")+"&name=" + Eval("serviceName") + "&sId="+ServerId+"&sName=" +ServerName  %>'><i class="ace-icon fa fa-search-plus bigger-130" title="查看站点列表" ></i></asp:HyperLink>
                            </div>
                        </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:BoundColumn DataField="serverId" HeaderText="serverId" Visible="False"></asp:BoundColumn>
                </Columns>
            </asp:DataGrid>
        
        <div class="clearfix">
	        <div class="col-xs-12">
                <asp:Label ID="lblWebPage" runat="server"></asp:Label>
                
            </div>
        </div>
        
        <div class="row form-horizontal">
            <div class="col-xs-12">
                <div class="form-group">
		            <label class="col-sm-3 control-label no-padding-right" for="txtWebName">服务名称</label>
		            <div class="col-sm-9">
		                <asp:TextBox ID="txtWebName" runat="server" CssClass="col-xs-10 col-sm-5"></asp:TextBox>
		                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="请输入web服务器名称！"
                        ControlToValidate="txtWebName" Display="Dynamic" ValidationGroup="webreg"></asp:RequiredFieldValidator>
		            </div>
		        </div>
		        <div class="form-group">
			        <label class="col-sm-3 control-label no-padding-right" for="txtServerName1">所在服务器</label>
		            <div class="col-sm-9">
		                <asp:TextBox ID="txtServerName1" runat="server" CssClass="col-xs-10 col-sm-5" Enabled="False" ReadOnly="True"></asp:TextBox>
		                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="请选择web所在服务器！"
                        ControlToValidate="txtServerName1" Display="Dynamic" ValidationGroup="webreg"></asp:RequiredFieldValidator>
		            </div>
		        </div>
		        <div class="form-group">
			        <label class="col-sm-3 control-label no-padding-right" for="ddlWebIp">服务器IP</label>
		            <div class="col-sm-9">
		                <asp:DropDownList ID="ddlWebIp" runat="server">
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="请选择web服务器Ip！"
                        ControlToValidate="ddlWebIp" Display="Dynamic" ValidationGroup="webreg"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="ddlWebIp" Display="Dynamic" ErrorMessage="IP地址格式不正确！" ValidationExpression="^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" ValidationGroup="webreg"></asp:RegularExpressionValidator>
		            </div>
		        </div>
		        <div class="form-group">
			        <label class="col-sm-3 control-label no-padding-right" for="txtWebPort">端口</label>
		            <div class="col-sm-9">
		                <asp:TextBox ID="txtWebPort" runat="server" CssClass="col-xs-1">80</asp:TextBox>
		                &nbsp;
                        <asp:Button ID="btnWebPort" runat="server" CssClass="btn btn-sm btn-primary" OnClientClick="return checkPort()" OnClick="btnWebPort_Click" Text="端口测试" CausesValidation="False"  />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtWebPort"
                        Display="Dynamic" ErrorMessage="请输入web端口！" ValidationGroup="webreg"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtWebPort"
                        Display="Dynamic" ErrorMessage="端口必须为大于0的整数！" ValidationExpression="^[0-9]*[1-9][0-9]*$" ValidationGroup="webreg"></asp:RegularExpressionValidator>
		            </div>
		        </div>
		        <div class="form-group">
			        <label class="col-sm-3 control-label no-padding-right" for="txtWebPath">默认路径</label>
		            <div class="col-sm-9">
		                <asp:TextBox ID="txtWebPath" runat="server" CssClass="col-xs-10 col-sm-5">C:\</asp:TextBox>
		                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="请输入web服务器默认路径！"
                        ControlToValidate="txtWebPath" Display="Dynamic" ValidationGroup="webreg"></asp:RequiredFieldValidator>
		            </div>
		        </div>
		    </div>
		    <div class="clearfix">
                <div class="col-md-offset-3 col-md-9">
                    <asp:Button ID="btnAddWeb" runat="server" Text="添加" CssClass="btn btn-sm btn-primary" OnClientClick="return checkPort()" OnClick="btnAddWeb_Click" ValidationGroup="webreg" />&nbsp;
                    <asp:Button ID="btnCancelWeb" runat="server" Text="取消" CssClass="btn btn-sm" CausesValidation="False" OnClick="btnCancelWeb_Click" />
                    <input id="hiddenWebServer" runat="server" name="hiddenWebServer" type="hidden" />
                    <input id="webId" runat="server" type="hidden" />
                    
                    
                </div>
            </div>
		</div>
		
		</div>
			    </div>
		        <!-- PAGE CONTENT ENDS -->
            </div>
        </div>
        
        </form>
        
        <!--#include file = "../assets/foot.htm" -->
            <script language="javascript" type="text/javascript">

                function checkPort() {
                    if (document.all.ddlWebIp.value.LTrim().RTrim().length == 0) {
                        alert("请输入服务器IP！");
                        return false;
                    }
                    if (document.all.txtWebPort.value.LTrim().RTrim().length == 0) {
                        alert("请输入端口号！");
                        return false;
                    }
                    if (IP2V(document.all.txtWebIp.value.LTrim().RTrim()) == false) {
                        alert("IP地址格式不正确！");
                        return false;
                    }
                    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, "");
                }
                function IP2V(ip) {
                    re = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/g;  //匹配IP地址的正则表达式
                    if (re.test(ip)) {
                        return true;
                    }
                    else {
                        return false;
                    }
                }

        </script>
        <script type="text/javascript">
			
		    function checkPort()
		    {
		        if(document.getElementById("txtWebName").value=="")
		        {
		            alert("请输入服务名称！");
		            return false;
		        }
		        if(document.getElementById("txtWebPort").value=="")
		        {
		            alert("请输入端口号！");
		            return false;
		        }
		        if(document.getElementById("txtWebPath").value=="")
		        {
		            alert("请输入默认路径！");
		            return false;
		        }
		        return true;
		    }

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