public override void Process(MediaGenerateMarkupArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNull(args.MediaItem, "args.PlayerProperties");
            Assert.ArgumentNotNull(args.AccountItem, "args.PlayerProperties");

            if (!this.CheckState(args))
            {
                return;
            }

            Field eventsField = AccountManager.GetSettingsField(args.AccountItem, FieldIDs.AccountSettings.PlaybackEventsRules);

            if (eventsField != null)
            {
                var ruleList = RuleFactory.GetRules <PlaybackRuleContext>(eventsField);

                var context = new PlaybackRuleContext {
                    Item = args.MediaItem
                };

                ruleList.Run(context);

                args.PlaybackEvents = context.PlaybackEvents;
            }
        }
        private static string GetFilter(Item item)
        {
            ID    id;
            Field filterField = item.Fields["Filter"];

            if (filterField == null)
            {
                return(null);
            }
            if (string.IsNullOrEmpty(filterField.Value))
            {
                return(null);
            }
            if (!ID.TryParse(filterField.Value, out id))
            {
                return(null);
            }
            var filter = item.Database.GetItem(id);

            if (filter == null)
            {
                return(null);
            }
            var ruleField = filter.Fields["Rule"];

            if (ruleField == null)
            {
                return(null);
            }
            return(JsonConvert.SerializeObject(RuleFactory.GetRules <RuleContext>(ruleField), new JsonSerializerSettings()
            {
                TypeNameHandling = TypeNameHandling.All
            }));
        }
        public void Run(Payment payment)
        {
            var rules      = RuleFactory.GetRules(payment);
            var evaaluator = new RuleEvaluator(rules);

            evaaluator.ExecuteRules();
        }
