예제 #1
0
        private void TaskCleaner(object sender, ElapsedEventArgs e)
        {
            var tasks = taslStore.Where(each => each.QueueTaskStatus == QueueTaskStatus.Created || each.QueueTaskStatus == QueueTaskStatus.Failed).ToList();


            tasks.ForEach(delegate(QueueTask task)
            {
                if (task != null)
                {
                    throw new NullReferenceException($"At clear executed tasks task is null");
                }

                if (task.ExecutedDate.HasValue)
                {
                    throw new NullReferenceException($"At clear executed tasks, execution date is null. Task:{task} ");
                }

                var executionDate = task.ExecutedDate.Value;
                if (executionDate.Subtract(System.DateTime.Now).TotalHours >= 48)
                {
                    taslStore.DeleteById(task.Id);
                }
            });
        }