public int SaveWorkConditionalOperatorDetails(ConditionalOperator conditionlOperator) { try { if (conditionlOperator.Id != 0) { var conditionalOperatorDetails = _conditionalDataRepository.FirstOrDefault(x => x.Id == conditionlOperator.Id); conditionalOperatorDetails.Variable1 = conditionlOperator.Variable1; conditionalOperatorDetails.Variable2 = conditionlOperator.Variable2; conditionalOperatorDetails.Condition = conditionlOperator.Condition; conditionalOperatorDetails.CreatedDateTime = DateTime.UtcNow; conditionalOperatorDetails.Operator = conditionlOperator.Operator; conditionalOperatorDetails.WorkFlowDetailId = conditionlOperator.WorkFlowDetailId; conditionalOperatorDetails.ParentConditionalOperatorId = conditionlOperator.ParentConditionalOperatorId; conditionalOperatorDetails.ModifiedDateTime = DateTime.UtcNow; _conditionalDataRepository.Update(conditionalOperatorDetails); _conditionalDataRepository.SaveChanges(); return(conditionalOperatorDetails.Id); } else { conditionlOperator.CreatedDateTime = DateTime.UtcNow; _conditionalDataRepository.Add(conditionlOperator); _conditionalDataRepository.SaveChanges(); return(conditionlOperator.Id); } } catch (Exception ex) { _errorLog.LogException(ex); throw; } }
/// <summary> /// 转换为sql条件字符串 /// </summary> /// <param name="key">关键字.</param> /// <param name="oper">条件运算符</param> /// <param name="link">操作类型.</param> /// <returns> /// System.String /// </returns> public string ToWhereString(string key, ConditionalOperator oper, LogicalOperator link) { if (Value == null) { return(""); } string result = ""; string column = !string.IsNullOrEmpty(key) ? key : Name; string query = ToCriteria(column, Value, oper); #region 处理逻辑运算符 if (query != "") { switch (link) { case LogicalOperator.Or: result = " OR (" + query + ")"; break; case LogicalOperator.And: default: result = " AND (" + query + ")"; break; } } #endregion return(result); }
public void TranslateConditional(ConditionalOperator type) { if (this.IsPredicateFunction()) { builder.Append($" {operators[type]} "); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="name"></param> /// <param name="value"></param> /// <param name="oper"></param> /// <param name="link"></param> public Condition(string name, string value, ConditionalOperator oper, LogicalOperator link) { Name = name; Value = value; Oper = oper; Link = link; }
/****************************************************************************************************************/ private void CreateSqlCondition() { this.cond = null; ConditionalOperator copt = this.and_radioButton.Checked ? ConditionalOperator.And : ConditionalOperator.Or; foreach (Filter_UserControl fuc in this.ctl_list) { SQL_relation rela = fuc.SQL_Rela; if (rela == null) { continue; } if (this.cond == null) { this.cond = new SQL_condition(rela); } else { this.cond = new SQL_condition(this.cond, copt, rela); } } this.Close(); }
/// <summary> /// 收集查询条件 /// </summary> /// <param name="node"><![CDATA[格式:<Id Oper="" Link="">1</Id>]]></param> /// <returns></returns> public static Condition Collection(XmlNode node) { //条件运算符 "="相等[Equal],"!"不等[Unequal],"%"包含[Contain],"^"开头[Front],"$"结尾[End] ConditionalOperator oper = ParseOper(node.Attributes != null && node.Attributes["Oper"] != null ? node.Attributes["Oper"].Value : "="); LogicalOperator link = node.Attributes != null && node.Attributes["Link"] != null && node.Attributes["Link"].Value.ToUpper() == "OR" ? LogicalOperator.Or : LogicalOperator.And; return(new Condition(node.Name, node.InnerText, oper, link)); }
public virtual bool VisitConditionalOperator(ConditionalOperator stmt) { if (!VisitAbstractConditionalOperator(stmt)) { return(false); } return(true); }
public SearchConstraint AddRule(string fieldName, object data, ConditionalOperator conditionalOperator) { this.Rules.Add(new ConstraintRule { Field = fieldName, Data = data.ToString(), Operator = conditionalOperator }); return(this); }
protected string ShowCondition(object conditionalOperator) { ConditionalOperator condition = (ConditionalOperator)conditionalOperator; if (condition == ConditionalOperator.Equal) { return("who answered"); } else { return("who didn't answer"); } }
private bool EvaluateString(StringGameProperty quality, ConditionalOperator @operator, string value) { switch (_operator) { case ConditionalOperator.NotEqualTo: return(quality.CurrentValue != value); case ConditionalOperator.EqualTo: return(quality.CurrentValue == value); default: throw new NotSupportedException("Opertor not supported"); } }
protected BaseAttribute(string displayName, string errorMessage) { this.DisplayName = displayName; base.ErrorMessage = errorMessage; this.Order = 10000; this.ShowForDisplay = true; this.ShowForEdit = true; this.RequiredFlag = false; this.ColumnLabel = displayName; this.ColumnAlign = Align.Center; this.ColumnWidth = 150; this.ColumnSortable = true; this.FilterLabel = displayName; this.SearchOperator = ConditionalOperator.Equal; }
public static void Main() { ConditionalOperator s = new ConditionalOperator(); s.CompareEqualI1((sbyte)0x02, (sbyte)0x02, (sbyte)0x05, (sbyte)0x01); s.CompareEqualI1((sbyte)0x60, (sbyte)0x00, (sbyte)0x60, (sbyte)0x06); s.CompareEqualI1((sbyte)1, (sbyte)0, (sbyte)1, (sbyte)2); s.CompareEqualI1((sbyte)2, (sbyte)2, (sbyte)2, (sbyte)1); Add add = new Add(); add.AddConstantCLeft('a', 'Z'); add.AddConstantCLeft('a', 'Z'); add.AddConstantCLeft('a', 'Z'); return; }
/// <summary> /// 追加查询条件,name存在时作更新处理 /// </summary> /// <param name="name"></param> /// <param name="value"></param> /// <param name="oper"></param> /// <param name="link"></param> public void AppendCondition(string name, string value, ConditionalOperator oper, LogicalOperator link) { if (Condition == null) { Condition = new List <Condition>(); } if (Condition.Any(n => n.Name == name)) { Condition cond = Condition.FirstOrDefault(c => c.Name == name); cond.Value = value; cond.Oper = oper; cond.Link = link; } else { Condition.Add(new Condition(name, value, oper, link)); } }
public string Generate(ConditionalOperator @operator) { switch (@operator) { case ConditionalOperator.And: return("&&"); case ConditionalOperator.Or: return("||"); case ConditionalOperator.Equal: return("=="); case ConditionalOperator.NotEqual: return("!="); } throw new NotImplementedException(); }
private string Create_SQL_str(SQL_condition con1, ConditionalOperator opt, SQL_relation rela2) { if (SQL_condition.IsNull_or_Empty(con1) && SQL_relation.IsNull_or_Empty(rela2)) { return(null); } if (SQL_condition.IsNull_or_Empty(con1)) { return(rela2.SQL_str); } if (SQL_relation.IsNull_or_Empty(rela2)) { return(con1.SQL_str); } SQL_condition con2 = new SQL_condition(rela2); return(this.Create_SQL_str(con1, opt, con2)); }
private bool EvaluateInteger(IntegerGameProperty quality, ConditionalOperator @operator, int value) { switch (_operator) { case ConditionalOperator.NotEqualTo: return(quality.CurrentValue != value); case ConditionalOperator.EqualTo: return(quality.CurrentValue == value); case ConditionalOperator.GreaterThan: return(quality.CurrentValue > value); case ConditionalOperator.LessThan: return(quality.CurrentValue < value); default: throw new NotSupportedException("Opertor not supported"); } }
private static string GetOperatorFormatExpression(ConditionalOperator constraintOperator) { string result = "it.{0}.toLower().{1}(@{2})"; if (constraintOperator <= ConditionalOperator.Contains) { if (constraintOperator != ConditionalOperator.BeginsWith) { if (constraintOperator == ConditionalOperator.NotBeginsWith) { result = "!it.{0}.toLower().{1}(@{2})"; } if (constraintOperator != ConditionalOperator.Contains) { result = "it.{0} {1} @{2}"; } } } else { if (constraintOperator == ConditionalOperator.NotContains) { result = "!it.{0}.toLower().{1}(@{2})"; } else if (constraintOperator != ConditionalOperator.EndsWith) { if (constraintOperator != ConditionalOperator.NotEndsWith) { result = "it.{0} {1} @{2}"; } else { result = "!it.{0}.toLower().{1}(@{2})"; } } } return(result); }
private string Create_SQL_str(SQL_condition con1, ConditionalOperator opt, SQL_condition con2) { if (SQL_condition.IsNull_or_Empty(con1) && SQL_condition.IsNull_or_Empty(con2)) { return(null); } if (SQL_condition.IsNull_or_Empty(con1)) { return(con2.SQL_str); } if (SQL_condition.IsNull_or_Empty(con2)) { return(con1.SQL_str); } StringBuilder sb = new StringBuilder("("); sb.Append(con1.SQL_str); sb.Append(' ').Append(opt.ToString()).Append(' '); sb.Append(con2.SQL_str); sb.Append(')'); return(sb.ToString()); }
/// <summary> /// 追加查询条件,name存在时作更新处理 /// </summary> /// <param name="name"></param> /// <param name="value"></param> /// <param name="oper"></param> public void AppendCondition(string name, string value, ConditionalOperator oper) { AppendCondition(name, value, oper, LogicalOperator.And); }
public IHttpActionResult SaveWorkFlowDetails(WorkFlowAc workFlowDetails) { try { if (HttpContext.Current.User.Identity.IsAuthenticated) { var userId = HttpContext.Current.User.Identity.GetUserId(); var companyDetails = _companyDataRepository.FirstOrDefault(x => x.UserId == userId); if (companyDetails != null) { foreach (var workFlow in workFlowDetails.Permission) { if (workFlow != null) { if (workFlow.IsApproval || workFlow.IsReview || workFlow.IsClosed || workFlow.IsCondition) { var workFlowDetail = new WorkFlowDetail { WorkFlowName = workFlowDetails.WorkFlowName, WorkFlowId = workFlowDetails.PermissionId, InitiatorId = workFlow.InitiatorId, AssignedId = workFlow.AssignedId, //OldStatusId = workFlow.OldStatus, //NewStatusId = workFlow.NewStatus, //CreatedDateTime = DateTime.UtcNow, CreatedBy = HttpContext.Current.User.Identity.GetUserId(), IsApproval = workFlow.IsApproval, IsReview = workFlow.IsReview, // WorkFlowActionId = workFlow.ActionId, CompanyId = companyDetails.Id, ActivityId = workFlow.ActivityId, NextActivityId = workFlow.NextActivityId, IsClosed = workFlow.IsClosed, IsParentAction = true, Id = workFlowDetails.workFlowActionId, //Variable1 = workFlow.Variable1, //Variable2 = workFlow.Variable2, //Operator = workFlow.Operator, IsCondition = workFlow.IsCondition, IsAllowOtherBranchUser = workFlow.IsAllowOtherBranchUser, ParentActivityId = 0, }; IsChildCondtion = workFlowDetail.IsCondition; _parentActivityId = _workFlowRepository.SaveWorkFlowActionDetails(workFlowDetail); if (workFlow.IsCondition) { foreach (var workFlowConditionalOperator in workFlow.ConditionalOperator) { //if (workFlowConditionalOperator.ConditionInfo == null) //{ var conditionlOperator = new ConditionalOperator { Id = workFlowConditionalOperator.ConditionalOperatorId, Variable1 = workFlowConditionalOperator.Variable1, Variable2 = workFlowConditionalOperator.Variable2, Condition = workFlowConditionalOperator.ConditionInfo, //CreatedDateTime = DateTime.UtcNow, Operator = workFlowConditionalOperator.Operator, WorkFlowDetailId = _parentActivityId, IsBoolenCondtion = workFlowConditionalOperator.IsBoolenCondtion, ParentConditionalOperatorId = _conditionalOperatorParentId }; _conditionalOperatorParentId = _workFlowRepository.SaveWorkConditionalOperatorDetails(conditionlOperator); // } //else //{ // var conditionlOperator = new ConditionalOperator // { // Id = workFlowConditionalOperator.ConditionalOperatorId, // Variable1 = workFlowConditionalOperator.Variable1, // Variable2 = workFlowConditionalOperator.Variable2, // Condition = workFlowConditionalOperator.ConditionInfo, // CreatedDateTime = DateTime.UtcNow, // Operator = workFlowConditionalOperator.Operator, // WorkFlowDetailId = _parentActivityId, // ParentConditionalOperatorId = _conditionalOperatorParentId // }; // _conditionalOperatorChildId = // _workFlowRepository.SaveWorkConditionalOperatorDetails(conditionlOperator); //} } } } else { var workFlowDetail = new WorkFlowDetail { // WorkFlowName = workFlowDetails.WorkFlowName, WorkFlowId = workFlowDetails.PermissionId, InitiatorId = workFlow.InitiatorId, AssignedId = workFlow.AssignedId, //OldStatusId = workFlow.OldStatus, //NewStatusId = workFlow.NewStatus, //CreatedDateTime = DateTime.UtcNow, CreatedBy = HttpContext.Current.User.Identity.GetUserId(), IsApproval = workFlow.IsApproval, IsReview = workFlow.IsReview, // WorkFlowActionId = workFlow.ActionId, CompanyId = companyDetails.Id, ActivityId = workFlow.ActivityId, NextActivityId = workFlow.NextActivityId, IsClosed = workFlow.IsClosed, IsApprovePanel = workFlow.IsApprovePanel, IsRejectPanel = workFlow.IsRejectPanel, ParentActivityId = _parentActivityId, IsChildAction = true, IsAllowOtherWorkFlow = workFlow.IsAllowOtherWorkFlow, OtherWorkFlowId = workFlow.OtherWorkFlowId, Id = workFlow.workFlowActionId, IsAllowOtherBranchUser = workFlow.IsAllowOtherBranchUser, //Variable2 = workFlow.Variable2, // Variable1 = workFlow.Variable1, //Operator = workFlow.Operator, IsCondition = workFlow.IsCondition, IsChildCondition = IsChildCondtion, }; _childActivityId = _workFlowRepository.SaveWorkFlowDetails(workFlowDetail); } } } workFlowDetails.PermissionId = _parentActivityId; } //var workFlowCollection = _workFlowRepository.GetWorkFlowDetailsForTreeViewByActivityId(workFlowDetails.ActivityId); return(Ok(workFlowDetails)); } else { return(BadRequest()); } } catch (Exception ex) { _errorLog.LogException(ex); throw; } }
private static string GetLinqOperator(ConditionalOperator constraintOperator) { string result = string.Empty; if (constraintOperator > ConditionalOperator.BeginsWith) { if (constraintOperator <= ConditionalOperator.Contains) { if (constraintOperator == ConditionalOperator.NotBeginsWith) { result = "StartsWith"; } return(result); } else { if (constraintOperator != ConditionalOperator.NotContains) { if (constraintOperator != ConditionalOperator.EndsWith && constraintOperator != ConditionalOperator.NotEndsWith) { return(result); } result = "EndsWith"; return(result);; } } result = "Contains"; return(result); } if (constraintOperator <= ConditionalOperator.LessThanOrEqual) { switch (constraintOperator) { case ConditionalOperator.Equal: result = "="; return(result); case ConditionalOperator.NotEqual: result = "!="; return(result); case ConditionalOperator.Equal | ConditionalOperator.NotEqual: return(result); case ConditionalOperator.LessThan: result = "<"; return(result); default: if (constraintOperator != ConditionalOperator.LessThanOrEqual) { return(result); } result = "<="; return(result); } } else { if (constraintOperator == ConditionalOperator.GreaterThan) { result = ">"; } if (constraintOperator == ConditionalOperator.GreaterThanOrEqual) { result = ">="; } if (constraintOperator != ConditionalOperator.BeginsWith) { } return(result); } }
public SQL_condition(SQL_relation rela1, ConditionalOperator opt, SQL_condition con2) { this.SQL_str = this.Create_SQL_str(con2, opt, rela1); }
protected string FormatRule(object conditionalOperator, string questionText, string answerText, string textFilter, string scoreText, string scoreMaxText, object expressionCondition) { ConditionalOperator condition = (ConditionalOperator)conditionalOperator; questionText = new Questions().ParseHTMLTagsFromQuestionText(questionText, 40); if (condition == ConditionalOperator.ScoredLess) { return(string.Format(((PageBase)Page).GetPageResource("SkipLogicRuleScoreLess"), scoreText, questionText)); } else if (condition == ConditionalOperator.ScoreGreater) { return(string.Format(((PageBase)Page).GetPageResource("SkipLogicRuleScoreGreater"), scoreText, questionText)); } else if (condition == ConditionalOperator.ScoreRange) { return(string.Format(((PageBase)Page).GetPageResource("SkipLogicRuleScoreRange"), scoreText, scoreMaxText, questionText)); } else if (condition == ConditionalOperator.ScoreEquals) { return(string.Format(((PageBase)Page).GetPageResource("SkipLogicRuleScoreEqual"), scoreText, questionText)); } else { if (answerText.Length == 0) { if (condition == ConditionalOperator.Equal) { return(string.Format(((PageBase)Page).GetPageResource("SkipLogicRuleNoAnswer"), Server.HtmlEncode(System.Text.RegularExpressions.Regex.Replace(questionText, "<[^>]*>", " ")))); } else { return(string.Format(((PageBase)Page).GetPageResource("SkipLogicRuleNoAnswerNot"), Server.HtmlEncode(System.Text.RegularExpressions.Regex.Replace(questionText, "<[^>]*>", " ")))); } } else if (textFilter.Length == 0) { if (condition == ConditionalOperator.Equal) { return(string.Format(((PageBase)Page).GetPageResource("SkipLogicRuleAnswer"), Server.HtmlEncode(System.Text.RegularExpressions.Regex.Replace(questionText, "<[^>]*>", " ")), Server.HtmlEncode(System.Text.RegularExpressions.Regex.Replace(answerText, "<[^>]*>", " ")))); } else { return(string.Format(((PageBase)Page).GetPageResource("SkipLogicRuleAnswerNot"), Server.HtmlEncode(System.Text.RegularExpressions.Regex.Replace(questionText, "<[^>]*>", " ")), Server.HtmlEncode(System.Text.RegularExpressions.Regex.Replace(answerText, "<[^>]*>", " ")))); } } else { string conditionText; ExpressionConditionalOperator conditionOperator = ExpressionConditionalOperator.Contains; if (expressionCondition.ToString().Length > 0) { conditionOperator = (ExpressionConditionalOperator)expressionCondition; } switch (conditionOperator) { case ExpressionConditionalOperator.Equals: { conditionText = (((PageBase)Page).GetPageResource("EqualsOperator")).ToLower(); break; } case ExpressionConditionalOperator.GreaterThan: { conditionText = (((PageBase)Page).GetPageResource("GreaterThanOperator")).ToLower(); break; } case ExpressionConditionalOperator.LessThan: { conditionText = (((PageBase)Page).GetPageResource("LessThanOperator")).ToLower(); break; } default: { conditionText = (((PageBase)Page).GetPageResource("ContainsOperator")).ToLower(); break; } } if (condition == ConditionalOperator.Equal) { return(string.Format(((PageBase)Page).GetPageResource("SkipLogicRuleAnswerWithText"), Server.HtmlEncode(System.Text.RegularExpressions.Regex.Replace(questionText, "<[^>]*>", " ")), Server.HtmlEncode(System.Text.RegularExpressions.Regex.Replace(answerText, "<[^>]*>", " ")), conditionText, Server.HtmlEncode(System.Text.RegularExpressions.Regex.Replace(textFilter, "<[^>]*>", " ")))); } else { return(string.Format(((PageBase)Page).GetPageResource("SkipLogicRuleAnswerWithTextNot"), Server.HtmlEncode(System.Text.RegularExpressions.Regex.Replace(questionText, "<[^>]*>", " ")), Server.HtmlEncode(System.Text.RegularExpressions.Regex.Replace(answerText, "<[^>]*>", " ")), conditionText, Server.HtmlEncode(System.Text.RegularExpressions.Regex.Replace(textFilter, "<[^>]*>", " ")))); } } } }
public static ExpressionToken TryParse(Scope scope, IEnumerable <string> endTokens, WordTokenCallback wordCallback = null, DataType expectedDataType = null) { var code = scope.Code; code.SkipWhiteSpace(); var startPos = code.Position; // Statement breaking tokens if (code.PeekExact(';') || code.PeekExact('{') || code.PeekExact('}')) { return(null); } // Caller-specific end tokens if (endTokens != null) { code.Peek(); if (endTokens.Contains(code.Text)) { return(null); } } var exp = new ExpressionToken(scope); var dataTypeArgs = new DataType.ParseArgs { Code = code, DataTypeCallback = (name) => { return(scope.DefinitionProvider.GetAny <DataTypeDefinition>(code.Position, name).FirstOrDefault()); }, VariableCallback = (name) => { return(scope.DefinitionProvider.GetLocal <VariableDefinition>(code.Position, name).FirstOrDefault()); }, Scope = scope, TokenCreateCallback = (token) => { exp.AddToken(token); }, VisibleModel = true }; var abortParsing = false; var parseDataType = expectedDataType; while (!code.EndOfFile && !abortParsing) { // Statement breaking tokens if (code.PeekExact(';') || code.PeekExact('{') || code.PeekExact('}')) { break; } if (endTokens != null && code.Peek() && endTokens.Contains(code.Text)) { break; } if (!code.Read()) { break; } switch (code.Type) { case CodeType.Word: { var word = code.Text; var wordSpan = code.Span; Token token; if (wordCallback != null && (token = wordCallback(word, wordSpan)) != null) { exp.AddToken(token); } else if (parseDataType != null && parseDataType.HasCompletionOptions && parseDataType.IsValidEnumOption(word)) { exp.AddToken(new EnumOptionToken(scope, wordSpan, word, parseDataType)); } else { var oldPos = code.Position; code.Position = wordSpan.Start; // DataType.TryParse() needs to be before the first word var dt = DataType.TryParse(dataTypeArgs); if (dt == null) { code.Position = oldPos; var wordToken = ProcessWord(exp, scope, word, wordSpan); if (wordToken != null) { exp.AddToken(wordToken); } else { code.Position = wordSpan.Start; abortParsing = true; } } } } break; case CodeType.Number: exp.AddToken(new NumberToken(scope, code.Span, code.Text)); break; case CodeType.StringLiteral: if (parseDataType != null && parseDataType.HasCompletionOptions && parseDataType.IsValidEnumOption(code.Text)) { exp.AddToken(new EnumOptionToken(scope, code.Span, code.Text, parseDataType)); } else { exp.AddToken(new StringLiteralToken(scope, code.Span, code.Text)); } break; case CodeType.Operator: switch (code.Text) { case "(": { code.Position = code.Span.Start; var bracketsToken = BracketsToken.Parse(scope, parseDataType); if (bracketsToken.IsCast) { exp.AddToken(Statements.CastStatement.Parse(scope, bracketsToken, endTokens)); } else { exp.AddToken(bracketsToken); } } break; case "{": code.Position = code.Span.Start; exp.AddToken(BracesToken.Parse(scope, null)); break; case "[": code.Position = code.Span.Start; exp.AddToken(ArrayBracesToken.Parse(scope)); break; case ",": exp.AddToken(new DelimiterToken(scope, code.Span)); break; case ".": exp.AddToken(new DotToken(scope, code.Span)); break; case "&": exp.AddToken(new ReferenceToken(scope, code.Span)); break; case "==": case "!=": case "<": case "<=": case ">": case ">=": if ((scope.Hint & ScopeHint.SuppressLogic) == 0) { if (exp.ChildrenCount > 0) { var dataType = exp.LastChild.ValueDataType; if (dataType != null) { parseDataType = dataType; } } exp.AddToken(ComparisonOperator.Parse(scope, exp.LastChild, new OperatorToken(scope, code.Span, code.Text), endTokens)); } else { exp.AddToken(new OperatorToken(scope, code.Span, code.Text)); } break; case "=": if ((scope.Hint & ScopeHint.SuppressLogic) == 0) { if (exp.ChildrenCount > 0) { var dataType = exp.LastChild.ValueDataType; if (dataType != null) { parseDataType = dataType; } } exp.AddToken(AssignmentOperator.Parse(scope, exp.LastChild, new OperatorToken(scope, code.Span, code.Text), endTokens)); } else { exp.AddToken(new OperatorToken(scope, code.Span, code.Text)); } break; case "+=": case "-=": case "*=": case "/=": case "%=": if ((scope.Hint & ScopeHint.SuppressLogic) == 0) { exp.AddToken(AssignmentOperator.Parse(scope, exp.LastChild, new OperatorToken(scope, code.Span, code.Text), endTokens)); } else { exp.AddToken(new OperatorToken(scope, code.Span, code.Text)); } break; case "?": parseDataType = expectedDataType; exp.AddToken(ConditionalOperator.Parse(scope, exp.LastChild, new OperatorToken(scope, code.Span, code.Text), endTokens, parseDataType)); break; default: exp.AddToken(new OperatorToken(scope, code.Span, code.Text)); break; } break; case CodeType.Preprocessor: exp.AddToken(new PreprocessorToken(scope, code.Span, code.Text)); break; default: exp.AddToken(new UnknownToken(scope, code.Span, code.Text)); break; } } if (exp.ChildrenCount == 0) { return(null); } return(exp); }
public SQL_condition(SQL_condition con1, ConditionalOperator opt, SQL_condition con2) { this.SQL_str = this.Create_SQL_str(con1, opt, con2); }
internal TriggerCondition(ConditionalOperator thresholdOperator, double threshold, LogMetricTrigger metricTrigger) { ThresholdOperator = thresholdOperator; Threshold = threshold; MetricTrigger = metricTrigger; }
/// <summary> /// Sets search option for column /// </summary> /// <param name="searchOption">Search option</param> public JQColumn SetSearchOption(ConditionalOperator searchOption) { var searchOptionValues = Enum.GetValues(typeof(ConditionalOperator)); foreach (ConditionalOperator value in searchOptionValues) { if ((searchOption & value) == value) { switch (value) { case ConditionalOperator.Equal: searchOptions.Add("eq"); break; case ConditionalOperator.NotEqual: searchOptions.Add("ne"); break; case ConditionalOperator.Less: searchOptions.Add("lt"); break; case ConditionalOperator.LessOrEqual: searchOptions.Add("le"); break; case ConditionalOperator.Greater: searchOptions.Add("gt"); break; case ConditionalOperator.GreaterOrEqual: searchOptions.Add("ge"); break; case ConditionalOperator.BeginsWith: searchOptions.Add("bw"); break; case ConditionalOperator.DoesNotBeginWith: searchOptions.Add("bn"); break; case ConditionalOperator.IsIn: searchOptions.Add("in"); break; case ConditionalOperator.IsNotIn: searchOptions.Add("ni"); break; case ConditionalOperator.EndsWith: searchOptions.Add("ew"); break; case ConditionalOperator.DoesNotEndWith: searchOptions.Add("en"); break; case ConditionalOperator.Contains: searchOptions.Add("cn"); break; case ConditionalOperator.DoesNotContain: searchOptions.Add("nc"); break; } } } return(this); }
/// <summary> /// 转换为条件(不带连接符) /// </summary> /// <param name="column"></param> /// <param name="value"></param> /// <param name="oper"></param> /// <returns></returns> public string ToCriteria(string column, string value, ConditionalOperator oper) { string query = string.Empty; #region 处理条件运算符 switch (oper) { case ConditionalOperator.Unequal: query = column + "<>'" + value + "'"; break; case ConditionalOperator.Contain: query = column + " LIKE '%" + value + "%'"; break; case ConditionalOperator.Uncontain: query = column + " NOT LIKE '%" + value + "%'"; break; case ConditionalOperator.Front: query = column + " LIKE '" + value + "%'"; break; case ConditionalOperator.NotFront: query = column + " NOT LIKE '" + value + "%'"; break; case ConditionalOperator.End: query = column + " LIKE '%" + value + "'"; break; case ConditionalOperator.NotEnd: query = column + " NOT LIKE '%" + value + "'"; break; case ConditionalOperator.Less: query = column + "<'" + value + "'"; break; case ConditionalOperator.Greater: query = column + ">'" + value + "'"; break; case ConditionalOperator.LessEqual: query = column + "<='" + value + "'"; break; case ConditionalOperator.GreaterEqual: query = column + ">='" + value + "'"; break; case ConditionalOperator.In: if (value != "") { string[] vals = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); query = column + " IN(" + string.Join(",", vals) + ")"; } break; case ConditionalOperator.NotIn: if (value != "") { string[] vals = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); query = column + " NOT IN(" + string.Join(",", vals) + ")"; } break; case ConditionalOperator.IsNull: query = column + " IS NULL"; break; case ConditionalOperator.NotNull: query = column + " IS NOT NULL"; break; case ConditionalOperator.Segment: try { if (!string.IsNullOrWhiteSpace(value)) { string[] segment = value.Split(",".ToCharArray()[0]); List <string> likes = new List <string>(); if (segment.Length > 0) { foreach (string s in segment) { likes.Add("{0} LIKE '%" + s + "%'"); } } else { likes.Add("{0} LIKE '%" + value + "%'"); } string likeStr = string.Join(" AND ", likes); query = "(" + string.Format(likeStr, column) + ")"; } } catch (Exception ex) { new ECFException(ex); } break; case ConditionalOperator.NumberRange: try { string[] num = value.Split(','); decimal? minNum = null; decimal? maxNum = null; if (num.Length >= 1 && !string.IsNullOrWhiteSpace(num[0])) { minNum = Utils.ToDecimal(num[0]); } if (num.Length == 2 && !string.IsNullOrWhiteSpace(num[1])) { maxNum = Utils.ToDecimal(num[1]); } if (minNum != null && maxNum != null) { query = "(" + column + " between " + minNum + " AND " + maxNum + ")"; } else if (minNum != null) { query = column + ">=" + minNum + ""; } else if (maxNum != null) { query = column + "<=" + maxNum + ""; } } catch (Exception ex) { new ECFException(ex.Message, ex); } break; case ConditionalOperator.DateRange: try { string[] date = value.Split(','); string minDate = null; string maxDate = null; if (date.Length >= 1 && !string.IsNullOrWhiteSpace(date[0])) { minDate = date[0] + " 00:00:00"; } if (date.Length == 2 && !string.IsNullOrWhiteSpace(date[1])) { maxDate = date[1] + " 23:59:59"; } if (minDate != null && maxDate != null) { query = "(" + column + " between '" + minDate + "' AND '" + maxDate + "')"; } else if (minDate != null) { query = column + ">='" + minDate + "'"; } else if (maxDate != null) { query = column + "<='" + maxDate + "'"; } } catch (Exception ex) { new ECFException(ex.Message, ex); } break; case ConditionalOperator.DateTimeRange: try { string[] dateTime = value.Split(','); string minDateTime = null; string maxDateTime = null; if (dateTime.Length >= 1 && !string.IsNullOrWhiteSpace(dateTime[0])) { minDateTime = dateTime[0]; } if (dateTime.Length == 2 && !string.IsNullOrWhiteSpace(dateTime[1])) { maxDateTime = dateTime[1]; } if (minDateTime != null && maxDateTime != null) { query = "(" + column + " between '" + minDateTime + "' AND '" + maxDateTime + "')"; } else if (minDateTime != null) { query = column + ">='" + minDateTime + "'"; } else if (maxDateTime != null) { query = column + "<='" + maxDateTime + "'"; } } catch (Exception ex) { new ECFException(ex.Message, ex); } break; case ConditionalOperator.Equal: default: query = column + "='" + value + "'"; break; } #endregion return(query); }
public bool VisitConditionalOperator(ConditionalOperator stmt) { throw new NotImplementedException(); }
/// <summary> /// 转换为sql条件字符串 /// </summary> /// <param name="key"></param> /// <param name="oper"></param> /// <returns></returns> public string ToWhereString(string key, ConditionalOperator oper) { return(ToWhereString(key, oper, this.Link)); }