代码之家  ›  专栏  ›  技术社区  ›  Tig7r

SearchItemInfo已过时。DNN 7.1中已弃用

  •  0
  • Tig7r  · 技术社区  · 6 年前

    我试图在我们的一个模块上实现ISearchable。

    VisualStudio指出SearchItemInfo在DNN7.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;
        }
    }
    
    0 回复  |  直到 6 年前
        1
  •  1
  •   Michael Tobisch    5 年前

    here .

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

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

    1 = Portable
    2 = Searchable
    4 = Upgradeable
    

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

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

    注: 我只建议在开发或测试环境中使用这种方法。在生产环境中,应该使用包来升级扩展。