Mono Support Discussion board container/activity stream 

Viewed 43795 time(s), 2 post(s), 8/30/2012 12:26:34 PM - by DanC
8/30/2012 12:26:34 PM
85 Reputation 9 Total posts

Hi,
I would like to use something like the blog container for a discussion board (or boards).
The best thing I think to use is an activity stream and dial in to the activities I want to listen to.
I have added an activity stream from events.ascx but I am having difficulty setting it. I seem to have made changes (using the webpart settings) and some of my changes in default.ascx are not being picked up. I don't know how to reset it after making those changes?

Also, I have set EventsToDisplay="Discussion" but the only activities I hear about are new topics and not necessarily new posts to topics. I'm not sure if the client requires this but I want to know if it is theoretically possible shouuld they ask me? I am seeing a lot more entries than just Discussion board related so i don't know what is going on.


<%@ Register TagPrefix="MonoX" TagName="EventsContainer" Src="/MonoX/ModuleGallery/SocialNetworking/Events.ascx" %>

<portal:PortalWebPartZoneTableless ID="PortalWebPartZoneTableless1" runat="server" Width="100%" ChromeTemplateFile="Standard.htm" HeaderText="Middle row left" >
<ZoneTemplate>
<MonoX:EventsContainer ID="EventContainer" NumberOfEventsToShow="4" EventsToDisplay="Discussion" PagerPageSize="7" runat="server" width="100%" ChromeTemplateFile="Standard.htm" HeaderText="Discussion board topics">
</MonoX:EventsContainer>
</ZoneTemplate>
</portal:PortalWebPartZoneTableless>

1
8/31/2012 1:43:23 PM
2218 Reputation 300 Total posts

Hello,

To show only Discussion Topic events you will need to create your own Repository method to fetch only Discussion Topic event types and then you will need to inherit Events.ascx control and override its BindData Method.

Example repository method:

public virtual EntityCollection<SnEventEntity> GetEvents(Guid userId, int numberOfEvents, int pageIndex, int pageSize, out int recordCount)
{
    EntityCollection<SnEventEntity> events = new EntityCollection<SnEventEntity>(new SnEventEntityFactory());
    IRelationPredicateBucket filter = new RelationPredicateBucket();
    filter.PredicateExpression.Add(FriendRepository.GetInstance().GetFriendshipFilter(userId));           
    filter.PredicateExpression.Add(SnEventFields.EventTypeId == SnEventTypeEntity.AddedDiscussionTopic.Id);
    filter.Relations.Add(SnEventEntity.Relations.AspnetUsersEntityUsingUserId);
 
    IPrefetchPath2 prefetchPath = new PrefetchPath2(EntityType.SnEventEntity);
    prefetchPath.Add(SnEventEntity.PrefetchPathFriendAspnetUsers);
    prefetchPath.Add(SnEventEntity.PrefetchPathBlogPost);
    prefetchPath.Add(SnEventEntity.PrefetchPathSnAlbum);
    prefetchPath.Add(SnEventEntity.PrefetchPathSnFile);
    prefetchPath.Add(SnEventEntity.PrefetchPathSnGroup);
    prefetchPath.Add(SnEventEntity.PrefetchPathAspnetUsers).SubPath.Add(AspnetUsersEntity.PrefetchPathUserProfile);
    prefetchPath.Add(SnEventEntity.PrefetchPathSnDiscussionBoard);
    prefetchPath.Add(SnEventEntity.PrefetchPathSnDiscussionTopic);
 
    ISortExpression sortExpression = new SortExpression(new SortClause(SnEventFields.DateCreated, null, SortOperator.Descending));
 
    FetchEntityCollection(events, filter, numberOfEvents, sortExpression, prefetchPath, pageIndex, pageSize);
    recordCount = GetDbCount(events, filter);
    return events;
}
Example BindData override:
MonoXCacheManager cacheManager = MonoXCacheManager.GetInstance(CacheKeys.Events.EventList, this.CacheDuration);
Guid userId = this.UserId;
if (userId == Guid.Empty)
    userId = SecurityUtility.GetUserId();
PagedCollectionContainer bindContainer = cacheManager.Get<PagedCollectionContainer>(userId, this.NumberOfEventsToShow, this.ShowUserOwnEvents, PagedCollectionContainer.GetPagerCacheKey(pager)) ?? PagedCollectionContainer.GetInstance();
 
if (!bindContainer.HasValue)
{
    bindContainer.Collection = EventRepository.GetInstance().GetEvents(userId, this.NumberOfEventsToShow, pager != null ? pager.CurrentPageIndex + 1 : 0, pager != null ? pager.PageSize : NumberOfEventsToShow, out bindContainer.RecordCount);
    cacheManager.Store(bindContainer, userId, this.NumberOfEventsToShow, this.ShowUserOwnEvents, PagedCollectionContainer.GetPagerCacheKey(pager));
}
if (bindContainer.HasValue)
{
    if (pager != null)
        PagerUtility.BindPager(pager, BindData, lvItems, bindContainer.Collection, bindContainer.RecordCount);
}
Adding events for new topic replies is possible however it is currently not implemented in the current MonoX build. Here's what you will need to do:
1. Add a DiscussionMessage event type
2. Override in DiscussionMessages OnPost method and insert your custom event type
3. Expand the code which I posted above to include your custom event type

Regards,
Mario

2
This is a demo site for MonoX. Please visit Mono Software for more info.