protected override void Execute(CodeActivityContext executionContext)
        {
            Type exType = null;

            Assembly assembly = Assembly.Load(AssemblyName.Get(executionContext));

            exType = assembly.GetType(ExceptionType.Get(executionContext));

            if (exType != null)
            {
                ConstructorInfo ci = exType.GetConstructor(new Type[] { typeof(string) });
                throw (Exception)ci.Invoke(new object[] { "Called From ISV Activity Throw Exception" });
            }
            else
            {
                throw new ArgumentException(String.Format("Did not find Exception {0} in any of the assemblies",
                                                          ExceptionType.Get(executionContext)));
            }
        }
Пример #2
0
        private void ActionFailed(NativeActivityFaultContext faultContext, Exception propagatedexception, ActivityInstance propagatedfrom)
        {
            Int32 currentAttemptCount = _attemptCount.Get(faultContext);
            Int32 maxAttempts         = MaxAttempts.Get(faultContext);

            Type[] exceptionType = ExceptionType.Get(faultContext);

            //Increment and track the count
            currentAttemptCount++;
            _attemptCount.Set(faultContext, currentAttemptCount);

            if (currentAttemptCount >= maxAttempts)
            {
                // There are no further attempts to make
                return;
            }

            if (ShouldRetryAction(exceptionType, propagatedexception) == false)
            {
                _log.Error("Will only retry exception of type '" + exceptionType.ToCSV() + "'. Unhandled type of '" + propagatedexception.GetType().FullName + "' was found.", propagatedexception);
                return;
            }

            faultContext.CancelChild(propagatedfrom);
            faultContext.HandleFault();

            TimeSpan retryInterval = _delayOverrideForUnitTests == null?RetryInterval.Get(faultContext) : _delayOverrideForUnitTests.Value;

            _log.Debug("Retrying in " + retryInterval.TotalSeconds + " seconds due to " + propagatedexception.GetType().FullName + ". " + currentAttemptCount + " of " + maxAttempts);

            if (retryInterval == TimeSpan.Zero)
            {
                ExecuteAttempt(faultContext);
            }
            else
            {
                // We are going to wait before trying again
                _delayDuration.Set(faultContext, retryInterval);
                faultContext.ScheduleActivity(
                    _internalDelay,
                    DelayCompleted);
            }
        }