public void ErrorResultTO_MakeErrorResultFromDataListString_WithEmptyErrors_ExpectedNotHasErrors() { var makeErrorResultFromDataListString = ErrorResultTO.MakeErrorResultFromDataListString(string.Empty); Assert.IsFalse(makeErrorResultFromDataListString.HasErrors()); Assert.AreEqual(0, makeErrorResultFromDataListString.FetchErrors().Count); }
public Guid Invoke(IDSFDataObject dataObject, out ErrorResultTO errors) { var result = GlobalConstants.NullDataListID; var time = new Stopwatch(); time.Start(); errors = new ErrorResultTO(); if (dataObject.Environment.HasErrors()) { var errorsFromDataList = ErrorResultTO.MakeErrorResultFromDataListString(dataObject.Environment.FetchErrors(), true); foreach (var error in errorsFromDataList.FetchErrors()) { errors.AddError(error, true); } DispatchDebugErrors(errors, dataObject, StateType.Before); } errors.ClearErrors(); try { errors = TryInvokeService(dataObject, errors); } finally { time.Stop(); ServerStats.IncrementTotalRequests(); ServerStats.IncrementTotalTime(time.ElapsedMilliseconds); DispatchDebugErrors(errors, dataObject, StateType.End); } return(result); }
/// <summary> /// Executes the sub request. /// </summary> /// <param name="dataObject">The data object.</param> /// <param name="workspaceId">The workspace unique identifier.</param> /// <param name="inputDefs">The input defs.</param> /// <param name="outputDefs">The output defs.</param> /// <param name="errors">The errors.</param> /// <returns></returns> public IExecutionEnvironment ExecuteSubRequest(IDSFDataObject dataObject, Guid workspaceId, string inputDefs, string outputDefs, out ErrorResultTO errors) { var theWorkspace = WorkspaceRepository.Instance.Get(workspaceId); var invoker = CreateEsbServicesInvoker(theWorkspace); ErrorResultTO invokeErrors; var oldID = dataObject.DataListID; errors = new ErrorResultTO(); // local non-scoped execution ;) var isLocal = !dataObject.IsRemoteWorkflow(); var principle = Thread.CurrentPrincipal; Dev2Logger.Log.Info("SUB-EXECUTION USER CONTEXT IS [ " + principle.Identity.Name + " ] FOR SERVICE [ " + dataObject.ServiceName + " ]"); _doNotWipeDataList = false; if (dataObject.RunWorkflowAsync) { _doNotWipeDataList = true; ExecuteRequestAsync(dataObject, inputDefs, invoker, isLocal, oldID, out invokeErrors); errors.MergeErrors(invokeErrors); } else { if (isLocal) { if (GetResource(workspaceId, dataObject.ResourceID) == null && GetResource(workspaceId, dataObject.ServiceName) == null) { errors.AddError(string.Format("Resource {0} not found.", dataObject.ServiceName)); return(null); } } var executionContainer = invoker.GenerateInvokeContainer(dataObject, dataObject.ServiceName, isLocal, oldID); if (executionContainer != null) { CreateNewEnvironmentFromInputMappings(dataObject, inputDefs); if (!isLocal) { _doNotWipeDataList = true; SetRemoteExecutionDataList(dataObject, executionContainer, errors); } if (!errors.HasErrors()) { executionContainer.InstanceInputDefinition = inputDefs; executionContainer.InstanceOutputDefinition = outputDefs; executionContainer.Execute(out invokeErrors); var env = UpdatePreviousEnvironmentWithSubExecutionResultUsingOutputMappings(dataObject, outputDefs); errors.MergeErrors(invokeErrors); string errorString = dataObject.Environment.FetchErrors(); invokeErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString); errors.MergeErrors(invokeErrors); return(env); } errors.AddError(string.Format("Resource {0} not found.", dataObject.ServiceName)); } } return(new ExecutionEnvironment()); }
public void ErrorResultsTOMakeErrorResultFromDataListStringWithMultipleErrorsExpectedCorrectErrorResultTO() { ErrorResultTO makeErrorResultFromDataListString = ErrorResultTO.MakeErrorResultFromDataListString("<InnerError>First Error</InnerError><InnerError>Second Error</InnerError>"); Assert.IsTrue(makeErrorResultFromDataListString.HasErrors()); Assert.AreEqual(2, makeErrorResultFromDataListString.FetchErrors().Count); Assert.AreEqual("First Error", makeErrorResultFromDataListString.FetchErrors()[0]); Assert.AreEqual("Second Error", makeErrorResultFromDataListString.FetchErrors()[1]); }
public void ErrorResultTO_MakeErrorResultFromDataListString_WithMultipleDuplicateErrors_ExpectedNotUniqueNotAdded() { var makeErrorResultFromDataListString = ErrorResultTO.MakeErrorResultFromDataListString("<InnerError>First Error</InnerError><InnerError>First Error</InnerError><InnerError>Second Error</InnerError>"); Assert.IsTrue(makeErrorResultFromDataListString.HasErrors()); Assert.AreEqual(2, makeErrorResultFromDataListString.FetchErrors().Count); Assert.AreEqual("First Error", makeErrorResultFromDataListString.FetchErrors()[0]); Assert.AreEqual("Second Error", makeErrorResultFromDataListString.FetchErrors()[1]); }
public void ErrorResultTO_MakeErrorResultFromDataListString_WhenErrorStringNotValidXML_ShouldJustAddTheError() { //------------Setup for test-------------------------- //------------Execute Test--------------------------- ErrorResultTO makeErrorResultFromDataListString = ErrorResultTO.MakeErrorResultFromDataListString("<InnerError>Could not insert <> into a field</InnerError>"); //------------Assert Results------------------------- Assert.AreEqual(1, makeErrorResultFromDataListString.FetchErrors().Count); Assert.AreEqual("<Error><InnerError>Could not insert <> into a field</InnerError></Error>", makeErrorResultFromDataListString.FetchErrors()[0]); }
private void DebugOutput(IDSFDataObject dataObject, int update, ErrorResultTO allErrors, string parentServiceName, string serviceName, Guid oldResourceId) { if (!dataObject.WorkflowResumeable || !dataObject.IsDataListScoped) { // Handle Errors if (allErrors.HasErrors()) { var env = dataObject.Environment; foreach (var allError in allErrors.FetchErrors()) { env.AddError(allError); } // add to datalist in variable specified if (!String.IsNullOrEmpty(OnErrorVariable)) { var errorString = env.FetchErrors(); var errors = ErrorResultTO.MakeErrorResultFromDataListString(errorString, true); var upsertVariable = DataListUtil.AddBracketsToValueIfNotExist(OnErrorVariable); if (errors.HasErrors()) { foreach (var error in errors.FetchErrors()) { //TODO: duplicate check on the Recordset might hide the real issue, //of multiple execution calls passing here which seems not to be the same on F7 env.Assign(upsertVariable, error, update); } } else { env.Assign(upsertVariable, errorString, update); } } DisplayAndWriteError(dataObject, serviceName, allErrors); } } if (dataObject.IsDebugMode() || dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer) { var dt = DateTime.Now; DispatchDebugState(dataObject, StateType.After, update, dt); ChildDebugStateDispatch(dataObject); _debugOutputs = new List <DebugItem>(); DispatchDebugState(dataObject, StateType.Duration, update, dt); } dataObject.ParentInstanceID = _previousInstanceId; dataObject.ParentServiceName = parentServiceName; dataObject.ServiceName = serviceName; dataObject.RemoteInvokeResultShape = new StringBuilder(); // reset targnet shape ;) dataObject.RunWorkflowAsync = false; dataObject.RemoteInvokerID = Guid.Empty.ToString(); dataObject.EnvironmentID = Guid.Empty; dataObject.ResourceID = oldResourceId; }
protected override IExecutionEnvironment ExecuteWorkflow(bool wasTestExecution, int update, bool handleErrors) { if (_isLocal && GetResourceById(_workspaceId, _dataObject.ResourceID) == null && GetResourceByName(_workspaceId, _dataObject.ServiceName) == null) { _errors.AddError(string.Format(ErrorResource.ResourceNotFound, _dataObject.ServiceName)); _dataObject.StartTime = _oldStartTime; return(null); } var executionContainer = _invoker.GenerateInvokeContainer(_dataObject, _dataObject.ServiceName, _isLocal, _oldId); _dataObject.IsServiceTestExecution = wasTestExecution; if (executionContainer != null) { _dataObject.CreateNewEnvironmentFromInputMappings(_inputDefs, update); ConfigureDataListIfRemote(executionContainer); if (!_errors.HasErrors()) { executionContainer.InstanceInputDefinition = _inputDefs; executionContainer.InstanceOutputDefinition = _outputDefs; ErrorResultTO invokeErrors; if (_dataObject.StartActivityId != Guid.Empty) { var dynamicService = ResourceCatalog.Instance.GetService(GlobalConstants.ServerWorkspaceID, _dataObject.ResourceID, ""); var sa = dynamicService.Actions.FirstOrDefault(); var container = CustomContainer.Get <IResumableExecutionContainerFactory>().New(_dataObject.StartActivityId, sa, (DsfDataObject)_dataObject); container.Execute(out invokeErrors, update); } else { executionContainer.Execute(out invokeErrors, update); } var env = _environmentOutputMappingManager.UpdatePreviousEnvironmentWithSubExecutionResultUsingOutputMappings(_dataObject, _outputDefs, update, handleErrors, _errors); _errors.MergeErrors(invokeErrors); var errorString = _dataObject.Environment.FetchErrors(); invokeErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString); _errors.MergeErrors(invokeErrors); _dataObject.StartTime = _oldStartTime; return(env); } _errors.AddError(string.Format(ErrorResource.ResourceNotFound, _dataObject.ServiceName)); } return(null); }
ErrorResultTO TryInvokeService(IDSFDataObject dataObject, ErrorResultTO errors) { var serviceId = dataObject.ResourceID; var serviceName = dataObject.ServiceName; if (serviceId == Guid.Empty && string.IsNullOrEmpty(serviceName)) { errors.AddError(Resources.DynamicServiceError_ServiceNotSpecified); } else { try { errors = InvokeService(dataObject, errors, serviceId, serviceName); } catch (Exception e) { errors.AddError(e.Message, true); } finally { var environment = dataObject.Environment; if (environment.HasErrors()) { var errorString = environment.FetchErrors(); var executionErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString, true); errors.MergeErrors(executionErrors); } if (dataObject.ReturnType == Web.EmitionTypes.XML || dataObject.ReturnType == Web.EmitionTypes.TRX) { environment.AddError(errors.MakeDataListReady(), true); } else { environment.AddError(errors.MakeDataListReady(false), true); } if (errors.HasErrors()) { Dev2Logger.Error(errors.MakeDisplayReady(), dataObject.ExecutionID.ToString()); } } } return(errors); }
protected void DoErrorHandling(NativeActivityContext context, IDataListCompiler compiler, IDSFDataObject dataObject) { string errorString = compiler.FetchErrors(dataObject.DataListID, true); string currentError = compiler.FetchErrors(dataObject.DataListID); ErrorResultTO _tmpErrorsAfter = ErrorResultTO.MakeErrorResultFromDataListString(errorString); _tmpErrors.MergeErrors(_tmpErrorsAfter); if (_tmpErrors.HasErrors()) { if (!(this is DsfFlowDecisionActivity)) { compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, _tmpErrors.MakeDataListReady(), out errorsTo); if (!String.IsNullOrEmpty(currentError)) { PerformCustomErrorHandling(context, compiler, dataObject, currentError, _tmpErrors); } } } }
ErrorResultTO TryInvokeService(IDSFDataObject dataObject, ErrorResultTO errors) { var serviceId = dataObject.ResourceID; var serviceName = dataObject.ServiceName; if (serviceId == Guid.Empty && string.IsNullOrEmpty(serviceName)) { errors.AddError(Resources.DynamicServiceError_ServiceNotSpecified); } else { try { errors = InvokeService(dataObject, errors, serviceId, serviceName); } catch (Exception e) { errors.AddError(e.Message); } finally { var environment = dataObject.Environment; if (environment.HasErrors()) { var errorString = environment.FetchErrors(); var executionErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString); errors.MergeErrors(executionErrors); } environment.AddError(errors.MakeDataListReady()); if (errors.HasErrors()) { Dev2Logger.Error(errors.MakeDisplayReady(), GlobalConstants.WarewolfError); } } } return(errors); }
protected override IExecutionEnvironment ExecuteWorkflow(bool wasTestExecution, int update, bool handleErrors) { if (_isLocal && GetResourceById(_workspaceId, _dataObject.ResourceID) == null && GetResourceByName(_workspaceId, _dataObject.ServiceName) == null) { _errors.AddError(string.Format(ErrorResource.ResourceNotFound, _dataObject.ServiceName)); _dataObject.StartTime = _oldStartTime; return(null); } var executionContainer = _invoker.GenerateInvokeContainer(_dataObject, _dataObject.ServiceName, _isLocal, _oldId); _dataObject.IsServiceTestExecution = wasTestExecution; if (executionContainer != null) { _dataObject.CreateNewEnvironmentFromInputMappings(_inputDefs, update); ConfigureDataListIfRemote(executionContainer); if (!_errors.HasErrors()) { executionContainer.InstanceInputDefinition = _inputDefs; executionContainer.InstanceOutputDefinition = _outputDefs; executionContainer.Execute(out var invokeErrors, update); var env = _environmentOutputMappingManager.UpdatePreviousEnvironmentWithSubExecutionResultUsingOutputMappings(_dataObject, _outputDefs, update, handleErrors, _errors); _errors.MergeErrors(invokeErrors); var errorString = _dataObject.Environment.FetchErrors(); invokeErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString); _errors.MergeErrors(invokeErrors); _dataObject.StartTime = _oldStartTime; return(env); } _errors.AddError(string.Format(ErrorResource.ResourceNotFound, _dataObject.ServiceName)); } return(null); }
/// <summary> /// Executes the sub request. /// </summary> /// <param name="dataObject">The data object.</param> /// <param name="workspaceId">The workspace unique identifier.</param> /// <param name="inputDefs">The input defs.</param> /// <param name="outputDefs">The output defs.</param> /// <param name="errors">The errors.</param> /// <returns></returns> public Guid ExecuteSubRequest(IDSFDataObject dataObject, Guid workspaceId, string inputDefs, string outputDefs, out ErrorResultTO errors) { var theWorkspace = WorkspaceRepository.Instance.Get(workspaceId); var invoker = CreateEsbServicesInvoker(theWorkspace); ErrorResultTO invokeErrors; var oldID = dataObject.DataListID; var compiler = DataListFactory.CreateDataListCompiler(); var remainingMappings = ShapeForSubRequest(dataObject, inputDefs, outputDefs, out errors); // local non-scoped execution ;) var isLocal = !dataObject.IsRemoteWorkflow(); var principle = Thread.CurrentPrincipal; Dev2Logger.Log.Info("SUB-EXECUTION USER CONTEXT IS [ " + principle.Identity.Name + " ] FOR SERVICE [ " + dataObject.ServiceName + " ]"); var result = dataObject.DataListID; _doNotWipeDataList = false; if (dataObject.RunWorkflowAsync) { _doNotWipeDataList = true; ExecuteRequestAsync(dataObject, compiler, invoker, isLocal, oldID, out invokeErrors); errors.MergeErrors(invokeErrors); } else { var executionContainer = invoker.GenerateInvokeContainer(dataObject, dataObject.ServiceName, isLocal, oldID); if (executionContainer != null) { if (!isLocal) { _doNotWipeDataList = true; SetRemoteExecutionDataList(dataObject, executionContainer); } executionContainer.InstanceOutputDefinition = outputDefs; result = executionContainer.Execute(out invokeErrors); errors.MergeErrors(invokeErrors); string errorString = compiler.FetchErrors(dataObject.DataListID, true); invokeErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString); errors.MergeErrors(invokeErrors); // If Web-service or Plugin, skip the final shaping junk ;) if (SubExecutionRequiresShape(workspaceId, dataObject.ServiceName)) { if (!dataObject.IsDataListScoped && remainingMappings != null) { // Adjust the remaining output mappings ;) compiler.SetParentID(dataObject.DataListID, oldID); var outputMappings = remainingMappings.FirstOrDefault(c => c.Key == enDev2ArgumentType.Output); compiler.Shape(dataObject.DataListID, enDev2ArgumentType.Output, outputMappings.Value, out invokeErrors); errors.MergeErrors(invokeErrors); } else { compiler.Shape(dataObject.DataListID, enDev2ArgumentType.Output, outputDefs, out invokeErrors); errors.MergeErrors(invokeErrors); } } // The act of doing this moves the index data correctly ;) // We need to remove this in the future. #pragma warning disable 168 // ReSharper disable UnusedVariable var dl1 = compiler.ConvertFrom(dataObject.DataListID, DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), enTranslationDepth.Data, out invokeErrors); var dl2 = compiler.ConvertFrom(oldID, DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), enTranslationDepth.Data, out invokeErrors); // ReSharper restore UnusedVariable #pragma warning restore 168 return(result); } errors.AddError("Null container returned"); } return(result); }
public IExecutionEnvironment ExecuteSubRequest(IDSFDataObject dataObject, Guid workspaceId, string inputDefs, string outputDefs, out ErrorResultTO errors, int update, bool handleErrors) { var wasTestExecution = dataObject.IsServiceTestExecution; dataObject.IsSubExecution = true; try { dataObject.IsServiceTestExecution = false; var theWorkspace = wRepository.Get(workspaceId); var invoker = CreateEsbServicesInvoker(theWorkspace); ErrorResultTO invokeErrors; var oldID = dataObject.DataListID; errors = new ErrorResultTO(); // local non-scoped execution ;) var isLocal = !dataObject.IsRemoteWorkflow(); var principle = Thread.CurrentPrincipal; Dev2Logger.Info("SUB-EXECUTION USER CONTEXT IS [ " + principle.Identity.Name + " ] FOR SERVICE [ " + dataObject.ServiceName + " ]", dataObject.ExecutionID.ToString()); var oldStartTime = dataObject.StartTime; dataObject.StartTime = DateTime.Now; if (dataObject.RunWorkflowAsync) { ExecuteRequestAsync(dataObject, inputDefs, invoker, isLocal, oldID, out invokeErrors, update); dataObject.StartTime = oldStartTime; errors.MergeErrors(invokeErrors); } else { if (isLocal && GetResource(workspaceId, dataObject.ResourceID) == null && GetResource(workspaceId, dataObject.ServiceName) == null) { errors.AddError(string.Format(ErrorResource.ResourceNotFound, dataObject.ServiceName)); dataObject.StartTime = oldStartTime; return(null); } var executionContainer = invoker.GenerateInvokeContainer(dataObject, dataObject.ServiceName, isLocal, oldID); dataObject.IsServiceTestExecution = wasTestExecution; if (executionContainer != null) { CreateNewEnvironmentFromInputMappings(dataObject, inputDefs, update); } if (executionContainer != null && !isLocal) { SetRemoteExecutionDataList(dataObject, executionContainer, errors); } if (executionContainer != null && !errors.HasErrors()) { executionContainer.InstanceInputDefinition = inputDefs; executionContainer.InstanceOutputDefinition = outputDefs; executionContainer.Execute(out invokeErrors, update); var env = UpdatePreviousEnvironmentWithSubExecutionResultUsingOutputMappings(dataObject, outputDefs, update, handleErrors, errors); errors.MergeErrors(invokeErrors); var errorString = dataObject.Environment.FetchErrors(); invokeErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString); errors.MergeErrors(invokeErrors); dataObject.StartTime = oldStartTime; return(env); } if (executionContainer != null) { errors.AddError(string.Format(ErrorResource.ResourceNotFound, dataObject.ServiceName)); } } dataObject.StartTime = oldStartTime; return(new ExecutionEnvironment()); } finally { dataObject.IsServiceTestExecution = wasTestExecution; dataObject.IsSubExecution = false; } }
/// <summary> /// Invokes the specified service as per the dataObject against theHost /// </summary> /// <param name="dataObject">The data object.</param> /// <param name="errors">The errors.</param> /// <returns></returns> /// <exception cref="System.Exception">Can only execute workflows from web browser</exception> public Guid Invoke(IDSFDataObject dataObject, out ErrorResultTO errors) { var result = GlobalConstants.NullDataListID; var time = new Stopwatch(); time.Start(); errors = new ErrorResultTO(); const int Update = 0; if (dataObject.Environment.HasErrors()) { errors.AddError(dataObject.Environment.FetchErrors()); DispatchDebugErrors(errors, dataObject, StateType.Before); } errors.ClearErrors(); try { var serviceId = dataObject.ResourceID; var serviceName = dataObject.ServiceName; if (serviceId == Guid.Empty && string.IsNullOrEmpty(serviceName)) { errors.AddError(Resources.DynamicServiceError_ServiceNotSpecified); } else { try { Dev2Logger.Debug("Finding service"); var theService = serviceId == Guid.Empty ? _serviceLocator.FindService(serviceName, _workspace.ID) : _serviceLocator.FindService(serviceId, _workspace.ID); if (theService == null) { if (!dataObject.IsServiceTestExecution) { theService = _serviceLocator.FindService(serviceName, GlobalConstants.ServerWorkspaceID); } if (theService == null) { if (dataObject.IsServiceTestExecution) { var testResult = new ServiceTestModelTO { Result = new TestRunResult { RunTestResult = RunResult.TestResourceDeleted, Message = "Resource has been deleted", DebugForTest = new List <IDebugState>(), TestName = dataObject.TestName }, TestPassed = false, TestInvalid = true, FailureMessage = "Resource has been deleted", TestName = dataObject.TestName, }; var ser = new Dev2JsonSerializer(); _request.ExecuteResult = ser.SerializeToBuilder(testResult); } errors.AddError(string.Format(ErrorResource.ServiceNotFound, serviceName)); } } else if (theService.Actions.Count <= 1) { #region Execute ESB container var theStart = theService.Actions.FirstOrDefault(); if (theStart != null && theStart.ActionType != enActionType.InvokeManagementDynamicService && theStart.ActionType != enActionType.Workflow && dataObject.IsFromWebServer) { throw new Exception(ErrorResource.CanOnlyExecuteWorkflowsFromWebBrowser); } Dev2Logger.Debug("Mapping Action Dependencies"); MapServiceActionDependencies(theStart); if (theStart != null) { theStart.Service = theService; theStart.DataListSpecification = theService.DataListSpecification; Dev2Logger.Debug("Getting container"); var container = GenerateContainer(theStart, dataObject, _workspace); ErrorResultTO invokeErrors; result = container.Execute(out invokeErrors, Update); errors.MergeErrors(invokeErrors); } #endregion } else { errors.AddError(string.Format(ErrorResource.MalformedService, serviceId)); } } catch (Exception e) { errors.AddError(e.Message); } finally { if (dataObject.Environment.HasErrors()) { var errorString = dataObject.Environment.FetchErrors(); var executionErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString); errors.MergeErrors(executionErrors); } dataObject.Environment.AddError(errors.MakeDataListReady()); if (errors.HasErrors()) { Dev2Logger.Error(errors.MakeDisplayReady()); } } } } finally { time.Stop(); ServerStats.IncrementTotalRequests(); ServerStats.IncrementTotalTime(time.ElapsedMilliseconds); DispatchDebugErrors(errors, dataObject, StateType.End); } return(result); }
// 4423 : TWR - sealed so that this cannot be overridden protected override sealed void Execute(NativeActivityContext context) { Dev2Logger.Log.Debug(String.Format("Start {0}", GetType().Name)); _tmpErrors = new ErrorResultTO(); _isOnDemandSimulation = false; var dataObject = context.GetExtension <IDSFDataObject>(); IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); // we need to register this child thread with the DataListRegistar so we can scope correctly ;) DataListRegistar.RegisterActivityThreadToParentId(dataObject.ParentThreadID, Thread.CurrentThread.ManagedThreadId); if (compiler != null) { string errorString = dataObject.Environment.FetchErrors(); _tmpErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString); if (!(this is DsfFlowDecisionActivity)) { } DataListExecutionID.Set(context, dataObject.DataListID); } _previousParentInstanceID = dataObject.ParentInstanceID; _isOnDemandSimulation = dataObject.IsOnDemandSimulation; OnBeforeExecute(context); try { var className = GetType().Name; Tracker.TrackEvent(TrackerEventGroup.ActivityExecution, className); if (ShouldExecuteSimulation) { OnExecuteSimulation(context); } else { OnExecute(context); } } catch (Exception ex) { Dev2Logger.Log.Error("OnExecute", ex); var errorString = ex.Message; var errorResultTO = new ErrorResultTO(); errorResultTO.AddError(errorString); if (compiler != null) { dataObject.Environment.AddError(errorResultTO.MakeDataListReady()); } } finally { if (!_isExecuteAsync || _isOnDemandSimulation) { var resumable = dataObject.WorkflowResumeable; OnExecutedCompleted(context, false, resumable); if (compiler != null) { DoErrorHandling(dataObject); } } } }
/// <summary> /// Invokes the specified service as per the dataObject against theHost /// </summary> /// <param name="dataObject">The data object.</param> /// <param name="errors">The errors.</param> /// <returns></returns> /// <exception cref="System.Exception">Can only execute workflows from web browser</exception> public Guid Invoke(IDSFDataObject dataObject, out ErrorResultTO errors) { var result = GlobalConstants.NullDataListID; var time = new Stopwatch(); time.Start(); errors = new ErrorResultTO(); int update = 0; // BUG 9706 - 2013.06.22 - TWR : added pre debug dispatch if (dataObject.Environment.HasErrors()) { errors.AddError(dataObject.Environment.FetchErrors()); DispatchDebugErrors(errors, dataObject, StateType.Before); } errors.ClearErrors(); try { var serviceId = dataObject.ResourceID; // we need to get better at getting this ;) var serviceName = dataObject.ServiceName; if (serviceId == Guid.Empty && string.IsNullOrEmpty(serviceName)) { errors.AddError(Resources.DynamicServiceError_ServiceNotSpecified); } else { try { var sl = new ServiceLocator(); Dev2Logger.Log.Debug("Finding service"); var theService = serviceId == Guid.Empty ? sl.FindService(serviceName, _workspace.ID) : sl.FindService(serviceId, _workspace.ID); if (theService == null) { errors.AddError("Service [ " + serviceName + " ] not found."); } else if (theService.Actions.Count <= 1) { #region Execute ESB container var theStart = theService.Actions.FirstOrDefault(); if (theStart != null && theStart.ActionType != Common.Interfaces.Core.DynamicServices.enActionType.InvokeManagementDynamicService && theStart.ActionType != Common.Interfaces.Core.DynamicServices.enActionType.Workflow && dataObject.IsFromWebServer) { throw new Exception("Can only execute workflows from web browser"); } Dev2Logger.Log.Debug("Mapping Action Dependencies"); MapServiceActionDependencies(theStart, sl); // Invoke based upon type ;) if (theStart != null) { theStart.DataListSpecification = theService.DataListSpecification; Dev2Logger.Log.Debug("Getting container"); var container = GenerateContainer(theStart, dataObject, _workspace); ErrorResultTO invokeErrors; result = container.Execute(out invokeErrors, update); errors.MergeErrors(invokeErrors); } #endregion } else { errors.AddError("Malformed Service [ " + serviceId + " ] it contains multiple actions"); } } catch (Exception e) { errors.AddError(e.Message); } finally { if (dataObject.Environment.HasErrors()) { var errorString = dataObject.Environment.FetchErrors(); var executionErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString); errors.MergeErrors(executionErrors); } dataObject.Environment.AddError(errors.MakeDataListReady()); if (errors.HasErrors()) { Dev2Logger.Log.Error(errors.MakeDisplayReady()); } } } } finally { time.Stop(); ServerStats.IncrementTotalRequests(); ServerStats.IncrementTotalTime(time.ElapsedMilliseconds); // BUG 9706 - 2013.06.22 - TWR : added DispatchDebugErrors(errors, dataObject, StateType.End); } return(result); }