Example #1
0
        string ResolveStarredIndices(IExecutionEnvironment env, string mode, out ErrorResultTO errors)
        {
            string        fn = DecisionDisplayHelper.GetDisplayValue(EvaluationFn);
            StringBuilder expandStarredIndices = new StringBuilder();

            if (DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col3) == enRecordsetIndexType.Star)
            {
                var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col3, env, out errors, 0);

                expandStarredIndices.Append(Col1 + " " + fn + " " + Col2 + " AND " + allCol3Values[0]);
                allCol3Values.RemoveAt(0);
                foreach (var value in allCol3Values)
                {
                    expandStarredIndices.Append(" " + mode + " " + Col1 + " " + fn + " " + Col2 + " AND " + value);
                }
                return("If " + expandStarredIndices);
            }
            if (DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col3) != enRecordsetIndexType.Star)
            {
                var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0);

                expandStarredIndices.Append(Col1 + " " + fn + " " + allCol2Values[0] + " AND " + Col3);
                allCol2Values.RemoveAt(0);
                foreach (var value in allCol2Values)
                {
                    expandStarredIndices.Append(" " + mode + " " + Col1 + " " + fn + " " + value + " AND " + Col3);
                }
                return("If " + expandStarredIndices);
            }
            if (DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col3) == enRecordsetIndexType.Star)
            {
                var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0);
                var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col3, env, out errors, 0);

                expandStarredIndices.Append(Col1 + " " + fn + " " + allCol2Values[0] + " AND " + allCol3Values[0]);
                allCol2Values.RemoveAt(0);
                allCol3Values.RemoveAt(0);
                for (var i = 0; i < Math.Max(allCol2Values.Count, allCol3Values.Count); i++)
                {
                    if (i > allCol2Values.Count)
                    {
                        allCol2Values.Add(null);
                    }
                    if (i > allCol3Values.Count)
                    {
                        allCol3Values.Add(null);
                    }
                    expandStarredIndices.Append(" " + mode + " " + Col1 + " " + fn + " " + allCol2Values[i] + " AND " + allCol3Values[i]);
                }
                return("If " + expandStarredIndices);
            }
            if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col3) != enRecordsetIndexType.Star)
            {
                var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0);

                expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + Col2 + " AND " + Col3);
                allCol1Values.RemoveAt(0);
                foreach (var value in allCol1Values)
                {
                    expandStarredIndices.Append(" " + mode + " " + value + " " + fn + " " + Col2 + " AND " + Col3);
                }
                return("If " + expandStarredIndices);
            }
            if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col3) == enRecordsetIndexType.Star)
            {
                var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0);
                var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col3, env, out errors, 0);

                expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + Col2 + " AND " + allCol3Values[0]);
                allCol1Values.RemoveAt(0);
                allCol3Values.RemoveAt(0);
                for (var i = 0; i < Math.Max(allCol1Values.Count, allCol3Values.Count); i++)
                {
                    if (i > allCol1Values.Count)
                    {
                        allCol1Values.Add(null);
                    }
                    if (i > allCol3Values.Count)
                    {
                        allCol3Values.Add(null);
                    }
                    expandStarredIndices.Append(" " + mode + " " + allCol1Values[i] + " " + fn + " " + Col2 + " AND " + allCol3Values[i]);
                }
                return("If " + expandStarredIndices);
            }
            if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col3) != enRecordsetIndexType.Star)
            {
                var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0);
                var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0);

                expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + allCol2Values[0] + " AND " + Col3);
                allCol1Values.RemoveAt(0);
                allCol2Values.RemoveAt(0);
                for (var i = 0; i < Math.Max(allCol1Values.Count, allCol2Values.Count); i++)
                {
                    if (i > allCol1Values.Count)
                    {
                        allCol1Values.Add(null);
                    }
                    if (i > allCol2Values.Count)
                    {
                        allCol2Values.Add(null);
                    }
                    expandStarredIndices.Append(" " + mode + " " + allCol1Values[i] + " " + fn + " " + allCol2Values[0] + " AND " + Col3);
                }
                return("If " + expandStarredIndices);
            }
            if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col3) == enRecordsetIndexType.Star)
            {
                var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0);
                var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0);
                var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col3, env, out errors, 0);

                expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + allCol2Values[0] + " AND " + allCol3Values[0]);
                allCol1Values.RemoveAt(0);
                allCol2Values.RemoveAt(0);
                allCol3Values.RemoveAt(0);
                for (var i = 0; i < Math.Max(allCol1Values.Count, Math.Max(allCol2Values.Count, allCol3Values.Count)); i++)
                {
                    if (i > allCol1Values.Count)
                    {
                        allCol1Values.Add(null);
                    }
                    if (i > allCol2Values.Count)
                    {
                        allCol2Values.Add(null);
                    }
                    if (i > allCol3Values.Count)
                    {
                        allCol3Values.Add(null);
                    }
                    expandStarredIndices.Append(" " + mode + " " + allCol1Values[i] + " " + fn + " " + allCol2Values[0] + " AND " + allCol3Values[i]);
                }
                return("If " + expandStarredIndices);
            }
            errors = new ErrorResultTO();
            return(null);
        }
