我正在尝试在我们的一个模块上实现 ISearchable。
Visual Studio 指示 SearchItemInfo 在 DNN 7.1 中已过时且已弃用。
我找到了这篇文章,但它确实显示了我必须使用的新替代代码,并且 GitHub 上有很多内部函数。
https://www.dnnsoftware.com/answers/searchdatastorecontroller-is-obsolete-in-71
public SearchItemInfoCollection
GetSearchItems(DotNetNuke.Entities.Modules.ModuleInfo ModInfo)
{
SearchItemInfoCollection SearchItemCollection = new SearchItemInfoCollection();
List<TestModuleInfo> colTestModules = GetTestModules(ModInfo.ModuleID);
foreach (TestModuleInfo objTestModule in colTestModules)
{
SearchItemInfo SearchItem = new SearchItemInfo(ModInfo.ModuleTitle, objTestModule.Content, objTestModule.CreatedByUser, objTestModule.CreatedDate, ModInfo.ModuleID, objTestModule.ItemId.ToString(), objTestModule.Content, "ItemId=" + objTestModule.ItemId.ToString());
SearchItemCollection.Add(SearchItem);
}
return SearchItemCollection;
throw new System.NotImplementedException("The method or operation is not implemented.");
}
我确实尝试编写以下方法并在 GetModifiedSearchDocuments 上附加了一个断点并安排了站点爬虫来爬取该站点,但它从未被命中。此外,通过实现此代码,这是否会显示模块上的复选框,使您能够打开和关闭 ISearchable?
//uncomment the interfaces to add the support.
public class FeatureController : ModuleSearchBase
{
public CommonDataDefinitions.Products.WebProductDetails ProductDetails { get; set; } = null;
public override IList<SearchDocument> GetModifiedSearchDocuments(ModuleInfo moduleInfo, DateTime beginDateUtc)
{
var searchDocs = new List<SearchDocument>();
var products = new List<QuickProduct>
{
new QuickProduct("CT4455", "Soundbar", "The soundbar is used for entertainment purposes." ),
new QuickProduct("BD5333", "Laser Pointer", "For Presentations." )
};
foreach (var product in products)
{
var searchDoc = new SearchDocument
{
IsActive = true,
CultureCode = moduleInfo.CultureCode,
Title = product.Title,
Description = product.Description,
Body = product.Description,
};
searchDocs.Add(searchDoc);
}
return searchDocs;
}
}
public class QuickProduct
{
public string SKU { get; set; }
public string Title{ get; set; }
public string Description { get; set; }
public QuickProduct(string SKU, string Title, string Description)
{
this.SKU = SKU;
this.Title = Title;
this.Description = Description;
}
}