У меня возникли проблемы с загрузкой Dynamic Component Presentation от брокера на основе довольно простого запроса, такого как ниже, где я пытаюсь загрузить компонент на основе того, что он помечен определенным ключевым словом:Tridion 2009 SP1 Брокер не возвращает результаты
private string GetComponentPresentations()
{
Logger.Log.Info("Entered GetComponentPresentations");
var publicationCriteria = new PublicationCriteria(_publicationId);
int schemaId = int.Parse(SchemaId.Split('-')[1]);
// Is it the correct content type (Schema)
var isSpecifedSchema = new ItemSchemaCriteria(schemaId);
// Type of the item is 16 (Component).
var isComponent = new ItemTypeCriteria(16);
// All of the above conditions must be true
Criteria isCorrectComponent = CriteriaFactory.And(isSpecifedSchema, isComponent);
var publicationAndIsComponent = CriteriaFactory.And(publicationCriteria, isCorrectComponent);
//Only get components tagged with the specified keyword
var keywordCriteria = new KeywordCriteria(_productsCategoryTcmId, ProductFilter, Criteria.Equal);
//Only get Components of the correct type from the correct publication
Criteria fullCriteria = CriteriaFactory.And(publicationAndIsComponent, keywordCriteria);
using (var query = new Query(fullCriteria))
{
string[] results = query.ExecuteQuery();
using (var cpf = new ComponentPresentationFactory(_publicationId))
{
if(results != null)
{
var resultString = new StringBuilder();
foreach (string componentTcmId in results)
{
Logger.Log.Info("Looping over results");
int componentId = int.Parse(componentTcmId.Split('-')[1]);
int templateId = int.Parse(TemplateId.Split('-')[1]);
ComponentPresentation cp = cpf.GetComponentPresentation(componentId, templateId);
if (cp != null && !string.IsNullOrEmpty(cp.Content))
{
resultString.Append(cp.Content);
Logger.Log.InfoFormat("Appended Content {0}",cp.Content);
}
}
Logger.Log.Info("Returning");
return resultString.ToString();
}
Logger.Log.Info("Results was null.");
return string.Empty;
}
}
}
Я могу видеть элемент в таблице ITEMS_CATEGORIES_AND_KEYWORDS в базе данных Broker с ключевым словом я ожидаю, и я могу загрузить CP вручную, если я закомментировать запрос и жёстко в TCM ID в.
у меня есть убедитесь, что категория опубликована и что все значения переменных верны.
Я обеспечил, чтобы ключевое слово имело значение, а ключ был установлен в соответствующее значение.
Что еще я могу проверить?
Запрос, похоже, не имеет этого метода. Я не уверен, что это говорит нам. –