Beispiel #1
0
        public IEnumerable <PageReference> GetPageReferencesByTags(IEnumerable <Tag> tags)
        {
            var matches = new Dictionary <PageReference, int>();

            foreach (Tag tag in tags)
            {
                if (tag != null && tag.PermanentLinks != null)
                {
                    foreach (Guid pageGuid in tag.PermanentLinks)
                    {
                        var pageReference = TagsHelper.GetPageReference(pageGuid);

                        if (matches.ContainsKey(pageReference))
                        {
                            matches[pageReference] += 1;
                        }
                        else
                        {
                            matches.Add(pageReference, 1);
                        }
                    }
                }
            }

            matches = matches.OrderByDescending(t => t.Value).ToDictionary(pair => pair.Key, pair => pair.Value);

            return(matches.Keys);
        }
Beispiel #2
0
        public PageDataCollection GetPagesByTag(Tag tag, PageReference rootPageReference)
        {
            if (tag == null || tag.PermanentLinks == null)
            {
                return(null);
            }

            IList <PageReference> descendantPageReferences = DataFactory.Instance.GetDescendents(rootPageReference);

            if (descendantPageReferences == null || descendantPageReferences.Count < 1)
            {
                return(null);
            }

            var pages = new PageDataCollection();

            foreach (Guid pageGuid in tag.PermanentLinks)
            {
                var pageReference = TagsHelper.GetPageReference(pageGuid);

                if (descendantPageReferences.FirstOrDefault(p => p.ID == pageReference.ID) != null)
                {
                    pages.Add(DataFactory.Instance.GetPage(pageReference));
                }
            }

            return(pages);
        }
Beispiel #3
0
        public override string Execute()
        {
            var tags      = _tagService.GetAllTags().ToList();
            var pageGuids = GetTaggedPageGuids(tags);

            foreach (var pageGuid in pageGuids)
            {
                if (_stop)
                {
                    return("Geta Tags maintenance was stopped");
                }

                PageData page = null;

                try
                {
                    page = DataFactory.Instance.GetPage(TagsHelper.GetPageReference(pageGuid));
                }
                catch (PageNotFoundException) {}

                if (page == null || page.IsDeleted)
                {
                    RemoveFromAllTags(pageGuid, tags);
                    continue;
                }

                CheckPageProperties(page, tags);
            }

            return("Geta Tags maintenance completed successfully");
        }
Beispiel #4
0
        public PageDataCollection GetPagesByTag(Tag tag)
        {
            if (tag == null)
            {
                return(null);
            }

            var pageLinks = new List <Guid>();

            if (tag.PermanentLinks == null)
            {
                var tempTerm = this._tagService.GetTagByName(tag.Name);

                if (tempTerm != null)
                {
                    pageLinks = tempTerm.PermanentLinks.ToList();
                }
            }
            else
            {
                pageLinks = tag.PermanentLinks.ToList();
            }

            var pages = new PageDataCollection();

            foreach (Guid pageGuid in pageLinks)
            {
                pages.Add(DataFactory.Instance.GetPage(TagsHelper.GetPageReference(pageGuid)));
            }

            return(pages);
        }
Beispiel #5
0
        public IEnumerable <PageReference> GetPageReferencesByTags(IEnumerable <Tag> tags, PageReference rootPageReference)
        {
            if (tags == null || PageReference.IsNullOrEmpty(rootPageReference))
            {
                return(null);
            }

            IList <PageReference> descendantPageReferences = DataFactory.Instance.GetDescendents(rootPageReference);

            if (descendantPageReferences == null || descendantPageReferences.Count < 1)
            {
                return(null);
            }

            var matches = new Dictionary <PageReference, int>();

            foreach (Tag tag in tags)
            {
                if (tag == null || tag.PermanentLinks == null)
                {
                    continue;
                }

                foreach (Guid pageGuid in tag.PermanentLinks)
                {
                    var pageReference = TagsHelper.GetPageReference(pageGuid);

                    if (descendantPageReferences.FirstOrDefault(p => p.ID == pageReference.ID) != null)
                    {
                        if (matches.ContainsKey(pageReference))
                        {
                            matches[pageReference] += 1;
                        }
                        else
                        {
                            matches.Add(pageReference, 1);
                        }
                    }
                }
            }

            matches = matches.OrderByDescending(t => t.Value).ToDictionary(pair => pair.Key, pair => pair.Value);

            return(new PageReferenceCollection(matches.Keys));
        }