Ejemplo n.º 1
0
        public async Task Execute()
        {
            var now = _UtcDateTimeProvider.Now();

            var timeToDie = _DbConfig.Set <ExposureKeySetContentEntity>()
                            .Where(x => x.Release < now - TimeSpan.FromDays(_GaenContentConfig.ExposureKeySetLifetimeDays))
                            .ToList();

            await _DbConfig.BulkDeleteAsync(timeToDie);
        }
        public async Task Execute()
        {
            var now = _UtcDateTimeProvider.Now();

            var hushNow = _Context.Set <KeyReleaseWorkflowState>()
                          .Where(x => x.Created < now - TimeSpan.FromDays(_GaenContentConfig.KeysLastSecretLifetimeDays))
                          .ToArray();

            await _Context.BulkDeleteAsync(hushNow);
        }
        private async Task DeleteContent <T>(double lifetime) where T : ContentEntity
        {
            var now = _DateTimeProvider.Now();

            var dbSet = _ContentDbContext.Set <T>();

            var exceptEntity = dbSet
                               .Where(x => x.Release <= now)
                               .OrderByDescending(x => x.Release)
                               .FirstOrDefault();

            if (exceptEntity != null)
            {
                var id = exceptEntity.Id;

                var recordToDelete = dbSet
                                     .Where(x => x.Release <= now.AddDays(lifetime))
                                     .Where(x => x.Id != id)
                                     .OrderByDescending(x => x.Release)
                                     .ToList();

                await _ContentDbContext.BulkDeleteAsync(recordToDelete);
            }
        }