I'm currently working on a event handler. This will, on a save-event, save the latest revision date of the page and its components into a custom database. It is working, but I'm facing some performance issues.
Let me give you an example of how it works:
If a component is saved/updated (changes are made), then I want to update all pages using this component in my custom database.
Basic blueprint setup: 200 contains components
400 translation publication for components (inherent components from 200)
500 master publication for pages
600 local site publication inherent components from 400 and pages from 500)
So lets say we have component, "X", in 200. This component is included in in a page in 500 and localized in 400 (let us call it X(l)). The page in 600 is NOT localized ( i.e it will use the component X(l) instead of X)
So now to my question: In my save event handler, I check what pages X(l) are included in by using :
var filter = new UsingItemsFilter(component.Session)
{
IncludeLocalCopies = true,
ItemTypes = new[] { ItemType.Page }
};
But this will only give me references to pages from 500. So then I (which feels kind of stupid) do the following: create a TCM ID of all pages in child publications(by looping over them) that inherent this page (now I'm using some psuedocode-like coding):
foreach(var 500page in foundPages)
foreach(var publication in publications){
if(subject.Session.IsExistingObject(
new TcmUri(page.Id.ItemId,page.Id.ItemType,publication.Id.ItemId)
))
{
someListThatWillContainAllChildPagesFrom500.Add(TheAboveTcmUri);
}
}
And then for each page, check the components in that page, and finally save this state to my custom database.
So the question is: is there a way to query for all pages that make use of the localized component by using the TOM.NET API (no not CoreServiceClient)?
Is there a better way to find child publications of a publication, so I only need to check for pages in the childPublication?
And yes, I have tried the :
if (pub.HasChildren)
{
var childs = pub.GetUsingItems(new UsingItemsFilter(subject.Session) {
ItemTypes=new []{ItemType.Publication}
});
which only throws : not implemented exception.
Be aware that this is on a 2011 implementation
Br Martin