コード例 #1
0
        // AppPool
        private void BindAppPoolState(AppPoolState state)
        {
            litAppPoolStatus.Text = GetLocalizedString("SiteState." + state.ToString());

            cmdAppPoolStart.Visible   = (state == AppPoolState.Stopped || state == AppPoolState.Stopping);
            cmdAppPoolStop.Visible    = (state == AppPoolState.Started || state == AppPoolState.Starting);
            cmdAppPoolRecycle.Visible = (state == AppPoolState.Started || state == AppPoolState.Starting);
        }
コード例 #2
0
        public void ChangeAppPoolState(string siteId, AppPoolState state)
        {
            using (var srvman = GetServerManager())
            {
                var site = srvman.Sites[siteId];
                //
                if (site == null)
                {
                    return;
                }

                foreach (Application app in site.Applications)
                {
                    string AppPoolName = app.ApplicationPoolName;

                    if (string.IsNullOrEmpty(AppPoolName))
                    {
                        continue;
                    }

                    ApplicationPool pool = srvman.ApplicationPools[AppPoolName];
                    if (pool == null)
                    {
                        continue;
                    }

                    //
                    switch (state)
                    {
                    case AppPoolState.Started:
                    case AppPoolState.Starting:
                        if ((pool.State != ObjectState.Started) && (pool.State != ObjectState.Starting))
                        {
                            pool.Start();
                            pool.AutoStart = true;
                        }
                        break;

                    case AppPoolState.Stopped:
                    case AppPoolState.Stopping:
                        if ((pool.State != ObjectState.Stopped) && (pool.State != ObjectState.Stopping))
                        {
                            pool.Stop();
                            pool.AutoStart = false;
                        }
                        break;

                    case AppPoolState.Recycle:
                        pool.Recycle();
                        pool.AutoStart = true;
                        break;
                    }

                    srvman.CommitChanges();
                }
            }
        }
コード例 #3
0
        public AppPoolState GetAppPoolState(ServerManager srvman, string siteId)
        {
            Site site = srvman.Sites[siteId];

            // ensure website exists
            if (site == null)
            {
                return(AppPoolState.Unknown);
            }

            string AppPoolName = site.ApplicationDefaults.ApplicationPoolName;

            foreach (Application app in site.Applications)
            {
                AppPoolName = app.ApplicationPoolName;
            }

            if (string.IsNullOrEmpty(AppPoolName))
            {
                return(AppPoolState.Unknown);
            }

            ApplicationPool pool = srvman.ApplicationPools[AppPoolName];

            if (pool == null)
            {
                return(AppPoolState.Unknown);
            }

            AppPoolState state = AppPoolState.Unknown;

            switch (pool.State)
            {
            case ObjectState.Started:
                state = AppPoolState.Started;
                break;

            case ObjectState.Starting:
                state = AppPoolState.Starting;
                break;

            case ObjectState.Stopped:
                state = AppPoolState.Stopped;
                break;

            case ObjectState.Stopping:
                state = AppPoolState.Stopping;
                break;
            }

            return(state);
        }
コード例 #4
0
        public AppPoolState GetAppPoolState(string AppPoolName)
        {
            AppPoolState   state     = 0;
            DirectoryEntry rootEntry = GetDirectoryEntry("/AppPools");

            foreach (DirectoryEntry ent in rootEntry.Children)
            {
                if (ent.SchemaClassName == "IIsApplicationPool" || ent.Name == AppPoolName)
                {
                    state = (AppPoolState)ent.Properties["AppPoolState"].Value;
                    break;
                }
            }
            DisposeDirectoryEntry(rootEntry);
            return(state);
        }
コード例 #5
0
ファイル: AsyncLoadHandler.cs プロジェクト: pasamsin/SolidCP
        private string GetAppPoolStatus()
        {
            string result = string.Empty;

            try
            {
                AppPoolState appPoolState = ES.Services.WebServers.GetAppPoolState(ItemId);
                if (appPoolState == AppPoolState.Started)
                {
                    result = "<span class=\"fa fa-play-circle-o fa-lg text-success\"></span>";
                }
                if (appPoolState == AppPoolState.Stopped)
                {
                    result = "<span class=\"fa fa-stop-circle-o fa-lg text-danger\"></span>";
                }
            }
            catch (Exception exception)
            {
                result = "<span class=\"fa fa-exclamation-triangle fa-lg text-danger\"></span>";
            }
            return(result);
        }
