Merge
This commit is contained in:
commit
e2b7191c98
102 changed files with 2361 additions and 964 deletions
|
@ -102,7 +102,6 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if (allowEmptyValue)
|
||||
{
|
||||
if (String.IsNullOrEmpty(str)) return str;
|
||||
if (String.IsNullOrEmpty(value)) return string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@ using System.Data.SqlClient;
|
|||
using System.Text.RegularExpressions;
|
||||
using WebsitePanel.Providers.HostedSolution;
|
||||
using Microsoft.ApplicationBlocks.Data;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WebsitePanel.EnterpriseServer
|
||||
{
|
||||
|
@ -2152,18 +2153,6 @@ namespace WebsitePanel.EnterpriseServer
|
|||
);
|
||||
}
|
||||
|
||||
public static void ChangeExchangeAcceptedDomainType(int itemId, int domainId, int domainTypeId)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"ChangeExchangeAcceptedDomainType",
|
||||
new SqlParameter("@ItemID", itemId),
|
||||
new SqlParameter("@DomainID", domainId),
|
||||
new SqlParameter("@DomainTypeID", domainTypeId)
|
||||
);
|
||||
}
|
||||
|
||||
public static IDataReader GetExchangeOrganizationStatistics(int itemId)
|
||||
{
|
||||
return SqlHelper.ExecuteReader(
|
||||
|
@ -3411,5 +3400,45 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
#endregion
|
||||
|
||||
public static int GetPackageIdByName(string Name)
|
||||
{
|
||||
// get Helicon Zoo provider
|
||||
int packageId = -1;
|
||||
List<ProviderInfo> providers = ServerController.GetProviders();
|
||||
foreach (ProviderInfo providerInfo in providers)
|
||||
{
|
||||
if (string.Equals(Name, providerInfo.ProviderName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
packageId = providerInfo.ProviderId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (-1 == packageId)
|
||||
{
|
||||
throw new Exception("Provider not found");
|
||||
}
|
||||
|
||||
return packageId;
|
||||
}
|
||||
|
||||
public static int GetServiceIdByProviderForServer(int providerId, int serverId)
|
||||
{
|
||||
IDataReader reader = SqlHelper.ExecuteReader(ConnectionString, CommandType.Text,
|
||||
@"SELECT TOP 1
|
||||
ServiceID
|
||||
FROM Services
|
||||
WHERE ProviderID = @ProviderID AND ServerID = @ServerID",
|
||||
new SqlParameter("@ProviderID", providerId),
|
||||
new SqlParameter("@ServerID", serverId));
|
||||
|
||||
if (reader.Read())
|
||||
{
|
||||
return (int)reader["ServiceID"];
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -310,7 +310,10 @@ namespace WebsitePanel.EnterpriseServer
|
|||
rr.MxPriority = record.MxPriority;
|
||||
|
||||
if (!String.IsNullOrEmpty(rr.RecordData))
|
||||
zoneRecords.Add(rr);
|
||||
{
|
||||
if (rr.RecordName != "[host_name]")
|
||||
zoneRecords.Add(rr);
|
||||
}
|
||||
}
|
||||
|
||||
return zoneRecords;
|
||||
|
|
|
@ -41,6 +41,7 @@ using WebsitePanel.Providers.OS;
|
|||
using OS = WebsitePanel.Providers.OS;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace WebsitePanel.EnterpriseServer
|
||||
{
|
||||
public class OperatingSystemController : IImportController, IBackupController
|
||||
|
@ -409,6 +410,23 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
#region Web Platform Installer
|
||||
|
||||
public static bool CheckLoadUserProfile(int serverId)
|
||||
{
|
||||
int packageId = DataProvider.GetPackageIdByName("IIS70");
|
||||
int serviceId = DataProvider.GetServiceIdByProviderForServer(packageId, serverId);
|
||||
return WebServerController.GetWebServer(serviceId).CheckLoadUserProfile();
|
||||
|
||||
}
|
||||
|
||||
public static void EnableLoadUserProfile(int serverId)
|
||||
{
|
||||
int packageId = DataProvider.GetPackageIdByName("IIS70");
|
||||
int serviceId = DataProvider.GetServiceIdByProviderForServer(packageId, serverId);
|
||||
WebServerController.GetWebServer(serviceId).EnableLoadUserProfile();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void InitWPIFeeds(int serverId, string feedUrls)
|
||||
{
|
||||
GetServerService(serverId).InitWPIFeeds(feedUrls);
|
||||
|
@ -746,6 +764,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -481,7 +481,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
// create web site
|
||||
try
|
||||
{
|
||||
int webSiteId = WebServerController.AddWebSite(packageId, hostName, domainId, 0, true);
|
||||
int webSiteId = WebServerController.AddWebSite(packageId, hostName, domainId, 0, true, false);
|
||||
if (webSiteId < 0)
|
||||
{
|
||||
result.Result = webSiteId;
|
||||
|
|
|
@ -1588,8 +1588,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return BusinessErrorCodes.ERROR_RESTRICTED_DOMAIN;
|
||||
else
|
||||
return checkDomainResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static List<DomainInfo> GetDomains(int packageId, bool recursive)
|
||||
{
|
||||
return ObjectUtils.CreateListFromDataSet<DomainInfo>(
|
||||
|
@ -1729,7 +1729,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
int webSiteId = 0;
|
||||
if (webEnabled && createWebSite)
|
||||
{
|
||||
webSiteId = WebServerController.AddWebSite(packageId, hostName, domainId, 0, createInstantAlias);
|
||||
webSiteId = WebServerController.AddWebSite(packageId, hostName, domainId, 0, createInstantAlias, false);
|
||||
|
||||
if (webSiteId < 0)
|
||||
{
|
||||
|
@ -2005,7 +2005,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
// delete zone if required
|
||||
DnsServerController.DeleteZone(domain.ZoneItemId);
|
||||
if (!domain.IsDomainPointer)
|
||||
DnsServerController.DeleteZone(domain.ZoneItemId);
|
||||
|
||||
// delete domain
|
||||
DataProvider.DeleteDomain(SecurityContext.User.UserId, domainId);
|
||||
|
|
|
@ -157,11 +157,11 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
public static int AddWebSite(int packageId, string hostName, int domainId, int ipAddressId)
|
||||
{
|
||||
return AddWebSite(packageId, hostName, domainId, ipAddressId, false);
|
||||
return AddWebSite(packageId, hostName, domainId, ipAddressId, false, true);
|
||||
}
|
||||
|
||||
public static int AddWebSite(int packageId, string hostName, int domainId, int packageAddressId,
|
||||
bool addInstantAlias)
|
||||
bool addInstantAlias, bool ignoreGlobalDNSRecords)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
|
@ -180,12 +180,15 @@ namespace WebsitePanel.EnterpriseServer
|
|||
DomainInfo domain = ServerController.GetDomain(domainId);
|
||||
string domainName = domain.DomainName;
|
||||
|
||||
// check if the web site already exists
|
||||
if (PackageController.GetPackageItemByName(packageId, domainName, typeof(WebSite)) != null)
|
||||
string siteName = string.IsNullOrEmpty(hostName) ? domainName : hostName + "." + domainName;
|
||||
|
||||
// check if the web site already exists (legacy)
|
||||
if (PackageController.GetPackageItemByName(packageId, siteName, typeof(WebSite)) != null)
|
||||
return BusinessErrorCodes.ERROR_WEB_SITE_ALREADY_EXISTS;
|
||||
|
||||
if (DataProvider.CheckDomain(domain.PackageId, siteName, true) != 0)
|
||||
return BusinessErrorCodes.ERROR_WEB_SITE_ALREADY_EXISTS;
|
||||
|
||||
string siteName = string.IsNullOrEmpty(hostName) ? domainName : hostName + "." + domainName; ;
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("WEB_SITE", "ADD", siteName);
|
||||
|
@ -240,13 +243,6 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if (ip != null)
|
||||
ipAddr = !String.IsNullOrEmpty(ip.InternalIP) ? ip.InternalIP : ip.ExternalIP;
|
||||
|
||||
// load domain instant alias
|
||||
/*
|
||||
string instantAlias = ServerController.GetDomainAlias(packageId, domainName);
|
||||
DomainInfo instantDomain = ServerController.GetDomain(instantAlias);
|
||||
if (instantDomain == null || instantDomain.WebSiteId > 0)
|
||||
instantAlias = "";
|
||||
*/
|
||||
|
||||
// load web DNS records
|
||||
List<GlobalDnsRecord> dnsRecords = ServerController.GetDnsRecordsByService(serviceId);
|
||||
|
@ -258,17 +254,15 @@ namespace WebsitePanel.EnterpriseServer
|
|||
{
|
||||
// SHARED IP
|
||||
// fill main domain bindings
|
||||
/*
|
||||
FillWebServerBindings(bindings, dnsRecords, ipAddr, domain.DomainName);
|
||||
FillWebServerBindings(bindings, dnsRecords, ipAddr, hostName, domain.DomainName, ignoreGlobalDNSRecords);
|
||||
|
||||
// fill alias bindings if required
|
||||
if (addInstantAlias && !String.IsNullOrEmpty(instantAlias))
|
||||
//double check all bindings
|
||||
foreach (ServerBinding b in bindings)
|
||||
{
|
||||
// fill bindings from DNS "A" records
|
||||
FillWebServerBindings(bindings, dnsRecords, ipAddr, instantAlias);
|
||||
if (DataProvider.CheckDomain(domain.PackageId, b.Host, true) != 0)
|
||||
return BusinessErrorCodes.ERROR_WEB_SITE_ALREADY_EXISTS;
|
||||
}
|
||||
*/
|
||||
bindings.Add(new ServerBinding(ipAddr, "80", siteName));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -392,14 +386,9 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
// update domain
|
||||
// add main pointer
|
||||
AddWebSitePointer(siteItemId, hostName, domain.DomainId, false);
|
||||
|
||||
// add instant pointer
|
||||
/*
|
||||
if (addInstantAlias && !String.IsNullOrEmpty(instantAlias))
|
||||
AddWebSitePointer(siteItemId, instantDomain.DomainId, false);
|
||||
*/
|
||||
AddWebSitePointer(siteItemId, hostName, domain.DomainId, false, ignoreGlobalDNSRecords);
|
||||
|
||||
|
||||
// add parking page
|
||||
// load package
|
||||
if (webPolicy["AddParkingPage"] != null)
|
||||
|
@ -574,12 +563,12 @@ namespace WebsitePanel.EnterpriseServer
|
|||
// remove all web site pointers
|
||||
List<DomainInfo> pointers = GetWebSitePointers(siteItemId);
|
||||
foreach (DomainInfo pointer in pointers)
|
||||
DeleteWebSitePointer(siteItemId, pointer.DomainId, false);
|
||||
DeleteWebSitePointer(siteItemId, pointer.DomainId, false, true);
|
||||
|
||||
// remove web site main pointer
|
||||
DomainInfo domain = ServerController.GetDomain(siteItem.Name);
|
||||
if(domain != null)
|
||||
DeleteWebSitePointer(siteItemId, domain.DomainId, false);
|
||||
DeleteWebSitePointer(siteItemId, domain.DomainId, false, true);
|
||||
|
||||
// delete web site
|
||||
WebServer web = new WebServer();
|
||||
|
@ -611,8 +600,110 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
}
|
||||
|
||||
public static int SwitchWebSiteToDedicatedIP(int siteItemId, int ipAddressId)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
|
||||
// load web site item
|
||||
WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
|
||||
if (siteItem == null)
|
||||
return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND;
|
||||
|
||||
// load assigned IP address
|
||||
IPAddressInfo ip = ServerController.GetIPAddress(ipAddressId);
|
||||
if (ip == null)
|
||||
return BusinessErrorCodes.ERROR_WEB_SITE_IP_ADDRESS_NOT_SPECIFIED;
|
||||
|
||||
string ipAddr = !String.IsNullOrEmpty(ip.InternalIP) ? ip.InternalIP : ip.ExternalIP;
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("WEB_SITE", "SWITCH_TO_DEDICATED_IP", siteItem.Name);
|
||||
TaskManager.ItemId = siteItemId;
|
||||
|
||||
try
|
||||
{
|
||||
// get web site pointers
|
||||
var sitePointers = GetWebSitePointers(siteItemId);
|
||||
|
||||
// get existing web site bindings
|
||||
WebServer web = new WebServer();
|
||||
ServiceProviderProxy.Init(web, siteItem.ServiceId);
|
||||
var bindings = web.GetSiteBindings(siteItem.SiteId);
|
||||
|
||||
// update site bindings
|
||||
web.UpdateSiteBindings(siteItem.SiteId, new ServerBinding[] { new ServerBinding(ipAddr, "80", "") });
|
||||
|
||||
// update site item
|
||||
siteItem.SiteIPAddressId = ipAddressId;
|
||||
PackageController.UpdatePackageItem(siteItem);
|
||||
|
||||
// associate IP with web site
|
||||
if (ipAddressId != 0)
|
||||
ServerController.AddItemIPAddress(siteItemId, ipAddressId);
|
||||
|
||||
// TODO - what would be correct logic here?
|
||||
// re-create pointers
|
||||
foreach (var pointer in sitePointers)
|
||||
DeleteWebSitePointer(siteItemId, pointer.DomainId, false, true);
|
||||
|
||||
foreach (var pointer in sitePointers)
|
||||
AddWebSitePointer(siteItemId, null, pointer.DomainId, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static int SwitchWebSiteToSharedIP(int siteItemId)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
|
||||
// load web site item
|
||||
WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
|
||||
if (siteItem == null)
|
||||
return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND;
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("WEB_SITE", "SWITCH_TO_SHARED_IP", siteItem.Name);
|
||||
TaskManager.ItemId = siteItemId;
|
||||
|
||||
try
|
||||
{
|
||||
// get web site pointers
|
||||
var sitePointers = GetWebSitePointers(siteItemId);
|
||||
|
||||
// get existing web site bindings
|
||||
WebServer web = new WebServer();
|
||||
ServiceProviderProxy.Init(web, siteItem.ServiceId);
|
||||
var bindings = web.GetSiteBindings(siteItem.SiteId);
|
||||
|
||||
// TODO - what would be correct logic here?
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
private static void FillWebServerBindings(List<ServerBinding> bindings, List<GlobalDnsRecord> dnsRecords,
|
||||
string ipAddr, string hostName, string domainName)
|
||||
string ipAddr, string hostName, string domainName, bool ignoreGlobalDNSRecords)
|
||||
// TODO test if IPv6 works
|
||||
{
|
||||
int bindingsCount = bindings.Count;
|
||||
|
@ -621,36 +712,46 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if ((dnsRecord.RecordType == "A" || dnsRecord.RecordType == "AAAA" || dnsRecord.RecordType == "CNAME") &&
|
||||
dnsRecord.RecordName != "*")
|
||||
{
|
||||
/*
|
||||
string recordData = dnsRecord.RecordName +
|
||||
((dnsRecord.RecordName != "") ? "." : "") + domainName;
|
||||
string recordData = Utils.ReplaceStringVariable(dnsRecord.RecordName, "host_name", hostName, true);
|
||||
|
||||
bindings.Add(new ServerBinding(ipAddr, "80", recordData));
|
||||
*/
|
||||
|
||||
string tmpName = string.Empty;
|
||||
if (!String.IsNullOrEmpty(hostName))
|
||||
tmpName = Utils.ReplaceStringVariable(dnsRecord.RecordName, "host_name", hostName);
|
||||
|
||||
string recordData = string.Empty;
|
||||
if (tmpName.Contains("."))
|
||||
recordData = hostName;
|
||||
if (!string.IsNullOrEmpty(domainName))
|
||||
recordData = recordData + ((string.IsNullOrEmpty(recordData)) ? "" : ".") + domainName;
|
||||
//otherwise full recordData is supplied by hostName
|
||||
|
||||
if (ignoreGlobalDNSRecords)
|
||||
{
|
||||
//only look for the host_nanme record, ignore all others
|
||||
if (dnsRecord.RecordName == "[host_name]")
|
||||
{
|
||||
AddBinding(bindings, new ServerBinding(ipAddr, "80", recordData));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
recordData = tmpName + ((tmpName != "") ? "." : "") + domainName;
|
||||
|
||||
bindings.Add(new ServerBinding(ipAddr, "80", recordData));
|
||||
{
|
||||
AddBinding(bindings, new ServerBinding(ipAddr, "80", recordData));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if(bindings.Count == bindingsCount)
|
||||
|
||||
if ((bindings.Count == bindingsCount) | (bindings.Count == 0))
|
||||
{
|
||||
bindings.Add(new ServerBinding(ipAddr, "80", domainName));
|
||||
bindings.Add(new ServerBinding(ipAddr, "80", "www." + domainName));
|
||||
AddBinding(bindings, new ServerBinding(ipAddr, "80", string.IsNullOrEmpty(hostName) ? domainName : hostName + "." + domainName));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private static void AddBinding(List<ServerBinding> bindings, ServerBinding binding)
|
||||
{
|
||||
foreach (ServerBinding b in bindings)
|
||||
{
|
||||
if (string.Compare(b.Host, binding.Host, true) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
bindings.Add(binding);
|
||||
}
|
||||
|
||||
|
||||
private static string GetWebSiteUsername(UserSettings webPolicy, string domainName)
|
||||
{
|
||||
UsernamePolicy policy = new UsernamePolicy(webPolicy["AnonymousAccountPolicy"]);
|
||||
|
@ -736,10 +837,15 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
public static int AddWebSitePointer(int siteItemId, string hostName, int domainId)
|
||||
{
|
||||
return AddWebSitePointer(siteItemId, hostName, domainId, true);
|
||||
return AddWebSitePointer(siteItemId, hostName, domainId, true, true);
|
||||
}
|
||||
|
||||
internal static int AddWebSitePointer(int siteItemId, string hostName, int domainId, bool updateWebSite)
|
||||
{
|
||||
return AddWebSitePointer(siteItemId, hostName, domainId, updateWebSite, false);
|
||||
}
|
||||
|
||||
internal static int AddWebSitePointer(int siteItemId, string hostName, int domainId, bool updateWebSite, bool ignoreGlobalDNSRecords)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
|
@ -755,6 +861,10 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if (domain == null)
|
||||
return BusinessErrorCodes.ERROR_DOMAIN_PACKAGE_ITEM_NOT_FOUND;
|
||||
|
||||
// check if the web site already exists
|
||||
if (DataProvider.CheckDomain(domain.PackageId, string.IsNullOrEmpty(hostName) ? domain.DomainName : hostName + "." + domain.DomainName, true) != 0)
|
||||
return BusinessErrorCodes.ERROR_WEB_SITE_ALREADY_EXISTS;
|
||||
|
||||
// get zone records for the service
|
||||
List<GlobalDnsRecord> dnsRecords = ServerController.GetDnsRecordsByService(siteItem.ServiceId);
|
||||
|
||||
|
@ -772,14 +882,41 @@ namespace WebsitePanel.EnterpriseServer
|
|||
{
|
||||
// load appropriate zone
|
||||
DnsZone zone = (DnsZone)PackageController.GetPackageItem(domain.ZoneItemId);
|
||||
|
||||
|
||||
if (zone != null)
|
||||
{
|
||||
// change DNS zone
|
||||
List<GlobalDnsRecord> tmpDnsRecords = new List<GlobalDnsRecord>();
|
||||
|
||||
string serviceIp = (ip != null) ? ip.ExternalIP : null;
|
||||
|
||||
//filter initiat GlobaDNSRecords list
|
||||
if (ignoreGlobalDNSRecords)
|
||||
{
|
||||
//ignore all other except the host_name record
|
||||
foreach (GlobalDnsRecord r in dnsRecords)
|
||||
{
|
||||
if (r.RecordName == "[host_name]")
|
||||
tmpDnsRecords.Add(r);
|
||||
}
|
||||
}
|
||||
else
|
||||
tmpDnsRecords = dnsRecords;
|
||||
|
||||
|
||||
List<DnsRecord> resourceRecords = DnsServerController.BuildDnsResourceRecords(
|
||||
dnsRecords, hostName, domain.DomainName, serviceIp);
|
||||
tmpDnsRecords, hostName, domain.DomainName, serviceIp);
|
||||
|
||||
foreach (DnsRecord r in resourceRecords)
|
||||
{
|
||||
if (r.RecordName != "*")
|
||||
{
|
||||
// check if the web site already exists
|
||||
if (DataProvider.CheckDomain(domain.PackageId, string.IsNullOrEmpty(r.RecordName) ? domain.DomainName : r.RecordName + "." + domain.DomainName, true) != 0)
|
||||
return BusinessErrorCodes.ERROR_WEB_SITE_ALREADY_EXISTS;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -796,59 +933,58 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
// update host headers
|
||||
if (updateWebSite)
|
||||
List<ServerBinding> bindings = new List<ServerBinding>();
|
||||
|
||||
// get existing web site bindings
|
||||
WebServer web = new WebServer();
|
||||
ServiceProviderProxy.Init(web, siteItem.ServiceId);
|
||||
|
||||
bindings.AddRange(web.GetSiteBindings(siteItem.SiteId));
|
||||
|
||||
// check if web site has dedicated IP assigned
|
||||
bool dedicatedIp = bindings.Exists(binding => { return String.IsNullOrEmpty(binding.Host) && binding.IP != "*"; });
|
||||
|
||||
// update binding only for "shared" ip addresses
|
||||
if (!dedicatedIp)
|
||||
{
|
||||
// get existing web site bindings
|
||||
WebServer web = new WebServer();
|
||||
ServiceProviderProxy.Init(web, siteItem.ServiceId);
|
||||
// add new host headers
|
||||
string ipAddr = "*";
|
||||
if (ip != null)
|
||||
ipAddr = !String.IsNullOrEmpty(ip.InternalIP) ? ip.InternalIP : ip.ExternalIP;
|
||||
|
||||
List<ServerBinding> bindings = new List<ServerBinding>();
|
||||
bindings.AddRange(web.GetSiteBindings(siteItem.SiteId));
|
||||
// fill bindings
|
||||
FillWebServerBindings(bindings, dnsRecords, ipAddr, hostName, domain.DomainName, ignoreGlobalDNSRecords);
|
||||
|
||||
// check if web site has dedicated IP assigned
|
||||
bool dedicatedIp = bindings.Exists(binding => { return String.IsNullOrEmpty(binding.Host) && binding.IP != "*"; });
|
||||
|
||||
// update binding only for "shared" ip addresses
|
||||
if (!dedicatedIp)
|
||||
//for logging purposes
|
||||
foreach (ServerBinding b in bindings)
|
||||
{
|
||||
// add new host headers
|
||||
string ipAddr = "*";
|
||||
if (ip != null)
|
||||
ipAddr = !String.IsNullOrEmpty(ip.InternalIP) ? ip.InternalIP : ip.ExternalIP;
|
||||
|
||||
// fill bindings
|
||||
FillWebServerBindings(bindings, dnsRecords, ipAddr, hostName, domain.DomainName);
|
||||
|
||||
foreach (ServerBinding b in bindings)
|
||||
{
|
||||
string header = string.Format("{0} {1} {2}", b.Host, b.IP, b.Port);
|
||||
TaskManager.WriteParameter("Add Binding", b.Host);
|
||||
}
|
||||
|
||||
// update bindings
|
||||
web.UpdateSiteBindings(siteItem.SiteId, bindings.ToArray());
|
||||
string header = string.Format("{0} {1} {2}", b.Host, b.IP, b.Port);
|
||||
TaskManager.WriteParameter("Add Binding", header);
|
||||
}
|
||||
|
||||
// update bindings
|
||||
if (updateWebSite)
|
||||
web.UpdateSiteBindings(siteItem.SiteId, bindings.ToArray());
|
||||
}
|
||||
|
||||
|
||||
// update domain
|
||||
domain.WebSiteId = siteItemId;
|
||||
//ServerController.UpdateDomain(domain);
|
||||
if (!String.IsNullOrEmpty(hostName))
|
||||
domain.DomainName = hostName + "." + domain.DomainName;
|
||||
else
|
||||
domain.DomainName = domain.DomainName;
|
||||
domain.IsDomainPointer = true;
|
||||
int domainID = ServerController.AddDomain(domain);
|
||||
|
||||
DomainInfo domainTmp = ServerController.GetDomain(domainID);
|
||||
if (domainTmp != null)
|
||||
foreach (ServerBinding b in bindings)
|
||||
{
|
||||
domainTmp.WebSiteId = siteItemId;
|
||||
domainTmp.ZoneItemId = domain.ZoneItemId;
|
||||
ServerController.UpdateDomain(domainTmp);
|
||||
//add new domain record
|
||||
domain.DomainName = b.Host;
|
||||
int domainID = ServerController.AddDomain(domain);
|
||||
DomainInfo domainTmp = ServerController.GetDomain(domainID);
|
||||
if (domainTmp != null)
|
||||
{
|
||||
domainTmp.WebSiteId = siteItemId;
|
||||
domainTmp.ZoneItemId = domain.ZoneItemId;
|
||||
ServerController.UpdateDomain(domainTmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -863,10 +999,10 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
public static int DeleteWebSitePointer(int siteItemId, int domainId)
|
||||
{
|
||||
return DeleteWebSitePointer(siteItemId, domainId, true);
|
||||
return DeleteWebSitePointer(siteItemId, domainId, true, true);
|
||||
}
|
||||
|
||||
public static int DeleteWebSitePointer(int siteItemId, int domainId, bool updateWebSite)
|
||||
public static int DeleteWebSitePointer(int siteItemId, int domainId, bool updateWebSite, bool ignoreGlobalDNSRecords)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
|
@ -895,16 +1031,29 @@ namespace WebsitePanel.EnterpriseServer
|
|||
TaskManager.StartTask("WEB_SITE", "DELETE_POINTER", siteItem.Name);
|
||||
TaskManager.ItemId = siteItemId;
|
||||
TaskManager.WriteParameter("Domain pointer", domain.DomainName);
|
||||
TaskManager.WriteParameter("updateWebSite", updateWebSite.ToString());
|
||||
|
||||
try
|
||||
{
|
||||
if (zone != null)
|
||||
{
|
||||
// change DNS zone
|
||||
List<GlobalDnsRecord> tmpDnsRecords = new List<GlobalDnsRecord>();
|
||||
|
||||
string serviceIp = (ip != null) ? ip.ExternalIP : null;
|
||||
|
||||
if (ignoreGlobalDNSRecords)
|
||||
{
|
||||
foreach (GlobalDnsRecord r in dnsRecords)
|
||||
{
|
||||
if ((r.RecordName == "[host_name]") | ((r.RecordName + (string.IsNullOrEmpty(r.RecordName) ? domain.ZoneName : "." + domain.ZoneName)) == domain.DomainName))
|
||||
tmpDnsRecords.Add(r);
|
||||
}
|
||||
}
|
||||
else tmpDnsRecords = dnsRecords;
|
||||
|
||||
List<DnsRecord> resourceRecords = DnsServerController.BuildDnsResourceRecords(
|
||||
dnsRecords, domain.DomainName, "", serviceIp);
|
||||
tmpDnsRecords, domain.DomainName, "", serviceIp);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -918,36 +1067,34 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
}
|
||||
|
||||
if (updateWebSite)
|
||||
// get existing web site bindings
|
||||
WebServer web = new WebServer();
|
||||
ServiceProviderProxy.Init(web, siteItem.ServiceId);
|
||||
|
||||
List<ServerBinding> bindings = new List<ServerBinding>();
|
||||
bindings.AddRange(web.GetSiteBindings(siteItem.SiteId));
|
||||
|
||||
// check if web site has dedicated IP assigned
|
||||
bool dedicatedIp = bindings.Exists(binding => { return String.IsNullOrEmpty(binding.Host) && binding.IP != "*"; });
|
||||
|
||||
// update binding only for "shared" ip addresses
|
||||
if (!dedicatedIp)
|
||||
{
|
||||
// get existing web site bindings
|
||||
WebServer web = new WebServer();
|
||||
ServiceProviderProxy.Init(web, siteItem.ServiceId);
|
||||
// remove host headers
|
||||
List<ServerBinding> domainBindings = new List<ServerBinding>();
|
||||
FillWebServerBindings(domainBindings, dnsRecords, "", domain.DomainName, "", ignoreGlobalDNSRecords);
|
||||
|
||||
List<ServerBinding> bindings = new List<ServerBinding>();
|
||||
bindings.AddRange(web.GetSiteBindings(siteItem.SiteId));
|
||||
// fill to remove list
|
||||
List<string> headersToRemove = new List<string>();
|
||||
foreach (ServerBinding domainBinding in domainBindings)
|
||||
headersToRemove.Add(domainBinding.Host);
|
||||
|
||||
// check if web site has dedicated IP assigned
|
||||
bool dedicatedIp = bindings.Exists(binding => { return String.IsNullOrEmpty(binding.Host) && binding.IP != "*"; });
|
||||
// remove bndings
|
||||
bindings.RemoveAll(b => { return headersToRemove.Contains(b.Host) && b.Port == "80"; } );
|
||||
|
||||
// update binding only for "shared" ip addresses
|
||||
if (!dedicatedIp)
|
||||
{
|
||||
// remove host headers
|
||||
List<ServerBinding> domainBindings = new List<ServerBinding>();
|
||||
FillWebServerBindings(domainBindings, dnsRecords, "", domain.DomainName, "");
|
||||
|
||||
// fill to remove list
|
||||
List<string> headersToRemove = new List<string>();
|
||||
foreach (ServerBinding domainBinding in domainBindings)
|
||||
headersToRemove.Add(domainBinding.Host);
|
||||
|
||||
// remove bndings
|
||||
bindings.RemoveAll(b => { return headersToRemove.Contains(b.Host) && b.Port == "80"; } );
|
||||
|
||||
// update bindings
|
||||
// update bindings
|
||||
if (updateWebSite)
|
||||
web.UpdateSiteBindings(siteItem.SiteId, bindings.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
// update domain
|
||||
|
|
|
@ -199,7 +199,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
try
|
||||
{
|
||||
int webSiteId = WebServerController.AddWebSite(
|
||||
createdPackageId, hostName, domainId, 0, true);
|
||||
createdPackageId, hostName, domainId, 0, true, false);
|
||||
if (webSiteId < 0)
|
||||
{
|
||||
// rollback wizard
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue