回答我自己的问题
此处的代码由该线程中 SDN 上的各种海报提供:
http://sdn.sitecore.net/forum//ShowPost.aspx?PostID=34012
如果为该线程做出贡献的任何人想要发布答案,那么我很乐意在应得的地方给予赞扬和代表。
首先:
John West 指出有一些有趣的私有方法:
private static IEnumerable<Item> GetClonesOfVersion(Item source)
{
Assert.ArgumentNotNull(source, "source");
return (from clone in GetAllClones(source)
where clone.SourceUri == source.Uri
select clone);
}
private static IEnumerable<Item> GetAllClones(Item source)
{
Assert.ArgumentNotNull(source, "source");
return (from link in Globals.LinkDatabase.GetReferrers(source)
select link.GetSourceItem() into clone
where ((clone != null) && (clone.Source != null)) && (clone.Source.ID == source.ID)
select clone);
}
有一张支持票要求将这些公开,否则只需将它们复制到您的项目中。
这需要与自定义工作流操作相结合,该操作应被编译并添加到源项目的工作流中。
下面这个由 Derek Roberti/Lauren Hightower 提供,用于强制接受克隆中的通知。 要提供电子邮件通知,我们需要颠倒逻辑 - 如果克隆有通知,我们不想执行操作,而是要确保在克隆没有通知时执行操作 - 即直接从源项继承已编辑的值。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.Data.Clones;
using Sitecore.Diagnostics;
using Sitecore.SecurityModel;
using Sitecore;
using Sitecore.Links;
namespace WorkFlowCustom
{
public class ForceCloneAccept
{
public void Process(Sitecore.Workflows.Simple.WorkflowPipelineArgs args)
{
Item workFlowItem = args.DataItem;
List itemList = GetItemClones(workFlowItem, true);
foreach (Item cloneItem in itemList)
{
List list = new List(workFlowItem.Database.NotificationProvider.GetNotifications(cloneItem));
foreach (Notification n in list)
{
if ((n != null) && (workFlowItem != null))
{
n.Accept(cloneItem);
}
}
}
}
protected virtual List GetItemClones(Item item, bool processChildren)
{
Assert.ArgumentNotNull(item, "item");
List list = new List();
using (new SecurityDisabler())
{
foreach (ItemLink link in Globals.LinkDatabase.GetReferrers(item))
{
if (!(link.SourceFieldID != FieldIDs.Source))
{
Item sourceItem = link.GetSourceItem();
if (sourceItem != null)
{
list.Add(sourceItem);
}
}
}
}
if (processChildren)
{
foreach (Item item4 in item.Children)
{
list.AddRange(this.GetItemClones(item4, true));
}
}
return list;
}
}
}
这里有一些关于自定义工作流程和调用操作的一般性阅读:
http://sdn.sitecore.net/FAQ/API/Cause%20the%20workflow%20to%20invoke%20an%20action.aspx
感谢所有提供的意见!