1

我需要在人们的 MySites 上的个人新闻源中添加自定义通知。我在网上找到了几个 SharePoint 2010 的教程和代码示例,并尝试对 SharePoint 2013 做同样的事情。它们都是关于ActivityEvents使用ActivityManager.

这是我尝试过的代码:

        var targetSite = new SPSite("URL to MySite webapp");
        SPServiceContext context = SPServiceContext.GetContext(targetSite);
        var userProfileManager = new UserProfileManager(context);

        var ownerProfile = userProfileManager.GetUserProfile("domain\\user1");
        var publisherProfile = userProfileManager.GetUserProfile("domain\\user2");

        var activityManager = new ActivityManager(ownerProfile, context);

        Entity publisher = new MinimalPerson(publisherProfile).CreateEntity(activityManager);
        Entity owner = new MinimalPerson(ownerProfile).CreateEntity(activityManager);
        ActivityEvent activityEvent = ActivityEvent.CreateActivityEvent(activityManager, 17, owner, publisher);
        activityEvent.Name = "StatusMessage";
        activityEvent.ItemPrivacy = (int)Privacy.Public;
        activityEvent.Owner = owner;
        activityEvent.Publisher = publisher;
        activityEvent.Value = "HELLOOOO";
        activityEvent.Commit();

        ActivityFeedGatherer.BatchWriteActivityEvents(new List<ActivityEvent> { activityEvent }, 0, 1);

函数中的 Id 用于17活动类型,其布局类似于资源文件中的布局,因此我提供了我的.CreateActivityEventStatusMessage{Publisher} says: {Value}ValueActivityEvent

代码运行没有任何异常,在User Profile Service Application_ProfileDB数据库中我可以看到正确的条目出现在ActivityEventsConsolidated表中。但是该活动在活动提要中不可见,无论是在所有者的提要上,还是在发布者的提要上,即使这些人互相关注。我在 CA 中手动运行了活动源作业以更新活动源。此外,我尝试对自定义ActivityTypes资源文件执行相同操作,结果相同:出现表中的条目ActivityEventsConsolidated(或者ActivityEventsPublished如果 Owner=Publisher),但 MySite 上没有条目。

任何人都可以帮忙吗?

4

1 回答 1

0

我自己找到了解决这个问题的方法。在Central Administration, 中Setup MySites,您必须启用该部分中的Enable SharePoint 2010 activity migration设置Newsfeed才能支持 SP2013 中的 SP1010 旧版活动。

于 2015-08-19T08:54:17.437 回答