public void CreateTableWithMultipleCheckConstraint2() { const string TableName = nameof(CreateTableWithMultipleCheckConstraint2); Table table = new Table(TableName); Column column1 = new Column("column1", DataType.Int()); Column column2 = new Column("column2", DataType.Int()); Column column3 = new Column("column3", DataType.VarChar(10)); table.Columns.AddAll(column1, column2, column3); CheckExpression expression = new CheckExpression("([column2]>=0)"); CheckConstraint checkConstraint1 = new CheckConstraint(expression); CheckExpression expression2 = new CheckExpression("([column2]!=(666))"); CheckConstraint checkConstraint2 = new CheckConstraint() { CheckExpression = new CheckExpression(column3, CheckOperator.Equals, "'a'") .And(column2, CheckOperator.NotEquals, column1) .Or(expression2) .Or(column2, CheckOperator.LessThan, column1) .And("1=1") .Or("2=2") }; table.Constraints.AddAll(checkConstraint1, checkConstraint2); VerifyCheckConstraint(table, "([column2]>=(0))", "([column3]='a' AND [column2]<>[column1] OR [column2]<>(666) OR [column2]<[column1] AND (1)=(1) OR (2)=(2))"); }
public Block BuildDocument(int indentation) { Paragraph p = new Paragraph(); p.Inlines.Add(new Run("if") { Foreground = StyleSettings.KeyWordColor }); p.Inlines.Add(" ("); p.Inlines.AddRange(CheckExpression.BuildDocument()); p.Inlines.Add(")"); Section s = new Section() { Margin = new Thickness(indentation, 0, 0, 0) }; s.Blocks.Add(p); s.Blocks.Add(IfTrueBody.BuildDocument(indentation)); s.Blocks.Add(new Paragraph(new Run("else") { Foreground = StyleSettings.KeyWordColor })); s.Blocks.Add(IfFalseBody.BuildDocument(indentation)); return(s); }
public void CreateTableWithMultipleCheckConstraint() { const string TableName = nameof(CreateTableWithMultipleCheckConstraint); Table table = new Table(TableName); Column column1 = new Column("column1", DataType.Int()); Column column2 = new Column("column2", DataType.Int()); Column column3 = new Column("column3", DataType.VarChar(10)); table.Columns.AddAll(column1, column2, column3); CheckExpression expression = new CheckExpression("([column2]>=(0))"); CheckConstraint checkConstraint1 = new CheckConstraint("CK_CheckConstraint_1") { CheckExpression = new CheckExpression(column1, CheckOperator.GreaterThanOrEquals, column2) .And(expression) }; CheckConstraint checkConstraint2 = new CheckConstraint("CK_CheckConstraint_2") { CheckExpression = new CheckExpression(column3, CheckOperator.GreaterThanOrEquals, "'a'") .And(column3, CheckOperator.LessThanOrEquals, "'zzzzzzzzzz'") .Or(column3, CheckOperator.GreaterThanOrEquals, "'A'") .And(column3, CheckOperator.LessThanOrEquals, "'ZZZZZZZZZZ'") }; table.Constraints.AddAll(checkConstraint1, checkConstraint2); VerifyCheckConstraint(table, "([column1]>=[column2] AND [column2]>=(0))", "([column3]>='a' AND [column3]<='zzzzzzzzzz' OR [column3]>='A' AND [column3]<='ZZZZZZZZZZ')"); }
public override void Excute(ExcutingStack stack) { DeclareExpression.Excute(stack); while (true) { if (_break) { break; } CheckExpression.Excute(stack); if (!(bool)stack.Get(CheckExpression.Root)) { break; } Body.Excute(stack); OperateExpression.Excute(stack); } UnsetAll(); _break = false; }
public void TypeCheck(ITypeEnvironment env) { if (!CheckExpression.TypeCheck(env).CompatibleWith(ExpressionType)) { env.ReportError("Unable to evaluate 'if'. Expression must be of type bool!", SourceStartPosition, SourceEndPosition); } IfTrueBody.TypeCheck(env); }
public override bool Equals(object obj) { if (!(obj is IfStmnt)) { return(false); } IfStmnt other = (IfStmnt)obj; return(CheckExpression.Equals(other.CheckExpression) && IfTrueBody.Equals(other.IfTrueBody)); }
public static bool CheckConditions(CheckExpression checkExpression, ref string message) { if (!checkExpression.Invoke(ref message)) { if (Transaction.Current != null) { Transaction.Current.Rollback(); } return(false); } return(true); }
private string GetCheckResult(string text) { try { var isCorrect = CheckExpression.IsCorrect(text); BracketsDataService.SaveResultToDatabase(isCorrect); return($"Result of checking: { isCorrect }"); } catch (Exception ex) { throw new Exception(ex.Message); } }
private void GetCheckResult(string text) { try { var isCorrect = CheckExpression.IsCorrect(text); BracketsDataService.SaveResultToDatabase(isCorrect); StatusLabel.Text = $"Result of checking: {isCorrect}"; } catch (Exception ex) { StatusLabel.Text = "The following error occured: " + ex.Message; } }
public static bool DoActionWithCheckOnTransaction(CheckExpression action, ref string message) { if (Transaction.Current == null) { using (var transaction = new TransactionScope()) { if (!action.Invoke(ref message)) { Transaction.Current.Rollback(); return(false); } transaction.Complete(); } return(true); } return(action.Invoke(ref message)); }
public FrameworkElement BuildForm(IValueEnvironment vEnv, ITypeEnvironment tEnv) { ValueContainer value = CheckExpression.Evaluate(vEnv); StackPanel sp = new StackPanel(); Action onValueChanged = () => { sp.Visibility = Convert.ToBoolean(value.Value) ? Visibility.Visible : Visibility.Collapsed; }; value.ValueChanged += onValueChanged; onValueChanged(); sp.Children.Add(IfTrueBody.BuildForm(vEnv, tEnv)); return(sp); }
protected void checkRecordExpression(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string id = e.ExtraParams["id"]; string obj = e.ExtraParams["values"]; string name = e.ExtraParams["name"]; string functionBody = e.ExtraParams["functionBody"]; CheckExpression b = JsonConvert.DeserializeObject <CheckExpression>(obj); //CheckExpressionRecordRequest req = new CheckExpressionRecordRequest(); PostRequest <CheckExpression> request = new PostRequest <CheckExpression>(); request.entity = new CheckExpression(); request.entity.recordId = id; request.entity.expression = functionBody; PostResponse <CheckExpression> resp = _payrollService.ChildAddOrUpdate <CheckExpression>(request); if (!resp.Success) { Common.errorMessage(resp); return; } //if (resp.result.success) // X.MessageBox.Alert(Resources.Common.Notification, GetLocalResourceObject("trueEX").ToString()).Show(); //else // X.MessageBox.Alert(Resources.Common.Error, resp.result.returnMessage).Show(); if (resp.Success) { X.MessageBox.Alert(Resources.Common.Notification, GetLocalResourceObject("trueEX").ToString()).Show(); } else { X.MessageBox.Alert(Resources.Common.Error, resp.Message).Show(); } }
public CheckExpression Or(CheckExpression checkExpression) { SqlDefinition = string.Concat(SqlDefinition.Trim(), " OR ", checkExpression.SqlDefinition.Trim()); return(this); }
public CheckConstraint(string name, CheckExpression checkExpression) : base(name) { CheckExpression = checkExpression; }
public CheckConstraint(CheckExpression checkExpression) : this(null, checkExpression) { }
public override int GetHashCode() { return(CheckExpression.GetHashCode() ^ IfTrueBody.GetHashCode() ^ IfFalseBody.GetHashCode()); }