private void ReportChildTreeDeletions(Data.Items.Item parentItem, List <XmlNode> manifestItems, Sitecore.Data.Database scDataBase, ManifestReportDataBase manifestReportDatabase) { var items = parentItem.GetChildren(); items.ForEach(item => { if (!manifestItems.Any(manifestItem => NormalizeGuid(manifestItem.Attributes["Id"].Value) == NormalizeGuid(item.ID.Guid))) { manifestReportDatabase.Items.Add(new ManifestReportItem() { FullPath = item.Paths.FullPath, Id = NormalizeGuid(item.ID.Guid), UpdateType = "DEL" }); logger.Info("[DELETE] " + item.Paths.FullPath + " " + NormalizeGuid(item.ID.Guid)); // report all decendants as deleted, as we know these are not kept. ReportChildTreeDeletionsAsDeleted(item, manifestItems, scDataBase, manifestReportDatabase); } else { // check any child nodes recursivly. ReportChildTreeDeletions(item, manifestItems, scDataBase, manifestReportDatabase); } }); }
private void ReportChildTreeDeletionsAsDeleted(Data.Items.Item parentItem, List <XmlNode> manifestItems, Sitecore.Data.Database scDataBase, ManifestReportDataBase manifestReportDatabase) { var items = parentItem.GetChildren(); items.ForEach(item => { manifestReportDatabase.Items.Add(new ManifestReportItem() { FullPath = item.Paths.FullPath, Id = NormalizeGuid(item.ID.Guid), UpdateType = "DEL" }); logger.Info("[DELETE] " + item.Name + " " + NormalizeGuid(item.ID.Guid)); ReportChildTreeDeletionsAsDeleted(item, manifestItems, scDataBase, manifestReportDatabase); }); }
private ManifestReportDataBase ReportManifestList(IEnumerable <XmlNode> manifestItems, string itemsExtractionPath, bool canDeleteItems, Sitecore.Data.Database scDataBase) { var manifestReportDatabase = new ManifestReportDataBase() { Database = scDataBase.Name, Items = new List <ManifestReportItem>() }; var parsingList = manifestItems.ToList(); // clone the list in case we need to parse it recursivly. manifestItems.ForEach(manifestItem => { var manifestReportItem = new ManifestReportItem(); bool parseChildren = false; var canDeleteChildren = canDeleteItems && ItemCanDeleteChildren(manifestItem); manifestReportItem.Id = NormalizeGuid(manifestItem.Attributes["Id"].Value); // check to see if we are adding or updating var scItem = scDataBase.GetItem(new ID(manifestReportItem.Id)); if (scItem == null) { manifestReportItem.FullPath = manifestItem.Attributes["Name"].Value; if (manifestReportItem.FullPath.EndsWith(".item")) { manifestReportItem.FullPath = manifestReportItem.FullPath.Substring(0, manifestReportItem.FullPath.Length - 5); } scItem = scDataBase.GetItem(new ID(manifestItem.Attributes["Parent"].Value)); if (scItem != null) { manifestReportItem.FullPath = scItem.Paths.Path + "/" + manifestReportItem.FullPath; } manifestReportItem.UpdateType = "ADD"; scItem = null; } else { if (IsItemDeployOnce(manifestItem, itemsExtractionPath)) { manifestReportItem.FullPath = scItem.Paths.FullPath; manifestReportItem.UpdateType = "IGNORE"; parseChildren = false; } else { manifestReportItem.FullPath = scItem.Paths.FullPath; manifestReportItem.UpdateType = "UPD"; if (canDeleteChildren) { parseChildren = true; } } } logger.Info(manifestReportItem.ToString()); manifestReportDatabase.Items.Add(manifestReportItem); if (parseChildren && scItem != null) { ReportChildTreeDeletions(scItem, parsingList, scDataBase, manifestReportDatabase); } }); manifestReportDatabase.Items = manifestReportDatabase.Items.OrderBy(i => i.FullPath).ToList(); return(manifestReportDatabase); }