private static async Task ExecuteSyncFilter(
     PageHandlerExecutingContext context,
     PageHandlerExecutionDelegate next,
     IPageFilter pageFilter)
 {
     pageFilter.OnPageHandlerExecuting(context);
     if (context.Result == null)
     {
         pageFilter.OnPageHandlerExecuted(await next());
     }
 }
Beispiel #2
0
        public IEnumerable <Aluno> ListarAlunosPorVencimento(IPageFilter pageFilter)
        {
            var query = IncludeTabela();

            query = query.OrderBy(a => a.Nome);

            var dataVencimento = DateTime.Today.AddDays(60);

            query = query.Where(x => x.TurmasAluno.Any(y => y.TipoStatusAlunoId == (int)TipoStatusAlunoEnum.Ativo) && x.DataValidade < dataVencimento);

            pageFilter.Total = query.Count();
            return(PaginarResultado(query, pageFilter).ToList());
        }
        public static void AfterOnPageHandlerSelected(
            this DiagnosticListener diagnosticListener,
            PageHandlerSelectedContext handlerSelectedContext,
            IPageFilter filter)
        {
            Debug.Assert(diagnosticListener != null);
            Debug.Assert(handlerSelectedContext != null);
            Debug.Assert(filter != null);

            // Inlinable fast-path check if Diagnositcs is enabled
            if (diagnosticListener.IsEnabled())
            {
                AfterOnPageHandlerSelectedImpl(diagnosticListener, handlerSelectedContext, filter);
            }
        }
        public static void BeforeOnPageHandlerExecuting(
            this DiagnosticListener diagnosticListener,
            PageHandlerExecutingContext handlerExecutingContext,
            IPageFilter filter)
        {
            Debug.Assert(diagnosticListener != null);
            Debug.Assert(handlerExecutingContext != null);
            Debug.Assert(filter != null);

            // Inlinable fast-path check if Diagnositcs is enabled
            if (diagnosticListener.IsEnabled())
            {
                BeforeOnPageHandlerExecutingImpl(diagnosticListener, handlerExecutingContext, filter);
            }
        }
Beispiel #5
0
        public IEnumerable <Retorno> FiltrarRetornos(IPageFilter filter, bool paginar = false)
        {
            var query = Query();

            query = query.Include(x => x.Registros);
            query = query.OrderBy(a => a.DataReferencia);

            if (paginar)
            {
                filter.Total = query.Count();
                return(PaginarResultado(query, filter).ToList());
            }
            else
            {
                return(query.ToList());
            }
        }
Beispiel #6
0
 public FilterResultDTO <AlunoDTO> ListarAlunosPorVencimento(IPageFilter filter)
 {
     try
     {
         IEnumerable <Aluno> alunos = alunoRepository.ListarAlunosPorVencimento(filter);
         var retorno = new FilterResultDTO <AlunoDTO>
         {
             Total         = filter.Total,
             Pagina        = filter.Pagina,
             TamanhoPagina = filter.TamanhoPagina,
             Lista         = alunos.Select(x => new AlunoDTO(x))
         };
         return(retorno);
     }
     catch (Exception e)
     {
         log.Error("Erro ao buscar alunos por vencimento.", e);
         throw new Exception("Erro ao buscar alunos por vencimento.");
     }
 }
Beispiel #7
0
 public FilterResultDTO <RetornoArquivoDTO> FiltrarRetornos(IPageFilter filter)
 {
     try
     {
         IEnumerable <Retorno> retornos = retornoRepository.FiltrarRetornos(filter, true);
         var retorno = new FilterResultDTO <RetornoArquivoDTO>
         {
             Total         = filter.Total,
             Pagina        = filter.Pagina,
             TamanhoPagina = filter.TamanhoPagina,
             Lista         = retornos.Select(x => new RetornoArquivoDTO(x))
         };
         return(retorno);
     }
     catch (Exception e)
     {
         log.Error("Erro ao buscar retornos.", e);
         throw new Exception("Erro ao buscar retornos.");
     }
 }
