4

我正在使用 Tridion.OutboundEmail.ContentManagement API 来检索和管理联系人详细信息。

检索联系人工作正常,拉回 ExtendedDetails 字典也是如此,但关键字 TcmUriCollection 始终为空。

[Test]
public void GetContacts_via_address_book()
{
    var uri = new TcmUri(101, 2, TcmItemTypes.StaticAddressBook);
    var addressBook = new StaticAddressBook(uri);
    var contacts = addressBook.GetContacts();

    foreach (var contact in contacts) 
    {
        var firstName = contact.ExtendedDetails["NAME"].StringValue;

        Assert.That(contact.EmailAddress, Is.Not.Empty); // PASS
        Assert.That(firstName, Is.Not.Empty); // PASS
        Assert.That(contact.Keywords.Count, Is.GreaterThan(0)); // FAIL
    }
}

我也尝试过以下方法:

[Test]
public void GetContacts_via_filter()
{
    var uri = new TcmUri(101, 2, TcmItemTypes.StaticAddressBook);
    var addressBook = new StaticAddressBook(uri);
    var filter = new ContactFilter(UserContext.Current);
    var contacts = Contact.GetContacts(filter, addressBook);

    foreach (var contact in contacts) 
    {
        var firstName = contact.ExtendedDetails["NAME"].StringValue;

        Assert.That(contact.EmailAddress, Is.Not.Empty); // PASS
        Assert.That(firstName, Is.Not.Empty); // PASS
        Assert.That(contact.Keywords.Count, Is.GreaterThan(0)); // FAIL
    }
}

我什至可以将关键字添加到联系人的关键字集合并保存,它在 Tridion 中正确显示,但是当我再次检索相同的联系人时,集合再次为空。

有没有人对此 API 有任何经验,和/或知道问题出在哪里?

4

1 回答 1

6

这是因为当您获得联系人列表时没有加载关键字。出于性能原因,只有一部分数据可用。

To solve this, you will need to re-load each Contact. Since Contacts are streamed from the database, you cannot do this inside of your loop. So you'll want to build the list of Contacts first and then loop over them and load them in full.

For more info and examples, please see my blog post on the subject: http://pkjaer.wordpress.com/2011/12/01/looping-through-contacts/

于 2012-03-13T16:24:48.060 回答