merge commit

This commit is contained in:
robvde 2013-05-15 07:37:26 +04:00
commit f37f82fdb7
16 changed files with 461 additions and 5 deletions

View file

@ -1422,6 +1422,27 @@ namespace WebsitePanel.EnterpriseServer {
}
}
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/ChangeAppPoolState", RequestNamespace = "http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace = "http://smbsaas/websitepanel/enterpriseserver", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public int ChangeAppPoolState(int siteItemId, AppPoolState state)
{
object[] results = this.Invoke("ChangeAppPoolState", new object[] {
siteItemId,
state});
return ((int)(results[0]));
}
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/GetAppPoolState", RequestNamespace = "http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace = "http://smbsaas/websitepanel/enterpriseserver", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public AppPoolState GetAppPoolState(int siteItemId)
{
object[] results = this.Invoke("GetAppPoolState", new object[] {
siteItemId
});
return ((AppPoolState)(results[0]));
}
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/GetSharedSSLDomains", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public string[] GetSharedSSLDomains(int packageId) {

View file

@ -583,6 +583,89 @@ namespace WebsitePanel.EnterpriseServer
}
}
// 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();
}
}
public static AppPoolState GetAppPoolState(int siteItemId)
{
AppPoolState state = AppPoolState.Unknown;
// check account
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
if (accountCheck < 0) return state;
// load site item
WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
if (siteItem == null)
return state;
// check package
int packageCheck = SecurityContext.CheckPackage(siteItem.PackageId, DemandPackage.IsActive);
if (packageCheck < 0) return state;
// place log record
TaskManager.StartTask("WEB_SITE", "GET_STATE", siteItem.Name);
TaskManager.ItemId = siteItemId;
try
{
// get state
WebServer web = new WebServer();
ServiceProviderProxy.Init(web, siteItem.ServiceId);
state = web.GetAppPoolState(siteItem.SiteId);
}
catch (Exception ex)
{
throw TaskManager.WriteError(ex);
}
finally
{
TaskManager.CompleteTask();
}
return state;
}
public static int DeleteWebSite(int siteItemId, bool deleteWebsiteDirectory)
{
// check account

View file

@ -181,6 +181,20 @@ namespace WebsitePanel.EnterpriseServer
return WebServerController.ChangeSiteState(siteItemId, state);
}
// AppPool
[WebMethod]
public int ChangeAppPoolState(int siteItemId, AppPoolState state)
{
return WebServerController.ChangeAppPoolState(siteItemId, state);
}
[WebMethod]
public AppPoolState GetAppPoolState(int siteItemId)
{
return WebServerController.GetAppPoolState(siteItemId);
}
#region Shared SSL Folders
[WebMethod]
public List<string> GetSharedSSLDomains(int packageId)

View file

@ -0,0 +1,43 @@
// Copyright (c) 2012, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
namespace WebsitePanel.Providers
{
[Serializable]
public enum AppPoolState
{
Unknown = 0,
Starting = 1,
Started = 2,
Stopping = 3,
Stopped = 4,
Recycle = 5
}
}

View file

@ -54,6 +54,10 @@ namespace WebsitePanel.Providers.Web
void UpdateSiteBindings(string siteId, ServerBinding[] bindings, bool emptyBindingsAllowed);
void DeleteSite(string siteId);
// AppPool
void ChangeAppPoolState(string siteId, AppPoolState state);
AppPoolState GetAppPoolState(string siteId);
// virtual directories
bool VirtualDirectoryExists(string siteId, string directoryName);
WebVirtualDirectory[] GetVirtualDirectories(string siteId);

View file

@ -72,6 +72,7 @@
<Compile Include="..\VersionInfo.cs">
<Link>VersionInfo.cs</Link>
</Compile>
<Compile Include="Common\AppPoolState.cs" />
<Compile Include="Common\ByteOperations.cs" />
<Compile Include="Common\ErrorCodes.cs" />
<Compile Include="Common\PasswdHelper.cs" />

View file

@ -1524,6 +1524,27 @@ namespace WebsitePanel.Providers.Web
}
}
// AppPool
public void ChangeAppPoolState(string siteId, AppPoolState state)
{
webObjectsSvc.ChangeAppPoolState(siteId, state);
}
public AppPoolState GetAppPoolState(string siteId)
{
using (ServerManager srvman = webObjectsSvc.GetServerManager())
{
return GetAppPoolState(srvman, siteId);
}
}
public AppPoolState GetAppPoolState(ServerManager srvman, string siteId)
{
return webObjectsSvc.GetAppPoolState(srvman, siteId);
}
/// <summary>
/// Checks whether virtual iisDirObject with supplied name under specified site exists.
/// </summary>

View file

@ -348,6 +348,98 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
return siteState;
}
// 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();
}
}
}
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;
}
public bool SiteExists(ServerManager srvman, string siteId)
{
return (srvman.Sites[siteId] != null);

View file

@ -849,6 +849,16 @@ namespace WebsitePanel.Providers.Web
}
}
// AppPool
public void ChangeAppPoolState(string siteId, AppPoolState state)
{
}
public AppPoolState GetAppPoolState(string siteId)
{
return AppPoolState.Unknown;
}
public virtual void UpdateSiteBindings(string siteId, ServerBinding[] bindings, bool emptyBindingsAllowed)
{
ManagementObject objSite = wmi.GetObject(String.Format("IIsWebServerSetting='{0}'", siteId));

View file

@ -593,6 +593,27 @@ namespace WebsitePanel.Providers.Web {
}
}
/// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/ChangeAppPoolState", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public void ChangeAppPoolState(string siteId, AppPoolState state)
{
this.Invoke("ChangeAppPoolState", new object[] {
siteId,
state});
}
/// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetAppPoolState", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public AppPoolState GetAppPoolState(string siteId)
{
object[] results = this.Invoke("GetAppPoolState", new object[] {
siteId});
return ((AppPoolState)(results[0]));
}
/// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetSiteId", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]

