2011-03-31 22 views
3

我們希望設置一個系統,克隆管理員在克隆克隆的項目更新時會收到電子郵件通知。這個項目中會創建多個克隆,理想情況下我們希望通過語言過濾通知(因此,法語版本更新時,英文克隆的管理員不會收到通知)。如何爲克隆提供電子郵件通知/工作流程

有沒有一種簡單的方法在工作流程內部實現這一點?如果是這樣,哪怕我應該嘗試並將工作流操作綁定到?

我是否需要擴展或重寫管道來執行此操作?

Crossposted到SDN http://sdn.sitecore.net/forum/ShowPost.aspx?PostID=34533#34533

編輯:阿多一點信息:

如果克隆不會從原來的項目覆蓋場再有就是在客戶沒有通知時,原來的項目領域被編輯。這個改變直接被複制 - 至少在master數據庫中。但是 - 克隆仍然需要發佈到Web數據庫,以使此更改在線生效。所以我有點卡住 - 我的用戶需要執行一個動作(發佈克隆),但不知道它...

我真的很想能夠掛鉤到通知事件莫名其妙。

+0

非常好的問題,詹姆斯!我想只要按照章節提出的問題,就可以增強有關克隆的文檔! :) – 2011-03-31 11:30:53

+0

謝謝,我當然希望如此!工作流參考標記爲6.0 - 6.4,但根本沒有提及克隆!而且我還在摸索如何處理克隆部分的內部鏈接...... – 2011-03-31 12:01:55

回答

1

回答我的問題 這裏是由各種海報上SDN在這個線程提供的代碼: http://sdn.sitecore.net/forum//ShowPost.aspx?PostID=34012

如果有人認爲該線程貢獻要張貼一個答案,然後我會很樂意給信貸 - 和代表 - 它應該在哪裏。

首先: 約翰·西指出,有幾個有趣的,雖然私有方法:

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

感謝所有提供的輸入!

相關問題