Beispiel #1
0
 protected override void Evaluate(CustomizeRenderingArgs args)
 {
     Sitecore.Diagnostics.Assert.ArgumentNotNull(args, "args");
     Sitecore.Layouts.RenderingReference renderingReference = SelectVariation.GetRenderingReference(args.Rendering, Context.Language, args.PageContext.Database);
     if (string.IsNullOrEmpty(renderingReference.Settings.MultiVariateTest))
     {
         return;
     }
     using (new Sitecore.SecurityModel.SecurityDisabler())
     {
         Sitecore.Data.Items.Item item = args.PageContext.Database.GetItem(renderingReference.Settings.GetMultiVariateTestForLanguage(Context.Language));
         if (item == null)
         {
             return;
         }
         MultivariateTestValueItem variation = this.GetVariation(item);
         if (variation == null)
         {
             return;
         }
         ComponentTestContext context = new ComponentTestContext(variation, renderingReference, new List <Sitecore.Layouts.RenderingReference>
         {
             renderingReference
         });
         this.ApplyVariation(args, context);
     }
     args.IsCustomized = true;
 }
        protected override void Evaluate(CustomizeRenderingArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Item item = args.PageContext.Item;

            if (item != null)
            {
                RenderingReference    renderingReference    = CustomizeRenderingProcessor.GetRenderingReference(args.Rendering, Context.Language, args.PageContext.Database);
                GetRenderingRulesArgs getRenderingRulesArgs = new GetRenderingRulesArgs(item, renderingReference);
                GetRenderingRulesPipeline.Run(getRenderingRulesArgs);
                RuleList <ConditionalRenderingsRuleContext> ruleList = getRenderingRulesArgs.RuleList;
                if (ruleList != null && ruleList.Count != 0)
                {
                    List <RenderingReference> references = new List <RenderingReference>
                    {
                        renderingReference
                    };
                    ConditionalRenderingsRuleContext conditionalRenderingsRuleContext = new ConditionalRenderingsRuleContext(references, renderingReference)
                    {
                        Item = item
                    };
                    conditionalRenderingsRuleContext.Parameters["mvc.rendering"] = args.Rendering;
                    RunRules(ruleList, conditionalRenderingsRuleContext);
                    ApplyActions(args, conditionalRenderingsRuleContext);
                    args.IsCustomized = true;
                }
            }
        }
        protected override void ApplyVariation(CustomizeRenderingArgs args, ComponentTestContext context)
        {
            // Begin copied from sitecore
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNull(context, "context");
            ComponentTestRunner componentTestRunner = new ComponentTestRunner();

            try
            {
                componentTestRunner.Run(context);
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                string    str       = (ItemUtil.IsNull(context.Component.RenderingID) ? string.Empty : context.Component.RenderingID.ToString());
                string    str1      = (args.PageContext.Item != null ? args.PageContext.Item.ID.ToString() : string.Empty);
                Log.Warn("Failed to execute MV testing on component with id \"{0}\". Item ID:\"{1}\"".FormatWith(new object[] { str, str1 }), exception, this);
            }
            RenderingReference renderingReference = context.Components.FirstOrDefault <RenderingReference>((RenderingReference c) => c.UniqueId == context.Component.UniqueId);

            if (renderingReference == null)
            {
                args.Renderer = new EmptyRenderer();
                return;
            }
            this.ApplyChanges(args.Rendering, renderingReference);
            // End copied from sitecore

            // Apply Parameters Too
            TransferRenderingParameters(args.Rendering, renderingReference);
        }
        protected virtual void Evaluate(CustomizeRenderingArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Item item = args.PageContext.Item;

            if (item != null)
            {
                RenderingReference    renderingReference    = GetRenderingReference(args.Rendering, args.Rendering.Item.Language, args.Rendering.Item.Database);
                GetRenderingRulesArgs getRenderingRulesArgs = new GetRenderingRulesArgs(item, renderingReference);
                GetRenderingRulesPipeline.Run(getRenderingRulesArgs);
                RuleList <ConditionalRenderingsRuleContext> ruleList = getRenderingRulesArgs.RuleList;
                if (ruleList != null && ruleList.Count != 0)
                {
                    List <RenderingReference> references = new List <RenderingReference>
                    {
                        renderingReference
                    };
                    ConditionalRenderingsRuleContext conditionalRenderingsRuleContext = new ConditionalRenderingsRuleContext(references, renderingReference)
                    {
                        Item = item
                    };
                    conditionalRenderingsRuleContext.Parameters["mvc.rendering"] = args.Rendering;
                    var matchingRule = GetMatchingRule(ruleList, conditionalRenderingsRuleContext);
                    ApplyActions(args, conditionalRenderingsRuleContext, matchingRule);
                }
            }
        }
 public override void Process(CustomizeRenderingArgs args)
 {
     Assert.ArgumentNotNull(args, "args");
     if (!args.IsCustomized && Tracker.IsActive)
     {
         Evaluate(args);
     }
 }
 public override void Process(CustomizeRenderingArgs args)
 {
     Sitecore.Diagnostics.Assert.ArgumentNotNull(args, "args");
     if (args.IsCustomized || !Context.PageMode.IsPageEditor || !Sitecore.Configuration.Settings.Analytics.Enabled)
     {
         return;
     }
     this.Evaluate(args);
 }
 public override void Process(CustomizeRenderingArgs args)
 {
     Assert.ArgumentNotNull((object)args, "args");
     if (args.IsCustomized || !Context.PageMode.IsNormal)
     {
         return;
     }
     this.Evaluate(args);
 }
