Ejemplo n.º 1
0
        private static void IsSimilarRulePreconditions(SimilarMatchedRule rule, DecimalCriteria amount,
                                                       StringCriteria description, StringCriteria[] references, StringCriteria transactionType)
        {
            if (rule == null)
            {
                throw new ArgumentNullException(nameof(rule));
            }

            if (amount == null)
            {
                throw new ArgumentNullException(nameof(amount));
            }

            if (description == null)
            {
                throw new ArgumentNullException(nameof(description));
            }

            if (references == null)
            {
                throw new ArgumentNullException(nameof(references));
            }

            if (transactionType == null)
            {
                throw new ArgumentNullException(nameof(transactionType));
            }
        }
Ejemplo n.º 2
0
        public void Initialize()
        {
            SimilarRules = null;
            AndChecked   = true;
            NewRule      = null;
            if (Description != null)
            {
                Description.PropertyChanged -= OnCriteriaValuePropertyChanged;
            }
            if (Reference1 != null)
            {
                Reference1.PropertyChanged -= OnCriteriaValuePropertyChanged;
            }
            if (Reference2 != null)
            {
                Reference2.PropertyChanged -= OnCriteriaValuePropertyChanged;
            }
            if (Reference3 != null)
            {
                Reference3.PropertyChanged -= OnCriteriaValuePropertyChanged;
            }
            if (Amount != null)
            {
                Amount.PropertyChanged -= OnCriteriaValuePropertyChanged;
            }
            if (TransactionType != null)
            {
                TransactionType.PropertyChanged -= OnCriteriaValuePropertyChanged;
            }

            Description = new StringCriteria {
                Applicable = true
            };
            Description.PropertyChanged += OnCriteriaValuePropertyChanged;
            Reference1 = new StringCriteria();
            Reference1.PropertyChanged += OnCriteriaValuePropertyChanged;
            Reference2 = new StringCriteria();
            Reference2.PropertyChanged += OnCriteriaValuePropertyChanged;
            Reference3 = new StringCriteria();
            Reference3.PropertyChanged += OnCriteriaValuePropertyChanged;
            Amount = new DecimalCriteria();
            Amount.PropertyChanged          += OnCriteriaValuePropertyChanged;
            TransactionType                  = new StringCriteria();
            TransactionType.PropertyChanged += OnCriteriaValuePropertyChanged;
        }
