private void TryExecuteTool(IDSFDataObject dataObject, int update, ErrorResultTO allErrors)
        {
            var rs = DataListUtil.ExtractRecordsetNameFromValue(RecordsetName);
            if (RecordsLength == string.Empty)
            {
                allErrors.AddError(ErrorResource.BlankResultVariable);
            }
            if (dataObject.IsDebugMode())
            {
                var warewolfEvalResult = dataObject.Environment.Eval(RecordsetName.Replace("()", "(*)"), update);
                if (warewolfEvalResult.IsWarewolfRecordSetResult && warewolfEvalResult is CommonFunctions.WarewolfEvalResult.WarewolfRecordSetResult recsetResult)
                {
                    AddDebugInputItem(new DebugItemWarewolfRecordset(recsetResult.Item, RecordsetName, "Recordset", "="));
                }

                //Because the environment eval above where you can only send through a recordset name and not list this code wont be reached.
                //No Coverage added.
                if (warewolfEvalResult.IsWarewolfAtomListresult && warewolfEvalResult is CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult atomListResult)
                {
                    AddDebugInputItem(new DebugEvalResult(RecordsetName, "Recordset", dataObject.Environment, update));
                }

            }
            var rule = new IsSingleValueRule(() => RecordsLength);
            var single = rule.Check();
            if (single != null)
            {
                allErrors.AddError(single.Message);
            }
            else
            {

                if (dataObject.Environment.HasRecordSet(RecordsetName))
                {
                    var count = dataObject.Environment.GetLength(rs);
                    var value = count.ToString();
                    dataObject.Environment.Assign(RecordsLength, value, update);
                    if (dataObject.Environment.Errors != null && !dataObject.Environment.Errors.Any())
                    {
                        AddDebugOutputItem(new DebugItemWarewolfAtomResult(value, RecordsLength, ""));
                    }

                }
                else
                {
                    if (TreatNullAsZero)
                    {
                        dataObject.Environment.Assign(RecordsLength, 0.ToString(), update);
                        AddDebugOutputItem(new DebugItemWarewolfAtomResult(0.ToString(), RecordsLength, ""));
                    }
                    else
                    {
                        allErrors.AddError(string.Format(ErrorResource.NullRecordSet, RecordsetName));
                    }

                }

            }
        }
        ErrorResultTO TryExecute(IDSFDataObject dataObject, int update, ErrorResultTO allErrors)
        {
            var rs = DataListUtil.ExtractRecordsetNameFromValue(RecordsetName);

            if (RecordsLength == string.Empty)
            {
                allErrors.AddError(ErrorResource.BlankResultVariable);
            }
            if (dataObject.IsDebugMode())
            {
                var warewolfEvalResult = dataObject.Environment.Eval(RecordsetName.Replace("()", "(*)"), update);
                if (warewolfEvalResult.IsWarewolfRecordSetResult && warewolfEvalResult is CommonFunctions.WarewolfEvalResult.WarewolfRecordSetResult recsetResult)
                {
                    AddDebugInputItem(new DebugItemWarewolfRecordset(recsetResult.Item, RecordsetName, "Recordset", "="));
                }

                if (warewolfEvalResult.IsWarewolfAtomListresult && warewolfEvalResult is CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult atomListResult)
                {
                    AddDebugInputItem(new DebugEvalResult(RecordsetName, "Recordset", dataObject.Environment, update));
                }
            }
            var rule   = new IsSingleValueRule(() => RecordsLength);
            var single = rule.Check();

            if (single != null)
            {
                allErrors.AddError(single.Message);
            }
            else
            {
                var count = 0;
                if (dataObject.Environment.HasRecordSet(RecordsetName))
                {
                    count = dataObject.Environment.GetLength(rs);
                }
                else
                {
                    allErrors.AddError("Recordset: " + RecordsetName + " does not exist.");
                }
                var value = count.ToString();
                dataObject.Environment.Assign(RecordsLength, value, update);
                AddDebugOutputItem(new DebugItemWarewolfAtomResult(value, RecordsLength, ""));
            }
            return(allErrors);
        }
        protected override void ExecuteTool(IDSFDataObject dataObject, int update)
        {
            ErrorResultTO allErrors = new ErrorResultTO();
            ErrorResultTO errors    = new ErrorResultTO();

            allErrors.MergeErrors(errors);
            InitializeDebug(dataObject);
            // Process if no errors
            try
            {
                ValidateRecordsetName(RecordsetName, errors);
                allErrors.MergeErrors(errors);
                if (!allErrors.HasErrors())
                {
                    try
                    {
                        string rs = DataListUtil.ExtractRecordsetNameFromValue(RecordsetName);
                        if (RecordsLength == string.Empty)
                        {
                            allErrors.AddError(ErrorResource.BlankResultVariable);
                        }
                        if (dataObject.IsDebugMode())
                        {
                            var warewolfEvalResult = dataObject.Environment.Eval(RecordsetName.Replace("()", "(*)"), update);
                            if (warewolfEvalResult.IsWarewolfRecordSetResult)
                            {
                                var recsetResult = warewolfEvalResult as CommonFunctions.WarewolfEvalResult.WarewolfRecordSetResult;
                                if (recsetResult != null)
                                {
                                    AddDebugInputItem(new DebugItemWarewolfRecordset(recsetResult.Item, RecordsetName, "Recordset", "="));
                                }
                            }
                            if (warewolfEvalResult.IsWarewolfAtomListresult)
                            {
                                var recsetResult = warewolfEvalResult as CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult;
                                if (recsetResult != null)
                                {
                                    AddDebugInputItem(new DebugEvalResult(RecordsetName, "Recordset", dataObject.Environment, update));
                                }
                            }
                        }
                        var rule   = new IsSingleValueRule(() => RecordsLength);
                        var single = rule.Check();
                        if (single != null)
                        {
                            allErrors.AddError(single.Message);
                        }
                        else
                        {
                            var count = 0;
                            if (dataObject.Environment.HasRecordSet(RecordsetName))
                            {
                                count = dataObject.Environment.GetLength(rs);
                            }
                            else
                            {
                                allErrors.AddError("Recordset: " + RecordsetName + " does not exist.");
                            }
                            var value = count.ToString();
                            dataObject.Environment.Assign(RecordsLength, value, update);
                            AddDebugOutputItem(new DebugItemWarewolfAtomResult(value, RecordsLength, ""));
                        }
                    }
                    catch (Exception e)
                    {
                        allErrors.AddError(e.Message);
                        dataObject.Environment.Assign(RecordsLength, "0", update);
                        AddDebugOutputItem(new DebugItemStaticDataParams("0", RecordsLength, "", "="));
                    }
                }
            }
            finally
            {
                // Handle Errors
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfRecordsetLengthActivity", allErrors);
                    var errorString = allErrors.MakeDisplayReady();
                    dataObject.Environment.AddError(errorString);
                }
                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(dataObject, StateType.Before, update);
                    DispatchDebugState(dataObject, StateType.After, update);
                }
            }
        }