Esempio n. 1
0
        public object Perform(PerformContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            var filterInfo = GetFilters(context.BackgroundJob.Job);

            try
            {
                return(PerformJobWithFilters(context, filterInfo.ServerFilters));
            }
            catch (OperationCanceledException)
            {
                throw;
            }
            catch (Exception ex)
            {
                var exceptionContext = new ServerExceptionContext(context, ex);
                InvokeServerExceptionFilters(exceptionContext, filterInfo.ServerExceptionFilters);

                if (!exceptionContext.ExceptionHandled)
                {
                    throw;
                }
            }

            return(null);
        }
Esempio n. 2
0
        public object Run(PerformContext context, IJobPerformer performer)
        {
            if (context == null) throw new ArgumentNullException("context");
            if (performer == null) throw new ArgumentNullException("performer");

            var filterInfo = GetFilters(context.Job);

            try
            {
                return PerformJobWithFilters(context, performer, filterInfo.ServerFilters);
            }
            catch (OperationCanceledException)
            {
                throw;
            }
            catch (Exception ex)
            {
                var exceptionContext = new ServerExceptionContext(context, ex);
                InvokeServerExceptionFilters(exceptionContext, filterInfo.ServerExceptionFilters);

                if (!exceptionContext.ExceptionHandled)
                {
                    throw;
                }
            }

            return null;
        }
        public object Perform(PerformContext context)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));

            var filterInfo = GetFilters(context.BackgroundJob.Job);

            try
            {
                return PerformJobWithFilters(context, filterInfo.ServerFilters);
            }
            catch (JobAbortedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // TODO: Catch only JobPerformanceException, and pass InnerException to filters in 2.0.0.

                if (ex is OperationCanceledException && context.CancellationToken.ShutdownToken.IsCancellationRequested)
                {
                    throw;
                }

                var exceptionContext = new ServerExceptionContext(context, ex);
                InvokeServerExceptionFilters(exceptionContext, filterInfo.ServerExceptionFilters);

                if (!exceptionContext.ExceptionHandled)
                {
                    throw;
                }
            }

            return null;
        }
Esempio n. 4
0
        public void Run(PerformContext context, IJobPerformer performer)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (performer == null)
            {
                throw new ArgumentNullException("performer");
            }

            var filterInfo = GetFilters(context.Job);

            try
            {
                PerformJobWithFilters(context, performer, filterInfo.ServerFilters);
            }
            catch (OperationCanceledException)
            {
                throw;
            }
            catch (Exception ex)
            {
                var exceptionContext = new ServerExceptionContext(context, ex);
                InvokeServerExceptionFilters(exceptionContext, filterInfo.ServerExceptionFilters);

                if (!exceptionContext.ExceptionHandled)
                {
                    throw;
                }
            }
        }
Esempio n. 5
0
 private static void InvokeServerExceptionFilters(
     ServerExceptionContext context,
     IEnumerable <IServerExceptionFilter> filters)
 {
     foreach (var filter in filters.Reverse())
     {
         filter.OnServerException(context);
     }
 }
Esempio n. 6
0
 private static void InvokeServerExceptionFilters(
     ServerExceptionContext context,
     IEnumerable <IServerExceptionFilter> filters)
 {
     foreach (var filter in filters.Reverse())
     {
         context.Profiler.InvokeMeasured(
             Tuple.Create(filter, context),
             InvokeOnServerException,
             $"OnServerException for {context.BackgroundJob.Id}");
     }
 }
Esempio n. 7
0
        public object Perform(PerformContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var filterInfo = GetFilters(context.BackgroundJob.Job);

            try
            {
                return(PerformJobWithFilters(context, filterInfo.ServerFilters));
            }
            catch (JobAbortedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // TODO: Catch only JobPerformanceException, and pass InnerException to filters in 2.0.0.

                if (ex is OperationCanceledException && context.CancellationToken.ShutdownToken.IsCancellationRequested)
                {
                    throw;
                }

                var exceptionContext = new ServerExceptionContext(context, ex);
                InvokeServerExceptionFilters(exceptionContext, filterInfo.ServerExceptionFilters);

                if (!exceptionContext.ExceptionHandled)
                {
                    throw;
                }
            }

            return(null);
        }
Esempio n. 8
0
 private static void InvokeServerExceptionFilters(
     ServerExceptionContext context,
     IEnumerable<IServerExceptionFilter> filters)
 {
     foreach (var filter in filters.Reverse())
     {
         filter.OnServerException(context);
     }
 }