Example #2
0
        public string GenerateUserFriendlyModel(IExecutionEnvironment env, Dev2DecisionMode mode, out ErrorResultTO errors)
        {
            errors = new ErrorResultTO();
            ErrorResultTO allErrors = new ErrorResultTO();
            string        fn        = DecisionDisplayHelper.GetDisplayValue(EvaluationFn);

            if (PopulatedColumnCount == 0)
            {
                return("If " + fn + " ");
            }

            if (PopulatedColumnCount == 1)
            {
                if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star)
                {
                    var allValues = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0);
                    allErrors.MergeErrors(errors);
                    StringBuilder expandStarredIndex = new StringBuilder();

                    expandStarredIndex.Append(allValues[0] + " " + fn);
                    allValues.RemoveAt(0);
                    foreach (var value in allValues)
                    {
                        expandStarredIndex.Append(" " + mode + " " + value + " " + fn);
                    }
                    errors = allErrors;
                    return("If " + expandStarredIndex);
                }
                errors = allErrors;
                return("If " + Col1 + " " + fn + " ");
            }

            if (PopulatedColumnCount == 2)
            {
                StringBuilder expandStarredIndices = new StringBuilder();
                if (DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star)
                {
                    var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0);
                    allErrors.MergeErrors(errors);
                    expandStarredIndices.Append(Col1 + " " + fn + " " + allCol2Values[0]);
                    allCol2Values.RemoveAt(0);
                    foreach (var value in allCol2Values)
                    {
                        expandStarredIndices.Append(" " + mode + " " + Col1 + " " + fn + " " + value);
                    }
                    errors = allErrors;
                    return("If " + expandStarredIndices);
                }
                if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star)
                {
                    var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0);
                    allErrors.MergeErrors(errors);
                    expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + Col2);
                    allCol1Values.RemoveAt(0);
                    foreach (var value in allCol1Values)
                    {
                        expandStarredIndices.Append(" " + mode + " " + value + " " + fn + " " + Col2);
                    }
                    errors = allErrors;
                    return("If " + expandStarredIndices);
                }
                if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star || DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star)
                {
                    var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0);
                    allErrors.MergeErrors(errors);
                    var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0);
                    allErrors.MergeErrors(errors);
                    expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + allCol2Values[0]);
                    allCol1Values.RemoveAt(0);
                    allCol2Values.RemoveAt(0);
                    for (var i = 0; i < Math.Max(allCol1Values.Count, allCol2Values.Count); i++)
                    {
                        if (i > allCol1Values.Count)
                        {
                            allCol1Values.Add(null);
                        }
                        if (i > allCol2Values.Count)
                        {
                            allCol2Values.Add(null);
                        }

                        try
                        {
                            expandStarredIndices.Append(" " + mode + " " + allCol1Values[i] + " " + fn + " " +
                                                        allCol2Values[i]);
                        }
                        catch (IndexOutOfRangeException)
                        {
                            errors.AddError("You appear to have recordsets of differnt sizes");
                            allErrors.MergeErrors(errors);
                        }
                    }
                    errors = allErrors;
                    return("If " + expandStarredIndices);
                }
                errors = allErrors;
                return("If " + Col1 + " " + fn + " " + Col2 + " ");
            }

            if (PopulatedColumnCount == 3)
            {
                var expandStarredIndices = ResolveStarredIndices(env, mode.ToString(), out errors);
                allErrors.MergeErrors(errors);
                if (!string.IsNullOrEmpty(expandStarredIndices))
                {
                    errors = allErrors;
                    return(expandStarredIndices);
                }
                errors = allErrors;
                return("If " + Col1 + " " + fn + " " + Col2 + " and " + Col3);
            }
            errors = allErrors;
            return("<< Internal Error Generating Decision Model: Populated Column Count Cannot Exeed 3 >>");
        }
Example #3
0
#pragma warning disable S3776, S1541 // Complexity of methods should not be too high
            public string Generate(out ErrorResultTO errors)
