private void OnCompleted(WorkflowApplicationCompletedEventArgs args) { _result = args.GetInstanceExtensions <IDSFDataObject>().ToList().First(); IDictionary <string, object> outputs = args.Outputs; try { if (!_isDebug) { // Travis.Frisinger : 19.10.2012 - Duplicated Recordset Data Bug 6038 object parentId; outputs.TryGetValue("ParentWorkflowInstanceId", out parentId); parentId = _result.ParentWorkflowInstanceId; object parentServiceName; outputs.TryGetValue("ParentServiceName", out parentServiceName); var parentServiceNameStr = string.IsNullOrEmpty(_result.ParentServiceName) ? string.Empty : _result.ParentServiceName; if (!string.IsNullOrEmpty(parentServiceNameStr) && Guid.TryParse(parentId.ToString(), out _parentWorkflowInstanceID)) { if (_parentWorkflowInstanceID != _currentInstanceID) { // BUG 7850 - TWR - 2013.03.11 - ResourceCatalog refactor var services = ResourceCatalog.Instance.GetDynamicObjects <DynamicServiceObjectBase>(_workspace.ID, parentServiceNameStr); if (services != null && services.Count > 0) { var service = services[0] as DynamicService; if (service != null) { _currentInstanceID = _parentWorkflowInstanceID; var actionSet = service.Actions; if (_result.WorkflowResumeable) { var serviceAction = actionSet.First(); PooledServiceActivity wfActivity = serviceAction.PopActivity(); try { ErrorResultTO invokeErrors; _result = _owner.InvokeWorkflow(wfActivity.Value, _result, _executionExtensions, _parentWorkflowInstanceID, _workspace, "dsfResumption", out invokeErrors); // attach any execution errors if (AllErrors != null) { AllErrors.MergeErrors(invokeErrors); } } finally { serviceAction.PushActivity(wfActivity); } } } } } } } } catch (Exception ex) { Dev2Logger.Log.Error(ex); ExecutionStatusCallbackDispatcher.Instance.Post(_result.ExecutionCallbackID, ExecutionStatusCallbackMessageType.ErrorCallback); } finally { try { if (_waitHandle != null) { _waitHandle.Set(); } ExecutableServiceRepository.Instance.Remove(this); if (DataTransferObject != null) { DataTransferObject.NumberOfSteps = _previousNumberOfSteps; } } catch (Exception e) { // Best effort ;) Dev2Logger.Log.Error(e); } } // force a throw to kill the engine ;) if (args.TerminationException != null) { _instance.Terminate("Force Terminate", new TimeSpan(0, 0, 1, 0)); } // Not compatable with run.Dispose() }
/// <summary> /// Executes the specified errors. /// </summary> /// <param name="errors">The errors.</param> /// <returns></returns> public override Guid Execute(out ErrorResultTO errors) { errors = new ErrorResultTO(); WorkflowApplicationFactory wfFactor = new WorkflowApplicationFactory(); Guid result = GlobalConstants.NullDataListID; // set current bookmark as per DataObject ;) string bookmark = DataObject.CurrentBookmarkName; Guid instanceId = DataObject.WorkflowInstanceId; // Set Service Name DataObject.ServiceName = ServiceAction.ServiceName; // Set server ID, only if not set yet - original server; if (DataObject.ServerID == Guid.Empty) { DataObject.ServerID = HostSecurityProvider.Instance.ServerID; } // Set resource ID, only if not set yet - original resource; if (DataObject.ResourceID == Guid.Empty && ServiceAction != null && ServiceAction.Service != null) { DataObject.ResourceID = ServiceAction.Service.ID; } // Travis : Now set Data List DataObject.DataList = ServiceAction.DataListSpecification; // Set original instance ID, only if not set yet - original resource; if (DataObject.OriginalInstanceID == Guid.Empty) { DataObject.OriginalInstanceID = DataObject.DataListID; } Dev2Logger.Log.Info(String.Format("Started Execution for Service Name:{0} Resource Id:{1} Mode:{2}", DataObject.ServiceName, DataObject.ResourceID, DataObject.IsDebug?"Debug":"Execute")); //Set execution origin if (!string.IsNullOrWhiteSpace(DataObject.ParentServiceName)) { DataObject.ExecutionOrigin = ExecutionOrigin.Workflow; DataObject.ExecutionOriginDescription = DataObject.ParentServiceName; } else if (DataObject.IsDebug) { DataObject.ExecutionOrigin = ExecutionOrigin.Debug; } else { DataObject.ExecutionOrigin = ExecutionOrigin.External; } PooledServiceActivity activity = ServiceAction.PopActivity(); try { var theActivity = activity.Value as DynamicActivity; // BUG 9304 - 2013.05.08 - TWR - Added CompileExpressions _workflowHelper.CompileExpressions(theActivity); IDSFDataObject exeResult = wfFactor.InvokeWorkflow(activity.Value, DataObject, new List <object> { EsbChannel, }, instanceId, TheWorkspace, bookmark, out errors); result = exeResult.DataListID; } catch (InvalidWorkflowException iwe) { Dev2Logger.Log.Error(iwe); var msg = iwe.Message; int start = msg.IndexOf("Flowchart ", StringComparison.Ordinal); // trap the no start node error so we can replace it with something nicer ;) errors.AddError(start > 0 ? GlobalConstants.NoStartNodeError : iwe.Message); } catch (Exception ex) { Dev2Logger.Log.Error(ex); errors.AddError(ex.Message); } finally { ServiceAction.PushActivity(activity); } Dev2Logger.Log.Info(String.Format("Completed Execution for Service Name:{0} Resource Id: {1} Mode:{2}", DataObject.ServiceName, DataObject.ResourceID, DataObject.IsDebug?"Debug":"Execute")); return(result); }