Re-factored IIS 7 provider to improve GetSite() operation performance.
This commit is contained in:
parent
58b073a6aa
commit
eb64f13221
21 changed files with 1058 additions and 1058 deletions
|
@ -47,7 +47,6 @@ namespace WebsitePanel.Providers.Web
|
|||
private string siteId;
|
||||
private string siteIPAddress;
|
||||
private int siteIPAddressId;
|
||||
private string logsPath;
|
||||
private string dataPath;
|
||||
private ServerBinding[] bindings;
|
||||
private bool frontPageAvailable;
|
||||
|
|
|
@ -908,7 +908,7 @@ namespace WebsitePanel.Providers.VirtualizationForPC
|
|||
steps.AppendLine("VM created");
|
||||
}
|
||||
}
|
||||
catch (System.TimeoutException ex)
|
||||
catch (System.TimeoutException)
|
||||
{
|
||||
vmTemplate.ProvisioningStatus = VirtualMachineProvisioningStatus.InProgress;
|
||||
}
|
||||
|
@ -1064,38 +1064,32 @@ namespace WebsitePanel.Providers.VirtualizationForPC
|
|||
{
|
||||
List<Virtualization.VirtualNetworkInfo> result = new List<Virtualization.VirtualNetworkInfo>();
|
||||
|
||||
try
|
||||
using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient())
|
||||
{
|
||||
using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient())
|
||||
VirtualizationForPC.SVMMService.VirtualNetworkInfo[] networks = client.GetVirtualNetworkByHost(hostInfo);
|
||||
foreach (var item in networks)
|
||||
{
|
||||
VirtualizationForPC.SVMMService.VirtualNetworkInfo[] networks = client.GetVirtualNetworkByHost(hostInfo);
|
||||
foreach (var item in networks)
|
||||
{
|
||||
result.Add(
|
||||
new Virtualization.VirtualNetworkInfo
|
||||
{
|
||||
BoundToVMHost = item.BoundToVMHost,
|
||||
DefaultGatewayAddress = item.DefaultGatewayAddress,
|
||||
Description = item.Description,
|
||||
DNSServers = item.DNSServers,
|
||||
EnablingIPAddress = item.EnablingIPAddress,
|
||||
HighlyAvailable = item.HighlyAvailable,
|
||||
HostBoundVlanId = item.HostBoundVlanId,
|
||||
Id = item.Id,
|
||||
Name = item.Name,
|
||||
NetworkAddress = item.NetworkAddress,
|
||||
NetworkMask = item.NetworkMask,
|
||||
Tag = item.Tag,
|
||||
VMHost = item.VMHost.ComputerName,
|
||||
VMHostId = item.VMHostId,
|
||||
WINServers = item.WINServers
|
||||
});
|
||||
}
|
||||
result.Add(
|
||||
new Virtualization.VirtualNetworkInfo
|
||||
{
|
||||
BoundToVMHost = item.BoundToVMHost,
|
||||
DefaultGatewayAddress = item.DefaultGatewayAddress,
|
||||
Description = item.Description,
|
||||
DNSServers = item.DNSServers,
|
||||
EnablingIPAddress = item.EnablingIPAddress,
|
||||
HighlyAvailable = item.HighlyAvailable,
|
||||
HostBoundVlanId = item.HostBoundVlanId,
|
||||
Id = item.Id,
|
||||
Name = item.Name,
|
||||
NetworkAddress = item.NetworkAddress,
|
||||
NetworkMask = item.NetworkMask,
|
||||
Tag = item.Tag,
|
||||
VMHost = item.VMHost.ComputerName,
|
||||
VMHostId = item.VMHostId,
|
||||
WINServers = item.WINServers
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
return result.ToArray();
|
||||
|
||||
|
@ -1287,35 +1281,29 @@ namespace WebsitePanel.Providers.VirtualizationForPC
|
|||
|
||||
List<VirtualMachineSnapshot> ret = new List<VirtualMachineSnapshot>();
|
||||
|
||||
try
|
||||
using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient())
|
||||
{
|
||||
using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient())
|
||||
{
|
||||
VMCheckpointInfo[] chkPtnList = client.GetVirtualMachineByName(vmId).VMCheckpoints;
|
||||
VMCheckpointInfo[] chkPtnList = client.GetVirtualMachineByName(vmId).VMCheckpoints;
|
||||
|
||||
if (chkPtnList != null)
|
||||
if (chkPtnList != null)
|
||||
{
|
||||
foreach (VMCheckpointInfo curr in chkPtnList)
|
||||
{
|
||||
foreach (VMCheckpointInfo curr in chkPtnList)
|
||||
ret.Add(new VirtualMachineSnapshot()
|
||||
{
|
||||
ret.Add(new VirtualMachineSnapshot()
|
||||
{
|
||||
Created = curr.AddedTime
|
||||
,
|
||||
Id = curr.Id.ToString()
|
||||
,
|
||||
Name = curr.Name
|
||||
,
|
||||
CheckPointId = curr.CheckpointID
|
||||
,
|
||||
ParentId = curr.ParentCheckpointID
|
||||
});
|
||||
}
|
||||
Created = curr.AddedTime
|
||||
,
|
||||
Id = curr.Id.ToString()
|
||||
,
|
||||
Name = curr.Name
|
||||
,
|
||||
CheckPointId = curr.CheckpointID
|
||||
,
|
||||
ParentId = curr.ParentCheckpointID
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1338,7 +1326,7 @@ namespace WebsitePanel.Providers.VirtualizationForPC
|
|||
client.NewVirtualMachineCheckpoint(vm.Id, String.Format("{0} - {1}", vm.Name, DateTime.Now), String.Empty);
|
||||
}
|
||||
}
|
||||
catch (TimeoutException ext)
|
||||
catch (TimeoutException)
|
||||
{
|
||||
ret.ReturnValue = ReturnCode.JobStarted;
|
||||
}
|
||||
|
@ -1368,7 +1356,7 @@ namespace WebsitePanel.Providers.VirtualizationForPC
|
|||
client.RestoreVirtualMachineCheckpoint(snapshotId);
|
||||
}
|
||||
}
|
||||
catch (TimeoutException ext)
|
||||
catch (TimeoutException)
|
||||
{
|
||||
error = true;
|
||||
ret.ReturnValue = ReturnCode.JobStarted;
|
||||
|
@ -1856,25 +1844,19 @@ namespace WebsitePanel.Providers.VirtualizationForPC
|
|||
public WSPVirtualMachineManagementServiceClient GetVMMSClient()
|
||||
{
|
||||
WSPVirtualMachineManagementServiceClient ret;
|
||||
try
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(SCVMMServer)
|
||||
&& !String.IsNullOrWhiteSpace(SCVMMPrincipalName))
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(SCVMMServer)
|
||||
&& !String.IsNullOrWhiteSpace(SCVMMPrincipalName))
|
||||
{
|
||||
EndpointAddress endPointAddress = GetEndPointAddress(SCVMMServer, SCVMMPrincipalName);
|
||||
EndpointAddress endPointAddress = GetEndPointAddress(SCVMMServer, SCVMMPrincipalName);
|
||||
|
||||
ret = new WSPVirtualMachineManagementServiceClient(new WSHttpBinding("WSHttpBinding_IVirtualMachineManagementService"), endPointAddress);
|
||||
ret = new WSPVirtualMachineManagementServiceClient(new WSHttpBinding("WSHttpBinding_IVirtualMachineManagementService"), endPointAddress);
|
||||
|
||||
VersionInfo ver = new VersionInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("SCVMMServer or SCVMMPrincipalName is empty");
|
||||
}
|
||||
VersionInfo ver = new VersionInfo();
|
||||
}
|
||||
catch (Exception ex)
|
||||
else
|
||||
{
|
||||
throw;
|
||||
throw new Exception("SCVMMServer or SCVMMPrincipalName is empty");
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -1884,23 +1866,16 @@ namespace WebsitePanel.Providers.VirtualizationForPC
|
|||
{
|
||||
WSPMonitoringServiceClient ret;
|
||||
|
||||
try
|
||||
if (!String.IsNullOrWhiteSpace(SCOMServer)
|
||||
&& !String.IsNullOrWhiteSpace(SCOMPrincipalName))
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(SCOMServer)
|
||||
&& !String.IsNullOrWhiteSpace(SCOMPrincipalName))
|
||||
{
|
||||
EndpointAddress endPointAddress = GetEndPointAddress(SCOMServer, SCOMPrincipalName);
|
||||
EndpointAddress endPointAddress = GetEndPointAddress(SCOMServer, SCOMPrincipalName);
|
||||
|
||||
ret = new WSPMonitoringServiceClient(new WSHttpBinding("WSHttpBinding_IMonitoringService"), endPointAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("MonitoringServer or MonitoringPrincipalName is empty");
|
||||
}
|
||||
ret = new WSPMonitoringServiceClient(new WSHttpBinding("WSHttpBinding_IMonitoringService"), endPointAddress);
|
||||
}
|
||||
catch (Exception ex)
|
||||
else
|
||||
{
|
||||
throw;
|
||||
throw new Exception("MonitoringServer or MonitoringPrincipalName is empty");
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -41,23 +41,20 @@ namespace WebsitePanel.Providers.Web.Iis.Authentication
|
|||
public const string UserNameAttribute = "userName";
|
||||
public const string PasswordAttribute = "password";
|
||||
|
||||
public PropertyBag GetAuthenticationSettings(string siteId)
|
||||
public PropertyBag GetAuthenticationSettings(ServerManager srvman, string siteId)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
var config = srvman.GetApplicationHostConfiguration();
|
||||
//
|
||||
var section = config.GetSection(Constants.AnonymousAuthenticationSection, siteId);
|
||||
//
|
||||
PropertyBag bag = new PropertyBag();
|
||||
//
|
||||
bag[AuthenticationGlobals.AnonymousAuthenticationUserName] = Convert.ToString(section.GetAttributeValue(UserNameAttribute));
|
||||
bag[AuthenticationGlobals.AnonymousAuthenticationPassword] = Convert.ToString(section.GetAttributeValue(PasswordAttribute));
|
||||
bag[AuthenticationGlobals.Enabled] = Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute));
|
||||
bag[AuthenticationGlobals.IsLocked] = section.IsLocked;
|
||||
//
|
||||
return bag;
|
||||
}
|
||||
var config = srvman.GetApplicationHostConfiguration();
|
||||
//
|
||||
var section = config.GetSection(Constants.AnonymousAuthenticationSection, siteId);
|
||||
//
|
||||
PropertyBag bag = new PropertyBag();
|
||||
//
|
||||
bag[AuthenticationGlobals.AnonymousAuthenticationUserName] = Convert.ToString(section.GetAttributeValue(UserNameAttribute));
|
||||
bag[AuthenticationGlobals.AnonymousAuthenticationPassword] = Convert.ToString(section.GetAttributeValue(PasswordAttribute));
|
||||
bag[AuthenticationGlobals.Enabled] = Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute));
|
||||
bag[AuthenticationGlobals.IsLocked] = section.IsLocked;
|
||||
//
|
||||
return bag;
|
||||
}
|
||||
|
||||
public void SetAuthenticationSettings(string virtualPath, string userName,
|
||||
|
|
|
@ -37,16 +37,13 @@ namespace WebsitePanel.Providers.Web.Iis.Authentication
|
|||
{
|
||||
public const string EnabledAttribute = "enabled";
|
||||
|
||||
public void GetAuthenticationSettings(WebVirtualDirectory virtualDir)
|
||||
public void GetAuthenticationSettings(ServerManager srvman, WebVirtualDirectory virtualDir)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
var config = srvman.GetApplicationHostConfiguration();
|
||||
//
|
||||
var section = config.GetSection(Constants.BasicAuthenticationSection, virtualDir.FullQualifiedPath);
|
||||
//
|
||||
virtualDir.EnableBasicAuthentication = Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute));
|
||||
}
|
||||
var config = srvman.GetApplicationHostConfiguration();
|
||||
//
|
||||
var section = config.GetSection(Constants.BasicAuthenticationSection, virtualDir.FullQualifiedPath);
|
||||
//
|
||||
virtualDir.EnableBasicAuthentication = Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute));
|
||||
}
|
||||
|
||||
public void SetAuthenticationSettings(WebVirtualDirectory virtualDir)
|
||||
|
|
|
@ -37,20 +37,15 @@ namespace WebsitePanel.Providers.Web.Iis.Authentication
|
|||
{
|
||||
public const string EnabledAttribute = "enabled";
|
||||
|
||||
public PropertyBag GetAuthenticationSettings(string siteId)
|
||||
public PropertyBag GetAuthenticationSettings(ServerManager srvman, string siteId)
|
||||
{
|
||||
PropertyBag bag = new PropertyBag();
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
var config = srvman.GetApplicationHostConfiguration();
|
||||
//
|
||||
var section = config.GetSection(Constants.WindowsAuthenticationSection, siteId);
|
||||
//
|
||||
bag[AuthenticationGlobals.IsLocked] = section.IsLocked;
|
||||
bag[AuthenticationGlobals.Enabled] = Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute));
|
||||
}
|
||||
//
|
||||
var config = srvman.GetApplicationHostConfiguration();
|
||||
//
|
||||
var section = config.GetSection(Constants.WindowsAuthenticationSection, siteId);
|
||||
//
|
||||
bag[AuthenticationGlobals.IsLocked] = section.IsLocked;
|
||||
bag[AuthenticationGlobals.Enabled] = Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute));
|
||||
return bag;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,20 +40,17 @@ namespace WebsitePanel.Providers.Web.Iis.ClassicAsp
|
|||
public const string SectionName = "system.webServer/asp";
|
||||
public const string EnableParentPathsAttribute = "enableParentPaths";
|
||||
|
||||
public PropertyBag GetClassicAspSettings(string siteId)
|
||||
public PropertyBag GetClassicAspSettings(ServerManager srvman, string siteId)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
var config = srvman.GetApplicationHostConfiguration();
|
||||
//
|
||||
var aspSection = config.GetSection(SectionName, siteId);
|
||||
//
|
||||
PropertyBag bag = new PropertyBag();
|
||||
//
|
||||
bag[ClassicAspGlobals.EnableParentPaths] = Convert.ToBoolean(aspSection.GetAttributeValue(EnableParentPathsAttribute));
|
||||
//
|
||||
return bag;
|
||||
}
|
||||
var config = srvman.GetApplicationHostConfiguration();
|
||||
//
|
||||
var aspSection = config.GetSection(SectionName, siteId);
|
||||
//
|
||||
PropertyBag bag = new PropertyBag();
|
||||
//
|
||||
bag[ClassicAspGlobals.EnableParentPaths] = Convert.ToBoolean(aspSection.GetAttributeValue(EnableParentPathsAttribute));
|
||||
//
|
||||
return bag;
|
||||
}
|
||||
|
||||
public void SetClassicAspSettings(WebVirtualDirectory virtualDir)
|
||||
|
|
|
@ -31,12 +31,14 @@ namespace WebsitePanel.Providers.Web.Iis.Common
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
|
||||
using Microsoft.Web.Administration;
|
||||
using Microsoft.Web.Management.Server;
|
||||
|
||||
public abstract class ConfigurationModuleService
|
||||
{
|
||||
private const string ServerManagerContextKey = "ServerManagerContextKey";
|
||||
/// <summary>
|
||||
/// We'll use it in the future to implement management of web farm with shared configuration enabled
|
||||
/// </summary>
|
||||
|
|
|
@ -43,31 +43,28 @@ namespace WebsitePanel.Providers.Web.Iis.DefaultDocuments
|
|||
{
|
||||
public const string ValueAttribute = "value";
|
||||
|
||||
public string GetDefaultDocumentSettings(string siteId)
|
||||
public string GetDefaultDocumentSettings(ServerManager srvman, string siteId)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
// Load web site configuration
|
||||
var config = srvman.GetWebConfiguration(siteId);
|
||||
// Load corresponding section
|
||||
var section = config.GetSection(Constants.DefaultDocumentsSection);
|
||||
//
|
||||
var filesCollection = section.GetCollection("files");
|
||||
// Build default documents
|
||||
var defaultDocs = new List<String>();
|
||||
//
|
||||
foreach (var item in filesCollection)
|
||||
{
|
||||
// Load web site configuration
|
||||
var config = srvman.GetWebConfiguration(siteId);
|
||||
// Load corresponding section
|
||||
var section = config.GetSection(Constants.DefaultDocumentsSection);
|
||||
var item2Get = GetDefaultDocument(item);
|
||||
//
|
||||
var filesCollection = section.GetCollection("files");
|
||||
// Build default documents
|
||||
var defaultDocs = new List<String>();
|
||||
if (String.IsNullOrEmpty(item2Get))
|
||||
continue;
|
||||
//
|
||||
foreach (var item in filesCollection)
|
||||
{
|
||||
var item2Get = GetDefaultDocument(item);
|
||||
//
|
||||
if (String.IsNullOrEmpty(item2Get))
|
||||
continue;
|
||||
//
|
||||
defaultDocs.Add(item2Get);
|
||||
}
|
||||
//
|
||||
return String.Join(",", defaultDocs.ToArray());
|
||||
defaultDocs.Add(item2Get);
|
||||
}
|
||||
//
|
||||
return String.Join(",", defaultDocs.ToArray());
|
||||
}
|
||||
|
||||
public void SetDefaultDocumentsEnabled(string siteId, bool enabled)
|
||||
|
|
|
@ -35,20 +35,17 @@ namespace WebsitePanel.Providers.Web.Iis.DirectoryBrowse
|
|||
|
||||
internal sealed class DirectoryBrowseModuleService : ConfigurationModuleService
|
||||
{
|
||||
public PropertyBag GetDirectoryBrowseSettings(string siteId)
|
||||
public PropertyBag GetDirectoryBrowseSettings(ServerManager srvman, string siteId)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
var config = srvman.GetWebConfiguration(siteId);
|
||||
//
|
||||
DirectoryBrowseSection directoryBrowseSection = (DirectoryBrowseSection)config.GetSection(Constants.DirectoryBrowseSection, typeof(DirectoryBrowseSection));
|
||||
//
|
||||
PropertyBag bag = new PropertyBag();
|
||||
bag[DirectoryBrowseGlobals.Enabled] = directoryBrowseSection.Enabled;
|
||||
bag[DirectoryBrowseGlobals.ShowFlags] = (int)directoryBrowseSection.ShowFlags;
|
||||
bag[DirectoryBrowseGlobals.ReadOnly] = directoryBrowseSection.IsLocked;
|
||||
return bag;
|
||||
}
|
||||
var config = srvman.GetWebConfiguration(siteId);
|
||||
//
|
||||
DirectoryBrowseSection directoryBrowseSection = (DirectoryBrowseSection)config.GetSection(Constants.DirectoryBrowseSection, typeof(DirectoryBrowseSection));
|
||||
//
|
||||
PropertyBag bag = new PropertyBag();
|
||||
bag[DirectoryBrowseGlobals.Enabled] = directoryBrowseSection.Enabled;
|
||||
bag[DirectoryBrowseGlobals.ShowFlags] = (int)directoryBrowseSection.ShowFlags;
|
||||
bag[DirectoryBrowseGlobals.ReadOnly] = directoryBrowseSection.IsLocked;
|
||||
return bag;
|
||||
}
|
||||
|
||||
public void SetDirectoryBrowseEnabled(string siteId, bool enabled)
|
||||
|
|
|
@ -58,36 +58,33 @@ using System.Collections.Specialized;
|
|||
{ Constants.AspNet40x64PathSetting, @"\Framework64\v4.0.30128\aspnet_isapi.dll" }
|
||||
};
|
||||
|
||||
public SettingPair[] GetISAPIExtensionsInstalled()
|
||||
public SettingPair[] GetISAPIExtensionsInstalled(ServerManager srvman)
|
||||
{
|
||||
List<SettingPair> settings = new List<SettingPair>();
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
var config = srvman.GetApplicationHostConfiguration();
|
||||
//
|
||||
var section = config.GetSection(Constants.IsapiCgiRestrictionSection);
|
||||
//
|
||||
foreach (var item in section.GetCollection())
|
||||
{
|
||||
var config = srvman.GetApplicationHostConfiguration();
|
||||
var isapiModulePath = Convert.ToString(item.GetAttributeValue(PathAttribute));
|
||||
//
|
||||
var section = config.GetSection(Constants.IsapiCgiRestrictionSection);
|
||||
//
|
||||
foreach (var item in section.GetCollection())
|
||||
for (int i = 0; i < ISAPI_MODULES.Keys.Count; i++)
|
||||
{
|
||||
var isapiModulePath = Convert.ToString(item.GetAttributeValue(PathAttribute));
|
||||
var pathExt = ISAPI_MODULES.Get(i);
|
||||
//
|
||||
for (int i = 0; i < ISAPI_MODULES.Keys.Count; i++)
|
||||
if (isapiModulePath.EndsWith(pathExt))
|
||||
{
|
||||
var pathExt = ISAPI_MODULES.Get(i);
|
||||
//
|
||||
if (isapiModulePath.EndsWith(pathExt))
|
||||
settings.Add(new SettingPair
|
||||
{
|
||||
settings.Add(new SettingPair
|
||||
{
|
||||
// Retrieve key name
|
||||
Name = ISAPI_MODULES.GetKey(i),
|
||||
// Evaluate ISAPI module path
|
||||
Value = isapiModulePath
|
||||
});
|
||||
//
|
||||
break;
|
||||
}
|
||||
// Retrieve key name
|
||||
Name = ISAPI_MODULES.GetKey(i),
|
||||
// Evaluate ISAPI module path
|
||||
Value = isapiModulePath
|
||||
});
|
||||
//
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,45 +87,22 @@ namespace WebsitePanel.Providers.Web.Handlers
|
|||
}
|
||||
}
|
||||
|
||||
public void SetHandlersAccessPolicy(string fqPath, HandlerAccessPolicy policy)
|
||||
public void SetHandlersAccessPolicy(ServerManager srvman, string fqPath, HandlerAccessPolicy policy)
|
||||
{
|
||||
var config = srvman.GetWebConfiguration(fqPath);
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
var config = srvman.GetWebConfiguration(fqPath);
|
||||
//
|
||||
HandlersSection section = (HandlersSection)config.GetSection(Constants.HandlersSection, typeof(HandlersSection));
|
||||
//
|
||||
section.AccessPolicy = policy;
|
||||
//
|
||||
srvman.CommitChanges();
|
||||
}
|
||||
HandlersSection section = (HandlersSection)config.GetSection(Constants.HandlersSection, typeof(HandlersSection));
|
||||
//
|
||||
section.AccessPolicy = policy;
|
||||
}
|
||||
|
||||
public HandlerAccessPolicy GetHandlersAccessPolicy(string fqPath)
|
||||
public HandlerAccessPolicy GetHandlersAccessPolicy(ServerManager srvman, string fqPath)
|
||||
{
|
||||
var config = srvman.GetWebConfiguration(fqPath);
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
var config = srvman.GetWebConfiguration(fqPath);
|
||||
//
|
||||
HandlersSection section = (HandlersSection)config.GetSection(Constants.HandlersSection, typeof(HandlersSection));
|
||||
//
|
||||
return section.AccessPolicy;
|
||||
}
|
||||
}
|
||||
|
||||
internal ConfigurationElementCollection GetHandlers(WebVirtualDirectory virtualDir)
|
||||
{
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
|
||||
//
|
||||
var section = config.GetSection(Constants.HandlersSection);
|
||||
//
|
||||
return section.GetCollection();
|
||||
}
|
||||
HandlersSection section = (HandlersSection)config.GetSection(Constants.HandlersSection, typeof(HandlersSection));
|
||||
//
|
||||
return section.AccessPolicy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -44,23 +44,20 @@ namespace WebsitePanel.Providers.Web.HttpRedirect
|
|||
public const string DestinationAttribute = "destination";
|
||||
public const string HttpResponseStatusAttribute = "httpResponseStatus";
|
||||
|
||||
public void LoadHttpRedirectSettings(WebVirtualDirectory virtualDir)
|
||||
public void GetHttpRedirectSettings(ServerManager srvman, WebVirtualDirectory virtualDir)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
// Load web site configuration
|
||||
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
|
||||
// Load corresponding section
|
||||
var section = config.GetSection(Constants.HttpRedirectSection);
|
||||
//
|
||||
if (!Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute)))
|
||||
return;
|
||||
//
|
||||
virtualDir.RedirectExactUrl = Convert.ToBoolean(section.GetAttributeValue(ExactDestinationAttribute));
|
||||
virtualDir.RedirectDirectoryBelow = Convert.ToBoolean(section.GetAttributeValue(ChildOnlyAttribute));
|
||||
virtualDir.HttpRedirect = Convert.ToString(section.GetAttributeValue(DestinationAttribute));
|
||||
virtualDir.RedirectPermanent = String.Equals("301", Convert.ToString(section.GetAttributeValue(HttpResponseStatusAttribute)));
|
||||
}
|
||||
// Load web site configuration
|
||||
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
|
||||
// Load corresponding section
|
||||
var section = config.GetSection(Constants.HttpRedirectSection);
|
||||
//
|
||||
if (!Convert.ToBoolean(section.GetAttributeValue(EnabledAttribute)))
|
||||
return;
|
||||
//
|
||||
virtualDir.RedirectExactUrl = Convert.ToBoolean(section.GetAttributeValue(ExactDestinationAttribute));
|
||||
virtualDir.RedirectDirectoryBelow = Convert.ToBoolean(section.GetAttributeValue(ChildOnlyAttribute));
|
||||
virtualDir.HttpRedirect = Convert.ToString(section.GetAttributeValue(DestinationAttribute));
|
||||
virtualDir.RedirectPermanent = String.Equals("301", Convert.ToString(section.GetAttributeValue(HttpResponseStatusAttribute)));
|
||||
}
|
||||
|
||||
public void SetHttpRedirectSettings(WebVirtualDirectory virtualDir)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -44,28 +44,25 @@ namespace WebsitePanel.Providers.Web.MimeTypes
|
|||
/// Loads available mime maps into supplied virtual iisDirObject description.
|
||||
/// </summary>
|
||||
/// <param name="vdir">Virtual iisDirObject description.</param>
|
||||
public void GetMimeMaps(WebVirtualDirectory virtualDir)
|
||||
public void GetMimeMaps(ServerManager srvman, WebVirtualDirectory virtualDir)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
|
||||
//
|
||||
var section = config.GetSection(Constants.StaticContentSection);
|
||||
//
|
||||
var mappings = new List<MimeMap>();
|
||||
//
|
||||
foreach (var item in section.GetCollection())
|
||||
{
|
||||
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
|
||||
var item2Get = GetMimeMap(item);
|
||||
//
|
||||
var section = config.GetSection(Constants.StaticContentSection);
|
||||
if (item2Get == null)
|
||||
continue;
|
||||
//
|
||||
var mappings = new List<MimeMap>();
|
||||
//
|
||||
foreach (var item in section.GetCollection())
|
||||
{
|
||||
var item2Get = GetMimeMap(item);
|
||||
//
|
||||
if (item2Get == null)
|
||||
continue;
|
||||
//
|
||||
mappings.Add(item2Get);
|
||||
}
|
||||
//
|
||||
virtualDir.MimeMaps = mappings.ToArray();
|
||||
mappings.Add(item2Get);
|
||||
}
|
||||
//
|
||||
virtualDir.MimeMaps = mappings.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -339,7 +339,7 @@ namespace WebsitePanel.Providers.Web.Iis
|
|||
|
||||
public void AddBinding(SSLCertificate certificate, WebSite website)
|
||||
{
|
||||
using (ServerManager sm = GetServerManager())
|
||||
using (ServerManager srvman = GetServerManager())
|
||||
{
|
||||
// Not sure why do we need to work with X.509 store here, so commented it out and lets see what happens
|
||||
X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
|
||||
|
@ -348,7 +348,7 @@ namespace WebsitePanel.Providers.Web.Iis
|
|||
List<ServerBinding> bindings = new List<ServerBinding>();
|
||||
// Retrieve existing site bindings to figure out what do we have here
|
||||
WebObjectsModuleService webObjSvc = new WebObjectsModuleService();
|
||||
bindings.AddRange(webObjSvc.GetSiteBindings(website.SiteId));
|
||||
bindings.AddRange(webObjSvc.GetSiteBindings(srvman, website.SiteId));
|
||||
// Look for dedicated ip
|
||||
bool dedicatedIp = bindings.Exists(binding => String.IsNullOrEmpty(binding.Host) && binding.IP != "*");
|
||||
//
|
||||
|
@ -357,11 +357,11 @@ namespace WebsitePanel.Providers.Web.Iis
|
|||
bindingInformation = dedicatedIp ? string.Format("{0}:443:", website.SiteIPAddress)
|
||||
: string.Format("{0}:443:{1}", website.SiteIPAddress, certificate.Hostname);
|
||||
//
|
||||
sm.Sites[website.SiteId].Bindings.Add(bindingInformation, certificate.Hash, store.Name);
|
||||
srvman.Sites[website.SiteId].Bindings.Add(bindingInformation, certificate.Hash, store.Name);
|
||||
//
|
||||
store.Close();
|
||||
//
|
||||
sm.CommitChanges();
|
||||
srvman.CommitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,31 +49,27 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
public const string ResponseModeAttribute = "responseMode";
|
||||
public const string PrefixLanguageFilePath = "prefixLanguageFilePath";
|
||||
|
||||
public void GetCustomErrors(WebVirtualDirectory virtualDir)
|
||||
public void GetCustomErrors(ServerManager srvman, WebVirtualDirectory virtualDir)
|
||||
{
|
||||
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
var httpErrorsSection = config.GetSection(Constants.HttpErrorsSection);
|
||||
//
|
||||
var errorsCollection = httpErrorsSection.GetCollection();
|
||||
//
|
||||
var errors = new List<HttpError>();
|
||||
//
|
||||
foreach (var item in errorsCollection)
|
||||
{
|
||||
var config = srvman.GetWebConfiguration(virtualDir.FullQualifiedPath);
|
||||
var item2Get = GetHttpError(item, virtualDir);
|
||||
//
|
||||
var httpErrorsSection = config.GetSection(Constants.HttpErrorsSection);
|
||||
if (item2Get == null)
|
||||
continue;
|
||||
//
|
||||
var errorsCollection = httpErrorsSection.GetCollection();
|
||||
//
|
||||
var errors = new List<HttpError>();
|
||||
//
|
||||
foreach (var item in errorsCollection)
|
||||
{
|
||||
var item2Get = GetHttpError(item, virtualDir);
|
||||
//
|
||||
if (item2Get == null)
|
||||
continue;
|
||||
//
|
||||
errors.Add(item2Get);
|
||||
}
|
||||
//
|
||||
virtualDir.HttpErrors = errors.ToArray();
|
||||
errors.Add(item2Get);
|
||||
}
|
||||
//
|
||||
virtualDir.HttpErrors = errors.ToArray();
|
||||
}
|
||||
|
||||
public void SetCustomErrors(WebVirtualDirectory virtualDir)
|
||||
|
|
|
@ -40,33 +40,30 @@ namespace WebsitePanel.Providers.Web.WebObjects
|
|||
public const string NameAttribute = "name";
|
||||
public const string ValueAttribute = "value";
|
||||
|
||||
public void GetCustomHttpHeaders(WebVirtualDirectory virtualDir)
|
||||
public void GetCustomHttpHeaders(ServerManager srvman, WebVirtualDirectory virtualDir)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
var config = srvman.GetApplicationHostConfiguration();
|
||||
//
|
||||
var httpProtocolSection = config.GetSection(Constants.HttpProtocolSection, virtualDir.FullQualifiedPath);
|
||||
//
|
||||
if (httpProtocolSection == null)
|
||||
return;
|
||||
//
|
||||
var headersCollection = httpProtocolSection.GetCollection("customHeaders");
|
||||
//
|
||||
var headers = new List<HttpHeader>();
|
||||
//
|
||||
foreach (var item in headersCollection)
|
||||
{
|
||||
var config = srvman.GetApplicationHostConfiguration();
|
||||
var item2Get = GetCustomHttpHeader(item);
|
||||
//
|
||||
var httpProtocolSection = config.GetSection(Constants.HttpProtocolSection, virtualDir.FullQualifiedPath);
|
||||
if (item2Get == null)
|
||||
continue;
|
||||
//
|
||||
if (httpProtocolSection == null)
|
||||
return;
|
||||
//
|
||||
var headersCollection = httpProtocolSection.GetCollection("customHeaders");
|
||||
//
|
||||
var headers = new List<HttpHeader>();
|
||||
//
|
||||
foreach (var item in headersCollection)
|
||||
{
|
||||
var item2Get = GetCustomHttpHeader(item);
|
||||
//
|
||||
if (item2Get == null)
|
||||
continue;
|
||||
//
|
||||
headers.Add(item2Get);
|
||||
}
|
||||
//
|
||||
virtualDir.HttpHeaders = headers.ToArray();
|
||||
headers.Add(item2Get);
|
||||
}
|
||||
//
|
||||
virtualDir.HttpHeaders = headers.ToArray();
|
||||
}
|
||||
|
||||
public void SetCustomHttpHeaders(WebVirtualDirectory virtualDir)
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
//
|
||||
if (virtualDir.DedicatedApplicationPool)
|
||||
{
|
||||
var appPool = GetApplicationPool(virtualDir);
|
||||
var appPool = GetApplicationPool(srvman, virtualDir);
|
||||
vdir.UserName = appPool.ProcessModel.UserName;
|
||||
vdir.Password = appPool.ProcessModel.Password;
|
||||
}
|
||||
|
@ -150,20 +150,17 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
}
|
||||
}
|
||||
|
||||
public ApplicationPool GetApplicationPool(WebVirtualDirectory virtualDir)
|
||||
public ApplicationPool GetApplicationPool(ServerManager srvman, WebVirtualDirectory virtualDir)
|
||||
{
|
||||
if (virtualDir == null)
|
||||
throw new ArgumentNullException("vdir");
|
||||
// read app pool
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
var appPool = srvman.ApplicationPools[virtualDir.ApplicationPool];
|
||||
//
|
||||
if (appPool == null)
|
||||
throw new ApplicationException("ApplicationPoolNotFound");
|
||||
//
|
||||
return appPool;
|
||||
}
|
||||
var appPool = srvman.ApplicationPools[virtualDir.ApplicationPool];
|
||||
//
|
||||
if (appPool == null)
|
||||
throw new ApplicationException("ApplicationPoolNotFound");
|
||||
//
|
||||
return appPool;
|
||||
}
|
||||
|
||||
public void CreateApplicationPool(string appPoolName, string appPoolUsername,
|
||||
|
@ -324,126 +321,105 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
}
|
||||
}
|
||||
|
||||
public ServerState GetSiteState(string siteId)
|
||||
public ServerState GetSiteState(ServerManager srvman, string siteId)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
// ensure website exists
|
||||
if (srvman.Sites[siteId] == null)
|
||||
return ServerState.Unknown;
|
||||
//
|
||||
var siteState = ServerState.Unknown;
|
||||
//
|
||||
switch (srvman.Sites[siteId].State)
|
||||
{
|
||||
// ensure website exists
|
||||
if (srvman.Sites[siteId] == null)
|
||||
return ServerState.Unknown;
|
||||
//
|
||||
var siteState = ServerState.Unknown;
|
||||
//
|
||||
switch (srvman.Sites[siteId].State)
|
||||
{
|
||||
case ObjectState.Started:
|
||||
siteState = ServerState.Started;
|
||||
break;
|
||||
case ObjectState.Starting:
|
||||
siteState = ServerState.Starting;
|
||||
break;
|
||||
case ObjectState.Stopped:
|
||||
siteState = ServerState.Stopped;
|
||||
break;
|
||||
case ObjectState.Stopping:
|
||||
siteState = ServerState.Stopping;
|
||||
break;
|
||||
}
|
||||
//
|
||||
return siteState;
|
||||
case ObjectState.Started:
|
||||
siteState = ServerState.Started;
|
||||
break;
|
||||
case ObjectState.Starting:
|
||||
siteState = ServerState.Starting;
|
||||
break;
|
||||
case ObjectState.Stopped:
|
||||
siteState = ServerState.Stopped;
|
||||
break;
|
||||
case ObjectState.Stopping:
|
||||
siteState = ServerState.Stopping;
|
||||
break;
|
||||
}
|
||||
//
|
||||
return siteState;
|
||||
}
|
||||
|
||||
public bool SiteExists(string siteId)
|
||||
public bool SiteExists(ServerManager srvman, string siteId)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
return (srvman.Sites[siteId] != null);
|
||||
}
|
||||
return (srvman.Sites[siteId] != null);
|
||||
}
|
||||
|
||||
public string[] GetSites()
|
||||
public string[] GetSites(ServerManager srvman)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
var iisObjects = new List<string>();
|
||||
//
|
||||
foreach (var item in srvman.Sites)
|
||||
iisObjects.Add(item.Name);
|
||||
//
|
||||
return iisObjects.ToArray();
|
||||
}
|
||||
var iisObjects = new List<string>();
|
||||
//
|
||||
foreach (var item in srvman.Sites)
|
||||
iisObjects.Add(item.Name);
|
||||
//
|
||||
return iisObjects.ToArray();
|
||||
}
|
||||
|
||||
public string GetWebSiteNameFromIIS(string siteName)
|
||||
public string GetWebSiteNameFromIIS(ServerManager srvman, string siteName)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
if (srvman.Sites[siteName] != null)
|
||||
return srvman.Sites[siteName].Name;
|
||||
//
|
||||
return null;
|
||||
}
|
||||
if (srvman.Sites[siteName] != null)
|
||||
return srvman.Sites[siteName].Name;
|
||||
//
|
||||
return null;
|
||||
}
|
||||
|
||||
public string GetWebSiteIdFromIIS(string siteId, string format)
|
||||
public string GetWebSiteIdFromIIS(ServerManager srvman, string siteId, string format)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
var iisObject = srvman.Sites[siteId];
|
||||
// Format string is empty
|
||||
if (String.IsNullOrEmpty(format))
|
||||
return Convert.ToString(iisObject.Id);
|
||||
//
|
||||
return String.Format(format, iisObject.Id);
|
||||
}
|
||||
var iisObject = srvman.Sites[siteId];
|
||||
// Format string is empty
|
||||
if (String.IsNullOrEmpty(format))
|
||||
return Convert.ToString(iisObject.Id);
|
||||
//
|
||||
return String.Format(format, iisObject.Id);
|
||||
}
|
||||
|
||||
public WebSite GetWebSiteFromIIS(string siteId)
|
||||
public WebSite GetWebSiteFromIIS(ServerManager srvman, string siteId)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
var webSite = new WebSite();
|
||||
//
|
||||
var iisObject = srvman.Sites[siteId];
|
||||
//
|
||||
webSite.SiteId = webSite.Name = iisObject.Name;
|
||||
//
|
||||
if (iisObject.LogFile.Enabled)
|
||||
{
|
||||
var webSite = new WebSite();
|
||||
//
|
||||
var iisObject = srvman.Sites[siteId];
|
||||
//
|
||||
webSite.SiteId = webSite.Name = iisObject.Name;
|
||||
//
|
||||
if (iisObject.LogFile.Enabled)
|
||||
{
|
||||
webSite.LogsPath = iisObject.LogFile.Directory;
|
||||
webSite[WebSite.IIS7_LOG_EXT_FILE_FIELDS] = iisObject.LogFile.LogExtFileFlags.ToString();
|
||||
}
|
||||
// Read instant website id
|
||||
webSite[WebSite.IIS7_SITE_ID] = GetWebSiteIdFromIIS(siteId, "W3SVC{0}");
|
||||
// Read web site iisAppObject pool name
|
||||
webSite.ApplicationPool = iisObject.Applications["/"].ApplicationPoolName;
|
||||
//
|
||||
return webSite;
|
||||
webSite.LogsPath = iisObject.LogFile.Directory;
|
||||
webSite[WebSite.IIS7_LOG_EXT_FILE_FIELDS] = iisObject.LogFile.LogExtFileFlags.ToString();
|
||||
}
|
||||
// Read instant website id
|
||||
webSite[WebSite.IIS7_SITE_ID] = GetWebSiteIdFromIIS(srvman, siteId, "W3SVC{0}");
|
||||
// Read web site iisAppObject pool name
|
||||
webSite.ApplicationPool = iisObject.Applications["/"].ApplicationPoolName;
|
||||
//
|
||||
return webSite;
|
||||
}
|
||||
|
||||
public ServerBinding[] GetSiteBindings(string siteId)
|
||||
public ServerBinding[] GetSiteBindings(ServerManager srvman, string siteId)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
var iisObject = srvman.Sites[siteId];
|
||||
// get server bingings
|
||||
var bindings = new List<ServerBinding>();
|
||||
//
|
||||
foreach (var bindingObj in iisObject.Bindings)
|
||||
{
|
||||
var iisObject = srvman.Sites[siteId];
|
||||
// get server bingings
|
||||
var bindings = new List<ServerBinding>();
|
||||
//
|
||||
foreach (var bindingObj in iisObject.Bindings)
|
||||
{
|
||||
// return only "http" bindings
|
||||
if (String.Equals(bindingObj.Protocol, Uri.UriSchemeHttp, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
string[] parts = bindingObj.BindingInformation.Split(':');
|
||||
// append binding
|
||||
bindings.Add(new ServerBinding(bindingObj.Protocol, parts[0], parts[1], parts[2]));
|
||||
}
|
||||
}
|
||||
//
|
||||
return bindings.ToArray();
|
||||
// return only "http" bindings
|
||||
if (String.Equals(bindingObj.Protocol, Uri.UriSchemeHttp, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
string[] parts = bindingObj.BindingInformation.Split(':');
|
||||
// append binding
|
||||
bindings.Add(new ServerBinding(bindingObj.Protocol, parts[0], parts[1], parts[2]));
|
||||
}
|
||||
}
|
||||
//
|
||||
return bindings.ToArray();
|
||||
}
|
||||
|
||||
private void SyncWebSiteBindingsChanges(string siteId, ServerBinding[] bindings)
|
||||
|
@ -487,40 +463,40 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
|
||||
public void UpdateSiteBindings(string siteId, ServerBinding[] bindings)
|
||||
{
|
||||
// Ensure web site exists
|
||||
if (!SiteExists(siteId))
|
||||
return;
|
||||
using (ServerManager srvman = GetServerManager())
|
||||
{
|
||||
// Ensure web site exists
|
||||
if (!SiteExists(srvman, siteId))
|
||||
return;
|
||||
}
|
||||
//
|
||||
SyncWebSiteBindingsChanges(siteId, bindings);
|
||||
}
|
||||
|
||||
public string GetPhysicalPath(WebVirtualDirectory virtualDir)
|
||||
public string GetPhysicalPath(ServerManager srvman, WebVirtualDirectory virtualDir)
|
||||
{
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
string siteId = (virtualDir.ParentSiteName == null)
|
||||
? virtualDir.Name : virtualDir.ParentSiteName;
|
||||
//
|
||||
var iisObject = srvman.Sites[siteId];
|
||||
string siteId = (virtualDir.ParentSiteName == null)
|
||||
? virtualDir.Name : virtualDir.ParentSiteName;
|
||||
//
|
||||
var iisObject = srvman.Sites[siteId];
|
||||
|
||||
if (iisObject == null)
|
||||
return null;
|
||||
if (iisObject == null)
|
||||
return null;
|
||||
|
||||
//
|
||||
var iisAppObject = iisObject.Applications[virtualDir.VirtualPath];
|
||||
//
|
||||
var iisAppObject = iisObject.Applications[virtualDir.VirtualPath];
|
||||
|
||||
if (iisAppObject == null)
|
||||
return null;
|
||||
if (iisAppObject == null)
|
||||
return null;
|
||||
|
||||
//
|
||||
var iisDirObject = iisAppObject.VirtualDirectories["/"];
|
||||
//
|
||||
var iisDirObject = iisAppObject.VirtualDirectories["/"];
|
||||
|
||||
if (iisDirObject == null)
|
||||
return null;
|
||||
if (iisDirObject == null)
|
||||
return null;
|
||||
|
||||
//
|
||||
return iisDirObject.PhysicalPath;
|
||||
}
|
||||
//
|
||||
return iisDirObject.PhysicalPath;
|
||||
}
|
||||
|
||||
public void DeleteApplicationPool(params string[] appPoolNames)
|
||||
|
@ -552,11 +528,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
|
||||
public void DeleteSite(string siteId)
|
||||
{
|
||||
if (!SiteExists(siteId))
|
||||
return;
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
if (!SiteExists(srvman, siteId))
|
||||
return;
|
||||
|
||||
//
|
||||
var indexOf = srvman.Sites.IndexOf(srvman.Sites[siteId]);
|
||||
srvman.Sites.RemoveAt(indexOf);
|
||||
|
@ -565,31 +541,28 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
}
|
||||
}
|
||||
|
||||
public WebVirtualDirectory[] GetVirtualDirectories(string siteId)
|
||||
public WebVirtualDirectory[] GetVirtualDirectories(ServerManager srvman, string siteId)
|
||||
{
|
||||
if (!SiteExists(siteId))
|
||||
return new WebVirtualDirectory[] { };
|
||||
if (!SiteExists(srvman, siteId))
|
||||
return new WebVirtualDirectory[] { };
|
||||
|
||||
using (var srvman = GetServerManager())
|
||||
var vdirs = new List<WebVirtualDirectory>();
|
||||
var iisObject = srvman.Sites[siteId];
|
||||
//
|
||||
foreach (var item in iisObject.Applications)
|
||||
{
|
||||
var vdirs = new List<WebVirtualDirectory>();
|
||||
var iisObject = srvman.Sites[siteId];
|
||||
// Skip root application which is web site itself
|
||||
if (item.Path == "/")
|
||||
continue;
|
||||
//
|
||||
foreach (var item in iisObject.Applications)
|
||||
vdirs.Add(new WebVirtualDirectory
|
||||
{
|
||||
// Skip root application which is web site itself
|
||||
if (item.Path == "/")
|
||||
continue;
|
||||
//
|
||||
vdirs.Add(new WebVirtualDirectory
|
||||
{
|
||||
Name = ConfigurationUtility.GetNonQualifiedVirtualPath(item.Path),
|
||||
ContentPath = item.VirtualDirectories[0].PhysicalPath
|
||||
});
|
||||
}
|
||||
//
|
||||
return vdirs.ToArray();
|
||||
Name = ConfigurationUtility.GetNonQualifiedVirtualPath(item.Path),
|
||||
ContentPath = item.VirtualDirectories[0].PhysicalPath
|
||||
});
|
||||
}
|
||||
//
|
||||
return vdirs.ToArray();
|
||||
}
|
||||
|
||||
public WebVirtualDirectory GetVirtualDirectory(string siteId, string directoryName)
|
||||
|
@ -601,11 +574,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
if (String.IsNullOrEmpty(directoryName))
|
||||
throw new ArgumentNullException("directoryName");
|
||||
//
|
||||
if (!SiteExists(siteId))
|
||||
return null;
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
if (!SiteExists(srvman, siteId))
|
||||
return null;
|
||||
|
||||
var site = srvman.Sites[siteId];
|
||||
//
|
||||
var vdir = new WebVirtualDirectory
|
||||
|
@ -622,11 +595,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
|
||||
public void CreateVirtualDirectory(string siteId, string directoryName, string physicalPath)
|
||||
{
|
||||
if (!SiteExists(siteId))
|
||||
throw new ApplicationException();
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
if (!SiteExists(srvman, siteId))
|
||||
throw new ApplicationException();
|
||||
|
||||
var iisSiteObject = srvman.Sites[siteId];
|
||||
var iisAppObject = iisSiteObject.Applications.Add(directoryName, physicalPath);
|
||||
//
|
||||
|
@ -636,11 +609,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
|
||||
public bool VirtualDirectoryExists(string siteId, string directoryName)
|
||||
{
|
||||
if (!SiteExists(siteId))
|
||||
return false;
|
||||
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
if (!SiteExists(srvman, siteId))
|
||||
return false;
|
||||
|
||||
var vdir = new WebVirtualDirectory
|
||||
{
|
||||
Name = directoryName,
|
||||
|
@ -653,11 +626,11 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
|
|||
|
||||
public void DeleteVirtualDirectory(WebVirtualDirectory virtualDir)
|
||||
{
|
||||
if (!SiteExists(virtualDir.ParentSiteName))
|
||||
return;
|
||||
//
|
||||
using (var srvman = GetServerManager())
|
||||
{
|
||||
if (!SiteExists(srvman, virtualDir.ParentSiteName))
|
||||
return;
|
||||
|
||||
var iisSiteObject = srvman.Sites[virtualDir.ParentSiteName];
|
||||
var iisAppObject = iisSiteObject.Applications[virtualDir.VirtualPath];
|
||||
//
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.DirectoryServices" />
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -2392,37 +2392,37 @@ namespace WebsitePanel.Providers.Web
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<HtaccessUser> GetHeliconApeUsers(string siteId)
|
||||
public virtual List<HtaccessUser> GetHeliconApeUsers(string siteId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public HtaccessUser GetHeliconApeUser(string siteId, string userName)
|
||||
public virtual HtaccessUser GetHeliconApeUser(string siteId, string userName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void UpdateHeliconApeUser(string siteId, HtaccessUser user)
|
||||
public virtual void UpdateHeliconApeUser(string siteId, HtaccessUser user)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void DeleteHeliconApeUser(string siteId, string userName)
|
||||
public virtual void DeleteHeliconApeUser(string siteId, string userName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<WebGroup> GetHeliconApeGroups(string siteId)
|
||||
public virtual List<WebGroup> GetHeliconApeGroups(string siteId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public WebGroup GetHeliconApeGroup(string siteId, string groupName)
|
||||
public virtual WebGroup GetHeliconApeGroup(string siteId, string groupName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void UpdateHeliconApeGroup(string siteId, WebGroup group)
|
||||
public virtual void UpdateHeliconApeGroup(string siteId, WebGroup group)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -2437,7 +2437,7 @@ namespace WebsitePanel.Providers.Web
|
|||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void DeleteHeliconApeGroup(string siteId, string groupName)
|
||||
public virtual void DeleteHeliconApeGroup(string siteId, string groupName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -3630,27 +3630,27 @@ namespace WebsitePanel.Providers.Web
|
|||
#endregion
|
||||
|
||||
#region Remote Management Access
|
||||
public void GrantWebManagementAccess(string siteName, string accountName, string accountPassword)
|
||||
public virtual void GrantWebManagementAccess(string siteName, string accountName, string accountPassword)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void RevokeWebManagementAccess(string siteName, string accountName)
|
||||
public virtual void RevokeWebManagementAccess(string siteName, string accountName)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void ChangeWebManagementAccessPassword(string accountName, string accountPassword)
|
||||
public virtual void ChangeWebManagementAccessPassword(string accountName, string accountPassword)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public bool CheckWebManagementAccountExists(string accountName)
|
||||
public virtual bool CheckWebManagementAccountExists(string accountName)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public ResultObject CheckWebManagementPasswordComplexity(string accountPassword)
|
||||
public virtual ResultObject CheckWebManagementPasswordComplexity(string accountPassword)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ namespace WebsitePanel.Server
|
|||
Log.WriteEnd("'{0}' CreateVMFromVM", ProviderSettings.ProviderName);
|
||||
return result;
|
||||
}
|
||||
catch (System.TimeoutException ex)
|
||||
catch (System.TimeoutException)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue