如何为克隆提供电子邮件通知/工作流程

发布于 2024-10-28 01:53:09 字数 552 浏览 0 评论 0原文

我们希望建立一个系统,当克隆的项目更新时,克隆的管理员会收到电子邮件通知。将从该项目创建多个克隆,理想情况下,我们希望按语言过滤通知(因此,当法语版本更新时,英语克隆的管理员不会收到通知)。

有没有一种简单的方法可以在工作流程中实现这些内容?如果是这样,我应该尝试将工作流程操作挂接到哪个?

我需要扩展或覆盖管道才能执行此操作吗?

交叉发布到 SDN http://sdn.sitecore.net/forum/ShowPost.aspx?PostID =34533#34533

编辑:更多信息:

如果克隆没有覆盖原始项目中的字段,则在编辑原始项目字段时客户端中不会有任何通知。更改是直接复制的 - 至少在主数据库中是这样。但是 - 克隆仍然需要发布到 Web 数据库才能使此更改在线生效。所以我有点卡住了 - 我的用户需要执行一个操作(发布克隆)但不知道......

我真的很希望能够以某种方式挂钩通知事件。

We want to set up a system where administrators of clones receive email notification when the item their clone was cloned from is updated. There will be multiple clones created from this item and ideally we'd like to filter notification by language (so administrators of an English clone don't receive notifications when the French version is updated).

Is there a simple way to implement any of this inside a workflow? If so, which even should I try and hook a workflow action to?

Will I need to extend or override a pipeline to do this?

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

EDIT: A little more info:

If the clone doesn't overwrite a field from the original item then there is no notification in the client when the original item field is edited. The change is copied straight through - at least in the master database. BUT - the clone still needs to be published to the web database for this change to take effect online. So I'm a bit stuck - my user needs to perform an action (publish clone) but doesn't know it...

I'd really like to be able hook into notification events somehow.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

抚笙 2024-11-04 01:53:09

回答我自己的问题
这里的代码是由 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

感谢所有提供的意见!

Answering my own question
The code here was provided by various posters on SDN in this thread:
http://sdn.sitecore.net/forum//ShowPost.aspx?PostID=34012

If anyone that contributed to that thread wants to post up an answer then I'll happily give credit - and rep - where it's due.

Firstly:
John West points out that there are a couple of interesting, though private methods:

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);
}

There's a support ticket asking for these to be made public, otherwise just copy them into your project.

That needs to be coupled with a custom workflow action, which should be compiled and added to a workflow for a source item.

This one below, provided by Derek Roberti/Lauren Hightower is to force accept of notifications in clones. To provide email notifications we'd need to reverse the logic - instead of performing an action if a clone has notifications we'd want to ensure an action was performed if the clone had no notifications - i.e. was directly inheriting the edited value from the source item.

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;
}

}
} 

And here's some general reading on custom workflows and invoking actions:
http://sdn.sitecore.net/FAQ/API/Cause%20the%20workflow%20to%20invoke%20an%20action.aspx

Thanks to all that provided input!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文