【问题标题】:Accessing Recycle Bin from Sitecore in C#在 C# 中从 Sitecore 访问回收站
【发布时间】:2014-11-06 07:48:10
【问题描述】:

我的目标是使用 C# 代码从 Sitecore 访问回收站,并将回收站中的项目作为数据读取操作列表返回。

我当前的代码基于我在 Google 上找到的文档以及我自己的经验,但它似乎并没有真正包含它声称的内容:

var recycleBinItems = Sitecore.Context.Database.Archives["recyclebin"].GetEntries(0, int.MaxValue);
var binItems = recycleBinItems as IList<ArchiveEntry> ?? recycleBinItems.ToList();

foreach (var item in binItems)
{
    Response.Write(item.Name);
}

以上内容应该只是从存档“recyclebin”中获取 ArchiveEntries 列表,该存档来自 Sitecore (URL.COM/Sitecore)。

但是,结果如下:

这当然不是预期的结果,因为我要求的是回收站的条目而不是它们的属性/设置(或返回的任何内容)

我已经在我的工作场所询问过,似乎没有人知道在哪里可以访问它,我希望有人可以在这里帮助我:)

【问题讨论】:

    标签: c# sitecore archive


    【解决方案1】:

    Sitecore 提供ArchiveManager 用于访问回收站。

    string archiveName = "recyclebin";
    var database = Sitecore.Data.Database.GetDatabase("master"); // Get content database
    
    Archive archive = Sitecore.Data.Archiving.ArchiveManager.GetArchive(archiveName, database);
    

    然后使用archive.GetEntriesForUser 方法检索归档项目。

    【讨论】:

    • 就是这样!现在完美运行,没有任何问题。欣赏它的人!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-05
    • 2018-03-03
    • 2020-01-07
    • 2016-03-20
    相关资源
    最近更新 更多