Exemplo n.º 1
0
        public ActionResult Send()
        {
            var rendering  = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull?.Rendering;
            var parameters = rendering?.Parameters;
            var makerKey   = ItemUtil.GetItemById(parameters?[Templates.Parameters.MakerKey])?[Templates.Account.Fields.MakerKey];
            var eventName  = ItemUtil.GetItemById(parameters?[Templates.Parameters.Event])?[Templates.Event.Fields.EventName];
            var threshold  = int.TryParse(parameters?[Templates.Parameters.Threshold], out int num)? num : -1;
            var value1     = parameters?[Templates.Parameters.Value1];
            var value2     = parameters?[Templates.Parameters.Value2];
            var value3     = parameters?[Templates.Parameters.Value3];

            if (threshold > 1)
            {
                var thresholdKey = KeyUtil.MakeKey(
                    $"{nameof(TriggerController)}_{nameof(Send)}_",
                    Sitecore.Context.Item?.ID.ToGuid().ToString(),
                    rendering?.UniqueId
                    );

                if (Threshold.IsMet(threshold, thresholdKey))
                {
                    Ifttt.Trigger(makerKey, eventName, value1, value2, value3);
                    return(Content($"<p>Threshold met, trigger '{eventName}' sent!</p>"));
                }
                else
                {
                    return(Content("<p>Threshold incremented</p>"));
                }
            }

            Ifttt.Trigger(makerKey, eventName, value1, value2, value3);
            return(Content($"<p>Trigger '{eventName}' sent!</p>"));
        }
Exemplo n.º 2
0
        public override void Apply(T ruleContext)
        {
            using (new SecurityDisabler())
            {
                var makerKey  = ItemUtil.GetItemById(MakerKey)?[Templates.Account.Fields.MakerKey];
                var eventName = ItemUtil.GetItemById(Event)?[Templates.Event.Fields.EventName];

                if (MeetsThreshold(this.UniqueId, int.TryParse(Threshold, out int threshold) ? threshold : 0))
                {
                    var iftttService = Sitecore.DependencyInjection.ServiceLocator.ServiceProvider.GetService <IIftttService>();
                    iftttService.Trigger(makerKey, eventName, ruleContext.Value1, ruleContext.Value2, ruleContext.Value3);
                }
            }
        }
Exemplo n.º 3
0
        }                             // Supported Event ID

        protected override bool Execute(T ruleContext)
        {
            Assert.ArgumentNotNull((object)ruleContext, "ruleContext");

            var supportedEvent = ItemUtil.GetItemById(Value);
            var eventName      = supportedEvent?.DisplayName; // Convention of using display name for full event name

            if (String.IsNullOrEmpty(eventName))
            {
                return(false);
            }

            return(ruleContext?.EventName == eventName);
        }
Exemplo n.º 4
0
        public override void Apply(T ruleContext)
        {
            var makerKey  = ItemUtil.GetItemById(IftttAccountId)?[Templates.Account.Fields.MakerKey];
            var eventName = ItemUtil.GetItemById(IftttEventId)?[Templates.Event.Fields.EventName];
            LoggerRuleContext loggerRuleContext = ruleContext as LoggerRuleContext;

            if (loggerRuleContext == null)
            {
                return;
            }
            var value1 = loggerRuleContext.LogText + " was written in logs " + loggerRuleContext.Threshold + " times";

            var iftttService = Sitecore.DependencyInjection.ServiceLocator.ServiceProvider.GetService <IIftttService>();

            iftttService.Trigger(makerKey, eventName, value1);
        }
        public override void Process(RegisterPageEventArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            if (args.PageEvent == null)
            {
                return;
            }

            var pageItem = ItemUtil.GetItemById(args.PageEvent.ItemId);

            Rules.RunEventRules(args.PageEvent?.Name,
                                pageItem,
                                args.PageEvent.DataKey,
                                args.PageEvent.IsGoal? "is goal":"not goal",
                                args.PageEvent.Value.ToString()
                                );
        }