SearchItemInfo 已过时。在 DNN 7.1 中已弃用
SearchItemInfo is Obsolete. Deprecated in DNN 7.1
我正在尝试在我们的模块之一上实施 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 上附加了一个断点并安排了 Site Crawler 来抓取该站点,但它从未被击中。此外,通过实施此代码,是否会在模块上显示复选框,使您能够打开和关闭 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;
}
}
了解这些接口如何实现的最简单方法始终是查看其工作模块的源代码,DNN 中包含的 HtmlText 模块是一个很好的起点。参见 here。
依稀记得模块在安装过程中被标记为Searchable等,所以必须制作升级包并安装才能生效
另一种方法(用于开发或测试安装)可能是直接在数据库中执行此操作,table DesktopModules,SupportedFeatures 列。值为:
1 = Portable
2 = Searchable
4 = Upgradeable
要组合两个特征,请添加数字,例如。 Portable and Searchable = 3, All = 7 etc.
更新此列后重新启动应用程序池以使其生效。
注意:我只建议将其用于开发或测试环境。在生产环境中,您应该使用包来升级扩展。
我正在尝试在我们的模块之一上实施 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 上附加了一个断点并安排了 Site Crawler 来抓取该站点,但它从未被击中。此外,通过实施此代码,是否会在模块上显示复选框,使您能够打开和关闭 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;
}
}
了解这些接口如何实现的最简单方法始终是查看其工作模块的源代码,DNN 中包含的 HtmlText 模块是一个很好的起点。参见 here。
依稀记得模块在安装过程中被标记为Searchable等,所以必须制作升级包并安装才能生效
另一种方法(用于开发或测试安装)可能是直接在数据库中执行此操作,table DesktopModules,SupportedFeatures 列。值为:
1 = Portable
2 = Searchable
4 = Upgradeable
要组合两个特征,请添加数字,例如。 Portable and Searchable = 3, All = 7 etc.
更新此列后重新启动应用程序池以使其生效。
注意:我只建议将其用于开发或测试环境。在生产环境中,您应该使用包来升级扩展。