private QueryFilter BuildKindFilter(ConditionOperation opt, object value) { if (AqsParser.KindKeywordMap.ContainsKey((string)value)) { KindKeyword kindKeyword = AqsParser.KindKeywordMap[(string)value]; if (this.IsQueryConverting) { return(this.BuildTextFilter(this.kindMapping, kindKeyword.ToString(), 1)); } List <QueryFilter> list = new List <QueryFilter>(); string[] array = Globals.KindKeywordToClassMap[kindKeyword]; foreach (string propertyValue in array) { QueryFilter queryFilter = this.BuildTextFilter(this.kindMapping, propertyValue, 13); if (queryFilter != null) { list.Add(queryFilter); } } if (list.Count > 0) { if (list.Count <= 1) { return(list[0]); } return(new OrFilter(list.ToArray())); } } return(null); }
/// <summary> /// È¡Ìõ¼þÔËËã×Ö·û´® /// </summary> /// <param name="condition">ÔËËãenum</param> /// <returns>Ìõ¼þÔËËã×Ö·û´®</returns> public static string GetConditionOperationString(ConditionOperation condition) { string strConditionOperation = ""; switch (condition) { case ConditionOperation.And: strConditionOperation = " AND "; break; case ConditionOperation.Or: strConditionOperation = " OR "; break; case ConditionOperation.Not: strConditionOperation = " NOT "; break; default: strConditionOperation = " OnKonw "; break; } return(strConditionOperation); }
private QueryFilter BuildComparisonFilter(ConditionOperation opt, PropertyDefinition[] properties, object propertyValue) { ComparisonOperator comparisionOpt; switch (opt) { case 1: comparisionOpt = ComparisonOperator.Equal; goto IL_3C; case 3: comparisionOpt = ComparisonOperator.LessThan; goto IL_3C; case 4: comparisionOpt = ComparisonOperator.GreaterThan; goto IL_3C; case 5: comparisionOpt = ComparisonOperator.LessThanOrEqual; goto IL_3C; case 6: comparisionOpt = ComparisonOperator.GreaterThanOrEqual; goto IL_3C; } return(null); IL_3C: return(this.BuildComparisonFilter(comparisionOpt, properties, propertyValue)); }
private QueryFilter BuildParticipantsFilter(ConditionOperation opt, object value) { return(this.BuildRecipientFilter(this.IsQueryConverting ? new PropertyDefinition[] { this.participantsMapping[0] } : this.participantsMapping, opt, value)); }
public ConditionalItem( ConditionOperation operation, string condition) { m_operation = operation; m_condition = condition; }
private static void SetRowRefValue(this SectionData self, UserSession Session, string fieldValue, string value, CardData reference, Guid sectionId, string searchFieldName = "Name", FieldType fieldType = FieldType.Unistring, ConditionOperation operation = ConditionOperation.Equals) { if (!String.IsNullOrEmpty(value) && !RegexEngine.IsMatch(value, @"^\s+$")) { RowData si = SearchItemInReference(Session, reference, sectionId, searchFieldName, value, fieldType, operation); if (si != null) { self.SetRowValue(fieldValue, "Value", si.Id, fieldType: FieldType.RefId); self.SetRowValue(fieldValue, "DisplayValue", si.DisplayString); } else { if (sectionId == DocsVision.Platform.Cards.Constants.RefStaff.Employees.ID) { RowData unit = SearchItemInReference(Session, reference, DocsVision.Platform.Cards.Constants.RefStaff.Units.ID, "Name", "Временные"); RowData ne = unit.ChildSections[DocsVision.Platform.Cards.Constants.RefStaff.Employees.ID].Rows.AddNew(); ne.SetString("LastName", value); ne.SetString("DisplayString", value); self.SetRowValue(fieldValue, "Value", ne.Id, fieldType: FieldType.RefId); self.SetRowValue(fieldValue, "DisplayValue", ne.DisplayString); } else { logger.Warn("cardId='{0}'; {2}='{1}' value not found", self.Card.Id, value, fieldValue); } } } }
private QueryFilter BuildIsReadFilter(ConditionOperation opt, object value) { if (value is bool) { return(this.BuildComparisonFilter(1, this.isReadMapping, (bool)value)); } return(null); }
private QueryFilter BuildHasAttachmentFilter(ConditionOperation opt, object value) { if (value is bool) { return(this.BuildComparisonFilter(1, this.hasAttachmentMapping, (bool)value)); } return(null); }
private static RowData SearchItemInReference(UserSession Session, CardData reference, Guid sectionId, string fieldName, string fieldValue, FieldType fieldType = FieldType.Unistring, ConditionOperation operation = ConditionOperation.Equals) { RowDataCollection rdc = reference.Sections[sectionId] .FindRows(GetSectionSearchQuery(Session, fieldName, fieldValue, fieldType, operation)); return(rdc.Count != 0 ? rdc[0] : null); }
private static string GetSectionSearchQuery(UserSession Session, string fieldName, string fieldValue, FieldType fieldType = FieldType.Unistring, ConditionOperation conditionOperation = ConditionOperation.Equals) { SectionQuery query = Session.CreateSectionQuery(); query.ConditionGroup.Conditions.AddNew(fieldName, fieldType, conditionOperation, fieldValue); return(query.GetXml(null, true)); }
public TableAttribute(string tableName, string fieldName, ConditionOperation operation, string value) { _tableName = tableName; _fieldName = fieldName; _operation = operation; _value = value; //foreach ( Condition arg in args ) // _conditions.Add(arg); }
public static ConditionExpression GetStartCondition(this Stories.Graph.Graph graph, HistoryStatement history) { ConditionExpression cond = new ConditionConstant(true); var vertices = graph.Vertexes.ToList(); foreach (var val in history.Values.Where(x => x.Actions.Count == 0)) { cond = new ConditionOperation() { Left = cond, Right = val.Condition, Operation = OperationType.And }; } return(cond); }
private QueryFilter BuildIsFlaggedFilter(ConditionOperation opt, object value) { if (!(value is bool)) { return(null); } if ((bool)value) { return(this.BuildComparisonFilter(1, this.isFlaggedMapping, FlagStatus.Flagged)); } return(new OrFilter(new QueryFilter[] { this.BuildComparisonFilter(1, this.isFlaggedMapping, FlagStatus.NotFlagged), new NotFilter(this.BuildExistsFilter(this.isFlaggedMapping)) })); }
private QueryFilter BuildSizeFilter(ConditionOperation opt, object value) { int?num = null; if (value is long) { num = new int?((int)((long)value)); } else if (value is int) { num = new int?((int)value); } if (num != null) { return(this.BuildComparisonFilter(opt, this.sizeMapping, num.Value)); } return(null); }
private QueryFilter BuildAttachmentFilter(ConditionOperation opt, object value) { QueryFilter queryFilter = this.BuildTextFilter(this.attachmentMapping, (string)value, opt); if (queryFilter != null && !this.IsContentIndexingEnabled) { QueryFilter queryFilter2 = this.BuildTextFilter(this.attachmentSubMapping, (string)value, opt); if (queryFilter2 != null) { return(new OrFilter(new QueryFilter[] { queryFilter, new SubFilter(SubFilterProperties.Attachments, queryFilter2) })); } } return(queryFilter); }
private QueryFilter BuildImportanceFilter(ConditionOperation opt, object value) { int?num = null; if (value is long) { num = new int?((int)((long)value)); } else if (value is int) { num = new int?((int)value); } if (num != null) { QueryFilter queryFilter = this.BuildComparisonFilter(opt, this.importanceMapping, num.Value / 2); if (this.IsQueryConverting && queryFilter.Equals(QueryFilterBuilder.importanceHighFilter)) { queryFilter = this.BuildTextFilter(this.importanceMapping, Importance.High.ToString(), 1); } return(queryFilter); } return(null); }
private QueryFilter BuildFromFilter(ConditionOperation opt, object value) { List <QueryFilter> list = new List <QueryFilter>(); QueryFilter queryFilter = this.BuildTextFilter(this.fromMapping, (string)value, opt); if (queryFilter != null) { list.Add(queryFilter); } if (this.RecipientResolver != null) { string[] array = this.RecipientResolver.Resolve(value as string); if (array != null) { foreach (string text in array) { if (!text.Equals((string)value, StringComparison.OrdinalIgnoreCase)) { queryFilter = this.BuildTextFilter(this.fromMapping, text, 1); if (queryFilter != null) { list.Add(queryFilter); } } } } } if (list.Count <= 0) { return(null); } if (list.Count <= 1) { return(list[0]); } return(new OrFilter(list.ToArray())); }
public static string GetOperationText(ConditionOperation operation) { switch (operation) { case ConditionOperation.EQUAL: return("="); case ConditionOperation.NOT_EQUAL: return("≠"); case ConditionOperation.GREATER_THAN: return(">"); case ConditionOperation.GREATER_THAN_OR_EQUAL: return("\u2265"); case ConditionOperation.LESS_THEN: return("<"); case ConditionOperation.LESS_THAN_OR_EQUAL: return("\u2264"); } return(""); }
private QueryFilter BuildCategoryFilter(ConditionOperation opt, object value) { return(this.BuildTextFilter(this.categoryMapping, (string)value, opt)); }
public static ConditionBuilder FromSearch <TEntity>(object search) { var builder = new ConditionBuilder(); if (search == null) { return(builder); } bool isFirst = true; foreach (PropertyInfo p in search.GetType().GetProperties()) { //取得ConditionAttribute特性 var attr = p.GetCustomAttribute <ConditionAttribute>(); var ignoreWhenNull = attr != null ? attr.WhenNull == WhenNull.Ignore : true; var value = p.GetValue(search); //值为NULL的处理 if (value == null && ignoreWhenNull) { continue; } if (p.PropertyType == typeof(string) && string.IsNullOrEmpty((string)value) && ignoreWhenNull) { continue; } if (isFirst) { isFirst = false; } else { builder.And(); } //取得字段名 var name = (attr != null && !string.IsNullOrEmpty(attr.Name)) ? attr.Name : p.Name; var t = FormatTableAliasKey <TEntity>(); var field = builder.FormatFiled(t, name); ConditionOperation operation = attr != null ? attr.Operation : ConditionOperation.Equal; switch (operation) { case ConditionOperation.Equal: builder.Expression(field, "=", value); break; case ConditionOperation.NotEqual: builder.Expression(field, "<>", value); break; case ConditionOperation.In: builder.In(field, value); break; case ConditionOperation.NotIn: builder.NotIn(field, value); break; case ConditionOperation.Like: builder.Like(field, value, attr?.LeftChar, attr?.RightChar); break; case ConditionOperation.NotLike: builder.NotLike(field, value, attr?.LeftChar, attr?.RightChar); break; case ConditionOperation.Greater: builder.Expression(field, ">", value); break; case ConditionOperation.GreaterOrEqual: builder.Expression(field, ">=", value); break; case ConditionOperation.Less: builder.Expression(field, "<", value); break; case ConditionOperation.LessOrEqual: builder.Expression(field, "<=", value); break; case ConditionOperation.Custom: //自定义 var s = attr?.CustomSql; if (!string.IsNullOrEmpty(s)) { string pn = builder.GetParameterName(); s = s.Replace("@value", "@" + pn); builder.Append(s, new KeyValuePair <string, object>(pn, value)); } break; default: builder.Expression(field, "=", value); break; } } return(builder); }
/// <summary> /// 设置查询参数,都是AND模式,如果值为空,将自动不作为条件 /// </summary> /// <param name="fieldName"></param> /// <param name="condOperation"></param> /// <param name="parameterDbType"></param> /// <param name="objValue"></param> public void QuerySetCondition(string fieldName, ConditionOperation condOperation, DbType parameterDbType, object objValue) { if (objValue == null) { return; } if (string.IsNullOrWhiteSpace(objValue.ToString())) { return; } string strCond = ""; switch (condOperation) { case ConditionOperation.Equal: strCond = string.Format(" AND {0}={1}", fieldName, _buildConditionValue(parameterDbType, objValue)); break; case ConditionOperation.NotEqual: strCond = string.Format(" AND {0}<>{1}", fieldName, _buildConditionValue(parameterDbType, objValue)); break; case ConditionOperation.LessThan: strCond = string.Format(" AND {0}<{1}", fieldName, _buildConditionValue(parameterDbType, objValue)); break; case ConditionOperation.LessThanEqual: strCond = string.Format(" AND {0}<={1}", fieldName, _buildConditionValue(parameterDbType, objValue)); break; case ConditionOperation.MoreThan: strCond = string.Format(" AND {0}>{1}", fieldName, _buildConditionValue(parameterDbType, objValue)); break; case ConditionOperation.MoreThanEqual: strCond = string.Format(" AND {0}>={1}", fieldName, _buildConditionValue(parameterDbType, objValue)); break; case ConditionOperation.Like: strCond = string.Format(" AND {0} LIKE {1}", fieldName, "N'%" + SetSafeParameter(objValue.ToString()) + "%'"); break; case ConditionOperation.LikeLeft: strCond = string.Format(" AND {0} LIKE {1}", fieldName, "N'" + SetSafeParameter(objValue.ToString()) + "%'"); break; case ConditionOperation.LikeRight: strCond = string.Format(" AND {0} LIKE {1}", fieldName, "N'%" + SetSafeParameter(objValue.ToString()) + "'"); break; case ConditionOperation.In: if (typeof(IList).IsAssignableFrom(objValue.GetType())) { if (objValue is List <int> || objValue is List <Int16> || objValue is List <Int32> || objValue is List <Int64> || objValue is List <uint> || objValue is List <UInt16> || objValue is List <UInt32> || objValue is List <UInt64> || objValue is List <decimal> || objValue is List <float> || objValue is List <long> || objValue is List <double> ) { string lstStr = string.Empty; foreach (var x in (IEnumerable)objValue) { lstStr += _buildConditionValue(parameterDbType, x) + ","; } if (!string.IsNullOrEmpty(lstStr)) { lstStr = lstStr.TrimEnd(','); } if (!string.IsNullOrEmpty(lstStr)) { strCond = string.Format(" AND {0} IN ({1})", fieldName, lstStr); } } else { string lstStr = string.Empty; foreach (var x in (IEnumerable)objValue) { lstStr += _buildConditionValue(parameterDbType, x) + ","; } if (!string.IsNullOrEmpty(lstStr)) { lstStr = lstStr.TrimEnd(','); } if (!string.IsNullOrEmpty(lstStr)) { strCond = string.Format(" AND {0} IN ({1})", fieldName, lstStr); } } } else { strCond = string.Format(" AND {0} IN ({1})", fieldName, objValue.ToString()); } break; case ConditionOperation.NotIn: strCond = string.Format(" AND {0} NOT IN ({1})", fieldName, objValue.ToString()); break; default: strCond = string.Format(" AND {0}={1}", fieldName, _buildConditionValue(parameterDbType, objValue)); break; } m_QueryConditionString += strCond; }
private QueryFilter BuildCcFilter(ConditionOperation opt, object value) { return(this.BuildRecipientFilter(this.ccMapping, opt, value)); }
internal QueryFilter BuildAllFilter(ConditionOperation opt, object value) { PropertyKeyword[] array2; switch (this.RescopedAll) { case RescopedAll.Default: return(this.BuildTextFilter(this.allMapping, (string)value, opt)); case RescopedAll.Subject: { PropertyKeyword[] array = new PropertyKeyword[1]; array2 = array; break; } case RescopedAll.Body: array2 = new PropertyKeyword[] { PropertyKeyword.Body }; break; case RescopedAll.BodyAndSubject: array2 = new PropertyKeyword[] { PropertyKeyword.Subject, PropertyKeyword.Body }; break; case RescopedAll.From: array2 = new PropertyKeyword[] { PropertyKeyword.From }; break; case RescopedAll.Participants: array2 = new PropertyKeyword[] { PropertyKeyword.Participants }; break; default: throw new ArgumentException("RescopedAll"); } List <QueryFilter> list = new List <QueryFilter>(); foreach (PropertyKeyword key in array2) { QueryFilter queryFilter = this.filterBuilderMap[key](opt, value); if (queryFilter != null) { list.Add(queryFilter); } } if (list.Count <= 0) { return(null); } if (list.Count <= 1) { return(list[0]); } return(new OrFilter(list.ToArray())); }
private QueryFilter BuildExpiresFilter(ConditionOperation opt, object value) { ExDateTime exDateTime = new ExDateTime(ExTimeZone.UtcTimeZone, ((DateTime)value).ToUniversalTime()); return(this.BuildComparisonFilter(opt, this.expiresMapping, exDateTime)); }
private QueryFilter BuildPolicyTagFilter(ConditionOperation opt, object value) { string tagName = value as string; if (string.IsNullOrEmpty(tagName)) { return(null); } List <QueryFilter> list = new List <QueryFilter>(); if (QueryFilterBuilder.guidRegex.Match(tagName).Success) { Guid guid = Guid.Empty; try { guid = new Guid(tagName); list.Add(this.BuildComparisonFilter(ComparisonOperator.Equal, this.policyTagMapping, guid.ToByteArray())); } catch (FormatException) { } } IEnumerable <PolicyTag> enumerable = null; if (this.PolicyTagProvider != null) { PolicyTag[] policyTags = this.PolicyTagProvider.PolicyTags; if (policyTags != null) { switch (opt) { case 1: case 12: enumerable = from x in policyTags where x.Name.Equals(tagName, StringComparison.OrdinalIgnoreCase) select x; break; case 7: case 8: case 9: case 11: case 13: { Regex regex = new Regex(tagName, RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant); enumerable = from x in policyTags where regex.Match(x.Name).Success select x; break; } } } } if (enumerable != null) { foreach (PolicyTag policyTag in enumerable) { list.Add(this.BuildComparisonFilter(ComparisonOperator.Equal, this.policyTagMapping, policyTag.PolicyGuid.ToByteArray())); } } if (list.Count <= 0) { return(null); } if (list.Count <= 1) { return(list[0]); } return(new OrFilter(list.ToArray())); }
private QueryFilter BuildAttachmentNamesFilter(ConditionOperation opt, object value) { return(this.BuildTextFilter(this.attachmentNamesMapping, (string)value, opt)); }
public Expression BuildExpression(string name, string value, ConditionOperation operation) { var property = _targetType.GetProperty(name); if (property == null) { return(null); } Type realType = Nullable.GetUnderlyingType(property.PropertyType) ?? property.PropertyType; Expression <Func <object> > valueLamba = () => Convert.ChangeType(value, realType); Func <Expression, Expression, Expression> Append = (exp1, exp2) => { if (exp1 == null) { return(exp2); } return(Expression.AndAlso(exp1, exp2)); }; switch (operation) { case ConditionOperation.Equal: { _expression = Append(_expression, Expression.Equal(Expression.Property(_parameter, name), Expression.Convert(valueLamba.Body, property.PropertyType))); break; } case ConditionOperation.GreaterThan: { _expression = Append(_expression, Expression.GreaterThan(Expression.Property(_parameter, name), Expression.Convert(valueLamba.Body, property.PropertyType))); break; } case ConditionOperation.GreaterThanOrEqual: { _expression = Append(_expression, Expression.GreaterThanOrEqual(Expression.Property(_parameter, name), Expression.Convert(valueLamba.Body, property.PropertyType))); break; } case ConditionOperation.LessThan: { _expression = Append(_expression, Expression.LessThan(Expression.Property(_parameter, name), Expression.Convert(valueLamba.Body, property.PropertyType))); break; } case ConditionOperation.LessThanOrEqual: { _expression = Append(_expression, Expression.LessThanOrEqual(Expression.Property(_parameter, name), Expression.Convert(valueLamba.Body, property.PropertyType))); break; } case ConditionOperation.Contains: { var nullCheck = Expression.Not(Expression.Call(typeof(string), "IsNullOrEmpty", null, Expression.Property(_parameter, name))); var contains = Expression.Call(Expression.Property(_expression, name), "Contains", null, Expression.Convert(valueLamba.Body, property.PropertyType)); _expression = Append(_expression, Expression.AndAlso(nullCheck, contains)); break; } } if (_expression == null) { return(null); } return(_expression); }
private QueryFilter BuildTextFilter(PropertyDefinition[] properties, string propertyValue, ConditionOperation opt) { if (string.IsNullOrEmpty(propertyValue)) { return(null); } MatchOptions matchOption; switch (opt) { case 1: case 12: matchOption = MatchOptions.ExactPhrase; goto IL_69; case 7: case 13: matchOption = (this.IsContentIndexingEnabled ? MatchOptions.PrefixOnWords : MatchOptions.SubString); goto IL_69; case 8: case 9: matchOption = MatchOptions.SubString; goto IL_69; case 11: matchOption = MatchOptions.WildcardString; goto IL_69; } return(null); IL_69: int num; if (!this.ShortWildcardsAllowed && (propertyValue.Length <= 1 || (propertyValue.Length <= 4 && int.TryParse(propertyValue, NumberStyles.Integer, this.culture, out num)))) { matchOption = MatchOptions.ExactPhrase; } return(this.BuildTextFilter(properties, propertyValue, matchOption, MatchFlags.Loose)); }
public FilterCondition(L leftOperand, R rightOperand, ConditionOperation operation) { this.LeftOperand = leftOperand; this.Operation = operation; this.RightOperand = rightOperand; }
string GetOperationText(SerializedProperty operationProp) { ConditionOperation operation = (ConditionOperation)operationProp.intValue; return(Condition.GetOperationText(operation)); }