Exemple #1
0
        /// <summary>
        /// Gets all backup files
        /// </summary>
        /// <returns>Backup file collection</returns>
        public virtual IList <string> GetAllBackupFiles()
        {
            var path = GetBackupDirectoryPath();

            if (!_fileProvider.DirectoryExists(path))
            {
                throw new SmiException("Backup directory not exists");
            }

            return(_fileProvider.GetFiles(path, $"*.{SmiCommonDefaults.DbBackupFileExtension}")
                   .OrderByDescending(p => _fileProvider.GetLastWriteTime(p)).ToList());
        }
        /// <summary>
        /// Create an file attachment for the specific file path
        /// </summary>
        /// <param name="filePath">Attachment file path</param>
        /// <param name="attachmentFileName">Attachment file name</param>
        /// <returns>A leaf-node MIME part that contains an attachment.</returns>
        protected MimePart CreateMimeAttachment(string filePath, string attachmentFileName = null)
        {
            if (string.IsNullOrWhiteSpace(filePath))
            {
                throw new ArgumentNullException(nameof(filePath));
            }

            if (string.IsNullOrWhiteSpace(attachmentFileName))
            {
                attachmentFileName = Path.GetFileName(filePath);
            }

            return(CreateMimeAttachment(
                       attachmentFileName,
                       _fileProvider.ReadAllBytes(filePath),
                       _fileProvider.GetCreationTime(filePath),
                       _fileProvider.GetLastWriteTime(filePath),
                       _fileProvider.GetLastAccessTime(filePath)));
        }