【问题标题】:SearchItemInfo is Obsolete. Deprecated in DNN 7.1SearchItemInfo 已过时。 DNN 7.1 中已弃用
【发布时间】:2019-04-10 17:11:18
【问题描述】:

我正在尝试在我们的一个模块上实现 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;
    }
}

【问题讨论】:

    标签: c# dotnetnuke dnn9


    【解决方案1】:

    了解如何实现这些接口的最简单方法始终是查看其工作所在模块的源代码,一个非常好的起点是 DNN 中包含的 HtmlText 模块。见here

    我依稀记得在安装过程中模块被标记为可搜索(等),所以你必须创建一个升级包并安装它才能生效。

    另一种方法(用于开发或测试安装)可能是直接在数据库、DesktopModules 表、SupportedFeatures 列中执行此操作。值为:

    1 = Portable
    2 = Searchable
    4 = Upgradeable
    

    要组合两个功能,请添加数字,例如。便携和可搜索 = 3,全部 = 7 等等。

    更新此列后,重新启动应用程序池以使其生效。

    注意:我只推荐用于开发或测试环境。在生产环境中,您应该使用包来升级扩展。

    【讨论】:

      猜你喜欢
      • 2019-05-30
      • 1970-01-01
      • 2017-03-19
      • 1970-01-01
      • 2012-03-01
      • 2012-11-06
      • 1970-01-01
      • 2014-02-12
      • 2018-01-02
      相关资源
      最近更新 更多