2

我正在创建一个事件处理程序来获取所有活动的活动实例详细信息。

EventSystem.Subscribe<ActivityInstance, FinishActivityEventArgs>(NotifyUser, EventPhases.TransactionCommitted);

在“NotifiyUser”功能中,我试图获取活动实例详细信息,如(标题、FinishMessage、所有者、执行者等)

我能够获取“手动活动”的“自动活动”的所有详细信息,但无法获取“所有者”和“执行者”值。

private void NotifyUser(ActivityInstance activityInstance, FinishActivityEventArgs args, EventPhases phase)
    {
        _session = activityInstance.Session;
       logdetails("Activity Owner--->" + activityInstance.Owner.Title);
        foreach (var performer in activityInstance.Performers)
        {
           logdetails("Activity Performer--->" + performer.Title);
        }
    }
4

1 回答 1

3

这很奇怪,我无法重现它。

在我的代码中,我这样做了(与您相同的订阅)

private void LogSomething(ActivityInstance instance, FinishActivityEventArgs args, EventPhases phases)
{
    User owner = instance.Owner;
    File.AppendAllLines("c:\\temp\\info.log", new[]
        {
            string.Format("Activity ID: {0} owned by: {1}({2}", instance.Id, owner.Title, owner.Id)
        });
    List<User> performers = new List<User>(instance.Performers);
    foreach (var performer in performers)
    {
        File.AppendAllLines("c:\\temp\\info.log", new[]
            {
                string.Format("Activity ID: {0} Performer: {1}({2}", instance.Id, performer.Title, performer.Id)
            });
    }
}

为我粗暴的伐木道歉。

这是我在 info.log 中得到的:

Activity ID: tcm:3-923-131104 owned by: T2011GURUV3\Administrator(tcm:0-11-65552
Activity ID: tcm:3-923-131104 Performer: T2011GURUV3\Administrator(tcm:0-11-65552
Activity ID: tcm:3-924-131104 owned by: NT AUTHORITY\SYSTEM(tcm:0-3-65552
Activity ID: tcm:3-924-131104 Performer: NT AUTHORITY\SYSTEM(tcm:0-3-65552
Activity ID: tcm:3-925-131104 owned by: T2011GURUV3\Administrator(tcm:0-11-65552
Activity ID: tcm:3-925-131104 Performer: T2011GURUV3\Administrator(tcm:0-11-65552
Activity ID: tcm:3-926-131104 owned by: T2011GURUV3\Administrator(tcm:0-11-65552
Activity ID: tcm:3-926-131104 Performer: T2011GURUV3\Administrator(tcm:0-11-65552
Activity ID: tcm:3-927-131104 owned by: NT AUTHORITY\SYSTEM(tcm:0-3-65552
Activity ID: tcm:3-927-131104 Performer: NT AUTHORITY\SYSTEM(tcm:0-3-65552
Activity ID: tcm:3-928-131104 owned by: T2011GURUV3\Administrator(tcm:0-11-65552
Activity ID: tcm:3-928-131104 Performer: T2011GURUV3\Administrator(tcm:0-11-65552

所以看起来这可能与你的环境有关?也许是特定版本的缺陷?我在使用 Hotfix Rollup 1 的 SDL Tridion 2011 SP1

于 2012-07-31T06:26:03.433 回答