Пример #1
0
 public void RemoveCondition(RuleConditionDefinition ruleConditionDefinition)
 {
     Debug.Assert(ruleConditionDefinition != null);
     Debug.Assert(ruleConditionDefinition.Id != null);
     //---
     inMemoryConditionStore.Remove((int)ruleConditionDefinition.Id);
 }
Пример #2
0
 public void UpdateCondition(RuleConditionDefinition ruleConditionDefinition)
 {
     Debug.Assert(ruleConditionDefinition != null);
     Debug.Assert(ruleConditionDefinition.Id != null);
     //---
     inMemoryConditionStore[(int)ruleConditionDefinition.Id] = ruleConditionDefinition;
 }
Пример #3
0
        public void AddCondition(RuleConditionDefinition ruleConditionDefinition)
        {
            Debug.Assert(ruleConditionDefinition != null);
            Debug.Assert(ruleConditionDefinition.Id == null, "A new condition must not have an id");
            //---
            int generatedId = Interlocked.Increment(ref memoryConditionSequenceGenerator);

            ruleConditionDefinition.Id          = generatedId;
            inMemoryConditionStore[generatedId] = ruleConditionDefinition;
        }
        /// <summary>
        /// Constructeur par recopie.
        /// </summary>
        /// <param name="bean">Source.</param>
        public RuleConditionDefinition(RuleConditionDefinition bean)
        {
            if (bean == null)
            {
                throw new ArgumentNullException(nameof(bean));
            }

            this.Id         = bean.Id;
            this.Field      = bean.Field;
            this.Operator   = bean.Operator;
            this.Expression = bean.Expression;
            this.RudId      = bean.RudId;

            this.OnCreated(bean);
        }
Пример #5
0
        public IList <RuleDefinition> FindRulesByCriteria(RuleCriteria criteria, IList <int> items)
        {
            Debug.Assert(criteria != null);
            //---
            IList <RuleDefinition> ret = new List <RuleDefinition>();

            foreach (int itemId in items)
            {
                IList <RuleDefinition> rules = (inMemoryRuleStore.Where(r => r.Value.Id.Equals(itemId)).Select(kp => kp.Value)).ToList();

                foreach (RuleDefinition rule in rules)
                {
                    Dictionary <string, RuleConditionDefinition> conditions = (inMemoryConditionStore.Where(r => r.Value.RudId.Equals(rule.Id)).Select(kp => kp.Value)).ToDictionary(r => r.Field);

                    int match = 0;
                    RuleConditionDefinition currentRule1 = conditions[criteria.ConditionCriteria1.Field];

                    if (currentRule1 != null && currentRule1.Expression.Equals(criteria.ConditionCriteria1.Value))
                    {
                        match++;
                    }

                    if (criteria.ConditionCriteria2 != null)
                    {
                        RuleConditionDefinition currentRule2 = conditions[criteria.ConditionCriteria2.Field];
                        if (currentRule2 != null && currentRule2.Expression.Equals(criteria.ConditionCriteria2.Value))
                        {
                            match++;
                        }
                    }

                    int expectedMatch = criteria.ConditionCriteria2 != null ? 2 : 1;

                    if (match == expectedMatch)
                    {
                        ret.Add(rule);
                        break;
                    }
                }
            }

            return(ret);
        }
Пример #6
0
 public void RemoveCondition(RuleConditionDefinition ruleConditionDefinition)
 {
     _ruleStorePlugin.RemoveCondition(ruleConditionDefinition);
 }
 /// <summary>
 /// Methode d'extensibilité possible pour les constructeurs par recopie.
 /// </summary>
 /// <param name="bean">Source.</param>
 partial void OnCreated(RuleConditionDefinition bean);
Пример #8
0
 public void AddCondition(RuleConditionDefinition ruleConditionDefinition)
 {
     _ruleStorePlugin.AddCondition(ruleConditionDefinition);
 }
Пример #9
0
 public void UpdateCondition(RuleConditionDefinition ruleConditionDefinition)
 {
     _ruleStorePlugin.UpdateCondition(ruleConditionDefinition);
 }
Пример #10
0
 public void RemoveCondition(RuleConditionDefinition ruleConditionDefinition)
 {
     Debug.Assert(ruleConditionDefinition.Id != null);
     BrokerManager.GetBroker <RuleConditionDefinition>().Delete(ruleConditionDefinition.Id.Value);
 }
Пример #11
0
 public void AddCondition(RuleConditionDefinition ruleConditionDefinition)
 {
     Debug.Assert(ruleConditionDefinition.Id == null);
     ruleConditionDefinition.Id = (int)BrokerManager.GetBroker <RuleConditionDefinition>().Save(ruleConditionDefinition);
 }
Пример #12
0
 public void UpdateCondition(RuleConditionDefinition ruleConditionDefinition)
 {
     Debug.Assert(ruleConditionDefinition.Id != null);
     BrokerManager.GetBroker <RuleConditionDefinition>().Save(ruleConditionDefinition);
 }