#pragma warning restore S3776, S1541 // Complexity of methods should not be too high
            {
                errors = new ErrorResultTO();

                var fn = DecisionDisplayHelper.GetDisplayValue(_evaluationFn);

                if (_populatedColumnCount == 0)
                {
                    return("If " + fn + " ");
                }

                var allErrors = new ErrorResultTO();

                if (_populatedColumnCount == 1)
                {
                    if (DataListUtil.GetRecordsetIndexType(_col1) == enRecordsetIndexType.Star)
                    {
                        var allValues = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col1, _env, out errors, 0);
                        if (errors.FetchErrors().Count >= 1)
                        {
                            return("If ");
                        }
                        allErrors.MergeErrors(errors);
                        var expandStarredIndex = new StringBuilder();

                        expandStarredIndex.Append(allValues[0] + " " + fn);
                        allValues.RemoveAt(0);
                        foreach (var value in allValues)
                        {
                            expandStarredIndex.Append(" " + _mode + " " + value + " " + fn);
                        }
                        errors = allErrors;
                        return("If " + expandStarredIndex);
                    }
                    errors = allErrors;
                    return("If " + _col1 + " " + fn + " ");
                }

                if (_populatedColumnCount == 2)
                {
                    var expandStarredIndices = new StringBuilder();
                    if (DataListUtil.GetRecordsetIndexType(_col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) == enRecordsetIndexType.Star)
                    {
                        var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col2, _env, out errors, 0);
                        if (errors.FetchErrors().Count >= 1)
                        {
                            return("If ");
                        }
                        allErrors.MergeErrors(errors);
                        expandStarredIndices.Append(_col1 + " " + fn + " " + allCol2Values[0]);
                        allCol2Values.RemoveAt(0);
                        foreach (var value in allCol2Values)
                        {
                            expandStarredIndices.Append(" " + _mode + " " + _col1 + " " + fn + " " + value);
                        }
                        errors = allErrors;
                        return("If " + expandStarredIndices);
                    }
                    if (DataListUtil.GetRecordsetIndexType(_col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) != enRecordsetIndexType.Star)
                    {
                        var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col1, _env, out errors, 0);
                        if (errors.FetchErrors().Count >= 1)
                        {
                            return("If ");
                        }
                        allErrors.MergeErrors(errors);
                        expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + _col2);
                        allCol1Values.RemoveAt(0);
                        foreach (var value in allCol1Values)
                        {
                            expandStarredIndices.Append(" " + _mode + " " + value + " " + fn + " " + _col2);
                        }
                        errors = allErrors;
                        return("If " + expandStarredIndices);
                    }
                    if (DataListUtil.GetRecordsetIndexType(_col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) == enRecordsetIndexType.Star || DataListUtil.GetRecordsetIndexType(_col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) != enRecordsetIndexType.Star)
                    {
                        var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col1, _env, out errors, 0);
                        if (errors.FetchErrors().Count >= 1)
                        {
                            return("If ");
                        }
                        allErrors.MergeErrors(errors);
                        var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col2, _env, out errors, 0);
                        allErrors.MergeErrors(errors);
                        expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + allCol2Values[0]);
                        allCol1Values.RemoveAt(0);
                        if (allCol2Values.Count > 0)
                        {
                            allCol2Values.RemoveAt(0);
                        }
                        AddAllColumns(_mode, errors, allErrors, fn, expandStarredIndices, allCol1Values, allCol2Values);
                        errors = allErrors;
                        return("If " + expandStarredIndices);
                    }
                    errors = allErrors;
                    return("If " + _col1 + " " + fn + " " + _col2 + " ");
                }

                if (_populatedColumnCount == 3)
                {
                    var expandStarredIndices = ResolveStarredIndicesForLabel(_env, _mode.ToString(), out errors);
                    allErrors.MergeErrors(errors);
                    if (!string.IsNullOrEmpty(expandStarredIndices))
                    {
                        errors = allErrors;
                        return(expandStarredIndices);
                    }
                    errors = allErrors;
                    return("If " + _col1 + " " + fn + " " + _col2 + " and " + _col3);
                }

                errors = allErrors;
                return("<< Internal Error Generating Decision Model: Populated Column Count Cannot Exceed 3 >>");
            }
Example #4
0
#pragma warning disable S3776, S1541 // Complexity of methods should not be too high
            string ResolveStarredIndicesForLabel(IExecutionEnvironment env, string mode, out ErrorResultTO errors)
