Dev2.Data.Decision.Dev2DataListDecisionHandler.EvaluateRegion C# (CSharp) Method

EvaluateRegion() private method

Evaluates the region.
private EvaluateRegion ( string payload, System.Guid dlId, int update ) : Dev2DecisionStack
payload string The payload.
dlId System.Guid The dl ID.
update int
return Dev2.Data.SystemTemplates.Models.Dev2DecisionStack
        private Dev2DecisionStack EvaluateRegion(string payload, Guid dlId,int update)
        {

            var env =  _environments[dlId];

            if(payload.StartsWith("{\"TheStack\":[{") || payload.StartsWith("{'TheStack':[{"))
            {
                //2013.05.06: Ashley Lewis for PBI 9460 - handle record-sets with stars in their index by resolving them
                var dds = DataListUtil.ConvertFromJsonToModel<Dev2DecisionStack>(new StringBuilder(payload));

                if(dds.TheStack != null)
                {
                    var effectedCols = new[] { false, false, false };
                    //Find decisions that mention record sets with starred indexes
                    var invalidDecisions = new List<Dev2Decision>();
                    for(int i = 0; i < dds.TotalDecisions; i++)
                    {
                        Dev2Decision dd = dds.GetModelItem(i);

                        if(dd.Col1 != null && DataListUtil.GetRecordsetIndexType(dd.Col1) == enRecordsetIndexType.Star)
                        {
                            invalidDecisions.Add(dd);
                            effectedCols[0] = true;
                        }
                        else
                        {
                            var warewolfEvalResult = GetWarewolfEvalResult(env, dd.Col1, update);
                            dd.Col1 = ExecutionEnvironment.WarewolfEvalResultToString(warewolfEvalResult);
                        }

                        if(dd.Col2 != null && DataListUtil.GetRecordsetIndexType(dd.Col2) == enRecordsetIndexType.Star)
                        {
                            if(!effectedCols[0])
                            {
                                invalidDecisions.Add(dd);
                            }
                            effectedCols[1] = true;
                        }
                        else
                        {
                            var warewolfEvalResult = GetWarewolfEvalResult(env, dd.Col2, update);
                            dd.Col2 = ExecutionEnvironment.WarewolfEvalResultToString(warewolfEvalResult);
                        }

                        if(dd.Col3 != null && DataListUtil.GetRecordsetIndexType(dd.Col3) == enRecordsetIndexType.Star)
                        {
                            if(!effectedCols[0] && !effectedCols[1])
                            {
                                invalidDecisions.Add(dd);
                            }
                            effectedCols[2] = true;
                        }
                        else
                        {
                            var warewolfEvalResult = GetWarewolfEvalResult(env, dd.Col3, update);
                            dd.Col3 = ExecutionEnvironment.WarewolfEvalResultToString(warewolfEvalResult);
                        }
                    }
                    //Remove those record sets and replace them with a new decision for each resolved value
                    foreach(Dev2Decision decision in invalidDecisions)
                    {
                        ErrorResultTO errors;
                        dds = ResolveAllRecords(env, dds, decision, effectedCols, out errors, update);
                    }
                }

                return dds;
            }
            return null;
        }