Beispiel #1
0
        /// <summary>
        /// This method is for passing the context and execute the current transaction
        /// </summary>
        /// <param name="input">Input Context which has to have the type Transaction Context</param>
        /// <returns></returns>
        public TransactionContext Process(TransactionContext input)
        {
            var     stepName       = string.Empty;
            dynamic previousOutput = null;

            while (_steps.Count > 0)
            {
                try
                {
                    var step = _steps.Dequeue();
                    stepName = step.GetType().FullName;

                    _listener?.Before(new ListenerModel()
                    {
                        Context = input, StepName = stepName, TransactionName = _name
                    });

                    step.Before(input);
                    previousOutput = step.Execute(input);

                    _listener?.After(new ListenerModel()
                    {
                        Context = input, StepName = stepName, TransactionName = _name
                    });
                }
                catch (System.Exception e)
                {
                    _listener?.OnError(new ListenerModel()
                    {
                        Context = input, StepName = stepName, TransactionName = _name
                    }, e);
                    throw;
                }
            }

            return(previousOutput);
        }