This short blog post contains information about how to restore archived item programmatically in Sitecore 8. Use the below code snippet to achieve the functionality:
void RestoreArchivedItems()
{
using (new SecurityDisabler())
{
DateTime archiveDate = new DateTime(2016, 11, 1);
string originalLocationPathPrefix = "/sitecore/content/Home";
string archivedBy = "sitecore\\admin";
// get the archive database for the master database
Sitecore.Data.Archiving.Archive archive = Sitecore.Data.Database.GetDatabase("master").Archives["archive"];
// get archived items
var archivedItems =
archive.GetEntries(0, int.MaxValue)
.Where(entry =>
entry.ArchiveDate > archiveDate &&
entry.OriginalLocation.StartsWith(originalLocationPathPrefix) && entry.ArchivedBy.Equals(archivedBy, StringComparison.OrdinalIgnoreCase)
).ToList();
foreach (var archiveItem in archivedItems)
{
// restore the item
archive.RestoreItem(archiveItem.ArchivalId);
}
}
}
Comments and suggestions are most welcome. Happy coding!
ReplyDeleteOyun oynamayı seviyorsanız, çeşitli platformlardan yeni ve eğlenceli içerikler bulabilirsiniz. Özellikle ücretsiz oyunlar arıyorsanız, https://oyun.indir.biz.tr/ adresi size geniş seçenekler sunuyor. Bu site sayesinde hem bilgisayar hem de mobil cihazlarınız için en güncel oyunlara ulaşabilirsiniz. Eğlenceyi doruklarda yaşamak için bu platformu tercih edebilirsiniz.
778FF379
ReplyDeleteDörtyol
Akçakoca
Şile
Esat
Akçay
Talas
Ortaköy
Tepebaşı
Finike
C9BF24B5
ReplyDeleteKeşan
Ödemiş
Etlik
Beydağ
Güzelbahçe
Güllük
Bayraklı
Nusaybin
Selçuk