示例#1
0
        /// <summary>
        /// 删除垃圾临时附件
        /// </summary>
        public void DeleteTrashTemporaryAttachments()
        {
            IAttachmentSettingsManager attachmentSettingsManager = DIContainer.Resolve <IAttachmentSettingsManager>();

            if (attachmentSettingsManager == null)
            {
                return;
            }
            AttachmentSettings attachmentSettings = attachmentSettingsManager.Get();
            int temporaryAttachmentStorageDay     = attachmentSettings.TemporaryAttachmentStorageDay;

            if (temporaryAttachmentStorageDay < 1)
            {
                temporaryAttachmentStorageDay = 1;
            }
            IEnumerable <T> attachments = attachmentRepository.GetTrashTemporaryAttachments(temporaryAttachmentStorageDay);

            if (attachments.Count() == 0)
            {
                return;
            }
            foreach (var attachment in attachments)
            {
                DeleteStoredFile(attachment);
            }
            attachmentRepository.DeleteTrashTemporaryAttachments(temporaryAttachmentStorageDay);
        }