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() 

            }
Beispiel #2
0
 private void WorkflowCompletedCallback(WorkflowApplicationCompletedEventArgs cArgs)
 {
     var output = cArgs.GetInstanceExtensions<List<string>>();
     var enumerable = output as List<string>[] ?? output.ToArray();
     if (enumerable.First() != null)
     {
         txbOutput.Dispatcher.Invoke(() =>
         {
             foreach (string item in enumerable.First())
             {
                 txbOutput.Text += item + "\r\n";
             }
         });
     }
 }