【问题标题】:Leverage Groups for Workflow Approvals利用组进行工作流审批
【发布时间】:2020-01-05 15:42:14
【问题描述】:

我们正在现有网站上实施新的工作流程(结合暂存任务同步),我们希望通知“拥有”该特定部分/内容的所有成员批准更改。

其中一个选项是为他们的角色和范围配置多个角色及其相应的工作流程,但这似乎有点过头了——至少对我们来说,因为目前只有一个角色用于审批(而另一个角色用于编辑)

但是我最近遇到了这个新的页面属性:

还有几个问题:

  • 普通 CMS 用户(没有成员资格)可以成为群组的成员吗?
  • 我们能否利用该组而不是角色来接收工作流的电子邮件通知?例如。发送页面以供批准时向所有者组中的每个人发送电子邮件。
  • 在创建新页面时,此选项是否默认从父页面继承,还是需要为每个页面单独设置?

我们拥有 Kentico 11 EMS 许可证并致力于高级工作流程,因此可以自定义代码。

【问题讨论】:

    标签: workflow kentico usergroups kentico-11


    【解决方案1】:
    • 普通 CMS 用户(没有成员资格)可以成为组的一部分吗? - 你为什么不在这里使用角色?
    • 我们能否利用该组接收工作流的电子邮件 通知而不是角色?例如。电子邮件给所有的人 发送页面以供批准时的所有者组。 -您需要自定义工作流管理器类,但通常是的,这是可能的。你可以在这个post中找到灵感
    • 这个选项是默认从父页面继承的吗? 是创建一个还是需要为每个页面单独设置? - 使用宏来默认字段。如果你用其他任何东西填充它,那么新值将被保存。

    【讨论】:

    • 啊,就是这样,我的要求与您链接的帖子完全相同,我们希望避免为此管理多个角色/工作流程,而促使我想到 Owner 组的原因是我们我们正试图避免为此类型添加自定义字段。我想将您和@vasu 的答案结合在下面可能是解决此问题的方法。当然,它完全未经测试,但我认为这是可行的。非常感谢你们的帮助。一旦我们开始测试,我会发布更新。
    【解决方案2】:

    用于工作流步骤(即拒绝和批准步骤)的自定义全局事件处理程序的示例代码 sn-p。

    using CMS;
    using CMS.Base;
    using CMS.DataEngine;
    using CMS.DocumentEngine;
    using CMS.EmailEngine;
    using CMS.EventLog;
    using CMS.Helpers;
    using CMS.MacroEngine;
    using CMS.SiteProvider;
    using CMS.WorkflowEngine;
    using System;
    
    // Registers the custom module into the system
    [assembly: RegisterModule(typeof(CustomWorkflowEvent))]
    
    public class CustomWorkflowEvent : CMSModuleLoader
    {
        // Module class constructor, the system registers the module under the name "CustomInit"
        public CustomWorkflowEvent()
            : base("CustomInit")
        {
        }
    
        // Contains initialization code that is executed when the application starts
        protected override void OnInit()
        {
            base.OnInit();
    
            // Assigns custom handlers to events
            //  WorkflowEvents.Approve.After += WorkFlow_Event_After();
            WorkflowEvents.Reject.After += WorkFlow_Event_After;
            WorkflowEvents.Approve.After += Approve_After;
    
            // WorkflowEvents.Action.After += WorkFlowAction_Event_After;
    
        }
    
        private void Approve_After(object sender, WorkflowEventArgs e)
        {
            try
            {
                WorkflowStepInfo wsi = e.PreviousStep;
                if (wsi != null)
                {
                    CMS.WorkflowEngine.Definitions.SourcePoint s = wsi.GetSourcePoint(Guid.NewGuid());
                    //Make sure it was an approval (standard) step
    
                    var approvers = WorkflowStepInfoProvider.GetUsersWhoCanApprove(wsi, null, SiteContext.CurrentSiteID, "UserID = " + CMSActionContext.CurrentUser.UserID, "UserID", 0, "Email, FullName, Username");
                    EventLogProvider.LogInformation("Approvers Data", "Approvers Data", approvers.ToString());
                    if (approvers != null)
                    {
                        //Loop through the approvers
    
                        string siteName = null;
                        SiteInfo si = SiteInfoProvider.GetSiteInfo(SiteContext.CurrentSiteID);
                        if (si != null)
                        {
                            siteName = si.SiteName;
                        }
    
                        EmailTemplateInfo eti = EmailTemplateProvider.GetEmailTemplate("Workflow.Rejected", SiteContext.CurrentSiteName);
    
                        MacroResolver mcr = MacroResolver.GetInstance();
    
    
                        EmailMessage message = new EmailMessage();
    
                        // Get sender from settings
                        message.EmailFormat = EmailFormatEnum.Both;
                        message.From = eti.TemplateFrom;
    
                        // Do not send the e-mail if there is no sender specified
                        if (message.From != "")
                        {
                            // Initialize message
                            // message.Recipients = strRecipientEmail;
                            message.Subject = eti.TemplateSubject;
    
                            // Send email via Email engine API
                            // EmailSender.SendEmailWithTemplateText(SiteContext.CurrentSiteName, message, eti, mcr, true);
                        }
                    }
    
                }
            }
    
            catch (Exception ex)
            {
    
                throw;
            }
    
        }
    
        private void WorkFlow_Event_After(object sender, WorkflowEventArgs e)
        {
            try
            {
                WorkflowStepInfo wsi = e.PreviousStep;
                if (wsi != null)
                {
                    CMS.WorkflowEngine.Definitions.SourcePoint s = wsi.GetSourcePoint(Guid.NewGuid());
                    //Make sure it was an approval (standard) step
    
                    var approvers = WorkflowStepInfoProvider.GetUsersWhoCanApprove(wsi, null, SiteContext.CurrentSiteID, "UserID = " + CMSActionContext.CurrentUser.UserID, "UserID", 0, "Email, FullName, Username");
                    EventLogProvider.LogInformation("Approvers Data", "Approvers Data", approvers.ToString());
                    if (approvers != null)
                    {
                        //Loop through the approvers
    
                        string siteName = null;
                        SiteInfo si = SiteInfoProvider.GetSiteInfo(SiteContext.CurrentSiteID);
                        if (si != null)
                        {
                            siteName = si.SiteName;
                        }
    
                        EmailTemplateInfo eti = EmailTemplateProvider.GetEmailTemplate("Workflow.Rejected", SiteContext.CurrentSiteName);
    
                        MacroResolver mcr = MacroResolver.GetInstance();
    
                        EmailMessage message = new EmailMessage();
    
                        // Get sender from settings
                        message.EmailFormat = EmailFormatEnum.Both;
                        message.From = eti.TemplateFrom;
    
                        // Do not send the e-mail if there is no sender specified
                        if (message.From != "")
                        {
                            // Initialize message
                            // message.Recipients = strRecipientEmail;
                            message.Subject = eti.TemplateSubject;
    
                            // Send email via Email engine API
                            // EmailSender.SendEmailWithTemplateText(SiteContext.CurrentSiteName, message, eti, mcr, true);
                        }
                    }
    
    
    
    
                }
            }
    
            catch (Exception ex)
            {
    
                throw;
            }
        }
    
    }
    

    希望能帮到你。

    【讨论】:

      【解决方案3】:
      • 普通 CMS 用户(没有成员资格)可以成为组的一部分吗?

        它不属于 CMS 用户。群组来自Groups Application

      GROUP:允许您管理用户组。群组是一种社交网络 功能使用户能够找到信息并根据 为了共同的兴趣。

      • 我们能否利用该组而不是角色来接收工作流的电子邮件通知?例如。发送页面以供批准时,向所有者组中的每个人发送电子邮件。

      没有

      • 在创建新页面时,此选项是否默认从父页面继承,还是需要为每个页面单独设置?

      没有

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-25
      • 2014-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-01
      相关资源
      最近更新 更多