本文整理汇总了C#中System.Item.MoveTo方法的典型用法代码示例。如果您正苦于以下问题:C# Item.MoveTo方法的具体用法?C# Item.MoveTo怎么用?C# Item.MoveTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Item
的用法示例。
在下文中一共展示了Item.MoveTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OrganizeItem
/// <summary>
/// Organizes the item in the configurd year, [month], [day] structure.
/// It will also remove any empty folders
/// </summary>
/// <param name="item">The item.</param>
/// <param name="config">The config.</param>
/// <param name="articleDate">The article date.</param>
protected void OrganizeItem(Item item, TemplateConfiguration config, DateTime articleDate)
{
Item root = GetRoot(item, config);
// get/create the year folder
root = GetOrCreateChild(root, config.YearFolder.Template, config.YearFolder.GetName(articleDate), config.SortOrder);
// get/create any month -> day structure we need
if (config.MonthFolder != null)
{
root = GetOrCreateChild(root, config.MonthFolder.Template, config.MonthFolder.GetName(articleDate), config.SortOrder);
if (config.DayFolder != null)
{
root = GetOrCreateChild(root, config.DayFolder.Template, config.DayFolder.GetName(articleDate), config.SortOrder);
}
}
// if the item is already where it should be, then bail out
if (string.Equals(item.Parent.Paths.FullPath, root.Paths.FullPath, StringComparison.OrdinalIgnoreCase))
{
return;
}
// save the original location so we can clean up
Item originalParent = item.Parent;
// move the item to the proper location
item.MoveTo(root);
// delete the original parent if there are no children.
// keep walking up while we are a year/month/day
while ((!originalParent.HasChildren) && IsItemYearMonthOrDay(originalParent, config))
{
Item parent = originalParent.Parent;
originalParent.Delete();
originalParent = parent;
}
if ((!Sitecore.Context.IsBackgroundThread) && Sitecore.Context.ClientPage.IsEvent)
{
var args = new MoveCompletedArgs() { Article = item, Root = item.Database.GetRootItem() };
CorePipeline.Run("NewsMover.MoveCompleted", args);
}
}
示例2: MoveItemToDisabledFolder
protected virtual void MoveItemToDisabledFolder(Item item, ref LevelLogger logger)
{
item.Editing.BeginEdit();
item.MoveTo(DisableItemsFolderItem);
logger.IncrementCounter(IncrementConstants.DisabledItems);
item.Editing.EndEdit();
}
示例3: FixPostLocation
public virtual void FixPostLocation(Item bloggrPost)
{
Assert.ArgumentNotNull(bloggrPost, "bloggrPost");
if (this.ValidatePostLocation(bloggrPost))
{
return;
}
var statistics = bloggrPost.Statistics;
Assert.IsNotNull(statistics, "statistics");
var created = statistics.Created;
if (created == DateTime.MinValue)
{
// in Sitecore 8.0 is used UTC, in previous versions - local time.
created = DateTime.UtcNow;
}
var createdYear = created.ToString("yyyy");
var createdMonth = created.ToString("MM");
var createdDay = created.ToString("dd");
var home = BloggrContext.GetHomeSure(bloggrPost);
var year = home.GetChild(createdYear) ?? this.CreateDateFolder(home, home, createdYear);
var month = year.GetChild(createdMonth) ?? this.CreateDateFolder(year, home, createdMonth);
var day = month.GetChild(createdDay) ?? this.CreateDateFolder(month, home, createdDay);
bloggrPost.MoveTo(day);
}
示例4: MoveItem
protected virtual void MoveItem(Item item, Item targetParentItem, ref LevelLogger logger)
{
using (new SecurityDisabler())
{
item.Editing.BeginEdit();
logger.AddInfo("Moved Item", String.Format("Moved item from '{0}' to '{1}'.", GetItemDebugInfo(item), GetItemDebugInfo(targetParentItem)));
item.MoveTo(targetParentItem);
item.Editing.EndEdit();
//Logger.MovedItems += 1;
logger.IncrementCounter(IncrementConstants.MovedItems);
}
}