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)); } } } }
public override int GetHashCode() { unchecked { var hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ (RecordsetName != null ? RecordsetName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (CountNumber != null ? CountNumber.GetHashCode() : 0); return(hashCode); } }
public override int GetHashCode() { unchecked { var hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ (RecordsetName != null ? RecordsetName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (RecordsLength != null ? RecordsLength.GetHashCode() : 0); return(hashCode); } }
public override int GetHashCode() { unchecked { var hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ (RecordsetName != null ? RecordsetName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Result != null ? Result.GetHashCode() : 0); hashCode = (hashCode * 397) ^ TreatNullAsZero.GetHashCode(); return(hashCode); } }
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); } } }
// ReSharper restore RedundantOverridenMember protected override void OnExecute(NativeActivityContext context) { _debugInputs = new List <DebugItem>(); _debugOutputs = new List <DebugItem>(); IDSFDataObject dataObject = context.GetExtension <IDSFDataObject>(); IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); Guid executionId = dataObject.DataListID; ErrorResultTO allErrors = new ErrorResultTO(); ErrorResultTO errors = new ErrorResultTO(); InitializeDebug(dataObject); try { ValidateRecordsetName(RecordsetName, errors); allErrors.MergeErrors(errors); if (!allErrors.HasErrors()) { var tmpRecsetIndex = DataListUtil.ExtractIndexRegionFromRecordset(RecordsetName); IBinaryDataListEntry indexEntry = compiler.Evaluate(executionId, enActionType.User, tmpRecsetIndex, false, out errors); IDev2DataListEvaluateIterator itr = Dev2ValueObjectFactory.CreateEvaluateIterator(indexEntry); IDev2IteratorCollection collection = Dev2ValueObjectFactory.CreateIteratorCollection(); collection.AddIterator(itr); while (collection.HasMoreData()) { var evaluatedRecordset = RecordsetName.Remove(RecordsetName.IndexOf("(", StringComparison.Ordinal) + 1) + collection.FetchNextRow(itr).TheValue + ")]]"; if (dataObject.IsDebugMode()) { IBinaryDataListEntry tmpentry = compiler.Evaluate(executionId, enActionType.User, evaluatedRecordset, false, out errors); AddDebugInputItem(new DebugItemVariableParams(RecordsetName, "Records", tmpentry, executionId)); } IBinaryDataListEntry entry = compiler.Evaluate(executionId, enActionType.Internal, evaluatedRecordset, false, out errors); allErrors.MergeErrors(errors); compiler.Upsert(executionId, Result, entry.FetchScalar().TheValue, out errors); if (dataObject.IsDebugMode() && !allErrors.HasErrors()) { AddDebugOutputItem(new DebugItemVariableParams(Result, "", entry, executionId)); } allErrors.MergeErrors(errors); } } } catch (Exception e) { allErrors.AddError(e.Message); } finally { // Handle Errors var hasErrors = allErrors.HasErrors(); if (hasErrors) { DisplayAndWriteError("DsfDeleteRecordsActivity", allErrors); compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errors); compiler.Upsert(executionId, Result, (string)null, out errors); } if (dataObject.IsDebugMode()) { if (hasErrors) { AddDebugOutputItem(new DebugItemStaticDataParams("", Result, "")); } DispatchDebugState(context, StateType.Before); DispatchDebugState(context, StateType.After); } } }