#pragma warning restore S3776, S1541 // Complexity of methods should not be too high
            {
                var fn = DecisionDisplayHelper.GetDisplayValue(_evaluationFn);
                var expandStarredIndices = new StringBuilder();

                if (DataListUtil.GetRecordsetIndexType(_col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col3) == enRecordsetIndexType.Star)
                {
                    var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col3, env, out errors, 0);

                    expandStarredIndices.Append(_col1 + " " + fn + " " + _col2 + " AND " + allCol3Values[0]);
                    allCol3Values.RemoveAt(0);
                    foreach (var value in allCol3Values)
                    {
                        expandStarredIndices.Append(" " + mode + " " + _col1 + " " + fn + " " + _col2 + " AND " + value);
                    }
                    return("If " + expandStarredIndices);
                }
                if (DataListUtil.GetRecordsetIndexType(_col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col3) != enRecordsetIndexType.Star)
                {
                    var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col2, env, out errors, 0);

                    expandStarredIndices.Append(_col1 + " " + fn + " " + allCol2Values[0] + " AND " + _col3);
                    allCol2Values.RemoveAt(0);
                    foreach (var value in allCol2Values)
                    {
                        expandStarredIndices.Append(" " + mode + " " + _col1 + " " + fn + " " + value + " AND " + _col3);
                    }
                    return("If " + expandStarredIndices);
                }
                if (DataListUtil.GetRecordsetIndexType(_col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col3) == enRecordsetIndexType.Star)
                {
                    var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col2, env, out errors, 0);
                    var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col3, env, out errors, 0);

                    expandStarredIndices.Append(_col1 + " " + fn + " " + allCol2Values[0] + " AND " + allCol3Values[0]);
                    allCol2Values.RemoveAt(0);
                    allCol3Values.RemoveAt(0);
                    for (var i = 0; i < Math.Max(allCol2Values.Count, allCol3Values.Count); i++)
                    {
                        if (i > allCol2Values.Count)
                        {
                            allCol2Values.Add(null);
                        }
                        if (i > allCol3Values.Count)
                        {
                            allCol3Values.Add(null);
                        }
                        expandStarredIndices.Append(" " + mode + " " + _col1 + " " + fn + " " + allCol2Values[i] + " AND " + allCol3Values[i]);
                    }
                    return("If " + expandStarredIndices);
                }
                if (DataListUtil.GetRecordsetIndexType(_col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col3) != enRecordsetIndexType.Star)
                {
                    var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col1, env, out errors, 0);

                    expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + _col2 + " AND " + _col3);
                    allCol1Values.RemoveAt(0);
                    foreach (var value in allCol1Values)
                    {
                        expandStarredIndices.Append(" " + mode + " " + value + " " + fn + " " + _col2 + " AND " + _col3);
                    }
                    return("If " + expandStarredIndices);
                }
                if (DataListUtil.GetRecordsetIndexType(_col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col3) == enRecordsetIndexType.Star)
                {
                    var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col1, env, out errors, 0);
                    var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col3, env, out errors, 0);

                    expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + _col2 + " AND " + allCol3Values[0]);
                    allCol1Values.RemoveAt(0);
                    if (allCol3Values.Count > 0)
                    {
                        allCol3Values.RemoveAt(0);
                    }
                    for (var i = 0; i < Math.Max(allCol1Values.Count, allCol3Values.Count); i++)
                    {
                        if (i > allCol1Values.Count)
                        {
                            allCol1Values.Add(null);
                        }
                        if (i > allCol3Values.Count)
                        {
                            allCol3Values.Add(null);
                        }
                        expandStarredIndices.Append(" " + mode + " " + allCol1Values[i] + " " + fn + " " + _col2 + " AND " + allCol3Values[i]);
                    }
                    return("If " + expandStarredIndices);
                }
                if (DataListUtil.GetRecordsetIndexType(_col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col3) != enRecordsetIndexType.Star)
                {
                    var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col1, env, out errors, 0);
                    var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col2, env, out errors, 0);

                    expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + allCol2Values[0] + " AND " + _col3);
                    allCol1Values.RemoveAt(0);
                    if (allCol2Values.Count > 0)
                    {
                        allCol2Values.RemoveAt(0);
                    }
                    for (var i = 0; i < Math.Max(allCol1Values.Count, allCol2Values.Count); i++)
                    {
                        if (i > allCol1Values.Count)
                        {
                            allCol1Values.Add(null);
                        }
                        if (i > allCol2Values.Count)
                        {
                            allCol2Values.Add(null);
                        }
                        expandStarredIndices.Append(" " + mode + " " + allCol1Values[i] + " " + fn + " " + allCol2Values[0] + " AND " + _col3);
                    }
                    return("If " + expandStarredIndices);
                }
                if (DataListUtil.GetRecordsetIndexType(_col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col3) == enRecordsetIndexType.Star)
                {
                    var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col1, env, out errors, 0);
                    var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col2, env, out errors, 0);
                    var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col3, env, out errors, 0);

                    expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + allCol2Values[0] + " AND " + allCol3Values[0]);
                    allCol1Values.RemoveAt(0);
                    if (allCol2Values.Count > 0)
                    {
                        allCol2Values.RemoveAt(0);
                    }
                    if (allCol3Values.Count > 0)
                    {
                        allCol3Values.RemoveAt(0);
                    }
                    for (var i = 0; i < Math.Max(allCol1Values.Count, Math.Max(allCol2Values.Count, allCol3Values.Count)); i++)
                    {
                        if (i > allCol1Values.Count)
                        {
                            allCol1Values.Add(null);
                        }
                        if (i > allCol2Values.Count)
                        {
                            allCol2Values.Add(null);
                        }
                        if (i > allCol3Values.Count)
                        {
                            allCol3Values.Add(null);
                        }
                        expandStarredIndices.Append(" " + mode + " " + allCol1Values[i] + " " + fn + " " + allCol2Values[0] + " AND " + allCol3Values[i]);
                    }
                    return("If " + expandStarredIndices);
                }
                errors = new ErrorResultTO();
                return(null);
            }