Beispiel #8
0
        protected override void ApplyActions(CustomizeRenderingArgs args, ConditionalRenderingsRuleContext context)
        {
            base.ApplyActions(args, context);
            RenderingReference renderingReference = context.References.Find((RenderingReference r) => r.UniqueId == context.Reference.UniqueId);

            if (renderingReference != null)
            {
                ExtensionMethods.TransferRenderingParameters(args.Rendering, renderingReference);
            }
        }
        protected override void ApplyVariation(CustomizeRenderingArgs args, ComponentTestContext context)
        {
            base.ApplyVariation(args, context);

            RenderingReference renderingReference = context.Components.FirstOrDefault((RenderingReference c) => c.UniqueId == context.Component.UniqueId);

            if (renderingReference != null)
            {
                ExtensionMethods.TransferRenderingParameters(args.Rendering, renderingReference);
            }
        }
Beispiel #10
0
        public override void Process(CustomizeRenderingArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            // the explicit check for "tracker.isactive" has been removed, as it prevents to evaluate conditions which should go off when there is no tracker

            if (args.IsCustomized)
            {
                return;
            }

            this.Evaluate(args);
        }
Beispiel #11
0
        protected override void ApplyActions(CustomizeRenderingArgs args, ConditionalRenderingsRuleContext context)
        {
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNull(context, "context");
            RenderingReference renderingReference = context.References.Find((RenderingReference r) => r.UniqueId == context.Reference.UniqueId);

            if (renderingReference == null)
            {
                args.Renderer = new EmptyRenderer();
                return;
            }
            this.ApplyChanges(args.Rendering, renderingReference);
        }
Beispiel #12
0
        protected override void ApplyActions(CustomizeRenderingArgs args, ConditionalRenderingsRuleContext context)
        {
            // Begin copied from sitecore
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNull(context, "context");
            RenderingReference renderingReference = context.References.Find((RenderingReference r) => r.UniqueId == context.Reference.UniqueId);

            if (renderingReference == null)
            {
                args.Renderer = new EmptyRenderer();
                return;
            }
            this.ApplyChanges(args.Rendering, renderingReference);
            // End copied from sitecore

            // Apply Parameters Too
            TransferRenderingParameters(args.Rendering, renderingReference);
        }
