Ejemplo n.º 1
0
        public CriteriaOperator GeneratrCriteria(Criterion filterCondition)
        {
            List <CriteriaNode> criteriaNodeList = filterCondition.CriteriaNodes.ToList() as List <CriteriaNode>;

            if (criteriaNodeList.Count() <= 0)
            {
                return(null);
            }
            CriteriaNode root = criteriaNodeList.Where(c => c.ParentNodeId == Guid.Empty).First();

            return(GeneratrNode(root, criteriaNodeList));
        }
Ejemplo n.º 2
0
        private GroupOperator GetGroupOperator(CriteriaNode node)
        {
            GroupOperator theOperator = new GroupOperator();

            if (node.OperatorType == "And")
            {
                theOperator.OperatorType = GroupOperatorType.And;
            }
            else if (node.OperatorType == "Or")
            {
                theOperator.OperatorType = GroupOperatorType.Or;
            }
            return(theOperator);
        }
Ejemplo n.º 3
0
 private CriteriaOperator GeneratrNode(CriteriaNode node, List <CriteriaNode> criteriaNodeList)
 {
     if (node.Operator == "Group")
     {
         GroupOperator gOperator = GetGroupOperator(node);
         var           subNodes  = criteriaNodeList.Where(c => c.ParentNodeId == node.CriteriaNodeId);
         foreach (var subNode in subNodes)
         {
             gOperator.Operands.Add(GeneratrNode(subNode, criteriaNodeList));
         }
         return(gOperator);
     }
     else if (node.Operator == "Binry" || node.Operator == "TimeCompare")
     {
         return(GetBinaryOperator(node));
     }
     return(null);
 }
Ejemplo n.º 4
0
        private BinaryOperator GetBinaryOperator(CriteriaNode node)
        {
            BinaryOperator     theOperator = new BinaryOperator();
            BinaryOperatorType operatorType;

            Enum.TryParse <BinaryOperatorType>(node.OperatorType, out operatorType);
            if (operatorType == null)
            {
                operatorType = BinaryOperatorType.Equal;
            }
            theOperator.OperatorType = operatorType;
            var entityInfo = MetadataProvider.Instance.EntiyMetadata
                             .Where(c => c.EntityId == _entityTypeId).First();
            EntityAttribute att = entityInfo.Attributes
                                  .Where(d => d.AttributeId == node.CompareAttributeId).First();

            if (node.Operator == "TimeCompare" && att.AttributeType.Description == "datetime")
            {
                theOperator.LeftOperand  = ConstantValue.Parse(att.TableColumnName);
                theOperator.RightOperand = new ConstantValue(DateTime.Today.AddDays(int.Parse(node.CompareValue)));
            }
            else
            {
                theOperator.LeftOperand = ConstantValue.Parse(att.TableColumnName);
                if (string.IsNullOrEmpty(node.CompareValue) && operatorType != BinaryOperatorType.NotEqual && att.AttributeType.Description == "uniqueidentifier")
                {
                    Guid entityId = GetEntityId(entityInfo, att);
                    theOperator.RightOperand = new ConstantValue(entityId);
                }
                else if (string.IsNullOrEmpty(node.CompareValue) && operatorType == BinaryOperatorType.NotEqual && _oldValue != null && _oldValue.Keys.Contains(att.PhysicalName))
                {
                    theOperator.RightOperand = new ConstantValue(GetValue(att.AttributeType, _oldValue[att.PhysicalName].ToString()));
                }
                else
                {
                    theOperator.RightOperand = new ConstantValue(GetValue(att.AttributeType, node.CompareValue));
                }
            }
            return(theOperator);
        }
Ejemplo n.º 5
0
 public UnkonwnCriteriaSaqlException(CriteriaNode criteriaNode, object pointcut) : base(string.Format("Unknown criteria '{0}' for {1}", criteriaNode, pointcut))
 {
 }
Ejemplo n.º 6
0
 public MissingArgumentSaqlException(CriteriaNode node)
     : base(string.Format("Missing argument for criteria: {0}", node))
 {
 }
Ejemplo n.º 7
0
 public UnexpectedArgumentSaqlException(CriteriaNode node)
     : base(string.Format("Argument unexpected for criteria: {0}", node))
 {
 }