Ejemplo n.º 4
0
        /// <summary> Gets item renderings </summary>
        /// <param name="item">item to proceed</param>
        /// <returns>list of item renderings</returns>
        protected List <RenderingReference> GetRenderings(Item item)
        {
            RuleList <ConditionalRenderingsRuleContext> globalRules = this.GetGlobalRules(item);
            List <RenderingReference> resultCollection = new List <RenderingReference>(item.Visualization.GetRenderings(Sitecore.Context.Device, true));

            foreach (RenderingReference reference in new List <RenderingReference>(resultCollection))
            {
                string conditions = reference.Settings.Conditions;
                if (!string.IsNullOrEmpty(conditions))
                {
                    List <Item> conditionItems = this.GetConditionItems(item.Database, conditions);
                    if (conditionItems.Count > 0)
                    {
                        RuleList <ConditionalRenderingsRuleContext> rules       = RuleFactory.GetRules <ConditionalRenderingsRuleContext>(conditionItems, "Rule");
                        ConditionalRenderingsRuleContext            ruleContext = new ConditionalRenderingsRuleContext(resultCollection, reference)
                        {
                            Item = item
                        };
                        rules.Run(ruleContext);
                    }
                }

                if (globalRules != null)
                {
                    ConditionalRenderingsRuleContext globalRuleContext = new ConditionalRenderingsRuleContext(resultCollection, reference)
                    {
                        Item = item
                    };
                    globalRules.Run(globalRuleContext);
                }
            }

            return(resultCollection);
        }
        public string ApplyDesign(Item ruleProgram, Item page, string crawlDepth = null)
        {
            BotLog.Log.Info($"::START:: program {ruleProgram?.DisplayName} on page {page.DisplayName}, {page.ID}, crawl depth {crawlDepth}");
            Log.Info($"DESIGNBOT::START:: program {ruleProgram?.DisplayName} on page {page.DisplayName}, {page.ID}, crawl depth {crawlDepth}", this);

            // Get design rules
            RuleList <DesignBotRuleContext> rules = RuleFactory.GetRules <DesignBotRuleContext>(ruleProgram, "Rule");

            if (rules != null)
            {
                // Apply design program
                int depth;
                if (!int.TryParse(crawlDepth ?? "0", out depth))
                {
                    depth = 0;
                }
                depth = Math.Max(0, depth);

                using (new SecurityDisabler())
                {
                    using (new ScreenshotGenerationDisabler())
                    {
                        RunProgram_r(rules, page, depth);
                    }
                }
            }

            BotLog.Log.Info($"::END:: program {ruleProgram?.DisplayName} on page {page.DisplayName}, {page.ID}, crawl depth {crawlDepth}");
            Log.Info($"DESIGNBOT::END:: program {ruleProgram?.DisplayName} on page {page.DisplayName}, {page.ID}, crawl depth {crawlDepth}", this);
            return("Success");
            // item.Editing.BeginEdit();
            // item.Editing.EndEdit(updateStatistics: true, silent: false);
            // item.Editing.CancelEdit();
        }
        public void Process(PipelineArgs args)
        {
            try
            {
                var rulesField = Context.Item?.Fields[PageRulesFieldName];

                if (rulesField == null || string.IsNullOrWhiteSpace(rulesField.Value))
                {
                    return;
                }

                var rules = RuleFactory.GetRules <PageRulesRuleContext>(rulesField);

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

                var ruleContext = new PageRulesRuleContext();
                rules.Run(ruleContext);
            }
            catch (Exception exc)
            {
                Log.Error("Exception while running page rules", exc, this);
            }
        }
        /// <summary>
        /// Gets the rules device.
        /// </summary>
        /// <param name="database">The database.</param>
        /// <returns>Resolved device</returns>
        private static DeviceItem GetRulesDevice(Database database)
        {
            DeviceItem[] all = database.Resources.Devices.GetAll();

            foreach (var device in all)
            {
                var ruleContext = new RuleContext();
                var rules       = RuleFactory.GetRules <RuleContext>(
                    device.InnerItem, "Conditions").Rules;
                foreach (Rule <RuleContext> rule in rules)
                {
                    if (rule.Condition != null)
                    {
                        var stack = new RuleStack();
                        rule.Condition.Evaluate(ruleContext, stack);
                        if (ruleContext.IsAborted)
                        {
                            continue;
                        }
                        if ((stack.Count != 0) && ((bool)stack.Pop()))
                        {
                            return(device);
                        }
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 8
0
        protected override void Evaluate(Sitecore.Pipelines.InsertRenderings.InsertRenderingsArgs args, Sitecore.Data.Items.Item item)
        {
            RuleList <ConditionalRenderingsRuleContext> globalRules = this.GetGlobalRules(item);

            foreach (RenderingReference reference in new List <RenderingReference>((IEnumerable <RenderingReference>)args.Renderings))
            {
                string conditions = reference.Settings.Conditions;
                if (!string.IsNullOrEmpty(conditions))
                {
                    List <Item> conditionItems = this.GetConditionItems(item.Database, conditions);
                    if (conditionItems.Count > 0)
                    {
                        RuleList <ConditionalRenderingsRuleContext> rules = RuleFactory.GetRules <ConditionalRenderingsRuleContext>((IEnumerable <Item>)conditionItems, "Rule");
                        ConditionalRenderingsRuleContext            renderingsRuleContext = new ConditionalRenderingsRuleContext(args.Renderings, reference);
                        renderingsRuleContext.Item = item;
                        ConditionalRenderingsRuleContext ruleContext = renderingsRuleContext;
                        rules.Run(ruleContext);
                    }
                }
                if (globalRules != null)
                {
                    ConditionalRenderingsRuleContext renderingsRuleContext = new ConditionalRenderingsRuleContext(args.Renderings, reference);
                    renderingsRuleContext.Item = item;
                    ConditionalRenderingsRuleContext ruleContext = renderingsRuleContext;
                    globalRules.Run(ruleContext);
                }

                GetCustomRules(args, item, reference);
            }
        }
Ejemplo n.º 9
0
        private static DeviceItem ExecuteDeviceConditions()
        {
            var devices = Context.Database.Resources.Devices.GetAll();

            foreach (var device in devices)
            {
                var ruleContext = new RuleContext();

                foreach (var rule in RuleFactory.GetRules <RuleContext>(new[] { device.InnerItem }, "Rule").Rules)
                {
                    if (rule.Condition != null)
                    {
                        var stack = new RuleStack();
                        rule.Condition.Evaluate(ruleContext, stack);
                        if (ruleContext.IsAborted)
                        {
                            continue;
                        }
                        if ((stack.Count != 0) && ((bool)stack.Pop()))
                        {
                            return(device);
                        }
                    }
                }
            }

            return(null);
        }
        public List <string> Classify(Item itemToTag, string text)
        {
            var tags = new List <string>();

            if (string.IsNullOrWhiteSpace(text))
            {
                return(tags);
            }

            //get all the tags
            var tagItems = ContentSearchService.GetTagsByTemplate(TaxonomyFolderId, InnerItem.Language.Name, InnerItem.Database.Name, TaxonomyItemTemplateIds);

            //loop through and pull out the rules
            foreach (var t in tagItems)
            {
                var rulesField = t.GetItem().Fields[Settings.RulesFieldId];
                if (rulesField == null)
                {
                    continue;
                }

                var rules = RuleFactory.GetRules <RuleContext>(rulesField);

                //run rule against the content
                var ruleContext = new RuleContext {
                    Item = itemToTag
                };
                if (EvaluateRules(rules, ruleContext))
                {
                    tags.Add(t.Name);
                }
            }

            return(tags);
        }
        public void OnItemAdded(object sender, EventArgs args)
        {
            var addedItem = ExtractItem(args);

            if (addedItem == null)
            {
                return;
            }

            var rulesFolderId  = ID.Parse(ItemAddedRulesConstants.ItemAddedRules.ItemId);
            var itemAddedRules = addedItem.Database.GetItem(rulesFolderId);

            if (itemAddedRules == null)
            {
                return;
            }

            var ruleContext = new RuleContext();

            ruleContext.Item = addedItem;

            RuleList <RuleContext> rules = RuleFactory.GetRules <RuleContext>(itemAddedRules, "Rule");

            if (rules.Count > 0)
            {
                rules.Run(ruleContext);
            }
        }
        public void Process(GetMastersArgs args)
        {
            Assert.ArgumentNotNull(args, nameof(args));

            var database          = args.Item.Database;
            var insertOptionRules = new List <Item>();

            foreach (var folder in Folders)
            {
                var rulesInFolder = GetInsertOptionsRules(database, folder);
                insertOptionRules.AddRange(rulesInFolder);
            }

            var rules = RuleFactory.GetRules <InsertOptionsRuleContext>(insertOptionRules, "Rule");

            if (rules == null)
            {
                return;
            }

            var ruleContext = new InsertOptionsRuleContext
            {
                Item          = args.Item,
                InsertOptions = args.Masters
            };

            rules.Run(ruleContext);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// runs the set of rules and checks for any matches, if it finds a match it will run the rule's associated action
        /// </summary>
        /// <param name="root">Item which holds the field</param>
        /// <param name="field">the rule field name</param>
        /// <param name="ruleContext"></param>
        /// <returns></returns>
        public static void RunRules <T>(this Item root, string field, T ruleContext)
            where T : RuleContext
        {
            foreach (Rule <T> rule in RuleFactory.GetRules <T>(new[] { root }, field).Rules)
            {
                if (rule.Condition != null)
                {
                    var stack = new RuleStack();
                    rule.Condition.Evaluate(ruleContext, stack);

                    if (ruleContext.IsAborted)
                    {
                        continue;
                    }
                    if ((stack.Count != 0) && ((bool)stack.Pop()))
                    {
                        rule.Execute(ruleContext);
                    }
                }
                else
                {
                    rule.Execute(ruleContext);
                }
            }
        }
        public TrackingField Evaluate(Item mapItem, Item contextItem)
        {
            var context = new RuleContext
            {
                Item = contextItem
            };

            foreach (Rule <RuleContext> rule in RuleFactory.GetRules <RuleContext>(new[] { mapItem }, Templates.RulesProfileMap.Fields.Rules.ToString()).Rules)
            {
                if (rule.Condition != null)
                {
                    var stack = new RuleStack();

                    rule.Condition.Evaluate(context, stack);

                    if (context.IsAborted)
                    {
                        continue;
                    }

                    if ((stack.Count != 0) && ((bool)stack.Pop()))
                    {
                        return(GetTrackingField(mapItem));
                    }
                }
            }

            return(null);
        }
        public void RunEventRules(string eventName, Item pageItem = null, params string[] values)
        {
            Assert.IsNotNullOrEmpty(eventName, $"{nameof(RulesService)}.{nameof(RunEventRules)} parameter {nameof(eventName)} is required");

            var ruleContext = new EventRuleContext()
            {
                EventName = eventName,
                Item      = pageItem,
                Value1    = ParamUtil.GetValue(1, values),
                Value2    = ParamUtil.GetValue(2, values),
                Value3    = ParamUtil.GetValue(3, values)
            };

            // Run Global Rules
            using (new SecurityDisabler())
            {
                var root = Utils.ItemUtil.GetItemById(ItemIds.GlobalRules.EventRules);
                if (root == null)
                {
                    return; // no root, exit
                }
                RuleList <EventRuleContext> rules = RuleFactory.GetRules <EventRuleContext>(root, "Rule");
                if (rules != null)
                {
                    rules.Run(ruleContext);
                }
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Runs the rules in the given rules folder
        /// </summary>
        /// <param name="ruleContext"></param>
        /// <param name="rulesFolderId">The rules folder.</param>
        public static void RunRules <TRuleContext>(TRuleContext ruleContext, Item rulesFolderItem)
            where TRuleContext : RuleContext
        {
            try
            {
                Assert.ArgumentNotNull(ruleContext, "ruleContext is null");
                Assert.ArgumentNotNull(rulesFolderItem, "rulesFolderItem is null");

                Assert.IsNotNull(rulesFolderItem.Database, "rulesFolderItem.Database is null");

                if (!Sitecore.Configuration.Settings.Rules.ItemEventHandlers.RulesSupported(rulesFolderItem.Database))
                {
                    return;
                }

                var rules = RuleFactory.GetRules <TRuleContext>(rulesFolderItem, "Rule");
                if (rules == null || rules.Count == 0)
                {
                    return;
                }

                rules.Run(ruleContext);
            }
            catch (Exception exception)
            {
                Log.Error(exception.Message, exception, typeof(RuleManager));
            }
        }
Ejemplo n.º 17
0
        public void Process(WorkflowPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            if (args.DataItem == null)
            {
                return;
            }

            var context = new WorkflowRuleContext(args);

            var actionItem = args.ProcessorItem.InnerItem;

            if (actionItem == null)
            {
                return;
            }

            if (actionItem["execute global rules"] == "1")
            {
                RunGlobalRules(args.DataItem.Database, context);
            }

            var rules = RuleFactory.GetRules <WorkflowRuleContext>(actionItem.Fields["rules"]);

            rules.Run(context);
        }
Ejemplo n.º 18
0
        private static void RunRules(Item item, string path)
        {
            Item item2;

            Assert.ArgumentNotNull(path, "path");
            using (new SecurityDisabler()) {
                item2 = item.Database.GetItem(path);
                if (item2 == null)
                {
                    return;
                }

                var context2 = new RuleContext
                {
                    Item = item
                };

                var ruleContext = context2;
                var rules       = RuleFactory.GetRules <RuleContext>(item2, "Rule");
                if (rules != null)
                {
                    rules.Run(ruleContext);
                }
            }
        }
Ejemplo n.º 19
0
        private void CheckForRulesMatch(Database db, string domain, string requestedUrl, string requestedPathAndQuery, HttpRequestArgs args)
        {
            // Loop through the pattern match items to find a match
            foreach (Item possibleRedirectRule in GetRedirects(db, domain, Constants.Templates.RedirectRule, Constants.Templates.VersionedRedirectRule, Sitecore.Configuration.Settings.GetSetting(Constants.Settings.QueryExactMatch)))
            {
                var ruleContext = new RuleContext();
                ruleContext.Parameters.Add("newUrl", requestedUrl);

                foreach (Rule <RuleContext> rule in RuleFactory.GetRules <RuleContext>((IEnumerable <Item>) new Item[1] {
                    possibleRedirectRule
                }, "Redirect Rule").Rules)
                {
                    if (rule.Condition != null)
                    {
                        RuleStack stack = new RuleStack();
                        rule.Condition.Evaluate(ruleContext, stack);
                        if (!ruleContext.IsAborted && (stack.Count != 0 && (bool)stack.Pop()))
                        {
                            foreach (var action in rule.Actions)
                            {
                                action.Apply(ruleContext);
                            }
                        }
                    }
                }

                if (ruleContext.Parameters["newUrl"] != null && ruleContext.Parameters["newUrl"].ToString() != string.Empty && ruleContext.Parameters["newUrl"].ToString() != requestedUrl)
                {
                    var responseStatus = GetResponseStatus(possibleRedirectRule);
                    // The query string will be in the URL already, so don't break it apart.
                    SendResponse(ruleContext.Parameters["newUrl"].ToString(), string.Empty, responseStatus, args);
                }
            }
        }
Ejemplo n.º 20
0
 private static void RunPromoRule(Sitecore.Pipelines.InsertRenderings.InsertRenderingsArgs args, Sitecore.Data.Items.Item item, RenderingReference reference, Item promo, string fieldName)
 {
     if (promo != null && !string.IsNullOrEmpty(fieldName))
     {
         RuleList <ConditionalRenderingsRuleContext> rules = RuleFactory.GetRules <ConditionalRenderingsRuleContext>(promo.Fields[fieldName]);
         var ruleContext = new ConditionalRenderingsRuleContext(args.Renderings, reference);
         ruleContext.Item = item;
         rules.Run(ruleContext);
     }
 }
        protected RuleList <PlaceholderRuleContext> CreateRuleList(GetPlaceholderRenderingsArgs args)
        {
            var ruleFolder = args.ContentDatabase.GetItem(FolderId);

            if (ruleFolder == null)
            {
                throw new InvalidOperationException("Placeholder settings rule folder could not be found.");
            }

            return(RuleFactory.GetRules <PlaceholderRuleContext>(ruleFolder, "Rule"));
        }
        public IDataFilter Parse(JobParser parser, ParseState state)
        {
            using (new SecurityDisabler())
            {
                var ruleContextItem = parser.Database.GetRootItem(parser.DefaultLanguage);

                var json = state.TryGet <string>("Rule");
                if (!string.IsNullOrEmpty(json))
                {
                    var filter = RulesFilter.FromString(json);
                    filter.RuleContextItem = ruleContextItem;
                    return(filter);
                }


                var  ruleItem = state.Require <string>("Item", true);
                Item item;
                ID   id;
                if (!ID.TryParse(ruleItem, out id))
                {
                    if (!ruleItem.StartsWith("/"))
                    {
                        var rootItem =
                            state.Parser.Database.GetItem(
                                ExperienceExtractorApiContainer.ItemPaths.GetOrDefault("experienceAnalyticsFilters") ??
                                "/sitecore/system/Marketing Control Panel/Experience Analytics/Filters");

                        ruleItem = rootItem.Paths.FullPath + "/" + ruleItem;
                    }


                    item = parser.Database.GetItem(ruleItem, parser.DefaultLanguage);
                }
                else
                {
                    item = parser.Database.GetItem(id, parser.DefaultLanguage);
                }



                if (item == null)
                {
                    throw ParseException.AttributeError(state, string.Format("Rule item not found '{0}'", ruleItem));
                }

                var rules = RuleFactory.GetRules <RuleContext>(item.Fields["Rule"]);

                return(new RulesFilter(rules)
                {
                    RuleContextItem = ruleContextItem
                });
            }
        }
Ejemplo n.º 23
0
 protected virtual RuleList <TrackingRuleContext> GetProfilingRules(Item item)
 {
     Assert.ArgumentNotNull(item, "item");
     using (var context = ContentSearchManager.CreateSearchContext(new SitecoreIndexableItem(item)))
     {
         var results = context.GetQueryable <ConfigItem>()
                       .Where(i => i.Paths.Contains(DefaultRulesFolderID))
                       .Where(i => !i.Disabled)
                       .Select(i => i.GetItem())
                       .ToArray();
         var rules = RuleFactory.GetRules <TrackingRuleContext>(results, "Rules");
         return(rules);
     }
 }
Ejemplo n.º 24
0
        private static void RunGlobalRules(Database database, WorkflowRuleContext context)
        {
            //TODO: Replace with GUID ?
            var rulesFolder = database.GetItem("/sitecore/system/Settings/Rules/Workflow/Rules");

            if (rulesFolder == null)
            {
                return;
            }

            var rules = RuleFactory.GetRules <WorkflowRuleContext>(rulesFolder, "rules");

            rules.Run(context);
        }
Ejemplo n.º 25
0
        public static bool EvaluateRule(Field field)
        {
            var ruleContext = new RuleContext();

            foreach (Rule <RuleContext> rule in RuleFactory.GetRules <RuleContext>(field).Rules)
            {
                if (!EvaluateSingleRule(rule, ruleContext))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Gets the rules device.
        /// </summary>
        /// <param name="database">The database.</param>
        /// <returns>Resolved device</returns>
        private static DeviceItem GetRulesDevice(Database database)
        {
            const string defaultLanguageName = "en";

            var savedLanguage = Context.Language;

            if (savedLanguage.Name != defaultLanguageName)
            {
                Context.Language = LanguageManager.GetLanguage(defaultLanguageName);
            }
            DeviceItem[] all = database.Resources.Devices.GetAll();

            foreach (var device in all)
            {
                var ruleContext = new RuleContext();

                foreach (Rule <RuleContext> rule in RuleFactory.GetRules <RuleContext>(new[]
                {
                    device.InnerItem
                }, "Conditions").Rules)
                {
                    if (rule.Condition != null)
                    {
                        var stack = new RuleStack();
                        rule.Condition.Evaluate(ruleContext, stack);
                        if (ruleContext.IsAborted)
                        {
                            continue;
                        }
                        if ((stack.Count != 0) && ((bool)stack.Pop()))
                        {
                            if (savedLanguage.Name != defaultLanguageName)
                            {
                                Context.Language = savedLanguage;
                            }

                            return(device);
                        }
                    }
                }
            }

            if (savedLanguage.Name != defaultLanguageName)
            {
                Context.Language = savedLanguage;
            }

            return(null);
        }
Ejemplo n.º 27
0
        /// <summary> Gets global conditional rules </summary>
        /// <param name="item">item to proceed</param>
        /// <returns>rulles collection</returns>
        protected RuleList <ConditionalRenderingsRuleContext> GetGlobalRules(Item item)
        {
            Assert.ArgumentNotNull(item, "item");
            RuleList <ConditionalRenderingsRuleContext> rules = null;

            using (new SecurityDisabler())
            {
                Item parentItem = item.Database.GetItem(ItemIDs.ConditionalRenderingsGlobalRules);
                if (parentItem != null)
                {
                    rules = RuleFactory.GetRules <ConditionalRenderingsRuleContext>(parentItem, "Rule");
                }
            }

            return(rules);
        }
        private PlaceholderSettingsRuleContext EvaluateRules(Item placeholder)
        {
            PlaceholderSettingsRuleContext ruleContext = new PlaceholderSettingsRuleContext();

            ruleContext.Item = _contextItem;
            foreach (Rule <PlaceholderSettingsRuleContext> rule in RuleFactory.GetRules <PlaceholderSettingsRuleContext>(new[] { placeholder }, AllowedModulesRulesField).Rules)
            {
                if (rule.Condition != null)
                {
                    var passed = rule.Evaluate(ruleContext);
                    if (passed)
                    {
                        rule.Execute(ruleContext);
                    }
                }
            }

            return(ruleContext);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Returns rules of a landing workflow action.
        /// </summary>
        /// <param name="processorItem">
        /// The processor item.
        /// </param>
        /// <returns>
        /// Returns RuleList of landing workflow.
        /// </returns>
        protected RuleList <WorkflowRuleContext> BuildRuleList(ProcessorItem processorItem)
        {
            Assert.ArgumentNotNull(processorItem, "processorItem");
            Item actionItem = processorItem.InnerItem;
            RuleList <WorkflowRuleContext> ruleList = new RuleList <WorkflowRuleContext>();

            if (!string.IsNullOrEmpty(actionItem["Rule"]))
            {
                ruleList.AddRange(RuleFactory.GetRules <WorkflowRuleContext>(actionItem.Fields["Rule"]).Rules);
            }

            if (!string.IsNullOrEmpty(actionItem["Rules"]))
            {
                Item[] rules = ((MultilistField)actionItem.Fields["Rules"]).GetItems();
                ruleList.AddRange(RuleFactory.GetRules <WorkflowRuleContext>(rules, "Rule").Rules);
            }

            return(ruleList);
        }
Ejemplo n.º 30
0
        public static bool EvaluateConditions <T>(this Item root, string field, T ruleContext)
            where T : RuleContext
        {
            var stack = new RuleStack();

            foreach (Rule <T> rule in RuleFactory.GetRules <T>(new[] { root }, field).Rules)
            {
                if (rule.Condition != null)
                {
                    rule.Condition.Evaluate(ruleContext, stack);

                    if (ruleContext.IsAborted)
                    {
                        continue;
                    }
                }
            }
            return(stack.Count != 0 && (bool)stack.Pop());
        }