コード例 #6
0
        protected void cmdAppPoolChangeState_Click(object sender, EventArgs e)
        {
            string       stateName = ((ImageButton)sender).CommandName;
            AppPoolState state     = (AppPoolState)Enum.Parse(typeof(AppPoolState), stateName, true);

            try
            {
                int result = ES.Services.WebServers.ChangeAppPoolState(PanelRequest.ItemID, state);
                if (result < 0)
                {
                    ShowResultMessage(result);
                    return;
                }

                state = ES.Services.WebServers.GetAppPoolState(PanelRequest.ItemID);
                BindAppPoolState(state);
            }
            catch (Exception ex)
            {
                ShowErrorMessage("WEB_CHANGE_SITE_STATE", ex);
                return;
            }
        }
コード例 #7
0
 public void ChangeAppPoolState(string siteId, AppPoolState state)
 {
     try
     {
         Log.WriteStart("'{0}' ChangeAppPoolState", ProviderSettings.ProviderName);
         WebProvider.ChangeAppPoolState(siteId, state);
         Log.WriteEnd("'{0}' ChangeAppPoolState", ProviderSettings.ProviderName);
     }
     catch (Exception ex)
     {
         Log.WriteError(String.Format("'{0}' ChangeAppPoolState", ProviderSettings.ProviderName), ex);
         throw;
     }
 }
