Ejemplo n.º 1
0
        public string GetSerializedRuleConditions(Guid ruleId, string entitySchemaName)
        {
            string result = string.Empty;
            var    helper = new RuleSerializationHelper();
            Select query  = helper.GetRuleSelectQuery(UserConnection, ruleId, entitySchemaName);

            if (query != null)
            {
                result = helper.SerializeSelectQuery(query);
            }
            return(result);
        }
Ejemplo n.º 2
0
        private ScoringRule CreateScoringRule(Entity scoringRuleEntity, ScoringModel scoringModel,
                                              RuleSerializationHelper ruleSerializationHelper)
        {
            var    rule         = new ScoringRule();
            string filterData   = scoringRuleEntity.GetTypedColumnValue <string>("FilterData");
            string ruleCriteria = ruleSerializationHelper.CreateRuleCriteria(filterData, scoringModel.ScoringObjectId,
                                                                             UserConnection);
            string ruleQuery = ruleSerializationHelper.CreateRuleCriteria(filterData, scoringModel.ScoringObjectId,
                                                                          UserConnection, true);

            rule.RuleCriteriaQuery = ruleQuery;
            rule.RuleCriteria      = ruleCriteria;
            rule.ScoringModelId    = scoringModel.Id;
            rule.Id            = scoringRuleEntity.GetTypedColumnValue <Guid>("Id");
            rule.ModifiedOn    = scoringRuleEntity.GetTypedColumnValue <DateTime>("ModifiedOn");
            rule.ScoringCount  = scoringRuleEntity.GetTypedColumnValue <int>("ScoringCount");
            rule.ScoringPoints = scoringRuleEntity.GetTypedColumnValue <decimal>("ScoringPoints");
            rule.Duration      = scoringRuleEntity.GetTypedColumnValue <int>("Duration");
            rule.Name          = scoringRuleEntity.GetTypedColumnValue <string>("Name");
            return(rule);
        }
Ejemplo n.º 3
0
        private void ApplyScoringRules(List <ScoringModel> models)
        {
            var               ruleSerializationHelper = new RuleSerializationHelper();
            EntitySchema      scoringRuleSchema       = UserConnection.EntitySchemaManager.GetInstanceByName("ScoringRule");
            EntitySchemaQuery esq = new EntitySchemaQuery(scoringRuleSchema);

            esq.PrimaryQueryColumn.IsAlwaysSelect = true;
            esq.IgnoreDisplayValues = true;
            esq.AddAllSchemaColumns();
            EntityCollection entityCollection = esq.GetEntityCollection(UserConnection);

            foreach (Entity scoringRuleEntity in entityCollection)
            {
                Guid         scoringModelId = scoringRuleEntity.GetTypedColumnValue <Guid>("ScoringModelId");
                ScoringModel scoringModel   = models.FirstOrDefault(model => model.Id == scoringModelId);
                if (scoringModel != null)
                {
                    ScoringRule rule = CreateScoringRule(scoringRuleEntity, scoringModel, ruleSerializationHelper);
                    scoringModel.Rules.Add(rule);
                }
            }
        }