static void Main(string[] args)
        {
            var configuration = GetConfiguration();

            try
            {
                var bastaConfig    = configuration.GetBastaAPIConfig();
                var contextOptions = new DbContextOptionsBuilder <BASTAContext>()
                                     .UseSqlServer(bastaConfig.DatabaseConnectionString)
                                     .Options;

                using var ctx = new BASTAContext(contextOptions);
                var oldLogs = ctx
                              .AuditLogs
                              .Where(al => al.TimeStamp < DateTime.UtcNow.AddDays(bastaConfig.AuditLogRetentionDays));

                ctx.RemoveRange(oldLogs);
                ctx.SaveChanges();
                Console.WriteLine("Audit Log cleaned up.");
            }
            catch (Exception exception)
            {
                Console.WriteLine($"ERROR while removing old AuditLogs.");
                Console.WriteLine(exception.Message);
                Console.WriteLine(exception.StackTrace);
            }
        }
Example #2
0
 public AuditLogRepository(BASTAContext context)
 {
     Context = context;
 }
Example #3
0
 public SessionsRepository(BASTAContext context)
 {
     Context = context;
 }
Example #4
0
 public SpeakersRepository(BASTAContext context)
 {
     Context = context;
 }
Example #5
0
 public AudiencesRepository(BASTAContext context)
 {
     Context = context;
 }