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