Esempio n. 1
0
        public void Process(WorkflowPipelineArgs args)
        {
            Item   contentItem     = args.DataItem;
            string workflowComment = (!string.IsNullOrEmpty(args.CommentFields[Constants.Comments])) ? args.CommentFields[Constants.Comments] : Constants.NoComment;

            try
            {
                using (new SecurityDisabler())
                {
                    Item notifyStepItem      = args.ProcessorItem.InnerItem;
                    Item currentWorkflowStep = WorkflowHelper.GetCurrentState(args); // Current workflow state
                    Item nextWorkflowStep    = WorkflowHelper.GetNextState(args);    // Next workflow state

                    var from = notifyStepItem.Fields[Templates.NotifyNextStepUser.Fields.From].Value;
                    var emailTemplateItem = notifyStepItem.TargetItem(Templates.NotifyNextStepUser.Fields.EmailTemplate);
                    var receivers         = GetReceivers(contentItem, currentWorkflowStep.ID, nextWorkflowStep.ID);

                    _workflowNotifyService.SendEmailNotifications(receivers, from, contentItem, workflowComment, emailTemplateItem);
                }
            }
            catch (Exception ex)
            {
                Log.Error($"NotifyNextStepUser: {ex}", this);
            }
        }
        public void Process(WorkflowPipelineArgs args)
        {
            string workflowComment = (!string.IsNullOrEmpty(args.CommentFields[Constants.Comments])) ? args.CommentFields[Constants.Comments] : Constants.NoComment;

            try
            {
                using (new SecurityDisabler())
                {
                    Item currentDataItem = args.DataItem;
                    if (currentDataItem.Fields[Multisite.Templates.MainSite.Fields.IsDisplayOnMainSite].IsChecked())
                    {
                        Item copiedItem     = _mallSiteWorkflowRepository.GetCopiedItemInMainSite(currentDataItem);
                        Item notifyStepItem = args.ProcessorItem.InnerItem;

                        var from = notifyStepItem.Fields[Templates.NotifyNextStepUser.Fields.From].Value;
                        var emailTemplateItem = notifyStepItem.TargetItem(Templates.NotifyNextStepUser.Fields.EmailTemplate);
                        var receivers         = WorkflowHelper.GetMainAdminsOf(copiedItem.GetSiteItem());

                        _workflowNotifyService.SendEmailNotifications(receivers, from, copiedItem, workflowComment, emailTemplateItem);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error($"NotifyNextStepUser: {ex}", this);
            }
        }