ErrorResultTO TryExecute(IDSFDataObject dataObject, int update, ErrorResultTO allErrors) { allErrors.MergeErrors(_errorsTo); if (dataObject.IsDebugMode()) { var debugItem = new DebugItem(); AddDebugItem(new DebugEvalResult(Url, "URL", dataObject.Environment, update), debugItem); _debugInputs.Add(debugItem); } var colItr = new WarewolfListIterator(); var urlitr = new WarewolfIterator(dataObject.Environment.Eval(Url, update)); var headerItr = new WarewolfIterator(dataObject.Environment.Eval(Headers, update)); colItr.AddVariableToIterateOn(urlitr); colItr.AddVariableToIterateOn(headerItr); var counter = 1; while (colItr.HasMoreData()) { var c = colItr.FetchNextValue(urlitr); var headerValue = colItr.FetchNextValue(headerItr); var headers = string.IsNullOrEmpty(headerValue) ? new string[0] : headerValue.Split(new[] { '\n', '\r', ';' }, StringSplitOptions.RemoveEmptyEntries); var headersEntries = new List <Tuple <string, string> >(); counter = DebugInputItemsAdd(dataObject, update, allErrors, counter, c, headers, headersEntries); } return(allErrors); }
private void GenerateRequestDictionaryFromDataObject(out ErrorResultTO errors) { var compiler = DataListFactory.CreateDataListCompiler(); errors = new ErrorResultTO(); ErrorResultTO invokeErrors; IBinaryDataList bdl = compiler.FetchBinaryDataList(DataObject.DataListID, out invokeErrors); errors.MergeErrors(invokeErrors); if (!invokeErrors.HasErrors()) { foreach (IBinaryDataListEntry entry in bdl.FetchScalarEntries()) { IBinaryDataListItem itm = entry.FetchScalar(); if (!DataListUtil.IsSystemTag(itm.FieldName)) { var stringBuilder = new StringBuilder(""); try { stringBuilder = new StringBuilder(itm.TheValue); } // ReSharper disable EmptyGeneralCatchClause catch (Exception) // ReSharper restore EmptyGeneralCatchClause { } Request.AddArgument(itm.FieldName, stringBuilder); } } } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { _debugOutputs.Clear(); _debugInputs.Clear(); InitializeDebug(dataObject); var errors = new ErrorResultTO(); var allErrors = new ErrorResultTO(); try { if (!errors.HasErrors()) { var innerCount = 1; foreach (ActivityDTO t in FieldsCollection) { innerCount = TryExecute(dataObject, update, allErrors, innerCount, t); } dataObject.Environment.CommitAssign(); allErrors.MergeErrors(errors); } } catch (Exception e) { Dev2Logger.Error(e, GlobalConstants.WarewolfError); allErrors.AddError(e.Message); } finally { // Handle Errors HandleErrors(dataObject, update, allErrors); } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { var allErrors = new ErrorResultTO(); var errors = new ErrorResultTO(); allErrors.MergeErrors(errors); InitializeDebug(dataObject); // Process if no errors try { TryExecute(dataObject, update, allErrors, errors); } catch (Exception e) { Dev2Logger.Error("DSFDateTime", e, GlobalConstants.WarewolfError); allErrors.AddError(e.Message); } finally { // Handle Errors if (allErrors.HasErrors()) { DisplayAndWriteError("DsfDateTimeDifferenceActivity", allErrors); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); dataObject.Environment.Assign(Result, null, update); } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
List <IDev2DataListEvaluateIterator> GetIteratorsFromInputMappings(IDataListCompiler compiler, Guid executionId, IDSFDataObject dataObject, IDev2IteratorCollection iteratorCollection, out ErrorResultTO errorsResultTo) { errorsResultTo = new ErrorResultTO(); var listOfIterators = new List <IDev2DataListEvaluateIterator>(); var indexCounter = 1; foreach (var row in InputMappings) { if (String.IsNullOrEmpty(row.InputColumn)) { continue; } ErrorResultTO invokeErrors; var expressionsEntry = compiler.Evaluate(executionId, enActionType.User, row.InputColumn, false, out invokeErrors); errorsResultTo.MergeErrors(invokeErrors); if (dataObject.IsDebugMode()) { AddDebugInputItem(row.InputColumn, row.OutputColumn.ColumnName, expressionsEntry, row.OutputColumn.DataTypeName, executionId, indexCounter); indexCounter++; } var itr = Dev2ValueObjectFactory.CreateEvaluateIterator(expressionsEntry); iteratorCollection.AddIterator(itr); listOfIterators.Add(itr); } return(listOfIterators); }
/// <summary> /// Shapes the mappings automatic target data list. /// </summary> /// <param name="inputs">The inputs.</param> /// <param name="outputs">The outputs.</param> /// <param name="errors">The errors.</param> /// <param name="isDbService"></param> /// <returns></returns> StringBuilder ShapeMappingsToTargetDataList(string inputs, string outputs, out ErrorResultTO errors, bool isDbService) { errors = new ErrorResultTO(); ErrorResultTO invokeErrors; var oDL = DataListUtil.ShapeDefinitionsToDataList(outputs, enDev2ArgumentType.Output, out invokeErrors, isDbService: isDbService); errors.MergeErrors(invokeErrors); var iDL = DataListUtil.ShapeDefinitionsToDataList(inputs, enDev2ArgumentType.Input, out invokeErrors, isDbService: isDbService); errors.MergeErrors(invokeErrors); var result = GlueInputAndOutputMappingSegments(iDL.ToString(), oDL.ToString(), out invokeErrors); errors.MergeErrors(invokeErrors); return(result); }
public Guid ExecuteRequest(IDSFDataObject dataObject, EsbExecuteRequest request, Guid workspaceId, out ErrorResultTO errors) { var resultID = GlobalConstants.NullDataListID; errors = new ErrorResultTO(); IWorkspace theWorkspace = null; Common.Utilities.PerformActionInsideImpersonatedContext(Common.Utilities.ServerUser, () => { theWorkspace = WorkspaceRepository.Instance.Get(workspaceId); }); var dataListOkay = EnsureDataListIdIsSet(dataObject, workspaceId, errors); if (!dataListOkay) { return(resultID); } try { Dev2Logger.Debug("Creating Invoker", dataObject.ExecutionID.ToString()); using (var invoker = new EsbServiceInvoker(this, theWorkspace, request)) { resultID = invoker.Invoke(dataObject, out var invokeErrors); errors.MergeErrors(invokeErrors); } } catch (Exception ex) { errors.AddError(ex.Message); } return(resultID); }
ErrorResultTO TryExecute(IDSFDataObject dataObject, int update, ErrorResultTO allErrors) { allErrors.MergeErrors(_errorsTo); if (dataObject.IsDebugMode()) { var debugItem = new DebugItem(); AddDebugItem(new DebugEvalResult(Url, "URL", dataObject.Environment, update), debugItem); _debugInputs.Add(debugItem); } var colItr = new WarewolfListIterator(); var urlitr = new WarewolfIterator(dataObject.Environment.Eval(Url, update)); var headerItr = new WarewolfIterator(dataObject.Environment.Eval(Headers, update)); colItr.AddVariableToIterateOn(urlitr); colItr.AddVariableToIterateOn(headerItr); const int IndexToUpsertTo = 1; while (colItr.HasMoreData()) { var c = colItr.FetchNextValue(urlitr); var headerValue = colItr.FetchNextValue(headerItr); var headers = string.IsNullOrEmpty(headerValue) ? new string[0] : headerValue.Split(new[] { '\n', '\r', ';' }, StringSplitOptions.RemoveEmptyEntries); var headersEntries = new List <Tuple <string, string> >(); foreach (var header in headers) { var headerSegments = header.Split(':'); headersEntries.Add(new Tuple <string, string>(headerSegments[0], headerSegments[1])); if (dataObject.IsDebugMode()) { var debugItem = new DebugItem(); AddDebugItem(new DebugEvalResult(Headers, "Header", dataObject.Environment, update), debugItem); _debugInputs.Add(debugItem); } } var result = WebRequestInvoker.ExecuteRequest(Method, c, headersEntries); allErrors.MergeErrors(_errorsTo); var expression = GetExpression(IndexToUpsertTo); PushResultsToDataList(expression, result, dataObject, update); } return(allErrors); }
/// <summary> /// Resumed the specified context. /// </summary> /// <param name="context">The context.</param> /// <param name="bookmark">The bookmark.</param> /// <param name="value">The value.</param> /// <exception cref="System.Exception"> /// Parent and Child DataList IDs are the same, aborting resumption! /// or /// Fatal Error : Cannot merge resumed data /// or /// Fatal Error : Cannot locate Root DataList for resumption! /// </exception> public virtual void Resumed(NativeActivityContext context, Bookmark bookmark, object value) { IDSFDataObject myDO = context.GetExtension <IDSFDataObject>(); IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); ErrorResultTO errorResultTO = new ErrorResultTO(); Guid executionID = myDO.DataListID; if (value != null) { Guid rootID; Guid.TryParse(value.ToString(), out rootID); if (executionID == rootID) { throw new Exception("Parent and Child DataList IDs are the same, aborting resumption!"); } try { /* Now perform the shape.... */ // First set the parentID on executionID to rootID.. so the shape happens correctly ;) compiler.SetParentID(rootID, executionID); // Next shape the execution result into the root datalist ;) ErrorResultTO tmpErrors; Guid shapeID = compiler.Shape(rootID, enDev2ArgumentType.Output, OutputMapping, out tmpErrors); errorResultTO.MergeErrors(tmpErrors); // set parent instanceID myDO.DataListID = executionID; // reset the DataListID accordingly if (shapeID != executionID) { throw new Exception("Fatal Error : Cannot merge resumed data"); } compiler.ConditionalMerge(DataListMergeFrequency.Always | DataListMergeFrequency.OnResumption, myDO.DatalistOutMergeID, myDO.DataListID, myDO.DatalistOutMergeFrequency, myDO.DatalistOutMergeType, myDO.DatalistOutMergeDepth); ExecutionStatusCallbackDispatcher.Instance.Post(myDO.BookmarkExecutionCallbackID, ExecutionStatusCallbackMessageType.ResumedCallback); } finally { // At resumption this is the root dl entry ;) // Handle Errors if (errorResultTO.HasErrors()) { DisplayAndWriteError("Resumption", errorResultTO); var errorString = errorResultTO.MakeDataListReady(); myDO.Environment.AddError(errorString); } } } else { throw new Exception("Fatal Error : Cannot locate Root DataList for resumption!"); } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { var errorResultTo = new ErrorResultTO(); var allErrors = new ErrorResultTO(); var addExceptionToErrorList = true; InitializeDebug(dataObject); try { var parametersIteratorCollection = BuildParametersIteratorCollection(dataObject.Environment, out IWarewolfIterator batchItr, out IWarewolfIterator timeoutItr, update); var currentOptions = BuildSqlBulkCopyOptions(); var runtimeDatabase = ResourceCatalog.GetResource <DbSource>(dataObject.WorkspaceID, Database.ResourceID); Common.Utilities.PerformActionInsideImpersonatedContext(Common.Utilities.OrginalExecutingUser, () => { if (!allErrors.HasErrors()) { if (runtimeDatabase.ServerType == enSourceType.MySqlDatabase) { DoInsertForMySql(runtimeDatabase, currentOptions, parametersIteratorCollection, batchItr, timeoutItr, dataObject, errorResultTo, allErrors, ref addExceptionToErrorList, update); } else { DoInsertForSqlServer(runtimeDatabase, currentOptions, dataObject, allErrors, batchItr, parametersIteratorCollection, timeoutItr, ref errorResultTo, ref addExceptionToErrorList, update); } } }); allErrors.MergeErrors(errorResultTo); } catch (Exception e) { if (addExceptionToErrorList) { allErrors.AddError(e.Message); } Dev2Logger.Error(this, e, GlobalConstants.WarewolfError); } finally { // Handle Errors if (allErrors.HasErrors()) { DisplayAndWriteError("DsfSqlBulkInsertActivity", allErrors); dataObject.Environment.Assign(Result, null, update); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); if (dataObject.IsDebugMode()) { AddDebugOutputItem(new DebugItemStaticDataParams("Failure", Result, "", "=")); } } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
void MergeResultIntoDataList(IDataListCompiler compiler, IOutputFormatter outputFormatter, object result, out ErrorResultTO errors) { errors = new ErrorResultTO(); // NOTE : This is only used by Plugin Services and is 1 of 4 locations that now needs to be updated should the DataList or execution model change ;) // Format the XML data if (RequiresFormatting) { if (result == null) { return; } try { errors = new ErrorResultTO(); ErrorResultTO invokeErrors; var formattedPayload = result.ToString(); if (!HandlesOutputFormatting) { formattedPayload = outputFormatter != null?outputFormatter.Format(result).ToString() : result.ToString(); } // Create a shape from the service action outputs var dlShape = compiler.ShapeDev2DefinitionsToDataList(Service.OutputSpecification, enDev2ArgumentType.Output, false, out invokeErrors); errors.MergeErrors(invokeErrors); // Push formatted data into a datalist using the shape from the service action outputs var shapeDataListID = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), formattedPayload.ToStringBuilder(), dlShape, out invokeErrors); errors.MergeErrors(invokeErrors); // This merge op is killing the alias data.... // We need to account for alias ops too ;) compiler.SetParentID(shapeDataListID, DataObj.DataListID); compiler.PopulateDataList(DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), InstanceOutputDefintions, InstanceOutputDefintions, shapeDataListID, out invokeErrors); errors.MergeErrors(invokeErrors); } catch (Exception) { errors.AddError("Data Format Error : It is likely that you tested with one format yet the service is returning another. IE you tested with XML and it now returns JSON"); } } }
void ExecuteServiceAndMergeResultIntoDataList(IOutputFormatter outputFormatter, IDataListCompiler compiler, IDev2IteratorCollection itrCollection, IEnumerable <IDev2DataListEvaluateIterator> itrs, out ErrorResultTO errors) { errors = new ErrorResultTO(); ErrorResultTO invokeErrors; var response = ExecuteService(Service.Method.Parameters, itrCollection, itrs, out invokeErrors, outputFormatter); errors.MergeErrors(invokeErrors); if (errors.HasErrors()) { return; } // TODO : This needs to move to the other side of the Marshaled Invoke MergeResultIntoDataList(compiler, outputFormatter, response, out invokeErrors); errors.MergeErrors(invokeErrors); }
public override Guid Execute(out ErrorResultTO errors, int update) { errors = new ErrorResultTO(); var invokeErrors = new ErrorResultTO(); var result = GlobalConstants.NullDataListID; try { var eme = _managementServiceLocator.LocateManagementService(ServiceAction.Name); if (eme != null) { // Web request for internal service ;) if (Request.Args == null) { GenerateRequestDictionaryFromDataObject(out invokeErrors); errors.MergeErrors(invokeErrors); } if (CanExecute(eme)) { Common.Utilities.PerformActionInsideImpersonatedContext(Common.Utilities.ServerUser, () => { var res = eme.Execute(Request.Args, TheWorkspace); Request.ExecuteResult = res; result = DataObject.DataListID; }); errors.MergeErrors(invokeErrors); } else { SetMessage(errors, eme); } Request.WasInternalService = true; } else { errors.AddError(string.Format(ErrorResource.CouldNotLocateManagementService, ServiceAction.ServiceName)); } } catch (Exception ex) { errors.AddError(ex.Message); } return(result); }
public virtual Guid Execute(out ErrorResultTO errors, int update) { //This execution will throw errors from the constructor errors = new ErrorResultTO(); errors.MergeErrors(_errorResult); TryExecuteImpl(out errors, update); return(DataObj.DataListID); }
protected override void ExecutionImpl(IEsbChannel esbChannel, IDSFDataObject dataObject, string inputs, string outputs, out ErrorResultTO tmpErrors, int update) { tmpErrors = new ErrorResultTO(); var webRequestResult = string.Empty; try { if (Headers == null) { tmpErrors.AddError(ErrorResource.HeadersAreNull); return; } if (QueryString == null) { tmpErrors.AddError(ErrorResource.QueryIsNull); return; } var(head, query, _) = ConfigureHttp(dataObject, update); var url = ResourceCatalog.GetResource <WebSource>(Guid.Empty, SourceId); if (dataObject.IsDebugMode()) { AddDebugInputItem(new DebugEvalResult(query, "URL", dataObject.Environment, update)); AddDebugInputItem(new DebugEvalResult(url.Address, "Query String", dataObject.Environment, update)); } webRequestResult = PerformWebRequest(head, query, url); } catch (Exception ex) { tmpErrors.AddError(ex.Message); } finally { tmpErrors.MergeErrors(_errorsTo); ResponseManager = new ResponseManager { OutputDescription = OutputDescription, Outputs = Outputs, IsObject = IsObject, ObjectName = ObjectName }; } if (IsResponseBase64) { ResponseManager.PushResponseIntoEnvironment(webRequestResult, update, dataObject); return; } webRequestResult = Scrubber.Scrub(webRequestResult); ResponseManager.PushResponseIntoEnvironment(webRequestResult, update, dataObject); }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { var errorResultTo = new ErrorResultTO(); var allErrors = new ErrorResultTO(); bool addExceptionToErrorList = true; InitializeDebug(dataObject); try { IWarewolfIterator batchItr; IWarewolfIterator timeoutItr; var parametersIteratorCollection = BuildParametersIteratorCollection(dataObject.Environment, out batchItr, out timeoutItr, update); var currentOptions = BuildSqlBulkCopyOptions(); var runtimeDatabase = ResourceCatalog.Instance.GetResource <DbSource>(dataObject.WorkspaceID, Database.ResourceID); if (runtimeDatabase.ServerType == enSourceType.MySqlDatabase) { DoInsertForMySql(runtimeDatabase, currentOptions, parametersIteratorCollection, batchItr, timeoutItr, dataObject, errorResultTo, allErrors, ref addExceptionToErrorList, update); } else { DoInsertForSqlServer(runtimeDatabase, currentOptions, dataObject, allErrors, batchItr, parametersIteratorCollection, timeoutItr, ref errorResultTo, ref addExceptionToErrorList, update); } allErrors.MergeErrors(errorResultTo); } catch (Exception e) { if (addExceptionToErrorList) { allErrors.AddError(e.Message); } // ReSharper disable InvokeAsExtensionMethod Dev2Logger.Log.Error(this, e); // ReSharper restore InvokeAsExtensionMethod } finally { // Handle Errors if (allErrors.HasErrors()) { DisplayAndWriteError("DsfSqlBulkInsertActivity", allErrors); dataObject.Environment.Assign(Result, null, update); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); if (dataObject.IsDebugMode()) { AddDebugOutputItem(new DebugItemStaticDataParams("Failure", Result, "", "=")); } } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
protected override void ExecutionImpl(IEsbChannel esbChannel, IDSFDataObject dataObject, string inputs, string outputs, out ErrorResultTO tmpErrors, int update) { _dataObject = dataObject; tmpErrors = new ErrorResultTO(); var webRequestResult = string.Empty; try { var(head, query, postData, conditions) = GetEnvironmentInputVariables(_dataObject.Environment, update); var source = ResourceCatalog.GetResource <WebSource>(Guid.Empty, SourceId); var isManualChecked = Convert.ToBoolean(Settings?.FirstOrDefault(s => s.Name == nameof(IsManualChecked))?.Value); var isFormDataChecked = Convert.ToBoolean(Settings?.FirstOrDefault(s => s.Name == nameof(IsFormDataChecked))?.Value); var isUrlEncodedChecked = Convert.ToBoolean(Settings?.FirstOrDefault(s => s.Name == nameof(IsUrlEncodedChecked))?.Value); if (isManualChecked || isFormDataChecked || isUrlEncodedChecked) { var webPostOptions = new WebPostOptions { Head = head, Headers = head?.Select(h => h.Name + ":" + h.Value)?.ToArray() ?? new string[0], Method = WebRequestMethod.Post, Parameters = conditions, Query = query, Source = source, PostData = postData, Settings = Settings, IsManualChecked = isManualChecked, IsFormDataChecked = isFormDataChecked, IsUrlEncodedChecked = isUrlEncodedChecked }; webRequestResult = PerformWebPostRequest(webPostOptions); } } catch (Exception ex) { tmpErrors.AddError(ex.Message); } finally { tmpErrors.MergeErrors(_errorsTo); var bytes = webRequestResult.Base64StringToByteArray(); var response = bytes.ReadToString(); ResponseManager = new ResponseManager { OutputDescription = OutputDescription, Outputs = Outputs, IsObject = IsObject, ObjectName = ObjectName }; response = Scrubber.Scrub(response); ResponseManager.PushResponseIntoEnvironment(response, update, dataObject); } }
public EvaluateRuleSet(EvaluateRuleSet prevIter) { Errors = new ErrorResultTO(); Errors.MergeErrors(prevIter.Errors); _result = prevIter._result; _ns = prevIter._ns; IsDebug = prevIter.IsDebug; EvaluateToRootOnly = prevIter.EvaluateToRootOnly; }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { var allErrors = new ErrorResultTO(); var errors = new ErrorResultTO(); allErrors.MergeErrors(errors); InitializeDebug(dataObject); // Process if no errors try { ValidateRecordsetName(RecordsetName, errors); allErrors.MergeErrors(errors); if (!allErrors.HasErrors()) { try { TryExecuteTool(dataObject, update, allErrors); } catch (Exception e) { AddDebugInputItem(new DebugItemStaticDataParams("", RecordsetName, "Recordset", "=")); allErrors.AddError(e.Message); dataObject.Environment.Assign(CountNumber, "0", update); AddDebugOutputItem(new DebugItemStaticDataParams("0", CountNumber, "", "=")); } } } finally { // Handle Errors var hasErrors = allErrors.HasErrors(); if (hasErrors) { var errorString = allErrors.MakeDataListReady(); dataObject.Environment.AddError(errorString); DisplayAndWriteError(dataObject, DisplayName, allErrors); } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
void ExecuteService(out ErrorResultTO errors, int update, IOutputFormatter formater = null) { errors = new ErrorResultTO(); try { var parameters = new List <MethodParameter>(); if (Service is WebService) { var webService = Service as WebService; if (!string.IsNullOrEmpty(webService.RequestBody)) { var methodParameter = new MethodParameter { Name = DataListUtil.RemoveLanguageBrackets(webService.RequestBody), Value = ExecutionEnvironment.WarewolfEvalResultToString(DataObj.Environment.Eval(webService.RequestBody, update)) }; parameters.Add(methodParameter); } if (!string.IsNullOrEmpty(webService.RequestHeaders)) { var methodParameter = new MethodParameter { Name = DataListUtil.RemoveLanguageBrackets(webService.RequestHeaders), Value = ExecutionEnvironment.WarewolfEvalResultToString(DataObj.Environment.Eval(webService.RequestHeaders, update)) }; parameters.Add(methodParameter); } } string result; if (parameters.Any()) { result = ExecuteService(update, out errors, formater).ToString(); } else { result = ExecuteService(update, out var invokeErrors, formater).ToString(); errors.MergeErrors(invokeErrors); } if (!HandlesOutputFormatting) { var formattedPayload = formater?.Format(result).ToString() ?? result; PushXmlIntoEnvironment(formattedPayload, update); } else { PushXmlIntoEnvironment(result, update); } } catch (Exception ex) { errors.AddError(string.Format(ErrorResource.ServiceExecutionError, ex.StackTrace)); } }
private void AddToErrorsToDebugOutput(IDSFDataObject dataObject, int update, IDev2MergeOperations mergeOperations, ErrorResultTO allErrors, ErrorResultTO errorResultTo) { dataObject.Environment.Assign(Result, mergeOperations.MergeData.ToString(), update); allErrors.MergeErrors(errorResultTo); if (dataObject.IsDebugMode() && !allErrors.HasErrors()) { AddDebugOutputItem(new DebugEvalResult(Result, "", dataObject.Environment, update)); } }
public virtual Guid Execute(out ErrorResultTO errors) { //This execution will throw errors from the constructor errors = new ErrorResultTO(); errors.MergeErrors(ErrorResult); IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); ExecuteImpl(compiler, out errors); return(DataObj.DataListID); }
/// <summary> /// Executes the request. /// </summary> /// <param name="dataObject">The data object.</param> /// <param name="request"></param> /// <param name="workspaceId">The workspace ID.</param> /// <param name="errors">The errors.</param> /// <returns></returns> public Guid ExecuteRequest(IDSFDataObject dataObject, EsbExecuteRequest request, Guid workspaceId, out ErrorResultTO errors) { var resultID = GlobalConstants.NullDataListID; errors = new ErrorResultTO(); IWorkspace theWorkspace = null; Common.Utilities.PerformActionInsideImpersonatedContext(Common.Utilities.ServerUser, () => { theWorkspace = wRepository.Get(workspaceId); }); // If no DLID, we need to make it based upon the request ;) if (dataObject.DataListID == GlobalConstants.NullDataListID) { IResource resource; try { resource = dataObject.ResourceID == Guid.Empty ? GetResource(workspaceId, dataObject.ServiceName) : GetResource(workspaceId, dataObject.ResourceID); } catch (Exception ex) { Dev2Logger.Error(ex); errors.AddError(string.Format(ErrorResource.ServiceNotFound, dataObject.ServiceName)); return(resultID); } if (resource?.DataList != null) { Dev2Logger.Debug("Mapping Inputs from Environment"); ExecutionEnvironmentUtils.UpdateEnvironmentFromInputPayload(dataObject, dataObject.RawPayload, resource.DataList.ToString()); } dataObject.RawPayload = new StringBuilder(); // We need to create the parentID around the system ;) dataObject.ParentThreadID = Thread.CurrentThread.ManagedThreadId; } try { // Setup the invoker endpoint ;) Dev2Logger.Debug("Creating Invoker"); using (var invoker = new EsbServiceInvoker(this, theWorkspace, request)) { // Should return the top level DLID ErrorResultTO invokeErrors; resultID = invoker.Invoke(dataObject, out invokeErrors); errors.MergeErrors(invokeErrors); } } catch (Exception ex) { errors.AddError(ex.Message); } return(resultID); }
/// <summary> /// this method exist for the datalist server port /// it is a crap way to upserting since it replicates all the existing functionality of the server, but it is the quickest /// and with an activity re-write coming, it is as good as it needs to be... /// </summary> /// <param name="outputs">The outputs.</param> /// <param name="dataListID">The data list unique identifier.</param> /// <param name="compiler">The compiler.</param> /// <param name="errors">The errors.</param> /// <returns></returns> public Guid UpsertOutputs(IList <OutputTO> outputs, Guid dataListID, IDataListCompiler compiler, out ErrorResultTO errors) { ErrorResultTO allErrors = new ErrorResultTO(); ActivityUpsertTO toUpsert = BinaryDataListEntryBuilder.CreateEntriesFromOutputTOs(outputs, compiler, dataListID, out errors); if (errors.HasErrors()) { allErrors.MergeErrors(errors); } Guid result = compiler.Upsert(dataListID, toUpsert.FetchExpressions(), toUpsert.FetchBinaryEntries(), out errors); if (errors.HasErrors()) { allErrors.MergeErrors(errors); } errors = allErrors; return(result); }
void MergeErrors(ErrorResultTO errors, int update, IOutputFormatter outputFormatter, List <IWarewolfIterator> itrs, IWarewolfListIterator itrCollection) { ErrorResultTO invokeErrors; if (Inputs != null && Inputs.Count == 0) { ExecuteService(out invokeErrors, update, outputFormatter); errors.MergeErrors(invokeErrors); } else { BuildParameterIterators(update, null, itrCollection, itrs); while (itrCollection.HasMoreData()) { ExecuteService(itrCollection, itrs, out invokeErrors, update, outputFormatter); errors.MergeErrors(invokeErrors); } } }
// NOTE : This will be tested by the related WebServices and Plugin Integration Test public Guid Populate(object input, Guid targetDl, string outputDefs, out ErrorResultTO errors) { // input is a string of output mappings ;) var compiler = DataListFactory.CreateDataListCompiler(); var outputDefinitions = (input as string); errors = new ErrorResultTO(); ErrorResultTO invokeErrors; // get sneeky and use the output shape operation for now, // as this should only every be called from external service containers all is good // if this is ever not the case be afraid, be very afraid! var targetDataList = compiler.FetchBinaryDataList(targetDl, out invokeErrors); errors.MergeErrors(invokeErrors); var parentDataList = compiler.FetchBinaryDataList(targetDataList.ParentUID, out invokeErrors); errors.MergeErrors(invokeErrors); var grandparentDl = compiler.FetchBinaryDataList(parentDataList.ParentUID, out invokeErrors); // as a result we need to re-set some alias operations that took place in the parent DataList where they happended ;) foreach (var entry in parentDataList.FetchRecordsetEntries()) { entry.AdjustAliasOperationForExternalServicePopulate(); } var parentId = parentDataList.UID; if (grandparentDl != null) { parentId = grandparentDl.UID; } compiler.SetParentID(targetDl, parentId); Guid result = compiler.Shape(targetDl, enDev2ArgumentType.Output, outputDefinitions, out invokeErrors); errors.MergeErrors(invokeErrors); return(result); }
/// <summary> /// Converts the and filter. /// </summary> /// <param name="payload">The payload.</param> /// <param name="filterShape">The filter shape.</param> /// <param name="errors">The errors.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">payload</exception> public StringBuilder ConvertAndFilter(IBinaryDataList payload, StringBuilder filterShape, out ErrorResultTO errors) { if (payload == null) { throw new ArgumentNullException("payload"); } int keyCnt = 0; errors = new ErrorResultTO(); TranslatorUtils tu = new TranslatorUtils(); ErrorResultTO invokeErrors; IBinaryDataList targetDl = tu.TranslateShapeToObject(filterShape, false, out invokeErrors); errors.MergeErrors(invokeErrors); IList <string> itemKeys = targetDl.FetchAllUserKeys(); StringBuilder result = new StringBuilder("{"); foreach (string key in itemKeys) { IBinaryDataListEntry entry; IBinaryDataListEntry tmpEntry; string error; if (payload.TryGetEntry(key, out entry, out error) && targetDl.TryGetEntry(key, out tmpEntry, out error)) { if (entry.IsRecordset) { result.Append(ProcessRecordSet(entry, out error)); errors.AddError(error); } else { result.Append(ProcessScalar(entry)); } // wack in , for field separator ;) keyCnt++; if (keyCnt < itemKeys.Count) { result.Append(","); } } errors.AddError(error); } result.Append("}"); return(result); }
private void ExecuteImpl(ErrorResultTO errors, int update, IOutputFormatter outputFormatter, List <IWarewolfIterator> itrs, IWarewolfListIterator itrCollection) { var method = Service.Method; var inputs = method.Parameters; if (inputs.Count == 0) { ExecuteService(out ErrorResultTO invokeErrors, update, outputFormatter); errors.MergeErrors(invokeErrors); } else { BuildParameterIterators(update, inputs, itrCollection, itrs); while (itrCollection.HasMoreData()) { ExecuteService(itrCollection, itrs, out ErrorResultTO invokeErrors, update, outputFormatter); errors.MergeErrors(invokeErrors); } } }
public void ErrorResultTO_MergeErrors_NullOtherDoesNotThrow() { var errorResultTo = new ErrorResultTO(); Assert.AreEqual(0, errorResultTo.FetchErrors().Count); errorResultTo.AddError("SomeError"); Assert.AreEqual(1, errorResultTo.FetchErrors().Count); errorResultTo.MergeErrors(null); Assert.AreEqual(1, errorResultTo.FetchErrors().Count); }
#pragma warning disable S1541 // Methods and properties should not be too complex private void TryExecute(IDSFDataObject dataObject, int update, ErrorResultTO allErrors, ErrorResultTO errors) #pragma warning restore S1541 // Methods and properties should not be too complex { IsSingleValueRule.ApplyIsSingleValueRule(Result, allErrors); var colItr = new WarewolfListIterator(); var iteratorPropertyDictionary = new Dictionary <string, IWarewolfIterator>(); foreach (var propertyInfo in GetType().GetProperties().Where(info => info.IsDefined(typeof(Inputs)))) { var attributes = (Inputs[])propertyInfo.GetCustomAttributes(typeof(Inputs), false); var variableValue = propertyInfo.GetValue(this) as string; if (!string.IsNullOrEmpty(variableValue)) { if (dataObject.IsDebugMode()) { AddDebugInputItem(new DebugEvalResult(variableValue, attributes[0].UserVisibleName, dataObject.Environment, update)); } var dtItr = CreateDataListEvaluateIterator(variableValue, dataObject.Environment, update); colItr.AddVariableToIterateOn(dtItr); iteratorPropertyDictionary.Add(propertyInfo.Name, dtItr); } } if (colItr.FieldCount <= 0) { var evaluatedValues = new Dictionary <string, string>(); _executionResult = PerformExecution(evaluatedValues); AssignResult(dataObject, update); } else { while (colItr.HasMoreData()) { var evaluatedValues = new Dictionary <string, string>(); foreach (var dev2DataListEvaluateIterator in iteratorPropertyDictionary) { var binaryDataListItem = colItr.FetchNextValue(dev2DataListEvaluateIterator.Value); evaluatedValues.Add(dev2DataListEvaluateIterator.Key, binaryDataListItem); } _executionResult = PerformExecution(evaluatedValues); AssignResult(dataObject, update); } } if (dataObject.IsDebugMode() && !allErrors.HasErrors() && !string.IsNullOrWhiteSpace(Result) && dataObject.IsDebugMode() && !allErrors.HasErrors() && !string.IsNullOrEmpty(Result)) { AddDebugOutputItem(new DebugEvalResult(Result, "", dataObject.Environment, update)); } allErrors.MergeErrors(errors); }
public void AddAlias(Guid dlId, string parentColumn, string parentNamespace, string childColumn, out ErrorResultTO errors) { errors = new ErrorResultTO(); // TODO : This needs to change so we can track at all levels what the root alias is ;) IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); Guid masterId = dlId; string masterRs = parentNamespace; string masterCol = parentColumn; Guid searchId = dlId; IBinaryDataListEntry masterEntry = null; int aliasSearchRounds = 0; BinaryDataListAlias binaryDataListAlias = null; while(searchId != Guid.Empty) { ErrorResultTO invokeErrors; var bdl = compiler.FetchBinaryDataList(searchId, out invokeErrors); errors.MergeErrors(invokeErrors); if(bdl != null) { string error; bdl.TryGetEntry(masterRs, out masterEntry, out error); errors.AddError(error); if(masterEntry != null) { var aliases = masterEntry.FetchAlias(); if(aliases.TryGetValue(masterCol, out binaryDataListAlias)) { // we have a hit ;) masterId = binaryDataListAlias.MasterKeyID; searchId = masterId; masterRs = binaryDataListAlias.MasterNamespace; masterCol = binaryDataListAlias.MasterColumn; aliasSearchRounds++; } else { // ensure we copy over the alias entry's keys ;) if(IsEmtpy) { var keyItr = masterEntry.FetchRecordsetIndexes(); _myKeys = new IndexList(keyItr.FetchGaps(), keyItr.MaxIndex(), keyItr.MinIndex()); IsEmtpy = false; } searchId = Guid.Empty; // signal end ;) } } else { if(aliasSearchRounds == 0) { throw new Exception("Missing Entry"); } // we hit the bottom earlier, handle it ;) if(binaryDataListAlias != null) { masterEntry = binaryDataListAlias.MasterEntry; } searchId = Guid.Empty; // signal end ;) } } else { throw new Exception("Missing DataList"); } } // Check MasterKeyID to see if it contains an alias, if so keep bubbling until we at end ;) _keyToAliasMap[childColumn] = new BinaryDataListAlias { MasterKeyID = masterId, ChildKey = GenerateKeyPrefix(Namespace, DataListKey), MasterKey = GenerateKeyPrefix(masterRs, masterId), MasterColumn = masterCol, MasterNamespace = masterRs, MasterEntry = masterEntry }; }