Collating list of pages that have subscribers

Vote:
 

I am writing a report for subscriptions to pages on our site.  Initially the report will present two views:

  1. Users: and the pages they subscribe to
  2. Pages: and the users who subscribe to them

Number 1 has been completed reasonably simply - looping through all profiles using ProfileManager, and then gathering each profiles SubscriptionInfo.SubscribedPages.

Doing similarly for number 2 is reaching road blocks: even considering the way that the subscriptionJob determines which pages have subscribers has not helped.

How do I get a listing of pages which have subscribers, and then derive who is subscribed to each page?

So, along the lines of this which works by profile: foreach (SubscriptionDescriptor sd in profile.SubscriptionInfo.SubscribedPages)

something like this for pages: foreach(EpiServerProfile pr in pageref.HasSubscribers.Subscriber.UserName)

Thanks in anticipation

 

#45797
Nov 18, 2010 2:49
Vote:
 

I would loop through the user profiles and add use a Dictionary<int, List<string>> to store a list of subscribers for each page ID that occurs. This will of course miss pages with no subscribers. And if you have subscribers for different languages you'd have to use something else as a key.

But this is basically what you did if I understand correctly. Why isn't it working?

#45810
Nov 18, 2010 8:07
Vote:
 

That could be a nice little blogpost or release on epis codesharing or epicode. 

Ok I admit it. I'm lazy and would like have to do it myself :)

#45816
Nov 18, 2010 12:57
Vote:
 

@Magnus: Thanks - yes, this is what I did, and it works fine.  It is the reverse of the problem that I'm trying to answer.

Looping through profiles and getting the pages they have subscribed to is okay.

BUT looping through and determining PAGES that HAVE subscribers is where I'm hoping for a pointer.

@Per: I believe it would be something that will be suitable to codesharing.  And, when complete I will be happy to.  I'm quite new to this whole technology - would you be prepared to look over my result and mentor me through the process?  Nothing too arduous.

Here's a screen shot of the intention.  Emails have been removed, because I'm caring.

#45869
Nov 21, 2010 21:06
Vote:
 

I think I'm missing the point here. What I suggested would be  sed to list the subscribers for each page (and not the subscriptions for each user) even though I'm finding the information by looping through the users. Like this:

var map = new Dictionary<int, List<string>>();
foreach (ProfileInfo profile in ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All))
{
    var epiProfile = EPiServerProfile.Get(profile.UserName);
    if ((epiProfile != null) && (epiProfile.SubscriptionInfo != null))
    {
        foreach (var pageLink in epiProfile.SubscriptionInfo.ListSubscriptions())
        {
            List<string> subscribers;
            if (!map.TryGetValue(pageLink.ID, out subscribers))
            {
                subscribers = new List<string>();
                map.Add(pageLink.ID, subscribers);
            }
            subscribers.Add(epiProfile.UserName);
        }
    }
}// map now contains all page IDs with subscribers and a list of subscribers for each page

Or is there a reason why you want to collect this information by looping through the pages rather than the profiles?

#45871
Nov 22, 2010 7:12
Vote:
 

Thank you Magnus. I was missing your point.  Fairly new to this environment and my mind-set was on having to troll pages.  I will look to making this report available through epicode.

#45925
Nov 22, 2010 21:55
Vote:
 
#48843
Feb 17, 2011 16:38
Vote:
 

just remember that the SubscriptionDescriptor Languages property with all the users subscribed languages for that page. Magnus code should work for single language sites thou

 

#48849
Feb 17, 2011 18:16
Vote:
 

Im using Episerver 6 R2 and I cant see how I would add a user to a subscription list and set up pages to subscribe to. I have seen a blog talking about EPSUBSCRIBE but I have no idea what this is and where to set it to TRUE.
Do you know of any step by step guides regarding Subscriptions using the CMS?
Thanks
Jonathan

#70281
Apr 16, 2013 15:08
Vote:
 

Jonathan,

As I understand it EPSUBSCRIBE (and its counterpart EPSUBSCRIBE-EXCLUDE) are effectively built-in EPiServer properties.  To make a page subscribable the page's PAGETYPE should have the EPSUBSCRIBE property included in it - this can be added in Admin mode.  It must be named correctly, and is of type "Selected/Unselected".  Checking this property on a published page allows it to be found and managed by your subscription processes - both your front end pages and logic that will allow a user to subscribe, and the backend scheduled process that undertakes to fulfil subscriptions.  A good starting place for the front end subscription process is using the Alloy Tech example pages/code.  The back end schedule works automagically.

#70308
Apr 17, 2013 4:00
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.