Ejemplo n.º 3
0
        public bool IsRuleSimilar(SimilarMatchedRule rule, DecimalCriteria amount, StringCriteria description,
                                  StringCriteria[] references, StringCriteria transactionTypeName)
        {
            IsSimilarRulePreconditions(rule, amount, description, references, transactionTypeName);

            var matchedByResults = new bool[6];

            matchedByResults[0] = amount.IsEqualButNotBlank(rule.Amount);
            matchedByResults[1] = description.IsEqualButNotBlank(rule.Description);
            matchedByResults[2] = references[0].IsEqualButNotBlank(rule.Reference1);
            matchedByResults[3] = references[1].IsEqualButNotBlank(rule.Reference2);
            matchedByResults[4] = references[2].IsEqualButNotBlank(rule.Reference3);
            matchedByResults[5] = transactionTypeName.IsEqualButNotBlank(rule.TransactionType);

            var match = matchedByResults[0];

            match |= matchedByResults[1];
            match |= matchedByResults[2];
            match |= matchedByResults[3];
            match |= matchedByResults[4];
            match |= matchedByResults[5];

            if (match)
            {
                this.logger.LogInfo(
                    l => l.Format("Rule Match: {0} Existing Rule:{1} Criteria:{2}", match, rule, description));
                rule.AmountMatched          = matchedByResults[0] && amount.Applicable;
                rule.DescriptionMatched     = matchedByResults[1] && description.Applicable;
                rule.Reference1Matched      = matchedByResults[2] && references[0].Applicable;
                rule.Reference2Matched      = matchedByResults[3] && references[1].Applicable;
                rule.Reference3Matched      = matchedByResults[4] && references[2].Applicable;
                rule.TransactionTypeMatched = matchedByResults[5] && transactionTypeName.Applicable;

                return(rule.AmountMatched ||
                       rule.DescriptionMatched ||
                       rule.Reference1Matched ||
                       rule.Reference2Matched ||
                       rule.Reference3Matched ||
                       rule.TransactionTypeMatched);
            }

            return(false);
        }
        private static void IsSimilarRulePreconditions(SimilarMatchedRule rule, DecimalCriteria amount,
                                                       StringCriteria description, StringCriteria[] references, StringCriteria transactionType)
        {
            if (rule == null)
            {
                throw new ArgumentNullException(nameof(rule));
            }

            if (amount == null)
            {
                throw new ArgumentNullException(nameof(amount));
            }

            if (description == null)
            {
                throw new ArgumentNullException(nameof(description));
            }

            if (references == null)
            {
                throw new ArgumentNullException(nameof(references));
            }

            if (transactionType == null)
            {
                throw new ArgumentNullException(nameof(transactionType));
            }
        }
        public bool IsRuleSimilar(SimilarMatchedRule rule, DecimalCriteria amount, StringCriteria description,
                                  StringCriteria[] references, StringCriteria transactionTypeName)
        {
            IsSimilarRulePreconditions(rule, amount, description, references, transactionTypeName);

            var matchedByResults = new bool[6];
            matchedByResults[0] = amount.IsEqualButNotBlank(rule.Amount);
            matchedByResults[1] = description.IsEqualButNotBlank(rule.Description);
            matchedByResults[2] = references[0].IsEqualButNotBlank(rule.Reference1);
            matchedByResults[3] = references[1].IsEqualButNotBlank(rule.Reference2);
            matchedByResults[4] = references[2].IsEqualButNotBlank(rule.Reference3);
            matchedByResults[5] = transactionTypeName.IsEqualButNotBlank(rule.TransactionType);

            var match = matchedByResults[0];
            match |= matchedByResults[1];
            match |= matchedByResults[2];
            match |= matchedByResults[3];
            match |= matchedByResults[4];
            match |= matchedByResults[5];

            if (match)
            {
                this.logger.LogInfo(
                    l => l.Format("Rule Match: {0} Existing Rule:{1} Criteria:{2}", match, rule, description));
                rule.AmountMatched = matchedByResults[0] && amount.Applicable;
                rule.DescriptionMatched = matchedByResults[1] && description.Applicable;
                rule.Reference1Matched = matchedByResults[2] && references[0].Applicable;
                rule.Reference2Matched = matchedByResults[3] && references[1].Applicable;
                rule.Reference3Matched = matchedByResults[4] && references[2].Applicable;
                rule.TransactionTypeMatched = matchedByResults[5] && transactionTypeName.Applicable;

                return rule.AmountMatched
                       || rule.DescriptionMatched
                       || rule.Reference1Matched
                       || rule.Reference2Matched
                       || rule.Reference3Matched
                       || rule.TransactionTypeMatched;
            }

            return false;
        }
Ejemplo n.º 6
0
        public void Initialize()
        {
            SimilarRules = null;
            AndChecked = true;
            NewRule = null;
            if (Description != null)
            {
                Description.PropertyChanged -= OnCriteriaValuePropertyChanged;
            }
            if (Reference1 != null)
            {
                Reference1.PropertyChanged -= OnCriteriaValuePropertyChanged;
            }
            if (Reference2 != null)
            {
                Reference2.PropertyChanged -= OnCriteriaValuePropertyChanged;
            }
            if (Reference3 != null)
            {
                Reference3.PropertyChanged -= OnCriteriaValuePropertyChanged;
            }
            if (Amount != null)
            {
                Amount.PropertyChanged -= OnCriteriaValuePropertyChanged;
            }
            if (TransactionType != null)
            {
                TransactionType.PropertyChanged -= OnCriteriaValuePropertyChanged;
            }

            Description = new StringCriteria { Applicable = true };
            Description.PropertyChanged += OnCriteriaValuePropertyChanged;
            Reference1 = new StringCriteria();
            Reference1.PropertyChanged += OnCriteriaValuePropertyChanged;
            Reference2 = new StringCriteria();
            Reference2.PropertyChanged += OnCriteriaValuePropertyChanged;
            Reference3 = new StringCriteria();
            Reference3.PropertyChanged += OnCriteriaValuePropertyChanged;
            Amount = new DecimalCriteria();
            Amount.PropertyChanged += OnCriteriaValuePropertyChanged;
            TransactionType = new StringCriteria();
            TransactionType.PropertyChanged += OnCriteriaValuePropertyChanged;
        }