Exemple #1
0
        public override ICollection <SpiderProxyUriEntity> SelectProxyEntities(ISpiderProxyUriEntityOption entityOption, int recentDays = 10, int count = 0)
        {
            if (recentDays < 1)
            {
                recentDays = 360;
            }
            IQueryable <SpiderProxyUriEntity> query;

            if (entityOption is null)
            {
                query = ProxyUriEntities.AsNoTracking()
                        .Where(p => MySqlDbFunctionsExtensions.DateDiffDay(EF.Functions, p.UpdateTime, DateTime.UtcNow) <= recentDays)
                        .OrderByDescending(e => e.UpdateTime);
            }
            else
            {
                var queryableData = ProxyUriEntities.AsNoTracking().AsQueryable();
                var expression    = entityOption.GetExpressionTree(queryableData);
                if (expression is null)
                {
                    query = ProxyUriEntities
                            .Where(p => MySqlDbFunctionsExtensions.DateDiffDay(EF.Functions, p.UpdateTime, DateTime.UtcNow) <= recentDays)
                            .OrderByDescending(e => e.UpdateTime);
                }
                else
                {
                    query = queryableData.Provider
                            .CreateQuery <SpiderProxyUriEntity>(expression)
                            .Where(p => MySqlDbFunctionsExtensions.DateDiffDay(EF.Functions, p.UpdateTime, DateTime.UtcNow) <= recentDays)
                            .OrderByDescending(e => e.UpdateTime);
                }
            }
            return((count > 0 ? query.Take(count) : query).ToArray());
        }
 public async Task <IEnumerable <ServiceInvoice> > GetPendingExpiredServiceInvoices()
 {
     return(await GetAll().Include(s => s.Client)
            .Include(s => s.ServiceInvoiceDetails)
            .Where(s => s.State == InvoiceState.Generated &&
                   MySqlDbFunctionsExtensions.DateDiffDay(EF.Functions, DateTime.Now, s.GenerationDate) >= Invoice.DayLimits)
            .ToListAsync());
 }
Exemple #3
0
        public async Task <IEnumerable <Employee> > EmployeesWithContractCloseToExpiration()
        {
            DateTime today = DateTime.Now;

            return(await GetAll().Include(e => e.EmployeeContract)
                   .Include(e => e.User)
                   .Where(e => MySqlDbFunctionsExtensions.DateDiffDay(EF.Functions, e.EmployeeContract.EndDate, today) == 3)
                   .ToListAsync());
        }
        public override ICollection <SpiderProxyUriEntity> SelectProxyEntities(Predicate <SpiderProxyUriEntity> predicate, int recentDays = 10, int count = 0)
        {
            if (recentDays < 1)
            {
                recentDays = 360;
            }
            Expression <Func <SpiderProxyUriEntity, bool> > filter = predicate != null
                                ? (p => MySqlDbFunctionsExtensions.DateDiffDay(EF.Functions, p.UpdateTime, DateTime.UtcNow) <= recentDays && predicate(p))
                                : (Expression <Func <SpiderProxyUriEntity, bool> >)(p => MySqlDbFunctionsExtensions.DateDiffDay(EF.Functions, p.UpdateTime, DateTime.UtcNow) <= recentDays);
            var query = ProxyUriEntities
                        .Where(filter)
                        .OrderByDescending(e => e.UpdateTime);

            return((count > 0 ? query.Take(count) : query).ToArray());
        }