Beispiel #8
0
        public static void AfterOnPageHandlerSelected(
            this DiagnosticSource diagnosticSource,
            PageHandlerSelectedContext handlerSelectedContext,
            IPageFilter filter)
        {
            Debug.Assert(diagnosticSource != null);
            Debug.Assert(handlerSelectedContext != null);
            Debug.Assert(filter != null);

            if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelected"))
            {
                diagnosticSource.Write(
                    "Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelected",
                    new
                {
                    actionDescriptor       = handlerSelectedContext.ActionDescriptor,
                    handlerSelectedContext = handlerSelectedContext,
                    filter = filter
                });
            }
        }
        protected async Task <IActionResult> GetByFilter(FilterRequest filter)
        {
            Expression <Func <TDto, bool> > expression = null;
            IPageFilter pageFilter = null;

            IOrder[] orders = null;
            if (filter != null)
            {
                if (filter.Filter != null)
                {
                    expression = _filterHelper.ToExpression <TDto>(filter.Filter);
                }

                pageFilter = filter.PageFilter ?? new PageFilter {
                    Page = 1, PageSize = 20
                };
                orders = filter.Orders?.ToArray();
            }

            var result = await _roService.GetByFilterAsync(pageFilter, expression, orders)
                         .ConfigureAwait(false);

            return(Ok(result));
        }
 private static void AfterOnPageHandlerSelectedImpl(DiagnosticListener diagnosticListener, PageHandlerSelectedContext handlerSelectedContext, IPageFilter filter)
 {
     if (diagnosticListener.IsEnabled(Diagnostics.AfterPageFilterOnPageHandlerSelectedEventData.EventName))
     {
         diagnosticListener.Write(
             Diagnostics.AfterPageFilterOnPageHandlerSelectedEventData.EventName,
             new AfterPageFilterOnPageHandlerSelectedEventData(
                 handlerSelectedContext.ActionDescriptor,
                 handlerSelectedContext,
                 filter
                 ));
     }
 }
 private static void BeforeOnPageHandlerExecutingImpl(DiagnosticListener diagnosticListener, PageHandlerExecutingContext handlerExecutingContext, IPageFilter filter)
 {
     if (diagnosticListener.IsEnabled(Diagnostics.BeforePageFilterOnPageHandlerExecutingEventData.EventName))
     {
         diagnosticListener.Write(
             Diagnostics.BeforePageFilterOnPageHandlerExecutingEventData.EventName,
             new BeforePageFilterOnPageHandlerExecutingEventData(
                 handlerExecutingContext.ActionDescriptor,
                 handlerExecutingContext,
                 filter
                 ));
     }
 }
Beispiel #12
0
 public void setPageFilter(IPageFilter pageFilter)
 {
     this.crawlerJobContext.pageFilter = pageFilter;
 }
Beispiel #13
0
 protected IEnumerable <TEntity> PaginarResultado(IEnumerable <TEntity> entities, IPageFilter filter)
 {
     return(entities.Skip(filter.Pagina * filter.TamanhoPagina).Take(filter.TamanhoPagina));
 }
 private static void AfterOnPageHandlerSelectedImpl(DiagnosticListener diagnosticListener, PageHandlerSelectedContext handlerSelectedContext, IPageFilter filter)
 {
     if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelected"))
     {
         diagnosticListener.Write(
             "Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelected",
             new
         {
             actionDescriptor       = handlerSelectedContext.ActionDescriptor,
             handlerSelectedContext = handlerSelectedContext,
             filter = filter
         });
     }
 }
 private static void BeforeOnPageHandlerExecutingImpl(DiagnosticListener diagnosticListener, PageHandlerExecutingContext handlerExecutingContext, IPageFilter filter)
 {
     if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuting"))
     {
         diagnosticListener.Write(
             "Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuting",
             new
         {
             actionDescriptor        = handlerExecutingContext.ActionDescriptor,
             handlerExecutingContext = handlerExecutingContext,
             filter = filter
         });
     }
 }