private void TextBind()
 {
     siteModel      = siteBll.SelBySiteID(iis.Sites[siteName].Id.ToString());
     sName.Text     = siteName;
     StartDate.Text = siteModel.CreateDate.ToString("yyyy年M月dd日");
     EndDate.Text   = siteModel.EndDate.ToString("yyyy年M月dd日");
 }
        protected void Update(int rowNum, string id)//Update WebSite with index=0,Name,Port,PPath,Domain
        {
            IISWebSite  site = new IISWebSite();
            GridViewRow gr   = EGV.Rows[rowNum];

            site.SiteName = ((TextBox)gr.FindControl("EditSiteName")).Text.Trim();
            site.Port     = ((TextBox)gr.FindControl("EditPort")).Text.Trim();
            //site.PhysicalPath = ((TextBox)gr.FindControl("EditPhySicalPath")).Text.Trim();
            //site.DomainName = ((TextBox)gr.FindControl("EditDomain")).Text.Trim();
            IISHelper iisM = new IISHelper();
            DataTable dt   = iisM.GetWebSiteList();

            dt.DefaultView.RowFilter = "SiteID=" + id;
            DataRow dr = dt.DefaultView.ToTable().Rows[0];

            //-----有更改才更新,先更新域名
            if (!(dr["SiteName"] as string).Equals(site.SiteName))
            {
                iisHelper.ChangeSiteName(dr["SiteName"] as string, site.SiteName);
            }
            if (!(dr["SitePort"] as string).Equals(site.Port))
            {
                iisHelper.ChangeSitePort(site.SiteName, site.Port);
            }
            //if (!(dr["PhysicalPath"] as string).Equals(site.PhysicalPath))
            //    iisHelper.ChangeSitePath(site.SiteName, site.PhysicalPath);
            //if (!(dr["Domain"] as string).Equals(site.DomainName))
            //    iisHelper.ChangeSiteDomain(site.SiteName, site.DomainName);

            B_Site_SiteList siteBll   = new B_Site_SiteList();
            M_Site_SiteList siteModel = new M_Site_SiteList();

            siteModel         = siteBll.SelBySiteID(id);
            siteModel.EndDate = DataConvert.CDate(((TextBox)gr.FindControl("EditEndDate")).Text.Trim());
            siteBll.UpdateModel(siteModel);
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('修改完成');location=location;", true);
        }
        //本地获取信息
        public void GetInfoLocal()
        {
            siteModel        = iisHelper.GetSiteModel(siteName);
            Name.Text        = siteModel.SiteName;
            siteAppPool.Text = siteModel.AppPool;

            lName.Text     = siteModel.SiteName;
            lSitePool.Text = siteModel.AppPool;
            string bind  = "";
            string lbind = "";

            for (int i = 0; i < siteModel.BindInfoList.Count; i++)
            {
                string[] temp = siteModel.BindInfoList[i].Split(':');
                if (i < 1)//第一行不显示移除,即最少要一行
                {
                    bind += "<tr><td>绑定信息:</td><td>";
                }
                else
                {
                    bind += "<tr><td>绑定信息:<a href='javascript:' onclick='remove(this)' title='移除'><i class='fa fa-remove'></i></a></td><td>";
                }

                bind += "<label style='float:left; display:block; width:50px;'>IP:</label><input type='text' name='siteIP'  class='form-control' style='width:150px;'   maxlength='15'  txt='IP不能为空' value='" + temp[0] + "' list='ipList'/>";
                bind += "<label style='float:left; display:block; width:50px;'>端口:</label>";
                bind += "<input type='text' name='sitePort' class='form-control'  maxlength='6'  txt='端口不能为空' style='width:150px;' value='" + temp[1] + "'/> ";
                bind += "<label style='float:left; display:block; width:50px;'>域名:</label><input type='text' name='Domain' style='width:150px;' class='form-control' txt='域名不能为空' value='" + temp[2] + "'/>";
                bind += "</td></tr>";

                //-----ReadOnly
                lbind     += "<tr'><td>绑定信息:</td><td><label>IP:" + temp[0] + "</label><br/>";
                lbind     += "<label >端口:" + temp[1] + "</label><br/>";
                lbind     += "<label >域名:" + temp[2] + "</label>";
                lbind     += "</td></tr>";
                sitePort   = temp[1];
                siteDomain = temp[2];
            }
            string path  = "";
            string lpath = "";

            foreach (string p in siteModel.PhysicalPathList)
            {
                path += "<tr><td>物理路径:</td><td>";
                path += "<input name='PPath' type='text' value='" + p + "' class='form-control text_md' maxlength='80' style='width:200px;' txt='物理路径为空'/>";
                path += "</td></tr>";

                lpath += "<tr><td>物理路径:</td><td>";
                lpath += "<label>" + p + "</label> ";
                lpath += "</td></tr>";
            }

            literalPath.Text = path;
            literalBind.Text = bind;
            labelPath.Text   = lpath;
            labelBind.Text   = lbind;

            siteM = siteBll.SelBySiteID(siteID); //如果无记录,则返回空
                                                 //------EditMode
            opSystem.Text            = enHelper.GetOSVersion();
            manageName.Text          = siteM == null ? "" : siteM.Remind;
            iisVersion.Text          = Request.ServerVariables["Server_SoftWare"].ToString();
            netVersion.SelectedValue = iis.ApplicationPools[appName].ManagedRuntimeVersion;
            runMode.SelectedValue    = iis.ApplicationPools[appName].ManagedPipelineMode.ToString();
            serverIP.Text            = enHelper.GetServerIP();
            //-----输出一个datalist服务于IP输入自动提示
            hideIPLiteral.Text = "<datalist id='ipList'><option>*</option>";
            foreach (string s in serverIP.Text.Split(','))
            {
                hideIPLiteral.Text += "<option>" + s + "</option>";
            }
            hideIPLiteral.Text += "</datalist>";
            //-----
            siteState.Text = iis.Sites[siteName].State == ObjectState.Started ? "运行中" : "已停止";
            ssBtn1.Text    = iis.Sites[siteName].State == ObjectState.Started ? "停止" : "启动";

            //------ReadOnly
            lOPSystem.Text = enHelper.GetOSVersion();
            lManager.Text  = (siteM == null || string.IsNullOrEmpty(siteM.SiteManager)) ? "尚未分配" : manageName.Text;
            //---颁发管理链接
            if (siteM != null)
            {
                string url      = Request.Url.AbsoluteUri;
                string userName = Server.UrlEncode(buser.GetUserByUserID(DataConverter.CLng(siteM.SiteManager)).UserName);
                Regex  re       = new Regex("(?<=(://))[.\\s\\S]*?(?=(/))", RegexOptions.IgnoreCase);
                url = re.Match(url).Value;

                manageID.Value     = "http://" + url + CustomerPageAction.customPath2 + "Site/Share.aspx?identity=" + userName;
                this.TextBox1.Text = manageID.Value;
                this.TextBox2.Text = manageID.Value;
            }

            lIISVersion.Text = Request.ServerVariables["Server_SoftWare"].ToString();
            lNetVersion.Text = iis.ApplicationPools[appName].ManagedRuntimeVersion;
            lRunMode.Text    = iis.ApplicationPools[appName].ManagedPipelineMode == ManagedPipelineMode.Classic ? "经典模式" : "集成模式";
            lServerIP.Text   = enHelper.GetServerIP();
            lSiteState.Text  = iis.Sites[siteName].State == ObjectState.Started ? "运行中" : "已停止";
            ssBtn2.Text      = iis.Sites[siteName].State == ObjectState.Started ? "停止" : "启动";

            try
            {
                //need Web.config
                errorPage1.Text = enHelper.GetCustomError(webPath, 403).Redirect;
                errorPage2.Text = enHelper.GetCustomError(webPath, 404).Redirect;
                errorPage3.Text = enHelper.GetCustomError(webPath, 500).Redirect;
                errorPage4.Text = enHelper.GetCustomError(webPath, 503).Redirect;

                lErrorPage1.Text = enHelper.GetCustomError(webPath, 403).Redirect;
                lErrorPage2.Text = enHelper.GetCustomError(webPath, 404).Redirect;
                lErrorPage3.Text = enHelper.GetCustomError(webPath, 500).Redirect;
                lErrorPage4.Text = enHelper.GetCustomError(webPath, 503).Redirect;
            }
            catch { }

            //------------------高级设置
            //---只读
            ApplicationPool appPool = iis.ApplicationPools[appName];

            lmaxCPULimit.Text      = appPool.Cpu.Limit.ToString();
            lconfigChange.Text     = appPool.Recycling.DisallowRotationOnConfigChange ? "是" : "否";
            lTimeSpanRecy.Text     = appPool.Recycling.PeriodicRestart.Time.TotalMinutes.ToString();
            lmaxMemory.Text        = (appPool.Recycling.PeriodicRestart.Memory / 1024).ToString();
            lmaxPrivateMemory.Text = (appPool.Recycling.PeriodicRestart.PrivateMemory / 1024).ToString();
            string[] defaultDoc = iisHelper.GetDefaultDocBySiteName(siteName);
            for (int i = 0; i < defaultDoc.Length; i++)
            {
                ldefaultDoc.Text += defaultDoc[i] + "<br />";
                edefaultDoc.Text += defaultDoc[i] + ",\r";//编辑状态
            }
            //---编辑
            emaxCPULimit.Text           = appPool.Cpu.Limit.ToString();
            econfigChange.SelectedValue = appPool.Recycling.DisallowRotationOnConfigChange.ToString();
            eTimeSpanRecy.Text          = appPool.Recycling.PeriodicRestart.Time.TotalMinutes.ToString();
            emaxMemory.Text             = (appPool.Recycling.PeriodicRestart.Memory / 1024).ToString();
            emaxPrivateMemory.Text      = (appPool.Recycling.PeriodicRestart.PrivateMemory / 1024).ToString();
        }