merge commit

This commit is contained in:
robvde 2013-09-21 11:56:18 +04:00
commit dd462e4c6a
37 changed files with 8177 additions and 666 deletions

View file

@ -123,4 +123,18 @@
<data name="SelectWebEngine.Text" xml:space="preserve">
<value>Select web application engine to set up</value>
</data>
<data name="gvInstalledApplicationsEnableConsole.Header" xml:space="preserve">
<value>Web console</value>
</data>
<data name="btnEnable.Text" xml:space="preserve">
<value>Enable</value>
</data>
<data name="btnDisable.Text" xml:space="preserve">
<value>Disable</value>
</data>
<data name="EnableWebConsole.Text" xml:space="preserve">
<value>Enable web console</value>
</data>
</root>

View file

@ -89,10 +89,12 @@ span.ValidationMessageBlock {
<fieldset>
<legend>
<span>Helicon Zoo engine quotas settings</span>
<span>Helicon Zoo settings</span>
</legend>
<div class="FormBody">
<asp:CheckBox runat="server" ID="QuotasEnabled" Text="Enable Quotas"/>
<asp:CheckBox runat="server" ID="QuotasEnabled" Text="Enable hosting plan controls for web engines."/>
<br />
<asp:CheckBox runat="server" ID="WebCosoleEnabled" Text="Enable web console."/>
</div>
</fieldset>

View file

@ -68,7 +68,7 @@ public partial class HeliconZoo_Settings : WebsitePanelControlBase, IHostingServ
private void BindHostingPackages()
{
// TODO: try...catch?
WPIProduct[] products = null;
try
{
@ -92,6 +92,12 @@ public partial class HeliconZoo_Settings : WebsitePanelControlBase, IHostingServ
private void BindEngines()
{
WPIProduct zooModule = ES.Services.Servers.GetWPIProductById(PanelRequest.ServerId, "HeliconZooModule");
if (!zooModule.IsInstalled || zooModule.IsUpgrade)
{
HostModule.ShowWarningMessage("Zoo Module is not installed or out-of-date. To proceed press 'Add' or 'Update' next to Helicon Zoo Module below, then press 'Install'.");
}
// get all engines from IIS
HeliconZooEngine[] engineList = ES.Services.HeliconZoo.GetEngines(PanelRequest.ServiceId);
@ -114,6 +120,8 @@ public partial class HeliconZoo_Settings : WebsitePanelControlBase, IHostingServ
// bind 'Enable quotas' checkbox
bool enabled = ES.Services.HeliconZoo.IsEnginesEnabled(PanelRequest.ServiceId);
QuotasEnabled.Checked = !enabled;
WebCosoleEnabled.Checked = ES.Services.HeliconZoo.IsWebCosoleEnabled(PanelRequest.ServiceId);
}
else
{
@ -139,6 +147,8 @@ public partial class HeliconZoo_Settings : WebsitePanelControlBase, IHostingServ
// save switcher
ES.Services.HeliconZoo.SwithEnginesEnabled(PanelRequest.ServiceId, !QuotasEnabled.Checked);
ES.Services.HeliconZoo.SetWebCosoleEnabled(PanelRequest.ServiceId, WebCosoleEnabled.Checked);
}
protected void ClearEngineForm()
@ -390,7 +400,15 @@ public partial class HeliconZoo_Settings : WebsitePanelControlBase, IHostingServ
private static WPIProduct[] RequestHostingPackages()
{
return ES.Services.Servers.GetWPIProducts(PanelRequest.ServerId, null, "ZooPackage");
List<WPIProduct> result = new List<WPIProduct>();
result.Add(ES.Services.Servers.GetWPIProductById(PanelRequest.ServerId, "HeliconZooModule"));
result.AddRange(ES.Services.Servers.GetWPIProducts(PanelRequest.ServerId, null, "ZooPackage"));
return result.ToArray();
}
protected string AddUpgradeRemoveText(WPIProduct wpiProduct)

View file

@ -26,6 +26,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
@ -84,6 +85,15 @@ public partial class HeliconZoo_Settings {
/// </remarks>
protected global::System.Web.UI.WebControls.Label HostingPackagesLoadingError;
/// <summary>
/// EnginesPanel control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Panel EnginesPanel;
/// <summary>
/// QuotasEnabled control.
/// </summary>
@ -94,13 +104,13 @@ public partial class HeliconZoo_Settings {
protected global::System.Web.UI.WebControls.CheckBox QuotasEnabled;
/// <summary>
/// EnginesPanel control.
/// WebCosoleEnabled control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Panel EnginesPanel;
protected global::System.Web.UI.WebControls.CheckBox WebCosoleEnabled;
/// <summary>
/// ButtonAddEngine control.

View file

@ -28,12 +28,72 @@
--%>
<p>
<asp:Label runat="server" meta:resourcekey="SelectWebEngine" CssClass="NormalBold"></asp:Label>
<asp:Label ID="lblConsole" runat="server" meta:resourcekey="EnableWebConsole" CssClass="NormalBold"></asp:Label>
</p>
<br />
<%--<asp:GridView id="gvInstalledApplications" runat="server" AutoGenerateColumns="True" AllowPaging="true"
ShowHeader="false" CssSelectorClass="LightGridView" EmptyDataText="gvInstalledApplications.Empty"
>
</asp:GridView>--%>
<asp:GridView ID="gvInstalledApplications" runat="server"
EnableViewState="True" AutoGenerateColumns="false"
ShowHeader="true" CssSelectorClass="NormalGridView"
EmptyDataText="gvVirtualDirectories"
onrowcommand="gvInstalledApplications_RowCommand">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name">
<ItemStyle Width="60%" />
</asp:BoundField>
<asp:TemplateField HeaderText="gvInstalledApplicationsEnableConsole">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:Button ID="btnEnable" runat="server"
Text='<%# GetLocalizedString("btnEnable.Text") %>' CssClass="Button1"
CommandArgument='<%# Eval("Name") %>'
CommandName="EnableConsole"
Visible= '<%# IsNullOrEmpty( (string)Eval("ConsoleUrl")) %>'
/>
<asp:Button ID="btnDisable" runat="server"
Text='<%# GetLocalizedString("btnDisable.Text") %>' CssClass="Button1"
CommandArgument='<%# Eval("Name") %>'
CommandName="DisableConsole"
Visible= '<%# !IsNullOrEmpty( (string)Eval("ConsoleUrl")) %>'
/>
&nbsp;&nbsp;
<asp:hyperlink
CssClass="MediumBold"
NavigateUrl='<%# GetConsoleFullUrl((string)Eval("ConsoleUrl")) %>'
runat="server"
ID="lnkAppDetails"
ToolTip='<%# Eval("ConsoleUrl") %>'
Target="_blank"
Visible= '<%# !IsNullOrEmpty( (string)Eval("ConsoleUrl")) %>'>
Open console
</asp:hyperlink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<p>
<asp:Label runat="server" meta:resourcekey="SelectWebEngine" CssClass="NormalBold"></asp:Label>
</p>
<br />
<asp:GridView id="gvApplications" runat="server" AutoGenerateColumns="False" AllowPaging="true"
ShowHeader="false" CssSelectorClass="LightGridView" EmptyDataText="gvApplications" OnRowCommand="gvApplications_RowCommand"
ShowHeader="false" CssSelectorClass="LightGridView" EmptyDataText="There are no applications" OnRowCommand="gvApplications_RowCommand"
OnPageIndexChanging="gvApplications_PageIndexChanging">
<Columns>
<asp:TemplateField HeaderText="gvApplicationsApplication">

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Web;
@ -9,6 +10,7 @@ using WebsitePanel.Providers.HeliconZoo;
using WebsitePanel.Providers.ResultObjects;
using WebsitePanel.Providers.Web;
using WebsitePanel.Providers.WebAppGallery;
using WebsitePanel.WebPortal;
namespace WebsitePanel.Portal
{
@ -32,6 +34,19 @@ namespace WebsitePanel.Portal
ViewState["WebSitePackageId"] = site.PackageId;
BindEngines(site);
try
{
BindInstalledApplications();
}
catch (Exception ex)
{
lblConsole.Text = "Zoo Module is not installed. Please ask your system administrator to install Zoo on the server to Configuration\\Server\\Web Application Engines.";
lblConsole.ForeColor = Color.Red;
lblConsole.Font.Size = 16;
return; // Exit
}
BindApplications();
}
@ -42,12 +57,17 @@ namespace WebsitePanel.Portal
ES.Services.HeliconZoo.GetAllowedHeliconZooQuotasForPackage(site.PackageId);
Array.Sort(allowedEngineArray, new ShortHeliconZooEngineComparer());
// get enabled engines for this site
// 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);
//EnabledEnginesList.DataSource = enabledEngineNames;
//EnabledEnginesList.DataBind();
List<ShortHeliconZooEngine> allowedEngines = new List<ShortHeliconZooEngine>(allowedEngineArray);
@ -55,18 +75,51 @@ namespace WebsitePanel.Portal
foreach (ShortHeliconZooEngine engine in allowedEngines)
{
engine.Name = engine.Name.Replace("HeliconZoo.", "");
engine.Enabled = enabledEngineNames.Contains(engine.Name, StringComparer.OrdinalIgnoreCase);
//engine.Enabled = enabledEngineNames.Contains(engine.Name, StringComparer.OrdinalIgnoreCase);
if (engine.Name == "console")
{
//console allowed in hosting plan
ViewState["IsZooWebConsoleEnabled"] = engine.Enabled;
}
}
ViewState["AllowedEngines"] = allowedEngines;
//AllowedEnginesList.DataSource = allowedEngines;
//AllowedEnginesList.DataBind();
}
private void BindInstalledApplications()
{
ViewState["IsZooEnabled"] = false;
var installedApplications = ES.Services.WebServers.GetZooApplications(PanelRequest.ItemID);
ViewState["IsZooEnabled"] = true;
if ((bool) ViewState["IsZooWebConsoleEnabled"])
{
gvInstalledApplications.DataSource = installedApplications;
gvInstalledApplications.DataBind();
}
else
{
HideInstalledApplications();
}
}
private void HideInstalledApplications()
{
gvInstalledApplications.Visible = false;
lblConsole.Visible = false;
}
private void BindApplications()
{
WebAppGalleryHelpers helper = new WebAppGalleryHelpers();
GalleryApplicationsResult result = helper.GetGalleryApplications("ZooTemplate", PanelSecurity.PackageId);
List<GalleryApplication> applications = result.Value as List<GalleryApplication>;
@ -77,19 +130,34 @@ namespace WebsitePanel.Portal
{
foreach (GalleryApplication application in applications)
{
foreach (string keyword in application.Keywords)
{
bool appAlreadyAdded = false;
if (keyword.StartsWith("ZooEngine", StringComparison.OrdinalIgnoreCase))
{
string appEngine = keyword.Substring("ZooEngine".Length);
foreach (ShortHeliconZooEngine engine in allowedEngines)
{
if (!engine.Enabled)
{
continue; //skip
}
if (string.Equals(appEngine, engine.KeywordedName, StringComparison.OrdinalIgnoreCase))
{
filteredApplications.Add(application);
appAlreadyAdded = true;
break;
}
}
if (appAlreadyAdded)
{
break;
}
}
}
}
@ -120,6 +188,11 @@ namespace WebsitePanel.Portal
private void UpdatedAllowedEngines()
{
if (!(bool) ViewState["IsZooEnabled"])
{
return; // exit;
}
List<ShortHeliconZooEngine> allowedEngines = (List<ShortHeliconZooEngine>)ViewState["AllowedEngines"];
string[] enabledEngineNames = (string[])ViewState["EnabledEnginesNames"];
@ -180,9 +253,11 @@ namespace WebsitePanel.Portal
{
//http://localhost:9001/Default.aspx?pid=SpaceWebApplicationsGallery&mid=122&ctl=edit&ApplicationID=DotNetNuke&SpaceID=7
var mid = GetWebAppGaleryModuleId();
List<string> url = new List<string>();
url.Add("pid=SpaceWebApplicationsGallery");
url.Add("mid=122");
url.Add(string.Format("{0}={1}", DefaultPage.MODULE_ID_PARAM, mid));
url.Add("ctl=edit");
url.Add("SpaceID="+PanelSecurity.PackageId.ToString(CultureInfo.InvariantCulture));
url.Add("ApplicationID=" + appId);
@ -195,5 +270,60 @@ namespace WebsitePanel.Portal
return "~/Default.aspx?" + String.Join("&", url.ToArray());
}
private static int GetWebAppGaleryModuleId()
{
// default value, valid in 2.1.0.166
int mid = 124;
foreach (KeyValuePair<int, PageModule> pair in PortalConfiguration.Site.Modules)
{
if (string.Equals(pair.Value.ModuleDefinitionID, "webapplicationsgallery", StringComparison.OrdinalIgnoreCase))
{
mid = pair.Value.ModuleId;
break;
}
}
return mid;
}
protected void gvInstalledApplications_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "EnableConsole")
{
UpdatedAllowedEngines();
string appName = e.CommandArgument.ToString();
ES.Services.WebServers.SetZooConsoleEnabled(PanelRequest.ItemID, appName);
BindInstalledApplications();
}
if (e.CommandName == "DisableConsole")
{
UpdatedAllowedEngines();
string appName = e.CommandArgument.ToString();
ES.Services.WebServers.SetZooConsoleDisabled(PanelRequest.ItemID, appName);
BindInstalledApplications();
}
}
protected bool IsNullOrEmpty(string value)
{
return string.IsNullOrEmpty(value);
}
protected string GetConsoleFullUrl(string consoleUrl)
{
WebSite site = ES.Services.WebServers.GetWebSite(PanelRequest.ItemID);
return "http://" + site.Name + consoleUrl;
}
}
}

View file

@ -26,6 +26,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
@ -40,6 +41,24 @@ namespace WebsitePanel.Portal {
public partial class WebSitesHeliconZooControl {
/// <summary>
/// lblConsole control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblConsole;
/// <summary>
/// gvInstalledApplications control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.GridView gvInstalledApplications;
/// <summary>
/// gvApplications control.
/// </summary>