Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="alias"></param>
        /// <param name="ruleKey"></param>
        /// <param name="rule"></param>
        public void addRule(string alias, string ruleKey, PawnRule rule)
        {
            if (StringUtilities.isEmpty(alias) ||
                StringUtilities.isEmpty(ruleKey) ||
                rule == null)
            {
                return;
            }
            Dictionary <string, List <PawnRule> > innerRules = null;
            bool createdInner     = false;
            bool createdInnerList = false;

            //Get/Create inner rule set for given alias
            if (this.rules.ContainsKey(alias))
            {
                innerRules = this.rules[alias];
            }
            if (innerRules == null)
            {
                innerRules   = new Dictionary <string, List <PawnRule> >();
                createdInner = true;
            }

            //Get/Create inner rule list for given rule key
            List <PawnRule> innerRuleList = null;

            if (innerRules.ContainsKey(ruleKey))
            {
                innerRuleList = innerRules[ruleKey];
            }
            if (innerRuleList == null)
            {
                innerRuleList    = new List <PawnRule>();
                createdInnerList = true;
            }

            //Add rule
            innerRuleList.Add(rule);

            //Ensure we populate parent lists and maps appropriately
            if (createdInner)
            {
                if (createdInnerList)
                {
                    innerRules.Add(ruleKey, innerRuleList);
                    this.rules.Add(alias, innerRules);
                }
                else
                {
                    this.rules.Add(alias, innerRules);
                }
            }
            else if (createdInnerList)
            {
                innerRules.Add(ruleKey, innerRuleList);
            }
        }
Exemple #2
0
        private bool updateBusinessRuleComponent(List <string> busRules, ref Dictionary <string, BusinessRuleVO> bvoHierarchy, ref PawnRule p)
        {
            if (p == null || busRules == null || bvoHierarchy == null)
            {
                return(false);
            }
            string pawnRuleCompKey = p.RuleKey;

            foreach (string bRule in busRules)
            {
                string         curRule = bRule;
                BusinessRuleVO curBR   = bvoHierarchy[curRule];
                if (curBR == null || !curBR.ContainsKey(pawnRuleCompKey))
                {
                    continue;
                }

                BusinessRuleComponentVO bvo = curBR[pawnRuleCompKey];
                bvo.FromDate = p.FromDate;
                bvo.ToDate   = p.ToDate;
                //bvo.CheckLoanRange = p.CheckLoanRange;
                //bvo.CheckLoanAmount = p.CheckLoanAmount;
                bvo.Alias = p.Alias;

                switch (bvo.ValueType)
                {
                case BusinessRuleComponentVO.RuleValueType.FEES:
                    bvo.FeesValue.Alias.Code   = p.Alias;
                    bvo.FeesValue.ParamKeyCode = p.RuleKey;
                    bvo.FeesValue.Value        = p.RuleValue;
                    break;

                case BusinessRuleComponentVO.RuleValueType.INTEREST:
                    bvo.InterestValue.Alias.Code     = p.Alias;
                    bvo.InterestValue.InterestAmount = 0.0M;
                    bvo.InterestValue.InterestRate   = decimal.Parse(p.RuleValue);
                    bvo.InterestValue.MinAmount      = p.LoanAmountMin;
                    bvo.InterestValue.MaxAmount      = p.LoanAmountMax;
                    break;

                case BusinessRuleComponentVO.RuleValueType.PARAM:
                    bvo.ParamValue.Alias.Code = p.Alias;
                    bvo.ParamValue.Cacheable  = false;
                    bvo.ParamValue.Company    = "1";
                    bvo.ParamValue.Code       = p.RuleKey;
                    bvo.ParamValue.Value      = p.RuleValue;
                    break;
                }
            }
            return(true);
        }