Beispiel #13
0
        protected override void Evaluate(CustomizeRenderingArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Item item = args.PageContext.Item;

            if (item == null)
            {
                return;
            }
            RenderingReference    renderingReference = CustomizeRenderingProcessor.GetRenderingReference(args.Rendering, Context.Language, args.PageContext.Database);
            GetRenderingRulesArgs expr_3E            = new GetRenderingRulesArgs(item, renderingReference);

            GetRenderingRulesPipeline.Run(expr_3E);
            RuleList <ConditionalRenderingsRuleContext> ruleList = expr_3E.RuleList;

            if (ruleList == null || ruleList.Count == 0)
            {
                return;
            }

            // after the ruleList has been retrieved AND ruleList > 0, instantiate a new personalization rulelist which has a fix to continue evaluation of conditions
            // even when some exceptions occur.
            PersonalizationRuleList <ConditionalRenderingsRuleContext> personalizationRuleList = new PersonalizationRuleList <ConditionalRenderingsRuleContext>();

            foreach (var r in ruleList.Rules)
            {
                personalizationRuleList.Add(r);
            }

            ConditionalRenderingsRuleContext conditionalRenderingsRuleContext = new ConditionalRenderingsRuleContext(new List <RenderingReference>
            {
                renderingReference
            }, renderingReference)
            {
                Item = item
            };

            conditionalRenderingsRuleContext.Parameters["mvc.rendering"] = args.Rendering;

            // runRules for the personalizationRuleList
            this.RunRules(personalizationRuleList, conditionalRenderingsRuleContext);
            this.ApplyActions(args, conditionalRenderingsRuleContext);
            args.IsCustomized = true;
        }
Beispiel #14
0
        public override void Process(CustomizeRenderingArgs args)
        {
            global::Sitecore.Diagnostics.Assert.ArgumentNotNull(args, "args");
            if (args.IsCustomized)
            {
                return;
            }

            var showPersonalisedContent = HttpContext.Current != null && HttpContext.Current.Request.Cookies.AllKeys.Any(t => t.ToLower().StartsWith(PersonalisationConstants.RequestPrefix));;

            if (!showPersonalisedContent)
            {
                if (!Tracker.IsActive)
                {
                    return;
                }
            }
            this.Evaluate(args);
        }
        /// <summary>
        /// Executes all the action against matched Rule.
        /// </summary>
        /// <param name="args"></param>
        /// <param name="context"></param>
        /// <param name="matchingRule"></param>
        protected virtual void ApplyActions(CustomizeRenderingArgs args, ConditionalRenderingsRuleContext context, Rule <ConditionalRenderingsRuleContext> matchingRule)
        {
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNull(context, "context");
            Assert.ArgumentNotNull(matchingRule, "matchingRule");
            if (matchingRule?.Actions?.Count <= 0)
            {
                return;
            }

            matchingRule.Actions?.Where(a => a.GetType().Name.StartsWith("SetRenderingVariantAction"))?.Each(a => a.Apply(context));

            var parameters = WebUtil.ParseQueryString(context.Reference.Settings.Parameters, true);

            if (!string.IsNullOrWhiteSpace(parameters["FieldNames"]))
            {
                args.Rendering.Parameters["FieldNames"] = parameters["FieldNames"];
            }
        }
Beispiel #16
0
        protected override void Evaluate(CustomizeRenderingArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            var renderingReference = GetRenderingReference(args.Rendering, Context.Language, args.PageContext.Database);

            if (string.IsNullOrEmpty(renderingReference.Settings.MultiVariateTest))
            {
                return;
            }

            using (new SecurityDisabler())
            {
                var mvVariateTestForLang = renderingReference.Settings.GetMultiVariateTestForLanguage(Context.Language);
                Sitecore.Data.Items.Item variableItem = null;

                if (mvVariateTestForLang != null)
                {
                    variableItem = args.PageContext.Database.GetItem(mvVariateTestForLang);
                }

                if (variableItem == null)
                {
                    return;
                }

                var variation = this.GetVariation(variableItem);
                if (variation == null)
                {
                    return;
                }

                var context = new ComponentTestContext(
                    variation,
                    renderingReference,
                    new List <RenderingReference> {
                    renderingReference
                });
                this.ApplyVariation(args, context);
            }

            args.IsCustomized = true;
        }