View file

@ -259,6 +259,41 @@ namespace WebsitePanel.Server
throw;
}
}
// AppPool
[WebMethod, SoapHeader("settings")]
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;
}
}
[WebMethod, SoapHeader("settings")]
public AppPoolState GetAppPoolState(string siteId)
{
try
{
Log.WriteStart("'{0}' GetAppPoolState", ProviderSettings.ProviderName);
AppPoolState result = WebProvider.GetAppPoolState(siteId);
Log.WriteEnd("'{0}' GetAppPoolState", ProviderSettings.ProviderName);
return result;
}
catch (Exception ex)
{
Log.WriteError(String.Format("'{0}' GetAppPoolState", ProviderSettings.ProviderName), ex);
throw;
}
}
#endregion
#region Virtual Directories

View file

@ -31,6 +31,7 @@ Default skin template. The following skins are provided as examples only.
<asp:ImageButton SkinID="StartMedium" runat="server" ImageUrl="Images/play_24.png" ImageAlign="AbsMiddle" Width="24" Height="24"/>
<asp:ImageButton SkinID="StopMedium" runat="server" ImageUrl="Images/stop_24.png" ImageAlign="AbsMiddle" Width="24" Height="24"/>
<asp:ImageButton SkinID="ContinueMedium" runat="server" ImageUrl="Images/play_24.png" ImageAlign="AbsMiddle" Width="24" Height="24"/>
<asp:ImageButton SkinID="RecycleMedium" runat="server" ImageUrl="Images/restart_24.png" ImageAlign="AbsMiddle" Width="24" Height="24"/>
<asp:ImageButton SkinID="PauseSmall" runat="server" ImageUrl="Images/pause_16.png" ImageAlign="AbsMiddle" Width="16" Height="16"/>
<asp:ImageButton SkinID="StartSmall" runat="server" ImageUrl="Images/play_16.png" ImageAlign="AbsMiddle" Width="16" Height="16"/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View file

@ -166,11 +166,12 @@
<td nowrap valign="top" align="right">
<table cellpadding="7" width="150px">
<tr>
<td>
<asp:Label ID="lblWebsiteStatus" runat="server" meta:resourcekey="lblWebsiteStatus" Text="Website Status"></asp:Label>
</td>
<td class="MediumBold" align="center">
<asp:Literal ID="litStatus" runat="server"></asp:Literal>
</td>
</tr>
<tr>
<td align="center">
<asp:ImageButton ID="cmdStart" runat="server" SkinID="StartMedium" meta:resourcekey="cmdStart"
CommandName="Started" OnClick="cmdChangeState_Click" />
@ -182,6 +183,22 @@
CommandName="Stopped" OnClick="cmdChangeState_Click" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblAppPoolStatus" runat="server" meta:resourcekey="lblAppPoolStatus" Text="App Pool Status"></asp:Label>
</td>
<td class="MediumBold" align="center">
<asp:Literal ID="litAppPoolStatus" runat="server"></asp:Literal>
</td>
<td align="center">
<asp:ImageButton ID="cmdAppPoolStart" runat="server" SkinID="StartMedium" meta:resourcekey="cmdStart"
CommandName="Started" OnClick="cmdAppPoolChangeState_Click" />
<asp:ImageButton ID="cmdAppPoolRecycle" runat="server" SkinID="RecycleMedium" meta:resourcekey="cmdRecycle"
CommandName="Recycle" OnClick="cmdAppPoolChangeState_Click" />
<asp:ImageButton ID="cmdAppPoolStop" runat="server" SkinID="StopMedium" meta:resourcekey="cmdStop"
CommandName="Stopped" OnClick="cmdAppPoolChangeState_Click" />
</td>
</tr>
</table>
</td>
</tr>

View file

@ -291,6 +291,9 @@ namespace WebsitePanel.Portal
// bind state
BindSiteState(site.SiteState);
// AppPool
AppPoolState appPoolState = ES.Services.WebServers.GetAppPoolState(PanelRequest.ItemID);
BindAppPoolState(appPoolState);
// bind pointers
BindPointers();
@ -988,6 +991,42 @@ namespace WebsitePanel.Portal
return;
}
}
// 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);
}
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;
}
}
#endregion
#region Pointers

View file

@ -346,6 +346,15 @@ namespace WebsitePanel.Portal {
/// </remarks>
protected global::System.Web.UI.WebControls.GridView gvPointers;
/// <summary>
/// lblWebsiteStatus 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 lblWebsiteStatus;
/// <summary>
/// litStatus control.
/// </summary>
@ -391,6 +400,51 @@ namespace WebsitePanel.Portal {
/// </remarks>
protected global::System.Web.UI.WebControls.ImageButton cmdStop;
/// <summary>
/// lblAppPoolStatus 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 lblAppPoolStatus;
/// <summary>
/// litAppPoolStatus 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.Literal litAppPoolStatus;
/// <summary>
/// cmdAppPoolStart 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.ImageButton cmdAppPoolStart;
/// <summary>
/// cmdAppPoolRecycle 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.ImageButton cmdAppPoolRecycle;
/// <summary>
/// cmdAppPoolStop 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.ImageButton cmdAppPoolStop;
/// <summary>
/// dlTabs control.
/// </summary>