예제 #1
0
        public static object ConvertToParameterValue(DataRow input, DataTable dataTable, Parameter paramInfo, DataObjectStore store)
        {
            string variableName = paramInfo.Reference ?? paramInfo.Name;
            object obj;

            if (paramInfo.Value == null)
            {
                obj = DDIHelper.GetVariableValue(store.ModifiedColumns, variableName, input, dataTable, store.IsGetListWorkflow);
            }
            else
            {
                string text = paramInfo.Value as string;
                if (DDIHelper.IsLambdaExpression(text))
                {
                    obj = ExpressionCalculator.CalculateLambdaExpression(ExpressionCalculator.BuildColumnExpression(text), typeof(object), DDIHelper.GetLambdaExpressionDataRow(dataTable), input);
                }
                else
                {
                    VariableReference variableReference = paramInfo.Value as VariableReference;
                    if (variableReference != null)
                    {
                        obj = DDIHelper.GetVariableValue(variableReference, input, dataTable);
                    }
                    else
                    {
                        obj = paramInfo.Value;
                    }
                }
            }
            if (obj == DBNull.Value)
            {
                return(null);
            }
            return(obj);
        }
예제 #2
0
        internal bool IsAccessingVariable(string accessingVariable)
        {
            List <string> list = new List <string>();

            if (this.Value != null)
            {
                VariableReference variableReference = this.Value as VariableReference;
                if (variableReference != null)
                {
                    list.Add(variableReference.Variable);
                }
                else
                {
                    string text = this.Value as string;
                    if (DDIHelper.IsLambdaExpression(text))
                    {
                        list.AddRange(ExpressionCalculator.BuildColumnExpression(text).DependentColumns);
                    }
                }
            }
            else
            {
                list.Add(this.Reference ?? this.Name);
            }
            return(list.Any((string c) => string.Equals(c, accessingVariable, StringComparison.OrdinalIgnoreCase)));
        }
        public static ExpressionCalculator Parse(DataTable table, string lambdaExpressionKey)
        {
            ExpressionCalculator expressionCalculator = new ExpressionCalculator();
            string text = string.Empty;

            try
            {
                IEnumerable <DataColumn> enumerable = from DataColumn o in table.Columns
                                                      where o.ExtendedProperties.Contains(lambdaExpressionKey)
                                                      select o;
                foreach (DataColumn dataColumn in enumerable)
                {
                    text = dataColumn.ExtendedProperties[lambdaExpressionKey].ToString();
                    ColumnExpression columnExpression = ExpressionCalculator.BuildColumnExpression(text);
                    columnExpression.ResultColumn = dataColumn.ColumnName;
                    expressionCalculator.query.Add(columnExpression);
                }
            }
            catch (ParseException innerException)
            {
                throw new LambdaExpressionException(text, innerException);
            }
            catch (TargetInvocationException innerException2)
            {
                throw new LambdaExpressionException(text, innerException2);
            }
            return(expressionCalculator);
        }
예제 #4
0
 public int GetResultSizeInt32(DataRow input, DataTable dataTable)
 {
     if (this.resultSizeInt32 == -1 && !string.IsNullOrEmpty(this.ResultSize))
     {
         int num = -1;
         if (DDIHelper.IsLambdaExpression(this.ResultSize))
         {
             num = (int)ExpressionCalculator.CalculateLambdaExpression(ExpressionCalculator.BuildColumnExpression(this.ResultSize), typeof(int), DDIHelper.GetLambdaExpressionDataRow(dataTable), input);
         }
         else
         {
             int.TryParse(this.ResultSize, out num);
         }
         this.resultSizeInt32 = num;
     }
     return(this.resultSizeInt32);
 }
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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));
        }
예제 #8
0
        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);
        }
예제 #9
0
 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;
         }
     }
 }
예제 #10
0
        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);
        }
예제 #11
0
 protected override bool CalculateCondition(DataRow input, DataTable dataTable)
 {
     return((bool)ExpressionCalculator.CalculateLambdaExpression(ExpressionCalculator.BuildColumnExpression(this.Condition), typeof(bool), DDIHelper.GetLambdaExpressionDataRow(dataTable), input));
 }
예제 #12
0
        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);
        }