예제 #1
0
        public static void DeleteLogsAndExceptions(DeleteLogParametersEntity parameters)
        {
            using (Connector.CommandTimeoutScope(DeleteLogsTimeOut))
            {
                foreach (var action in DeleteLogs.GetInvocationListTyped())
                {
                    action(parameters);
                }

                int exceptions = Database.Query <ExceptionEntity>().UnsafeUpdate().Set(a => a.Referenced, a => false).Execute();

                var ex         = Schema.Current.Table <ExceptionEntity>();
                var referenced = (FieldValue)ex.GetField(ReflectionTools.GetPropertyInfo((ExceptionEntity e) => e.Referenced));

                var commands = (from t in Schema.Current.GetDatabaseTables()
                                from c in t.Columns.Values
                                where c.ReferenceTable == ex
                                select new SqlPreCommandSimple("UPDATE ex SET {1} = 1 FROM {0} ex JOIN {2} log ON ex.Id = log.{3}"
                                                               .FormatWith(ex.Name, referenced.Name, t.Name, c.Name))).ToList();

                foreach (var c in commands)
                {
                    c.ExecuteNonQuery();
                }

                int deletedExceptions = Database.Query <ExceptionEntity>()
                                        .Where(a => !a.Referenced && a.CreationDate < parameters.DateLimit)
                                        .UnsafeDeleteChunks(parameters.ChunkSize, parameters.MaxChunks);
            }
        }
예제 #2
0
 public static void ExceptionLogic_DeleteLogs(DeleteLogParametersEntity parameters)
 {
     Database.Query <OperationLogEntity>().Where(o => o.Start < parameters.DateLimit).UnsafeDeleteChunks(parameters.ChunkSize, parameters.MaxChunks);
 }