public Task StartAsync(CancellationToken cancellationToken)
        {
            timerSpamProtectionCache = new Timer(_ =>
            {
                Console.WriteLine("SpamProtectionCache.RemoveExpired");
                spamProtectionCache.RemoveExpired();
            }, null, TimeSpan.Zero, TimeSpan.FromMinutes(schedulerOptions.SpamProtectionCacheClearMinutes));

            timerJwtBlackListService = new Timer(_ =>
            {
                Console.WriteLine("JwtBlackListService.RemoveExpired");
                jwtBlackListService.RemoveExpired();
            }, null, TimeSpan.Zero, TimeSpan.FromMinutes(schedulerOptions.JwtBlackListServiceClearMinutes));

            timerLongSessionsClearer = new Timer(_ =>
            {
                Console.WriteLine("LongSessionsClearer.ClearExpiredLongSessions");
                using (var db = dbFactory.CreateDb())
                {
                    LongSessionsClearer.ClearExpiredLongSessions(db);
                }
            }, null, TimeSpan.Zero, TimeSpan.FromDays(schedulerOptions.LongSessionsClearDays));

            timerExpiredRegistrationUsersCleaner = new Timer(_ =>
            {
                Console.WriteLine("OldNotRegisteredUsersClearer.CleanOldNotRegisteredUsers");
                using (var db = dbFactory.CreateDb())
                {
                    ExpiredRegistrationUsersClearer.CleanExpiredRegistrationUsers(db);
                }
            }, null, TimeSpan.Zero, TimeSpan.FromDays(schedulerOptions.ExpiredRegistrationUsersClearDays));


            return(Task.CompletedTask);
        }
示例#2
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            timerSpamProtectionCache = new Timer(_ =>
            {
                if (schedulerOptions.CurrentValue.LogJobs)
                {
                    Console.WriteLine("SpamProtectionCache.RemoveExpired");
                }
                spamProtectionCache.RemoveExpired();
            }, null, TimeSpan.Zero,
                                                 TimeSpan.FromMinutes(schedulerOptions.CurrentValue.SpamProtectionCacheClearMinutes));

            timerJwtBlackListService = new Timer(_ =>
            {
                if (schedulerOptions.CurrentValue.LogJobs)
                {
                    Console.WriteLine("JwtBlackListService.RemoveExpired");
                }
                jweBlackListService.RemoveExpired();
            }, null, TimeSpan.Zero,
                                                 TimeSpan.FromMinutes(schedulerOptions.CurrentValue.JwtBlackListServiceClearMinutes));

            timerLongSessionsClearer = new Timer(_ =>
            {
                if (schedulerOptions.CurrentValue.LogJobs)
                {
                    Console.WriteLine("LongSessionsClearer.ClearExpiredLongSessions");
                }
                using var db = dbFactory.CreateDb();
                LongSessionsClearer.ClearExpiredLongSessions(db);
            }, null, TimeSpan.Zero, TimeSpan.FromDays(schedulerOptions.CurrentValue.LongSessionsClearDays));

            timerExpiredRegistrationUsersCleaner = new Timer(_ =>
            {
                if (schedulerOptions.CurrentValue.LogJobs)
                {
                    Console.WriteLine("OldNotRegisteredUsersClearer.CleanOldNotRegisteredUsers");
                }
                using var db = dbFactory.CreateDb();
                ExpiredRegistrationUsersClearer.CleanExpiredRegistrationUsers(db);
            }, null, TimeSpan.Zero, TimeSpan.FromDays(schedulerOptions.CurrentValue.ExpiredRegistrationUsersClearDays));

            timerCountersUpload = new Timer(_ =>
            {
                if (schedulerOptions.CurrentValue.LogJobs)
                {
                    Console.WriteLine("CountersUploadToDataBase");
                }
                materialsVisitsCounterCache.UploadToDataBase();
                profilesVisitsCounterService.UploadToDataBase();
            }, null, TimeSpan.FromMinutes(schedulerOptions.CurrentValue.UploadVisitsToDataBaseMinutes),
                                            TimeSpan.FromMinutes(schedulerOptions.CurrentValue.UploadVisitsToDataBaseMinutes));

            return(Task.CompletedTask);
        }