fixed: Verification on dependencies when domain or domain instant alias gets
deleted
This commit is contained in:
parent
37c44cdd63
commit
599d7666e8
4 changed files with 100 additions and 10 deletions
|
@ -5703,6 +5703,40 @@ DROP TABLE #TempCRMUsers
|
|||
GO
|
||||
|
||||
|
||||
IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'GetDomainsByZoneID]')
|
||||
BEGIN
|
||||
EXEC sp_executesql N'CREATE PROCEDURE [dbo].[GetDomainsByZoneID]
|
||||
(
|
||||
@ActorID int,
|
||||
@ZoneID int
|
||||
)
|
||||
AS
|
||||
|
||||
SELECT
|
||||
D.DomainID,
|
||||
D.PackageID,
|
||||
D.ZoneItemID,
|
||||
D.DomainName,
|
||||
D.HostingAllowed,
|
||||
ISNULL(D.WebSiteID, 0) AS WebSiteID,
|
||||
WS.ItemName AS WebSiteName,
|
||||
ISNULL(D.MailDomainID, 0) AS MailDomainID,
|
||||
MD.ItemName AS MailDomainName,
|
||||
Z.ItemName AS ZoneName,
|
||||
D.IsSubDomain,
|
||||
D.IsInstantAlias,
|
||||
D.IsDomainPointer
|
||||
FROM Domains AS D
|
||||
INNER JOIN Packages AS P ON D.PackageID = P.PackageID
|
||||
LEFT OUTER JOIN ServiceItems AS WS ON D.WebSiteID = WS.ItemID
|
||||
LEFT OUTER JOIN ServiceItems AS MD ON D.MailDomainID = MD.ItemID
|
||||
LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID
|
||||
WHERE
|
||||
D.ZoneItemID = @ZoneID
|
||||
AND dbo.CheckActorPackageRights(@ActorID, P.PackageID) = 1
|
||||
RETURN'
|
||||
END
|
||||
GO
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -793,6 +793,15 @@ namespace WebsitePanel.EnterpriseServer
|
|||
new SqlParameter("@domainName", domainName));
|
||||
}
|
||||
|
||||
public static DataSet GetDomainsByZoneId(int actorId, int zoneId)
|
||||
{
|
||||
return SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure,
|
||||
ObjectQualifier + "GetDomainsByZoneID",
|
||||
new SqlParameter("@ActorId", actorId),
|
||||
new SqlParameter("@ZoneID", zoneId));
|
||||
}
|
||||
|
||||
|
||||
public static int CheckDomain(int packageId, string domainName, bool isDomainPointer)
|
||||
{
|
||||
SqlParameter prmId = new SqlParameter("@Result", SqlDbType.Int);
|
||||
|
|
|
@ -1602,6 +1602,13 @@ namespace WebsitePanel.EnterpriseServer
|
|||
DataProvider.GetDomains(SecurityContext.User.UserId, packageId, true));
|
||||
}
|
||||
|
||||
|
||||
public static List<DomainInfo> GetDomainsByZoneId(int zoneId)
|
||||
{
|
||||
return ObjectUtils.CreateListFromDataSet<DomainInfo>(
|
||||
DataProvider.GetDomainsByZoneId(SecurityContext.User.UserId, zoneId));
|
||||
}
|
||||
|
||||
public static List<DomainInfo> GetMyDomains(int packageId)
|
||||
{
|
||||
return ObjectUtils.CreateListFromDataSet<DomainInfo>(
|
||||
|
@ -1913,6 +1920,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
// load domain
|
||||
DomainInfo domain = GetDomain(domainId);
|
||||
if (domain == null)
|
||||
return 0;
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("DOMAIN", "DETACH", domain.DomainName);
|
||||
|
@ -1939,6 +1948,17 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return BusinessErrorCodes.ERROR_ORGANIZATION_DOMAIN_IS_IN_USE;
|
||||
}
|
||||
|
||||
List<DomainInfo> domains = GetDomainsByZoneId(domain.ZoneItemId);
|
||||
foreach (DomainInfo d in domains)
|
||||
{
|
||||
if (d.WebSiteId > 0)
|
||||
{
|
||||
TaskManager.WriteError("Domain points to the existing web site");
|
||||
return BusinessErrorCodes.ERROR_DOMAIN_POINTS_TO_WEB_SITE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// remove DNS zone meta-item if required
|
||||
if (domain.ZoneItemId > 0)
|
||||
{
|
||||
|
@ -1968,6 +1988,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
// load domain
|
||||
DomainInfo domain = GetDomain(domainId);
|
||||
if (domain == null)
|
||||
return 0;
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("DOMAIN", "DELETE", domain.DomainName);
|
||||
|
@ -1994,6 +2016,17 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return BusinessErrorCodes.ERROR_ORGANIZATION_DOMAIN_IS_IN_USE;
|
||||
}
|
||||
|
||||
List<DomainInfo> domains = GetDomainsByZoneId(domain.ZoneItemId);
|
||||
foreach (DomainInfo d in domains)
|
||||
{
|
||||
if (d.WebSiteId > 0)
|
||||
{
|
||||
TaskManager.WriteError("Domain points to the existing web site");
|
||||
return BusinessErrorCodes.ERROR_DOMAIN_POINTS_TO_WEB_SITE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// delete instant alias
|
||||
if (domain.InstantAliasId > 0)
|
||||
{
|
||||
|
@ -2210,6 +2243,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
// load domain
|
||||
DomainInfo domain = GetDomain(domainId);
|
||||
if (domain == null)
|
||||
return 0;
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("DOMAIN", "DELETE_INSTANT_ALIAS", domain.DomainName);
|
||||
|
@ -2229,7 +2264,20 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if (webRes < 0)
|
||||
return webRes;
|
||||
}
|
||||
/*
|
||||
|
||||
|
||||
List<DomainInfo> domains = GetDomainsByZoneId(domain.ZoneItemId);
|
||||
foreach (DomainInfo d in domains)
|
||||
{
|
||||
if (d.WebSiteId > 0)
|
||||
{
|
||||
int webRes = WebServerController.DeleteWebSitePointer(d.WebSiteId, d.DomainId);
|
||||
if (webRes < 0)
|
||||
return webRes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// remove from mail domain pointers
|
||||
if (instantAlias.MailDomainId > 0)
|
||||
{
|
||||
|
@ -2237,7 +2285,6 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if (mailRes < 0)
|
||||
return mailRes;
|
||||
}
|
||||
*/
|
||||
|
||||
// delete instant alias
|
||||
int res = DeleteDomain(instantAlias.DomainId);
|
||||
|
|
|
@ -735,7 +735,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
DomainInfo ZoneInfo = ServerController.GetDomain(domain.ZoneName);
|
||||
|
||||
if (ZoneInfo == null)
|
||||
throw new Exception("failed to retrieve parent zone");
|
||||
throw new Exception("Parent zone not found");
|
||||
|
||||
|
||||
// remove all web site pointers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue