Пример #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);

                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);

                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);
                var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col3, env, out errors);

                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);

                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);
                var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col3, env, out errors);

                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);
                var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors);

                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);
                var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors);
                var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col3, env, out errors);

                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);
        }
Пример #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);
                    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);
                    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);
                    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);
                    allErrors.MergeErrors(errors);
                    var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors);
                    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 >>");
        }