HeliconApeStatus instead of several boolean variables

This commit is contained in:
Sergey 2012-12-18 13:15:05 +02:00
parent 202d058912
commit a22fc06d07
4 changed files with 44 additions and 23 deletions

View file

@ -30,6 +30,7 @@ using System;
using System.ComponentModel; using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using WebsitePanel.Providers.ResultObjects;
namespace WebsitePanel.Providers.Web namespace WebsitePanel.Providers.Web
{ {
@ -61,6 +62,7 @@ namespace WebsitePanel.Providers.Web
private bool securedFoldersInstalled; private bool securedFoldersInstalled;
private bool heliconApeInstalled; private bool heliconApeInstalled;
private bool heliconApeEnabled; private bool heliconApeEnabled;
private HeliconApeStatus heliconApeStatus;
public WebSite() public WebSite()
{ {
@ -179,6 +181,12 @@ namespace WebsitePanel.Providers.Web
get { return this.heliconApeEnabled; } get { return this.heliconApeEnabled; }
set { this.heliconApeEnabled = value; } set { this.heliconApeEnabled = value; }
} }
public HeliconApeStatus HeliconApeStatus
{
get { return this.heliconApeStatus; }
set { this.heliconApeStatus = value; }
}
} }
[Flags] [Flags]

View file

@ -1165,6 +1165,7 @@ namespace WebsitePanel.Providers.Web
HeliconApeStatus heliconApeStatus = GetHeliconApeStatus(srvman, siteId); HeliconApeStatus heliconApeStatus = GetHeliconApeStatus(srvman, siteId);
site.HeliconApeInstalled = heliconApeStatus.IsInstalled; site.HeliconApeInstalled = heliconApeStatus.IsInstalled;
site.HeliconApeEnabled = heliconApeStatus.IsEnabled; site.HeliconApeEnabled = heliconApeStatus.IsEnabled;
site.HeliconApeStatus = heliconApeStatus;
// //
site.SiteState = GetSiteState(srvman, siteId); site.SiteState = GetSiteState(srvman, siteId);

View file

@ -132,6 +132,9 @@
<data name="EnableHeliconApe.Text" xml:space="preserve"> <data name="EnableHeliconApe.Text" xml:space="preserve">
<value>Enable Helicon Ape</value> <value>Enable Helicon Ape</value>
</data> </data>
<data name="EnableHeliconApeTrial.Text" xml:space="preserve">
<value>Enable Helicon Ape (45 days trial)</value>
</data>
<data name="gvHeliconApeFolders.Empty" xml:space="preserve"> <data name="gvHeliconApeFolders.Empty" xml:space="preserve">
<value>Click "Add Folder" button to add .htaccess folder</value> <value>Click "Add Folder" button to add .htaccess folder</value>
</data> </data>

View file

@ -38,23 +38,12 @@ using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls; using System.Web.UI.HtmlControls;
using WebsitePanel.Providers.Web; using WebsitePanel.Providers.Web;
using WebsitePanel.Providers.ResultObjects;
namespace WebsitePanel.Portal namespace WebsitePanel.Portal
{ {
public partial class WebSitesHeliconApeControl : WebsitePanelControlBase public partial class WebSitesHeliconApeControl : WebsitePanelControlBase
{ {
private bool IsHeliconApeInstalled
{
get { return ViewState["IsHeliconApeInstalled"] != null ? (bool)ViewState["IsHeliconApeInstalled"] : false; }
set { ViewState["IsHeliconApeInstalled"] = value; }
}
private bool IsHeliconApeEnabled
{
get { return ViewState["IsHeliconApeEnabled"] != null ? (bool)ViewState["IsHeliconApeEnabled"] : false; }
set { ViewState["IsHeliconApeEnabled"] = value; }
}
private bool IsSecuredFoldersInstalled private bool IsSecuredFoldersInstalled
{ {
@ -62,9 +51,16 @@ namespace WebsitePanel.Portal
set { ViewState["IsSecuredFoldersInstalled"] = value; } set { ViewState["IsSecuredFoldersInstalled"] = value; }
} }
private HeliconApeStatus HeliconApeStatus
{
get { return (HeliconApeStatus)ViewState["HeliconApeStatus"]; }
set { ViewState["HeliconApeStatus"] = value; }
}
protected void Page_Load(object sender, EventArgs e) protected void Page_Load(object sender, EventArgs e)
{ {
if (IsHeliconApeInstalled) if (HeliconApeStatus.IsInstalled)
{ {
if (!IsPostBack) if (!IsPostBack)
{ {
@ -90,12 +86,12 @@ namespace WebsitePanel.Portal
public void BindHeliconApe(WebSite site) public void BindHeliconApe(WebSite site)
{ {
// save initial state // save initial state
IsHeliconApeInstalled = site.HeliconApeInstalled; this.IsSecuredFoldersInstalled = site.SecuredFoldersInstalled;
IsHeliconApeEnabled = site.HeliconApeEnabled; this.HeliconApeStatus = site.HeliconApeStatus;
IsSecuredFoldersInstalled = site.SecuredFoldersInstalled;
// Render a warning message about the automatic site's settings change // Render a warning message about the automatic site's settings change
if (!IsHeliconApeEnabled && site.IIs7) if (!HeliconApeStatus.IsEnabled && site.IIs7)
{ {
// Ensure the message is displayed only when neccessary // Ensure the message is displayed only when neccessary
if (site.EnableWindowsAuthentication || !site.AspNetInstalled.EndsWith("I") || site.SecuredFoldersInstalled) if (site.EnableWindowsAuthentication || !site.AspNetInstalled.EndsWith("I") || site.SecuredFoldersInstalled)
@ -113,11 +109,21 @@ namespace WebsitePanel.Portal
private void ToggleControls() private void ToggleControls()
{ {
if (IsHeliconApeInstalled) if (HeliconApeStatus.IsInstalled)
{ {
bool IsHeliconApeEnabled = HeliconApeStatus.IsEnabled;
// toggle button // toggle button
btnToggleHeliconApe.Text = GetLocalizedString( if (IsHeliconApeEnabled)
IsHeliconApeEnabled ? "DisableHeliconApe.Text" : "EnableHeliconApe.Text"); {
btnToggleHeliconApe.Text = GetLocalizedString("DisableHeliconApe.Text");
}
else
{
btnToggleHeliconApe.Text = GetLocalizedString("EnableHeliconApe.Text");
}
// toggle panels // toggle panels
HeliconApeFoldersPanel.Visible = IsHeliconApeEnabled; HeliconApeFoldersPanel.Visible = IsHeliconApeEnabled;
@ -165,7 +171,7 @@ namespace WebsitePanel.Portal
try try
{ {
int result = 0; int result = 0;
if (IsHeliconApeEnabled) if (HeliconApeStatus.IsEnabled)
{ {
// uninstall folders // uninstall folders
result = ES.Services.WebServers.DisableHeliconApe(PanelRequest.ItemID); result = ES.Services.WebServers.DisableHeliconApe(PanelRequest.ItemID);
@ -189,7 +195,10 @@ namespace WebsitePanel.Portal
} }
// change state // change state
IsHeliconApeEnabled = !IsHeliconApeEnabled; HeliconApeStatus status = HeliconApeStatus;
status.IsEnabled = !status.IsEnabled;
HeliconApeStatus = status;
// bind items // bind items
ToggleControls(); ToggleControls();