private static void RunWorkflow(WfTriggerUserUpdatesResource trigger, EntityRef updatedEntity)
        {
            var wf = trigger.WorkflowToRun;

            if (wf != null)
            {
                var args = new Dictionary <string, object>();

                var actionArg = wf.InputArgumentForAction;

                if (actionArg != null && !string.IsNullOrEmpty(actionArg.Name))
                {
                    args.Add(actionArg.Name, updatedEntity.Entity);
                }

                WorkflowRunner.Instance.RunWorkflow(new WorkflowStartEvent(trigger.Cast <WfTrigger>())
                {
                    Arguments = args
                });
            }
            else
            {
                EventLog.Application.WriteWarning($"WorkflowTriggerHelper.RunWorkflow: Trigger is missing a workflow to run. This is a constraints violation, igoring trigger. Trigger: {trigger.Name ?? "[Unnamed]"}({trigger.Id})");
            }
        }
Пример #2
0
        protected ResourceTriggerFilterDef CreateTrigger(string name, EntityType triggeredOn, Workflow wf, bool enabled = true)
        {
            var trigger = new WfTriggerUserUpdatesResource()
            {
                Name           = name,
                TriggerEnabled = enabled, WorkflowToRun = wf, TriggeringCondition = Entity.Get <TriggeredOnEnum>("core:triggeredOnEnumCreateUpdate")
            };

            if (triggeredOn != null)
            {
                trigger.TriggeredOnType = triggeredOn;
            }

            trigger.Save();
            ToDelete.Add(trigger.Id);

            return(trigger.Cast <ResourceTriggerFilterDef>());
        }