Example #5
0
        public string GenerateUserFriendlyModel(IExecutionEnvironment env, Dev2DecisionMode mode, out ErrorResultTO errors)
        {
            errors = new ErrorResultTO();
            var allErrors = new ErrorResultTO();
            var fn        = DecisionDisplayHelper.GetDisplayValue(EvaluationFn);

            if (PopulatedColumnCount == 0)
            {
                return("If " + fn + " ");
            }

            if (PopulatedColumnCount == 1)
            {
                if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star)
                {
                    var allValues = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0);
                    allErrors.MergeErrors(errors);
                    var expandStarredIndex = new StringBuilder();

                    expandStarredIndex.Append(allValues[0] + " " + fn);
                    allValues.RemoveAt(0);
                    foreach (var value in allValues)
                    {
                        expandStarredIndex.Append(" " + mode + " " + value + " " + fn);
                    }
                    errors = allErrors;
                    return("If " + expandStarredIndex);
                }
                errors = allErrors;
                return("If " + Col1 + " " + fn + " ");
            }

            if (PopulatedColumnCount == 2)
            {
                var expandStarredIndices = new StringBuilder();
                if (DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star)
                {
                    var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0);
                    allErrors.MergeErrors(errors);
                    expandStarredIndices.Append(Col1 + " " + fn + " " + allCol2Values[0]);
                    allCol2Values.RemoveAt(0);
                    foreach (var value in allCol2Values)
                    {
                        expandStarredIndices.Append(" " + mode + " " + Col1 + " " + fn + " " + value);
                    }
                    errors = allErrors;
                    return("If " + expandStarredIndices);
                }
                if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star)
                {
                    var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0);
                    allErrors.MergeErrors(errors);
                    expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + Col2);
                    allCol1Values.RemoveAt(0);
                    foreach (var value in allCol1Values)
                    {
                        expandStarredIndices.Append(" " + mode + " " + value + " " + fn + " " + Col2);
                    }
                    errors = allErrors;
                    return("If " + expandStarredIndices);
                }
                if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star || DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star)
                {
                    var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0);
                    allErrors.MergeErrors(errors);
                    var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0);
                    allErrors.MergeErrors(errors);
                    expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + allCol2Values[0]);
                    allCol1Values.RemoveAt(0);
                    if (allCol2Values.Count > 0)
                    {
                        allCol2Values.RemoveAt(0);
                    }
                    AddAllColumns(mode, errors, allErrors, fn, expandStarredIndices, allCol1Values, allCol2Values);
                    errors = allErrors;
                    return("If " + expandStarredIndices);
                }
                errors = allErrors;
                return("If " + Col1 + " " + fn + " " + Col2 + " ");
            }

            if (PopulatedColumnCount == 3)
            {
                var expandStarredIndices = ResolveStarredIndices(env, mode.ToString(), out errors);
                allErrors.MergeErrors(errors);
                if (!string.IsNullOrEmpty(expandStarredIndices))
                {
                    errors = allErrors;
                    return(expandStarredIndices);
                }
                errors = allErrors;
                return("If " + Col1 + " " + fn + " " + Col2 + " and " + Col3);
            }
            errors = allErrors;
            return("<< Internal Error Generating Decision Model: Populated Column Count Cannot Exceed 3 >>");
        }