public static ColumnExpression BuildColumnExpression(string lambdaExpression) { ColumnExpression result; try { result = ExpressionCalculator.BuildColumnExpression(lambdaExpression); } catch (ParseException innerException) { throw new LambdaExpressionException(lambdaExpression, innerException); } catch (TargetInvocationException innerException2) { throw new LambdaExpressionException(lambdaExpression, innerException2); } return(result); }
protected override void Initialize(DataRow input, DataTable dataTable) { base.Initialize(input, dataTable); if (string.IsNullOrEmpty(this.MaxProgressBarEventsExpected) || !DDIHelper.IsLambdaExpression(this.MaxProgressBarEventsExpected)) { return; } MaximumCountProgressCalculator maximumCountProgressCalculator = base.ProgressCalculatorInstance as MaximumCountProgressCalculator; if (maximumCountProgressCalculator != null) { maximumCountProgressCalculator.ProgressRecord.MaxCount = (int)ExpressionCalculator.CalculateLambdaExpression(ExpressionCalculator.BuildColumnExpression(this.MaxProgressBarEventsExpected), typeof(int), DDIHelper.GetLambdaExpressionDataRow(dataTable), input); return; } string message = string.Format("BulkCustomMaximumEventExpectedWorkflow should be used only with MaximumCountProgressCalculator. Current: {0}", (base.ProgressCalculatorInstance == null) ? "<null>" : base.ProgressCalculatorInstance.GetType().Name); throw new InvalidOperationException(message); }
internal static List <string> GetOutputDepVariables(DataColumn column) { List <string> list = new List <string>(); Variable variable = column.ExtendedProperties["Variable"] as Variable; if (variable != null) { string text = variable.Value as string; if (DDIHelper.IsLambdaExpression(text)) { list = ExpressionCalculator.BuildColumnExpression(text).DependentColumns; } else { list.AddRange(DDIHelper.GetCodeBehindRegisteredDepVariables(column)); } } return(list); }
public bool IsRunnable(DataRow input, DataTable dataTable) { DataObjectStore dataObjectStore = dataTable.ExtendedProperties["DataSourceStore"] as DataObjectStore; if (this.Type == ParameterType.RunOnModified) { if (this.Value != null) { VariableReference variableReference = this.Value as VariableReference; if (variableReference != null && !dataObjectStore.ModifiedColumns.Contains(variableReference.Variable)) { return(false); } string text = this.Value as string; if (DDIHelper.IsLambdaExpression(text)) { List <string> dependentColumns = ExpressionCalculator.BuildColumnExpression(text).DependentColumns; bool flag = false; foreach (string item in dependentColumns) { if (dataObjectStore != null && dataObjectStore.ModifiedColumns.Contains(item)) { flag = true; break; } } if (!flag) { return(false); } } } else if (!dataObjectStore.ModifiedColumns.Contains(this.Reference ?? this.Name)) { return(false); } } if (!string.IsNullOrEmpty(this.Condition)) { return((bool)ExpressionCalculator.CalculateLambdaExpression(ExpressionCalculator.BuildColumnExpression(this.Condition), typeof(bool), DDIHelper.GetLambdaExpressionDataRow(dataTable), input)); } return(this.runnableTester == null || this.runnableTester.IsRunnable(input, dataTable)); }
protected override List <string> OnValidate(string lambdaExpression, Service profile) { List <string> list = new List <string>(); try { lambdaExpression = lambdaExpression.Replace("@1", "@0"); ColumnExpression expression = ExpressionCalculator.BuildColumnExpression(lambdaExpression); using (DataTable dataTable = new DataTable()) { DataRow dataRow = dataTable.NewRow(); ExpressionCalculator.CompileLambdaExpression(expression, typeof(object), profile.PredefinedTypes.ToArray(), dataRow, null); } } catch (Exception ex) { list.Add(string.Format("Fail to compile lambda expression {0} with error {1}. \r\n If the error is about no applicable method, please also double check you do type cast explicitly in your lambdaexpression, like SearchText=>DDIHelper.AsteriskAround(String(@1[SearchText])) ", lambdaExpression, ex.ToString())); } return(list); }
internal static void SetDefaultValues(DataRow input, DataRow row, DataTable dataTable, Collection <Set> defaultValues) { if (defaultValues != null) { foreach (Set set in defaultValues) { object obj = set.Value; string text = obj as string; if (DDIHelper.IsLambdaExpression(text)) { obj = ExpressionCalculator.CalculateLambdaExpression(ExpressionCalculator.BuildColumnExpression(text), typeof(object), DDIHelper.GetLambdaExpressionDataRow(dataTable), input); } else { VariableReference variableReference = obj as VariableReference; if (variableReference != null) { obj = DDIHelper.GetVariableValue(variableReference, input, dataTable); } } row[set.Variable] = obj; } } }
public override RunResult Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate) { RunResult result = new RunResult(); string text = this.Value as string; if (DDIHelper.IsLambdaExpression(text)) { dataTable.Rows[0][this.Variable] = ExpressionCalculator.CalculateLambdaExpression(ExpressionCalculator.BuildColumnExpression(text), typeof(object), DDIHelper.GetLambdaExpressionDataRow(dataTable), input); } else { dataTable.Rows[0][this.Variable] = this.Value; } return(result); }
protected override bool CalculateCondition(DataRow input, DataTable dataTable) { return((bool)ExpressionCalculator.CalculateLambdaExpression(ExpressionCalculator.BuildColumnExpression(this.Condition), typeof(bool), DDIHelper.GetLambdaExpressionDataRow(dataTable), input)); }
private IList <KeyValuePair <string, object> > CalculateCore(DataRow dataRow, DataRow inputRow, IList <ColumnExpression> query) { List <KeyValuePair <string, object> > list = new List <KeyValuePair <string, object> >(); foreach (ColumnExpression columnExpression in query) { list.Add(new KeyValuePair <string, object>(columnExpression.ResultColumn, ExpressionCalculator.CalculateLambdaExpression(columnExpression, this.GetColumnRealDataType(dataRow.Table.Columns[columnExpression.ResultColumn]), dataRow, inputRow))); } return(list); }
public static ExpressionCalculator Parse(DataTable table) { return(ExpressionCalculator.Parse(table, "LambdaExpression")); }