コード例 #1
0
        public override void Execute(WxeContext context)
        {
            ArgumentUtility.CheckNotNull("context", context);
            Assertion.IsNotNull(_executionListener);

            if (!IsExecutionStarted)
            {
                _variablesContainer.EnsureParametersInitialized(null);
                var wxeSecurityAdapter = GetWxeSecurityAdapter();
                _executionListener = new SecurityExecutionListener(this, _executionListener, wxeSecurityAdapter);

                _transactionStrategy = _transactionMode.CreateTransactionStrategy(this, context);
                Assertion.IsNotNull(_transactionStrategy);

                _executionListener = _transactionStrategy.CreateExecutionListener(_executionListener);
                Assertion.IsNotNull(_executionListener);
            }

            try
            {
                _executionListener.OnExecutionPlay(context);
                base.Execute(context);
                _executionListener.OnExecutionStop(context);
            }
            catch (WxeFatalExecutionException)
            {
                // bubble up
                throw;
            }
            catch (ThreadAbortException)
            {
                _executionListener.OnExecutionPause(context);
                throw;
            }
            catch (Exception stepException)
            {
                try
                {
                    _executionListener.OnExecutionFail(context, stepException);
                }
                catch (Exception listenerException)
                {
                    throw new WxeFatalExecutionException(stepException, listenerException);
                }

                var unwrappedException = WxeHttpExceptionPreservingException.GetUnwrappedException(stepException) ?? stepException;
                if (!_exceptionHandler.Catch(unwrappedException))
                {
                    throw new WxeUnhandledException(
                              string.Format("An exception ocured while executing WxeFunction '{0}'.", GetType().FullName),
                              stepException);
                }
            }

            if (_exceptionHandler.Exception == null && ParentStep != null)
            {
                _variablesContainer.ReturnParametersToCaller();
            }
        }