public static void ExceptionLogic_DeleteLogs(DeleteLogParametersEmbedded parameters, StringBuilder sb, CancellationToken token) { void Remove(ProcessState processState, DateTime dateLimit, bool withExceptions) { var query = Database.Query <ProcessEntity>().Where(p => p.State == processState && p.CreationDate < dateLimit && (!withExceptions || p.Exception != null)); query.SelectMany(a => a.ExceptionLines()).UnsafeDeleteChunksLog(parameters, sb, token); query.UnsafeDeleteChunksLog(parameters, sb, token); } var dateLimit = parameters.GetDateLimitDelete(typeof(ProcessEntity).ToTypeEntity()); if (dateLimit != null) { Remove(ProcessState.Canceled, dateLimit.Value, false); Remove(ProcessState.Finished, dateLimit.Value, false); Remove(ProcessState.Error, dateLimit.Value, false); } dateLimit = parameters.GetDateLimitDeleteWithExceptions(typeof(ProcessEntity).ToTypeEntity()); if (dateLimit == null) { return; } Remove(ProcessState.Canceled, dateLimit.Value, true); Remove(ProcessState.Finished, dateLimit.Value, true); Remove(ProcessState.Error, dateLimit.Value, true); }
private static void ExceptionLogic_DeleteRestLogs(DeleteLogParametersEmbedded parameters, StringBuilder sb, CancellationToken token) { var dateLimit = parameters.GetDateLimitDelete(typeof(RestLogEntity).ToTypeEntity()); if (dateLimit != null) { Database.Query <RestLogEntity>().Where(a => a.StartDate < dateLimit.Value).UnsafeDeleteChunksLog(parameters, sb, token); } dateLimit = parameters.GetDateLimitDeleteWithExceptions(typeof(RestLogEntity).ToTypeEntity()); if (dateLimit == null) { return; } Database.Query <RestLogEntity>().Where(a => a.StartDate < dateLimit.Value && a.Exception != null).UnsafeDeleteChunksLog(parameters, sb, token); }
public static void ExceptionLogic_DeleteLogs(DeleteLogParametersEmbedded parameters, StringBuilder sb, CancellationToken token) { var dateLimit = parameters.GetDateLimitDelete(typeof(EmailMessageEntity).ToTypeEntity()); if (dateLimit != null) { Database.Query <EmailMessageEntity>().Where(o => o.CreationDate < dateLimit !.Value).UnsafeDeleteChunksLog(parameters, sb, token); } dateLimit = parameters.GetDateLimitDeleteWithExceptions(typeof(EmailMessageEntity).ToTypeEntity()); if (dateLimit == null) { return; } Database.Query <EmailMessageEntity>().Where(o => o.CreationDate < dateLimit !.Value && o.Exception != null).UnsafeDeleteChunksLog(parameters, sb, token); }
public static void ExceptionLogic_DeleteLogs(DeleteLogParametersEmbedded parameters, StringBuilder sb, CancellationToken token) { void Remove(DateTime?dateLimit, bool withExceptions) { if (dateLimit == null) { return; } var query = Database.Query <SystemEventLogEntity>().Where(a => a.Date < dateLimit); if (withExceptions) { query = query.Where(a => a.Exception != null); } query.UnsafeDeleteChunksLog(parameters, sb, token); } Remove(parameters.GetDateLimitDelete(typeof(SystemEventLogEntity).ToTypeEntity()), withExceptions: false); Remove(parameters.GetDateLimitDeleteWithExceptions(typeof(SystemEventLogEntity).ToTypeEntity()), withExceptions: true); }
public static void ExceptionLogic_DeleteLogs(DeleteLogParametersEmbedded parameters, StringBuilder sb, CancellationToken token) { Database.Query <SchedulerTaskExceptionLineEntity>().Where(a => a.SchedulerTaskLog == null).UnsafeDeleteChunksLog(parameters, sb, token); var dateLimit = parameters.GetDateLimitDelete(typeof(ScheduledTaskLogEntity).ToTypeEntity()); if (dateLimit != null) { var query = Database.Query <ScheduledTaskLogEntity>().Where(a => a.StartTime < dateLimit.Value); query.SelectMany(a => a.ExceptionLines()).UnsafeDeleteChunksLog(parameters, sb, token); query.UnsafeDeleteChunksLog(parameters, sb, token); } dateLimit = parameters.GetDateLimitDeleteWithExceptions(typeof(ScheduledTaskLogEntity).ToTypeEntity()); if (dateLimit == null) { return; } var queryWithExceptions = Database.Query <ScheduledTaskLogEntity>().Where(a => a.StartTime < dateLimit.Value && a.Exception != null); queryWithExceptions.SelectMany(a => a.ExceptionLines()).UnsafeDeleteChunksLog(parameters, sb, token); queryWithExceptions.UnsafeUpdate().Set(a => a.Exception, a => null).ExecuteChunksLog(parameters, sb, token); }
public static void ExceptionLogic_DeleteLogs(DeleteLogParametersEmbedded parameters, StringBuilder sb, CancellationToken token) { void Remove(DateTime?dateLimit, bool withExceptions) { if (dateLimit == null) { return; } var query = Database.Query <ScheduledTaskLogEntity>().Where(a => a.StartTime < dateLimit); if (withExceptions) { query = query.Where(a => a.Exception != null); } query.SelectMany(a => a.ExceptionLines()).UnsafeDeleteChunksLog(parameters, sb, token); query.Where(a => !a.ExceptionLines().Any()).UnsafeDeleteChunksLog(parameters, sb, token); } Database.Query <SchedulerTaskExceptionLineEntity>().Where(a => a.SchedulerTaskLog == null).UnsafeDeleteChunksLog(parameters, sb, token); Remove(parameters.GetDateLimitDelete(typeof(ScheduledTaskLogEntity).ToTypeEntity()), withExceptions: false); Remove(parameters.GetDateLimitDeleteWithExceptions(typeof(ScheduledTaskLogEntity).ToTypeEntity()), withExceptions: true); }