From e2283b5358c42f13fb950a7e985f31fa5f797dc7 Mon Sep 17 00:00:00 2001 From: Ruslan Keba Date: Thu, 31 Oct 2013 12:40:57 +0200 Subject: [PATCH] Fixed in Web Engines: check allowed engines (hosting plan quotas) is enabled --- .../Data/DataProvider.cs | 20 +++++++++++++++ .../HeliconZoo/HeliconZooController.cs | 25 +++++++++++++++++++ .../WebSitesHeliconZooControl.ascx.cs | 12 ++++----- 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs index 9b13ea19..196376ce 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs @@ -4050,6 +4050,26 @@ namespace WebsitePanel.EnterpriseServer return reader; } + public static int GetServiceIdForProviderIdAndPackageId(int providerId, int packageId) + { + IDataReader reader = SqlHelper.ExecuteReader(ConnectionString, CommandType.Text, + @"SELECT PackageServices.ServiceID + FROM PackageServices + INNER JOIN Services ON PackageServices.ServiceID = Services.ServiceID + WHERE Services.ProviderID = @ProviderID and PackageID = @PackageID", + new SqlParameter("@ProviderID", providerId), + new SqlParameter("@PackageID", packageId) + ); + + if (reader.Read()) + { + return (int)reader["ServiceID"]; + } + + return -1; + + } + public static int GetServerIdForPackage(int packageId) { IDataReader reader = SqlHelper.ExecuteReader(ConnectionString, CommandType.Text, diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HeliconZoo/HeliconZooController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HeliconZoo/HeliconZooController.cs index a5055e37..d7be53b7 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HeliconZoo/HeliconZooController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HeliconZoo/HeliconZooController.cs @@ -76,6 +76,31 @@ namespace WebsitePanel.EnterpriseServer public static ShortHeliconZooEngine[] GetAllowedHeliconZooQuotasForPackage(int packageId) { + // first, check IsEnginesAllowed for this server + + // get helicon zoo provider serviceId + int heliconZooProviderId, heliconZooGroupId; + DataProvider.GetHeliconZooProviderAndGroup("HeliconZoo", out heliconZooProviderId, out heliconZooGroupId); + + // get helicon zoo service id for heliconZooProviderId and packageId + int serviceId = DataProvider.GetServiceIdForProviderIdAndPackageId(heliconZooProviderId, packageId); + + if (serviceId > 0) + { + if (IsEnginesEnabled(serviceId)) + { + // all engines allowed by default + return new ShortHeliconZooEngine[] + { + new ShortHeliconZooEngine{Name = "*", DisplayName = "*", Enabled = true} + }; + } + } + + + // all engines is not allowed + // get allowed engines from hosting plan quotas + List allowedEngines = new List(); IDataReader reader = DataProvider.GetEnabledHeliconZooQuotasForPackage(packageId); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesHeliconZooControl.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesHeliconZooControl.ascx.cs index 9fdd126c..91da8f10 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesHeliconZooControl.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesHeliconZooControl.ascx.cs @@ -58,20 +58,17 @@ namespace WebsitePanel.Portal Array.Sort(allowedEngineArray, new ShortHeliconZooEngineComparer()); - - // get enabled engines for this site from applicationHost.config string[] enabledEngineNames = ES.Services.HeliconZoo.GetEnabledEnginesForSite(site.SiteId, site.PackageId); ViewState["EnabledEnginesNames"] = enabledEngineNames; //console allowed in applicationHost.config ViewState["IsZooWebConsoleEnabled"] = enabledEngineNames.Contains("console", StringComparer.OrdinalIgnoreCase); - - List allowedEngines = new List(allowedEngineArray); + // fix engine name and check is web console enabled foreach (ShortHeliconZooEngine engine in allowedEngines) { engine.Name = engine.Name.Replace("HeliconZoo.", ""); @@ -82,7 +79,6 @@ namespace WebsitePanel.Portal //console allowed in hosting plan ViewState["IsZooWebConsoleEnabled"] = engine.Enabled; } - } ViewState["AllowedEngines"] = allowedEngines; @@ -146,7 +142,11 @@ namespace WebsitePanel.Portal continue; //skip } - if (string.Equals(appEngine, engine.KeywordedName, StringComparison.OrdinalIgnoreCase)) + if ( + string.Equals(appEngine, engine.KeywordedName, StringComparison.OrdinalIgnoreCase) + || + engine.Name == "*" + ) { filteredApplications.Add(application);