/// <inheritdoc/>
        public void ExecutePipeline(GracefulCancellationToken cancellationToken)
        {
            Exception exception = null;

            try
            {
                _listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Debug, "Starting pipeline engine"));

                if (!initialized)
                {
                    throw new Exception(
                              "Engine has not been initialized, call Initialize(DataFlowPipelineContext context, params object[] initializationObjects");
                }

                var hasMoreData = true;
                while (!cancellationToken.IsCancellationRequested && hasMoreData)
                {
                    hasMoreData = ExecuteSinglePass(cancellationToken);
                }

                if (cancellationToken.IsAbortRequested)
                {
                    Source.Abort(_listener);

                    foreach (var c in Components)
                    {
                        c.Abort(_listener);
                    }

                    Destination.Abort(_listener);

                    _listener.OnNotify(this,
                                       new NotifyEventArgs(ProgressEventType.Information, "Pipeline engine aborted"));
                    return;
                }
            }
            catch (Exception e)
            {
                exception = e;
                _listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Error, "Data Flow Pipeline Engine execution threw Exception", e));
            }
            finally
            {
                _listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Debug, "Preparing to Dispose of DataFlowPipelineEngine components"));

                _listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Trace, "About to Dispose " + Source));
                try
                {
                    Source.Dispose(_listener, exception);
                }
                catch (Exception e)
                {
                    //dispose crashing is only a dealbreaker if there wasn't already an exception in the pipeline
                    if (exception == null)
                    {
                        throw;
                    }

                    _listener.OnNotify(Source, new NotifyEventArgs(ProgressEventType.Error, "Error Disposing Source Component", e));
                }

                foreach (IDataFlowComponent <T> dataLoadComponent in Components)
                {
                    _listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Trace, "About to Dispose " + dataLoadComponent));
                    try
                    {
                        dataLoadComponent.Dispose(_listener, exception);
                    }
                    catch (Exception e)
                    {
                        //dispose crashing is only a dealbreaker if there wasn't already an exception in the pipeline
                        if (exception == null)
                        {
                            throw;
                        }

                        _listener.OnNotify(dataLoadComponent, new NotifyEventArgs(ProgressEventType.Error, "Error Disposing Component", e));
                    }
                }

                _listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Trace, "About to Dispose " + Destination));
                try
                {
                    Destination.Dispose(_listener, exception);
                }
                catch (Exception e)
                {
                    //dispose crashing is only a dealbreaker if there wasn't already an exception in the pipeline
                    if (exception == null)
                    {
                        throw;
                    }

                    _listener.OnNotify(Destination, new NotifyEventArgs(ProgressEventType.Error, "Error Disposing Destination Component", e));
                }
            }

            if (exception != null)
            {
                throw new Exception("Data Flow Pipeline Crashed", exception);
            }
        }
Exemple #2
0
 protected override void DoRetry()
 {
     Source.Abort();
     Source = DLHandler.CreateRequest(Location);
     Source.SendWebRequest();
 }