コード例 #8
0
        // AppPool
        public static int ChangeAppPoolState(int siteItemId, AppPoolState state)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // load site item
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
            if (siteItem == null)
                return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND;

            // check package
            int packageCheck = SecurityContext.CheckPackage(siteItem.PackageId, DemandPackage.IsActive);
            if (packageCheck < 0) return packageCheck;

            // place log record
            TaskManager.StartTask("WEB_SITE", "CHANGE_STATE", siteItem.Name);
            TaskManager.ItemId = siteItemId;
            TaskManager.WriteParameter("New state", state);

            try
            {

                // change state
                WebServer web = new WebServer();
                ServiceProviderProxy.Init(web, siteItem.ServiceId);
                web.ChangeAppPoolState(siteItem.SiteId, state);

                return 0;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
コード例 #9
0
 public AppPoolDescriptor(string name, AppPoolState state)
 {
     Name  = name;
     State = state;
 }
コード例 #10
0
 /// <remarks/>
 public void ChangeAppPoolStateAsync(int siteItemId, AppPoolState state)
 {
     this.ChangeAppPoolStateAsync(siteItemId, state, null);
 }
コード例 #11
0
 public int ChangeAppPoolState(int siteItemId, AppPoolState state)
 {
     object[] results = this.Invoke("ChangeAppPoolState", new object[] {
                 siteItemId,
                 state});
     return ((int)(results[0]));
 }
コード例 #12
0
 public void ChangeAppPoolState(string siteId, AppPoolState state)
 {
     this.Invoke("ChangeAppPoolState", new object[] {
                 siteId,
                 state});
 }
コード例 #13
0
        // AppPool
        public void ChangeAppPoolState(string siteId, AppPoolState state)
        {
            using (var srvman = GetServerManager())
            {
                var site = srvman.Sites[siteId];
                //
                if (site == null)
                    return;

                foreach (Application app in site.Applications)
                {
                    string AppPoolName = app.ApplicationPoolName;

                    if (string.IsNullOrEmpty(AppPoolName))
                        continue;

                    ApplicationPool pool = srvman.ApplicationPools[AppPoolName];
                    if (pool == null) continue;

                    //
                    switch (state)
                    {
                        case AppPoolState.Started:
                        case AppPoolState.Starting:
                            if ((pool.State != ObjectState.Started) && (pool.State != ObjectState.Starting))
                            {
                                pool.Start();
                                pool.AutoStart = true;
                            }
                            break;
                        case AppPoolState.Stopped:
                        case AppPoolState.Stopping:
                            if ((pool.State != ObjectState.Stopped) && (pool.State != ObjectState.Stopping))
                            {
                                pool.Stop();
                                pool.AutoStart = false;
                            }
                            break;
                        case AppPoolState.Recycle:
                            pool.Recycle();
                            pool.AutoStart = true;
                            break;
                    }

                    srvman.CommitChanges();

                }
            }
        }
コード例 #14
0
        // AppPool
        private void BindAppPoolState(AppPoolState state)
        {
            litAppPoolStatus.Text = GetLocalizedString("SiteState." + state.ToString());

            cmdAppPoolStart.Visible = (state == AppPoolState.Stopped || state == AppPoolState.Stopping);
            cmdAppPoolStop.Visible = (state == AppPoolState.Started || state == AppPoolState.Starting);
            cmdAppPoolRecycle.Visible = (state == AppPoolState.Started || state == AppPoolState.Starting);
        }
コード例 #15
0
 /// <remarks/>
 public void ChangeAppPoolStateAsync(string siteId, AppPoolState state)
 {
     this.ChangeAppPoolStateAsync(siteId, state, null);
 }
コード例 #16
0
        private void BindWebSite()
        {
            WebSite site = null;

            try
            {
                site = ES.Services.WebServers.GetWebSite(PanelRequest.ItemID);
            }
            catch (Exception ex)
            {
                ShowErrorMessage("WEB_GET_SITE", ex);
                return;
            }

            if (site == null)
            {
                RedirectToBrowsePage();
            }

            // IIS 7.0 mode
            IIs7 = site.IIs7;



            PackageId = site.PackageId;

            // bind site
            lnkSiteName.Text        = site.Name;
            lnkSiteName.NavigateUrl = "http://" + site.Name;

            // bind unassigned IP addresses
            ddlIpAddresses.Items.Clear();
            PackageIPAddress[] ips = ES.Services.Servers.GetPackageUnassignedIPAddresses(site.PackageId, 0, IPAddressPool.WebSites);
            foreach (PackageIPAddress ip in ips)
            {
                string fullIP = ip.ExternalIP;
                if (ip.InternalIP != null &&
                    ip.InternalIP != "" &&
                    ip.InternalIP != ip.ExternalIP)
                {
                    fullIP += " (" + ip.InternalIP + ")";
                }

                ddlIpAddresses.Items.Add(new ListItem(fullIP, ip.PackageAddressID.ToString()));
            }

            if (site.IsDedicatedIP)
            {
                litIPAddress.Text = site.SiteIPAddress;
            }
            else
            {
                IPAddressInfo[] ipsGeneral      = ES.Services.Servers.GetIPAddresses(IPAddressPool.General, PanelRequest.ServerId);
                bool            generalIPExists = ipsGeneral.Any() && !string.IsNullOrEmpty(ipsGeneral[0].ExternalIP);
                if (generalIPExists)
                {
                    lblSharedIP.Text = string.Format("({0})", ipsGeneral[0].ExternalIP);
                }
                lblSharedIP.Visible = generalIPExists;
            }

            dedicatedIP.Visible = site.IsDedicatedIP;
            sharedIP.Visible    = !site.IsDedicatedIP;

            PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            if (Utils.CheckQouta(Quotas.WEB_ALLOWIPADDRESSMODESWITCH, cntx))
            {
                cmdSwitchToDedicatedIP.Visible = (ddlIpAddresses.Items.Count > 0);
            }
            else
            {
                cmdSwitchToDedicatedIP.Visible = cmdSwitchToSharedIP.Visible = false;
            }


            litFrontPageUnavailable.Visible = false;
            tblSharePoint.Visible           = site.SharePointInstalled;
            tblFrontPage.Visible            = !site.SharePointInstalled;


            if (!site.ColdFusionAvailable)
            {
                litCFUnavailable.Text    = GetLocalizedString("Text.COLDFUSION_UNAVAILABLE");
                litCFUnavailable.Visible = true;
                rowCF.Visible            = false;
                rowVirtDir.Visible       = false;
            }
            else
            {
                if (site.ColdFusionVersion.Equals("7"))
                {
                    litCFUnavailable.Text    = "ColdFusion 7.x is installed";
                    litCFUnavailable.Visible = true;
                }
                else
                {
                    if (site.ColdFusionVersion.Equals("8"))
                    {
                        litCFUnavailable.Text = "ColdFusion 8.x is installed";
                    }
                    litCFUnavailable.Visible = true;
                }

                if (site.ColdFusionVersion.Equals("9"))
                {
                    litCFUnavailable.Text = "ColdFusion 9.x is installed";
                }
                litCFUnavailable.Visible = true;

                if (site.ColdFusionVersion.Equals("10"))
                {
                    litCFUnavailable.Text = "ColdFusion 10.x is installed";
                }
                litCFUnavailable.Visible = true;

                if (site.ColdFusionVersion.Equals("11"))
                {
                    litCFUnavailable.Text = "ColdFusion 11.x is installed";
                }
                litCFUnavailable.Visible = true;

                if (site.ColdFusionVersion.Equals("12"))
                {
                    litCFUnavailable.Text = "ColdFusion 12.x is installed";
                }
                litCFUnavailable.Visible = true;
            }

            if (!PackagesHelper.CheckGroupQuotaEnabled(PackageId, ResourceGroups.Web, Quotas.WEB_CFVIRTUALDIRS))
            {
                //virtual directories are not implemented for IIS 7
                rowVirtDir.Visible = false;
            }

            chkCfExt.Checked   = site.ColdFusionInstalled;
            chkVirtDir.Checked = site.CreateCFVirtualDirectories;

            // bind FrontPage
            if (!site.FrontPageAvailable)
            {
                litFrontPageUnavailable.Text    = GetLocalizedString("Text.FPSE_UNAVAILABLE");
                litFrontPageUnavailable.Visible = true;
                tblFrontPage.Visible            = false;
            }
            else
            {
                // set control policies
                frontPageUsername.SetPackagePolicy(site.PackageId, UserSettings.WEB_POLICY, "FrontPageAccountPolicy");
                frontPagePassword.SetPackagePolicy(site.PackageId, UserSettings.WEB_POLICY, "FrontPagePasswordPolicy");

                // set default account name
                frontPageUsername.Text = site.FrontPageAccount;
                ToggleFrontPageControls(site.FrontPageInstalled);
            }

            AppPoolRestartPanel.Visible = Utils.CheckQouta(Quotas.WEB_APPPOOLSRESTART, cntx);

            // bind controls
            webSitesHomeFolderControl.BindWebItem(PackageId, site);
            webSitesSecuredFoldersControl.BindSecuredFolders(site);
            webSitesHeliconApeControl.BindHeliconApe(site);
            webSitesExtensionsControl.BindWebItem(PackageId, site);
            webSitesMimeTypesControl.BindWebItem(site);
            webSitesCustomHeadersControl.BindWebItem(site);
            webSitesCustomErrorsControl.BindWebItem(site);
            webSitesHeliconZooControl.BindWebItem(site);

            // If SNI is enabled on the server, we do allow for SSL even if site not has dedicated Ip
            if (site.IsDedicatedIP || site.SniEnabled)
            {
                AllowSsl = true;
                WebsitesSSLControl.Visible = true;
                WebsitesSSLControl.BindWebItem(site);
            }
            else
            {
                AllowSsl = false;
                WebsitesSSLControl.Visible = false;
            }

            BindVirtualDirectories();

            // bind state
            BindSiteState(site.SiteState);
            // AppPool
            AppPoolState appPoolState = ES.Services.WebServers.GetAppPoolState(PanelRequest.ItemID);

            BindAppPoolState(appPoolState);

            // bind pointers
            BindPointers();

            // save packageid
            ViewState["PackageID"] = site.PackageId;

            //
            ToggleWmSvcControls(site);

            //
            if (!site.GetValue <bool>(WebVirtualDirectory.WmSvcSiteEnabled))
            {
                txtWmSvcAccountName.Text = AutoSuggestWmSvcAccontName(site, "_admin");
            }

            ToggleWmSvcConnectionHint(site);

            // Web Deploy Publishing
            ToggleWebDeployPublishingControls(site);
            BindWebPublishingProfileDatabases();
            BindWebPublishingProfileDatabaseUsers();
            BindWebPublishingProfileFtpAccounts(site);

            // bind tabs
            BindTabs();
        }
コード例 #17
0
 public int ChangeAppPoolState(int siteItemId, AppPoolState state)
 {
     return WebServerController.ChangeAppPoolState(siteItemId, state);
 }
コード例 #18
0
 /// <remarks/>
 public System.IAsyncResult BeginChangeAppPoolState(int siteItemId, AppPoolState state, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("ChangeAppPoolState", new object[] {
                 siteItemId,
                 state}, callback, asyncState);
 }
コード例 #19
0
ファイル: IIs70.cs プロジェクト: jonwbstr/Websitepanel
 // AppPool
 public void ChangeAppPoolState(string siteId, AppPoolState state)
 {
     webObjectsSvc.ChangeAppPoolState(siteId, state);
 }
コード例 #20
0
 /// <remarks/>
 public void ChangeAppPoolStateAsync(int siteItemId, AppPoolState state, object userState)
 {
     if ((this.ChangeAppPoolStateOperationCompleted == null))
     {
         this.ChangeAppPoolStateOperationCompleted = new System.Threading.SendOrPostCallback(this.OnChangeAppPoolStateOperationCompleted);
     }
     this.InvokeAsync("ChangeAppPoolState", new object[] {
                 siteItemId,
                 state}, this.ChangeAppPoolStateOperationCompleted, userState);
 }
コード例 #21
0
 public int ChangeAppPoolState(int siteItemId, AppPoolState state)
 {
     return(WebServerController.ChangeAppPoolState(siteItemId, state));
 }