internal List <AuditableContent> LoopForAuditableContentNodes(IContent ThisNode)
        {
            var nodesList = new List <AuditableContent>();

            //Add current node, then loop for children
            AuditableContent auditContent = ConvertIContentToAuditableContent(ThisNode);

            nodesList.Add(auditContent);

            //figure out num of children
            long countChildren;
            var  test = _services.ContentService.GetPagedChildren(ThisNode.Id, 0, 1, out countChildren);

            if (countChildren > 0)
            {
                long countTest;
                var  allChildren = _services.ContentService.GetPagedChildren(ThisNode.Id, 0, Convert.ToInt32(countChildren), out countTest);
                foreach (var childNode in allChildren.OrderBy(n => n.SortOrder))
                {
                    nodesList.AddRange(LoopForAuditableContentNodes(childNode));
                }
            }

            return(nodesList);
        }
Ejemplo n.º 2
0
        public static AuditableContent ConvertToAuditableContent(IPublishedContent IPub)
        {
            var iContent = umbContentService.GetById(IPub.Id);
            var ac       = new AuditableContent();

            ac.UmbContentNode = iContent;
            ac.IsPublished    = ac.UmbContentNode.Published;
            ac.DocTypeAlias   = iContent.ContentType.Alias;

            if (iContent.Template != null)
            {
                var template = umbFileService.GetTemplate((int)iContent.Template.Id);
                ac.TemplateAlias = template.Alias;
            }
            else
            {
                ac.TemplateAlias = "NONE";
            }

            if (ac.UmbContentNode.Published)
            {
                try
                {
                    var iPub = umbHelper.Content(iContent.Id);
                    ac.UmbPublishedNode = iPub;
                }
                catch (Exception e)
                {
                    try
                    {
                        //Get preview - unpublished
                        var iPub = umbContext.ContentCache.GetById(true, iContent.Id);
                        ac.UmbPublishedNode = iPub;
                    }
                    catch (Exception exception)
                    {
                        ac.UmbPublishedNode = null;
                        var nodeId   = iContent != null ? iContent.Id : 0;
                        var nodeName = iContent != null ? iContent.Name : "UNKNOWN - IContent is NULL";
                        LogHelper.Error <AuditableContent>($"Unable to get a PublishedContent for node #{nodeId} : '{nodeName}'", exception);
                    }
                }
            }

            ac.RelativeNiceUrl = ac.UmbPublishedNode != null ? ac.UmbPublishedNode.Url : "UNPUBLISHED";
            ac.FullNiceUrl     = ac.UmbPublishedNode != null?ac.UmbPublishedNode.UrlAbsolute() : "UNPUBLISHED";

            ac.NodePath       = AuditHelper.NodePath(iContent);
            ac.NodePathAsText = string.Join(siteAuditorService.DefaultDelimiter, ac.NodePath);

            return(ac);
        }