public static CriteriaOperator Concat(GroupOperatorType groupOperatorType, params CriteriaOperator[] operators) { var actualSource = operators.EvictNull().ToList(); if (actualSource.IsEmpty()) return null; if (actualSource.Count == 1) return actualSource[0]; return new GroupOperator(groupOperatorType, actualSource); }
private static string Process(GroupOperatorType groupOperatorType) { switch (groupOperatorType) { case GroupOperatorType.And: return(" AND "); case GroupOperatorType.Or: return(" OR "); default: throw new NotSupportedException("Не поддерживаем GroupOperatorType отличный от 'And' или 'Or'. Переданное значение GroupOperatorType: '{0}'".FillWith(groupOperatorType)); } }
public static CriteriaOperator Concat(GroupOperatorType groupOperatorType, params CriteriaOperator[] operators) { var actualSource = operators.EvictNull().ToList(); if (actualSource.IsEmpty()) { return(null); } if (actualSource.Count == 1) { return(actualSource[0]); } return(new GroupOperator(groupOperatorType, actualSource)); }
public static void SetFilter(this GridView gv, GroupOperatorType type, params BinaryOperator[] valuePairs) { SetFilter(gv, new GroupOperator(type, valuePairs .Where(o => !ReferenceEquals(o, null)) .ToArray() )); }
public static void ClearGroupFilter(this GridView gv, GroupOperatorType type, params string[] groupPropertyNames) { var cos = FindGroupFilter(gv, type, groupPropertyNames); if (ReferenceEquals(cos, null)) return; if (cos.Contains(gv.ActiveFilterCriteria as GroupOperator)) gv.ActiveFilterCriteria = null; else { var Criteria = gv.GetCriteria(); foreach (var co in cos.ToArray()) Criteria.Remove(co); } gv.ApplyColumnsFilter(); }
private string CreateWhereClauseGroupOperator(GroupOperator filter, CriteriaOperatorCollection operands, GroupOperatorType operatorType) { var whereClause = string.Empty; // var operands = ((GroupOperator)eventLogGrid.FilterCriteria).Operands; // var operatorType = ((GroupOperator)eventLogGrid.FilterCriteria).OperatorType.ToString(); for (int i = 0; i < operands.Count; i++) { if (operands[i].GetType() == typeof(GroupOperator)) { whereClause += CreateWhereClauseGroupOperator((GroupOperator)operands[i], operands, operatorType); } else { whereClause += CreateWhereClauseCriteriaOperator(operands[i]); if (i + 1 != operands.Count) { whereClause += $" {operatorType} "; } } } return(whereClause); }
public static GroupOperator GroupOperand(GroupOperatorType type, params CriteriaOperator[] operands) { return(new GroupOperator(type, operands)); }
public static CriteriaOperator GetCriteriaByText(string text, string columnName, GroupOperatorType groupOperatorType) { var ids = text.Split(';'); var operandProp = new OperandProperty(columnName); var criteriaList = Enumerable.Range(0, ids.Length).Select(s => new FunctionOperator(FunctionOperatorType.Contains, operandProp, ids[s])); var criteria = new GroupOperator(groupOperatorType, criteriaList); return(criteria); }
public GroupOperator(CriteriaOperator[] fOperands, GroupOperatorType fOperatorType) { Operands = fOperands; OperatorType = fOperatorType; }
public XpandSearchCriteriaBuilder(ITypeInfo typeInfo, ICollection<string> properties, string valueToSearch, GroupOperatorType valuesGroupOperatorType) : base(typeInfo, properties, valueToSearch, valuesGroupOperatorType) { }
public XpandSearchCriteriaBuilder(ITypeInfo typeInfo, ICollection<string> properties, string valueToSearch, GroupOperatorType valuesGroupOperatorType, bool includeNonPersistentMembers) : base(typeInfo, properties, valueToSearch, valuesGroupOperatorType, includeNonPersistentMembers) { }
public void AddCriteria(GroupOperatorType groupOperatorType, CriteriaOperator criteriaOperator) { Criteria = new GroupOperator(groupOperatorType, Criteria, criteriaOperator); }
public static CriteriaOperator ToGroup(this IEnumerable<CriteriaOperator> source, GroupOperatorType groupOperatorType) { return Concat(groupOperatorType, source.ToArray()); }
public static GroupOperator GroupOperand(GroupOperatorType type, params CriteriaOperator[] operands) { return new GroupOperator(type, operands); }
public static CriteriaOperator Concat(this CriteriaOperator source, CriteriaOperator anotherCriteria, GroupOperatorType groupOperatorType) { return Concat(groupOperatorType, source, anotherCriteria); }
public static void SetGroupFilter(this GridView gv, GroupOperatorType type, params BinaryOperator[] valuePairs) { string[] groupPropertyNames = valuePairs .Where(o => !ReferenceEquals(o,null)) .Select(o => (o.LeftOperand as OperandProperty).PropertyName) .ToArray(); var gos = FindGroupFilter(gv, type, groupPropertyNames); if (gos == null) { SetFilter(gv, new GroupOperator(type, valuePairs .Where(o => !ReferenceEquals(o, null)) .ToArray() )); return; } else { foreach (var go in gos) { var matches = from g in go.Operands.OfType<BinaryOperator>() join v in valuePairs on (g.LeftOperand as OperandProperty).PropertyName equals (v.LeftOperand as OperandProperty).PropertyName where g.OperatorType.Equals(v.OperatorType) select new { Left = g, Right = v }; if (matches.Count() == valuePairs.Count()) foreach (var p in matches) p.Left.RightOperand = p.Right.RightOperand; } } gv.ApplyColumnsFilter(); }
private static List<GroupOperator> FindGroupFilter(this GridView gv, GroupOperatorType type, params string[] groupPropertyNames) { var Criteria = gv.GetCriteria(); if (Criteria == null) return null; var groups = Criteria.OfType<GroupOperator>() .Union(new[] { gv.ActiveFilterCriteria as GroupOperator }) .Where(g => g.OperatorType.Equals(type)); if (!groups.Any()) return null; List<GroupOperator> co = new List<GroupOperator>(); foreach (var g in groups) { if (g.Operands.Count(o => o is BinaryOperator) == g.Operands.Count) { var found = g.Operands .OfType<BinaryOperator>() .Where(o => o.LeftOperand is OperandProperty) .Select(o => (o.LeftOperand as OperandProperty).PropertyName); if (found.Union(groupPropertyNames).Count() == g.Operands.Count) co.Add(g); } } return co; }
private static string Process(GroupOperatorType groupOperatorType) { switch (groupOperatorType) { case GroupOperatorType.And: return " AND "; case GroupOperatorType.Or: return " OR "; default: throw new NotSupportedException("Не поддерживаем GroupOperatorType отличный от 'And' или 'Or'. Переданное значение GroupOperatorType: '{0}'".FillWith(groupOperatorType)); } }
public static CriteriaOperator ToGroup(this IEnumerable <CriteriaOperator> source, GroupOperatorType groupOperatorType) { return(Concat(groupOperatorType, source.ToArray())); }
public XpandSearchCriteriaBuilder(ITypeInfo typeInfo, ICollection <string> properties, string valueToSearch, GroupOperatorType valuesGroupOperatorType, bool includeNonPersistentMembers) : base(typeInfo, properties, valueToSearch, valuesGroupOperatorType, includeNonPersistentMembers) { }
public static CriteriaOperator Concat(this CriteriaOperator source, CriteriaOperator anotherCriteria, GroupOperatorType groupOperatorType) { return(Concat(groupOperatorType, source, anotherCriteria)); }
public XpandSearchCriteriaBuilder(ITypeInfo typeInfo, ICollection <string> properties, string valueToSearch, GroupOperatorType valuesGroupOperatorType) : base(typeInfo, properties, valueToSearch, valuesGroupOperatorType) { }
/// <summary> /// 그리트 뷰에 필터 조건을 적용한다. /// </summary> /// <param name="gv"></param> /// <param name="value"></param> /// <param name="columnName"></param> /// <param name="GOType"></param> /// <param name="OType"></param> public static void GridView_FilterApply(GridView gv, object value, string columnName, GroupOperatorType GOType = GroupOperatorType.And, BinaryOperatorType OType = BinaryOperatorType.Equal) { if (value == null) { //gvBooks.Columns[columnName].FilterInfo. return; } if (OType == BinaryOperatorType.Like) { value = "%" + value + "%"; } CriteriaOperator binaryFilter = new GroupOperator(GroupOperatorType.And, new BinaryOperator(columnName, value, OType)); //string filterDisplayText = String.Format("{0} = {1} ", columnName, value); //ColumnFilterInfo dateFilter = new ColumnFilterInfo(binaryFilter.ToString(), filterDisplayText); ColumnFilterInfo dateFilter = new ColumnFilterInfo(binaryFilter); gv.Columns[columnName].FilterInfo = dateFilter; }
public override String GetOperatorString(GroupOperatorType operatorType) { return base.GetOperatorString(operatorType); }
/// <summary> /// 그리트 뷰에 필터 Between 조건을 적용한다. /// </summary> /// <param name="gv"></param> /// <param name="value"></param> /// <param name="columnName"></param> /// <param name="GOType"></param> /// <param name="OType1"></param> /// <param name="OType2"></param> public static void GridView_FilterApply(GridView gv, object value_from, object value_to, string columnName, GroupOperatorType GOType = GroupOperatorType.And, BinaryOperatorType OType1 = BinaryOperatorType.GreaterOrEqual, BinaryOperatorType OType2 = BinaryOperatorType.LessOrEqual) { if (value_from == null || value_to == null) { //gvBooks.Columns[columnName].FilterInfo. return; } CriteriaOperator binaryFilter = new GroupOperator(GroupOperatorType.And, new BinaryOperator(columnName, value_from, OType1), new BinaryOperator(columnName, value_to, OType2)); //string filterDisplayText = String.Format("{0} = {1} ", columnName, value); //ColumnFilterInfo dateFilter = new ColumnFilterInfo(binaryFilter.ToString(), filterDisplayText); ColumnFilterInfo dateFilter = new ColumnFilterInfo(binaryFilter); gv.Columns[columnName].FilterInfo = dateFilter; }