public string Run(CreateContext context, IJobCreator creator)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (creator == null)
            {
                throw new ArgumentNullException("creator");
            }

            var filterInfo = GetFilters(context.Job);

            try
            {
                var createdContext = CreateWithFilters(context, creator, filterInfo.ClientFilters);
                return(createdContext.JobId);
            }
            catch (Exception ex)
            {
                var exceptionContext = new ClientExceptionContext(context, ex);

                InvokeExceptionFilters(exceptionContext, filterInfo.ClientExceptionFilters);
                if (!exceptionContext.ExceptionHandled)
                {
                    throw;
                }

                return(null);
            }
        }
Пример #2
0
        public BackgroundJob Create(CreateContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var filterInfo = GetFilters(context.Job);

            try
            {
                var createdContext = CreateWithFilters(context, filterInfo.ClientFilters);
                return(createdContext.BackgroundJob);
            }
            catch (Exception ex)
            {
                var exceptionContext = new ClientExceptionContext(context, ex);

                InvokeExceptionFilters(exceptionContext, filterInfo.ClientExceptionFilters);
                if (!exceptionContext.ExceptionHandled)
                {
                    throw;
                }

                return(null);
            }
        }
Пример #3
0
        public string Run(CreateContext context, IJobCreator creator)
        {
            if (context == null) throw new ArgumentNullException("context");
            if (creator == null) throw new ArgumentNullException("creator");

            var filterInfo = GetFilters(context.Job);

            try
            {
                var createdContext = CreateWithFilters(context, creator, filterInfo.ClientFilters);
                return createdContext.JobId;
            }
            catch (Exception ex)
            {
                var exceptionContext = new ClientExceptionContext(context, ex);

                InvokeExceptionFilters(exceptionContext, filterInfo.ClientExceptionFilters);
                if (!exceptionContext.ExceptionHandled)
                {
                    throw;
                }

                return null;
            }
        }
        public void Ctor_CorrectlySets_AllProperties()
        {
            var exception = new Exception();
            var context = new ClientExceptionContext(_createContext, exception);

            Assert.Same(exception, context.Exception);
            Assert.False(context.ExceptionHandled);
        }
Пример #5
0
 private static void InvokeExceptionFilters(
     ClientExceptionContext context, IEnumerable <IClientExceptionFilter> filters)
 {
     foreach (var filter in filters.Reverse())
     {
         filter.OnClientException(context);
     }
 }
Пример #6
0
 private static void InvokeExceptionFilters(
     ClientExceptionContext context, IEnumerable <IClientExceptionFilter> filters)
 {
     foreach (var filter in filters.Reverse())
     {
         context.Profiler.InvokeMeasured(
             filter,
             x => x.OnClientException(context),
             $"OnClientException for {context.Job.Type.FullName}.{context.Job.Method.Name}");
     }
 }
Пример #7
0
        public void Run(CreateContext context)
        {
            if (context == null) throw new ArgumentNullException("context");

            var filterInfo = GetFilters(context.Job);

            try
            {
                CreateWithFilters(context, filterInfo.ClientFilters);
            }
            catch (Exception ex)
            {
                var exceptionContext = new ClientExceptionContext(context, ex);

                InvokeExceptionFilters(exceptionContext, filterInfo.ClientExceptionFilters);
                if (!exceptionContext.ExceptionHandled)
                {
                    throw;
                }
            }
        }
Пример #8
0
        public void Run(CreateContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            var filterInfo = GetFilters(context.Job);

            try
            {
                CreateWithFilters(context, filterInfo.ClientFilters);
            }
            catch (Exception ex)
            {
                var exceptionContext = new ClientExceptionContext(context, ex);

                InvokeExceptionFilters(exceptionContext, filterInfo.ClientExceptionFilters);
                if (!exceptionContext.ExceptionHandled)
                {
                    throw;
                }
            }
        }
Пример #9
0
        public BackgroundJob Create(CreateContext context)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));

            var filterInfo = GetFilters(context.Job);

            try
            {
                var createdContext = CreateWithFilters(context, filterInfo.ClientFilters);
                return createdContext.BackgroundJob;
            }
            catch (Exception ex)
            {
                var exceptionContext = new ClientExceptionContext(context, ex);

                InvokeExceptionFilters(exceptionContext, filterInfo.ClientExceptionFilters);
                if (!exceptionContext.ExceptionHandled)
                {
                    throw;
                }

                return null;
            }
        }
Пример #10
0
 private static void InvokeExceptionFilters(
     ClientExceptionContext context, IEnumerable<IClientExceptionFilter> filters)
 {
     foreach (var filter in filters.Reverse())
     {
         filter.OnClientException(context);
     }
 }