From 4093fd9b7942718330ea24325b9e5cd3836caf27 Mon Sep 17 00:00:00 2001 From: Shannon Date: Sat, 18 Mar 2017 16:52:30 +1100 Subject: [PATCH] U4-9637 addDashboardSection package action shouldn't add the dashboard if it already exists --- .../PackageActions/addDashboardSection.cs | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/umbraco.cms/businesslogic/Packager/PackageActions/addDashboardSection.cs b/src/umbraco.cms/businesslogic/Packager/PackageActions/addDashboardSection.cs index 6025123bc4..ceca7c21ff 100644 --- a/src/umbraco.cms/businesslogic/Packager/PackageActions/addDashboardSection.cs +++ b/src/umbraco.cms/businesslogic/Packager/PackageActions/addDashboardSection.cs @@ -43,23 +43,28 @@ namespace umbraco.cms.businesslogic.packager.standardPackageActions if (xmlData.HasChildNodes) { - string sectionAlias = xmlData.Attributes["dashboardAlias"].Value; - string dbConfig = SystemFiles.DashboardConfig; + string sectionAlias = xmlData.Attributes["dashboardAlias"].Value; + string dbConfig = SystemFiles.DashboardConfig; - XmlNode section = xmlData.SelectSingleNode("./section"); - XmlDocument dashboardFile = XmlHelper.OpenAsXmlDocument(dbConfig); + XmlNode section = xmlData.SelectSingleNode("./section"); + XmlDocument dashboardFile = XmlHelper.OpenAsXmlDocument(dbConfig); - XmlNode importedSection = dashboardFile.ImportNode(section, true); + //don't continue if it already exists + var found = dashboardFile.SelectNodes("//section[@alias='" + sectionAlias + "']"); + if (found == null || found.Count <= 0) + { + XmlNode importedSection = dashboardFile.ImportNode(section, true); - XmlAttribute alias = XmlHelper.AddAttribute(dashboardFile, "alias", sectionAlias); - importedSection.Attributes.Append(alias); + XmlAttribute alias = XmlHelper.AddAttribute(dashboardFile, "alias", sectionAlias); + importedSection.Attributes.Append(alias); - dashboardFile.DocumentElement.AppendChild(importedSection); + dashboardFile.DocumentElement.AppendChild(importedSection); - dashboardFile.Save(IOHelper.MapPath(dbConfig)); + dashboardFile.Save(IOHelper.MapPath(dbConfig)); + } - return true; - } + return true; + } return false; }