public static async Task <string> ExportRelatedFieldListAsync(IPathManager pathManager, IDatabaseManager databaseManager, int siteId) { var directoryPath = pathManager.GetTemporaryFilesPath("relatedField"); var filePath = pathManager.GetTemporaryFilesPath("relatedField.zip"); FileUtils.DeleteFileIfExists(filePath); DirectoryUtils.DeleteDirectoryIfExists(directoryPath); DirectoryUtils.CreateDirectoryIfNotExists(directoryPath); var site = await databaseManager.SiteRepository.GetAsync(siteId); var relatedFieldInfoList = await databaseManager.RelatedFieldRepository.GetRelatedFieldsAsync(siteId); var relatedFieldIe = new RelatedFieldIe(databaseManager, site, directoryPath); foreach (var relatedFieldInfo in relatedFieldInfoList) { await relatedFieldIe.ExportRelatedFieldAsync(relatedFieldInfo); } pathManager.CreateZip(filePath, directoryPath); DirectoryUtils.DeleteDirectoryIfExists(directoryPath); return(PathUtils.GetFileName(filePath)); }
public async Task ExportFilesAsync(string filePath) { var filesDirectoryPath = PathUtils.Combine(DirectoryUtils.GetDirectoryPath(filePath), PathUtils.GetFileNameWithoutExtension(filePath)); DirectoryUtils.DeleteDirectoryIfExists(filesDirectoryPath); FileUtils.DeleteFileIfExists(filePath); var sitePath = await _pathManager.GetSitePathAsync(_site); DirectoryUtils.Copy(sitePath, filesDirectoryPath); _pathManager.CreateZip(filePath, filesDirectoryPath); DirectoryUtils.DeleteDirectoryIfExists(filesDirectoryPath); }
public static async Task <(string title, string imageUrl, string body)> GetWordAsync(IPathManager pathManager, Site siteInfo, bool isFirstLineTitle, bool isClearFormat, bool isFirstLineIndent, bool isClearFontSize, bool isClearFontFamily, bool isClearImages, string docsFilePath, string docsFileTitle) { string imageDirectoryPath; string imageDirectoryUrl; if (siteInfo != null) { imageDirectoryPath = await pathManager.GetUploadDirectoryPathAsync(siteInfo, UploadType.Image); imageDirectoryUrl = await pathManager.GetSiteUrlByPhysicalPathAsync(siteInfo, imageDirectoryPath, true); } else { var fileName = PathUtils.GetFileName(docsFilePath); imageDirectoryPath = PathUtils.Combine(pathManager.WebRootPath, PathUtils.GetMaterialVirtualDirectoryPath(UploadType.Image)); imageDirectoryUrl = PathUtils.GetMaterialVirtualFilePath(UploadType.Image, fileName); } var settings = new ConverterSettings { IsFirstLineTitle = isFirstLineTitle, IsClearFormat = isClearFormat, IsFirstLineIndent = isFirstLineIndent, IsClearFontSize = isClearFontSize, IsClearFontFamily = isClearFontFamily, IsClearImages = isClearImages, ImageDirectoryPath = imageDirectoryPath, ImageDirectoryUrl = imageDirectoryUrl, IsSaveHtml = false }; var(title, imageUrl, body) = ConvertToHtml(docsFilePath, settings); FileUtils.DeleteFileIfExists(docsFilePath); if (siteInfo != null) { body = await pathManager.DecodeTextEditorAsync(siteInfo, body, true); } if (string.IsNullOrEmpty(title)) { title = docsFileTitle; } return(title, imageUrl, body); }
public async Task <bool> ExportContentsAsync(string filePath, List <Content> contentInfoList) { var siteContentDirectoryPath = PathUtils.Combine(DirectoryUtils.GetDirectoryPath(filePath), PathUtils.GetFileNameWithoutExtension(filePath)); FileUtils.DeleteFileIfExists(filePath); DirectoryUtils.DeleteDirectoryIfExists(siteContentDirectoryPath); DirectoryUtils.CreateDirectoryIfNotExists(siteContentDirectoryPath); var contentIe = new ContentIe(_pathManager, _databaseManager, _caching, _site, siteContentDirectoryPath); var isExport = await contentIe.ExportContentsAsync(_site, contentInfoList); if (isExport) { _pathManager.CreateZip(filePath, siteContentDirectoryPath); DirectoryUtils.DeleteDirectoryIfExists(siteContentDirectoryPath); } return(isExport); }
public async Task <bool> ExportContentsAsync(string filePath, int channelId, List <int> contentIdArrayList, bool isPeriods, string dateFrom, string dateTo, bool?checkedState) { var siteContentDirectoryPath = PathUtils.Combine(DirectoryUtils.GetDirectoryPath(filePath), PathUtils.GetFileNameWithoutExtension(filePath)); FileUtils.DeleteFileIfExists(filePath); DirectoryUtils.DeleteDirectoryIfExists(siteContentDirectoryPath); DirectoryUtils.CreateDirectoryIfNotExists(siteContentDirectoryPath); var contentIe = new ContentIe(_pathManager, _databaseManager, _caching, _site, siteContentDirectoryPath); var isExport = await contentIe.ExportContentsAsync(_site, channelId, contentIdArrayList, isPeriods, dateFrom, dateTo, checkedState); if (isExport) { _pathManager.CreateZip(filePath, siteContentDirectoryPath); DirectoryUtils.DeleteDirectoryIfExists(siteContentDirectoryPath); } return(isExport); }