<%@ Page Language="C#" AutoEventWireup="true" Inherits="WebApp.Admin.ServiceList" CodeBehind="ServiceList.aspx.cs" %>
<!DOCTYPE html>
<!--[if lt IE 9]><html class="lte-ie8"><![endif]-->
<!--[if gt IE 8]><!-->
<html>
<!--<![endif]-->
<head runat="server">
    <title>服务器维护</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!--#include file = "../Css/adminCssEdit.htm" -->
    <script language="javascript" type="text/javascript">
		    function selectServer(val)
		    {
		        showModalDialog("selectServer.aspx?type=" + val,window, "dialogWidth:302px;dialogHeight:378px;help:no;scroll:no;status:no");		        
		    }
		    function BindSelect(type, txt, val)
		    {
		        if(type=="1")
		        {
		            document.all.txtServerName1.value = txt;
		            document.all.hiddenWebServer.value = val;
		        }
		        else
		        {
		            document.all.txtServerName2.value = txt;
		            document.all.hiddenSqlServer.value = val;
		        }
		    }
		    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>

</head>
<body>
    <div class="edit-func-box func-box">
        <form id="form1" runat="server">
        <div class="hd">
            <asp:Label ID="lblTitle" runat="server"></asp:Label></div>
        <div class="bd">
            <div class="function-hd">
                <div class="search-box fr">
                </div>
                <!--/search-box-->
                <div class="action-field">
                    <asp:Button ID="btnSaveWeb" CssClass="btn" runat="server" CausesValidation="False"
                        Text="保存表格" OnClick="btnSaveWeb_Click" />
                </div>
                <!--/action-field-->
            </div>
            <asp:DataGrid ID="dgWebServer" runat="server" class="list-table" 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 HeaderStyle-CssClass="title">
                        <ItemTemplate>
                            <asp:LinkButton ID="editWeb" runat="server" CausesValidation="false" CommandName="edit">编辑</asp:LinkButton>&nbsp;
                            <asp:LinkButton ID="delWeb" runat="server" CommandName="delete" CausesValidation="false"
                                CommandArgument='<%# DataBinder.Eval(Container, "DataItem.serviceName") %>'>删除</asp:LinkButton>&nbsp;
                            <asp:HyperLink ID="hplViewWebSite" runat="server" NavigateUrl='<%# "WebSiteList.aspx?webId="+Eval("pkId")+"&name=" + Eval("serviceName") + "&sId="+ServerId+"&sName=" +ServerName  %>'>查看子站列表</asp:HyperLink>
                        </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:BoundColumn DataField="serverId" HeaderText="serverId" Visible="False"></asp:BoundColumn>
                </Columns>
            </asp:DataGrid>
        </div>
        <div class="ft">
            <div class="pagination">
                <asp:Label ID="lblWebPage" runat="server"></asp:Label>
            </div>
            <!--/action-field-->
        </div>
        <table class="edit-table">
            <tr>
                <th width="25%">
                    服务名称：
                </th>
                <td width="75%">
                    <asp:TextBox ID="txtWebName" runat="server" CssClass="input-txt input-txt3"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <th>
                    所在服务器：
                </th>
                <td>
                    <asp:TextBox ID="txtServerName1" runat="server" CssClass="input-txt input-txt3" Enabled="False"
                        ReadOnly="True"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <th>
                    服务器IP：
                </th>
                <td>
                    <asp:DropDownList ID="ddlWebIp" runat="server">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <th>
                    端口：
                </th>
                <td>
                    <asp:TextBox ID="txtWebPort" runat="server" CssClass="input-txt input-txt2">80</asp:TextBox>&nbsp;
                    <asp:Button ID="btnWebPort" runat="server" CssClass="btn" OnClick="btnWebPort_Click"
                        Text="端口测试" CausesValidation="False" Visible="False" />
                </td>
            </tr>
            <tr>
                <th>
                    默认路径：
                </th>
                <td>
                    <asp:TextBox ID="txtWebPath" runat="server" CssClass="input-txt input-txt3">C:\</asp:TextBox>
                </td>
            </tr>
        </table>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="请输入web服务器名称！"
            ControlToValidate="txtWebName" Display="None"></asp:RequiredFieldValidator>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="请选择web所在服务器！"
            ControlToValidate="txtServerName1" Display="None"></asp:RequiredFieldValidator>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="请输入web服务器默认路径！"
            ControlToValidate="txtWebPath" Display="None"></asp:RequiredFieldValidator>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="请选择web服务器Ip！"
            ControlToValidate="ddlWebIp" Display="None"></asp:RequiredFieldValidator>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtWebPort"
            Display="None" ErrorMessage="请输入web端口！" Width="140px"></asp:RequiredFieldValidator>
        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtWebPort"
            Display="None" ErrorMessage="端口必须为大于0的整数！" ValidationExpression="^[0-9]*[1-9][0-9]*$"></asp:RegularExpressionValidator>
        <input id="hiddenWebServer" runat="server" name="hiddenWebServer" style="height: 15px;
            width: 57px;" type="hidden" />
        <input id="webId" runat="server" style="height: 15px; width: 58px;" type="hidden" />&nbsp;
        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="ddlWebIp"
            Display="None" 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])$"></asp:RegularExpressionValidator>
        <div class="ft">
            <div class="action-field txt-c">
                <asp:Button ID="btnAddWeb" runat="server" Text="添加" CssClass="btn" OnClick="btnAddWeb_Click" />&nbsp;
                <asp:Button ID="btnCancelWeb" runat="server" Text="取消" CssClass="btn" CausesValidation="False"
                    OnClick="btnCancelWeb_Click" />&nbsp;
                <input id="Button2" type="button" value="返回服务器" class="btn" onclick="window.location.href='./ServerList.aspx'" />
            </div>
        </div>
        <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True"
            ShowSummary="False" />
        </form>
    </div>
</body>
</html>

<script language="javascript">
			function ShowWebSiteList(webId, name)
			{
				window.open("WebSiteList.aspx?webId=" + webId + "&name=" + name,"", "Width=760,Height=500");
			}
</script>

