public void ImportChannelsAndContents(int parentId, string siteContentDirectoryPath, bool isOverride) { var filePathList = GetSiteContentFilePathList(siteContentDirectoryPath); var siteIe = new SiteIe(_siteInfo, siteContentDirectoryPath); var parentOrderString = "none"; //int parentID = 0; foreach (var filePath in filePathList) { var firstIndex = filePath.LastIndexOf(PathUtils.SeparatorChar) + 1; var lastIndex = filePath.LastIndexOf(".", StringComparison.Ordinal); var orderString = filePath.Substring(firstIndex, lastIndex - firstIndex); if (StringUtils.StartsWithIgnoreCase(orderString, parentOrderString)) { parentId = siteIe.ImportChannelsAndContents(filePath, true, isOverride, parentId, _adminName); parentOrderString = orderString; } else { siteIe.ImportChannelsAndContents(filePath, true, isOverride, parentId, _adminName); } } }
public async Task ImportChannelsAndContentsAsync(int parentId, string siteContentDirectoryPath, bool isOverride, string guid) { var filePathList = GetSiteContentFilePathList(siteContentDirectoryPath); var siteIe = new SiteIe(_pathManager, _databaseManager, _caching, _site, siteContentDirectoryPath); var parentOrderString = "none"; //int parentID = 0; foreach (var filePath in filePathList) { var firstIndex = filePath.LastIndexOf(PathUtils.SeparatorChar) + 1; var lastIndex = filePath.LastIndexOf(".", StringComparison.Ordinal); var orderString = filePath.Substring(firstIndex, lastIndex - firstIndex); if (StringUtils.StartsWithIgnoreCase(orderString, parentOrderString)) { parentId = await siteIe.ImportChannelsAndContentsAsync(filePath, true, isOverride, parentId, _adminId, guid); parentOrderString = orderString; } else { await siteIe.ImportChannelsAndContentsAsync(filePath, true, isOverride, parentId, _adminId, guid); } } }
public void ImportChannelsAndContentsFromZip(int parentId, string siteContentDirectoryPath, bool isOverride) { var filePathList = GetSiteContentFilePathList(siteContentDirectoryPath); var siteIe = new SiteIe(_siteInfo, siteContentDirectoryPath); Hashtable levelHashtable = null; foreach (var filePath in filePathList) { var firstIndex = filePath.LastIndexOf(PathUtils.SeparatorChar) + 1; var lastIndex = filePath.LastIndexOf(".", StringComparison.Ordinal); var orderString = filePath.Substring(firstIndex, lastIndex - firstIndex); var level = StringUtils.GetCount("_", orderString); if (levelHashtable == null) { levelHashtable = new Hashtable { [level] = parentId }; } var insertChannelId = siteIe.ImportChannelsAndContents(filePath, true, isOverride, (int)levelHashtable[level], _adminName); levelHashtable[level + 1] = insertChannelId; } }
private async Task ImportChannelsAndContentsFromZipAsync(int parentId, string siteContentDirectoryPath, bool isOverride, string guid) { var filePathList = GetSiteContentFilePathList(siteContentDirectoryPath); var siteIe = new SiteIe(_pathManager, _databaseManager, _caching, _site, siteContentDirectoryPath); Hashtable levelHashtable = null; foreach (var filePath in filePathList) { var firstIndex = filePath.LastIndexOf(PathUtils.SeparatorChar) + 1; var lastIndex = filePath.LastIndexOf(".", StringComparison.Ordinal); var orderString = filePath.Substring(firstIndex, lastIndex - firstIndex); var level = StringUtils.GetCount("_", orderString); if (levelHashtable == null) { levelHashtable = new Hashtable { [level] = parentId }; } var insertChannelId = await siteIe.ImportChannelsAndContentsAsync(filePath, true, isOverride, (int)levelHashtable[level], _adminId, guid); levelHashtable[level + 1] = insertChannelId; } }
/// <summary> /// 导出网站内容至默认的临时文件地址 /// </summary> public async Task ExportSiteContentAsync(string siteContentDirectoryPath, bool isSaveContents, bool isSaveAllChannels, IList <int> channelIdArrayList) { DirectoryUtils.DeleteDirectoryIfExists(siteContentDirectoryPath); DirectoryUtils.CreateDirectoryIfNotExists(siteContentDirectoryPath); var allChannelIdList = await _databaseManager.ChannelRepository.GetChannelIdsAsync(_site.Id); var includeChannelIdArrayList = new ArrayList(); foreach (int channelId in channelIdArrayList) { var nodeInfo = await _databaseManager.ChannelRepository.GetAsync(channelId); var parentIdArrayList = ListUtils.GetIntList(nodeInfo.ParentsPath); foreach (int parentId in parentIdArrayList) { if (!includeChannelIdArrayList.Contains(parentId)) { includeChannelIdArrayList.Add(parentId); } } if (!includeChannelIdArrayList.Contains(channelId)) { includeChannelIdArrayList.Add(channelId); } } var siteIe = new SiteIe(_pathManager, _databaseManager, _caching, _site, siteContentDirectoryPath); foreach (var channelId in allChannelIdList) { if (!isSaveAllChannels) { if (!includeChannelIdArrayList.Contains(channelId)) { continue; } } await siteIe.ExportAsync(_site, channelId, isSaveContents); } }
/// <summary> /// 导出网站内容至默认的临时文件地址 /// </summary> public void ExportSiteContent(string siteContentDirectoryPath, bool isSaveContents, bool isSaveAllChannels, List <int> channelIdArrayList) { DirectoryUtils.DeleteDirectoryIfExists(siteContentDirectoryPath); DirectoryUtils.CreateDirectoryIfNotExists(siteContentDirectoryPath); var allChannelIdList = ChannelManager.GetChannelIdList(_siteInfo.Id); var includeChannelIdArrayList = new ArrayList(); foreach (int channelId in channelIdArrayList) { var nodeInfo = ChannelManager.GetChannelInfo(_siteInfo.Id, channelId); var parentIdArrayList = TranslateUtils.StringCollectionToIntList(nodeInfo.ParentsPath); foreach (int parentId in parentIdArrayList) { if (!includeChannelIdArrayList.Contains(parentId)) { includeChannelIdArrayList.Add(parentId); } } if (!includeChannelIdArrayList.Contains(channelId)) { includeChannelIdArrayList.Add(channelId); } } var siteIe = new SiteIe(_siteInfo, siteContentDirectoryPath); foreach (var channelId in allChannelIdList) { if (!isSaveAllChannels) { if (!includeChannelIdArrayList.Contains(channelId)) { continue; } } siteIe.Export(_siteInfo.Id, channelId, isSaveContents); } }
public async Task <string> ExportChannelsAsync(List <int> channelIdList, string filePath) { var siteContentDirectoryPath = PathUtils.Combine(DirectoryUtils.GetDirectoryPath(filePath), PathUtils.GetFileNameWithoutExtension(filePath)); DirectoryUtils.DeleteDirectoryIfExists(siteContentDirectoryPath); DirectoryUtils.CreateDirectoryIfNotExists(siteContentDirectoryPath); var allChannelIdList = new List <int>(); foreach (var channelId in channelIdList) { if (!allChannelIdList.Contains(channelId)) { allChannelIdList.Add(channelId); var nodeInfo = await _databaseManager.ChannelRepository.GetAsync(channelId); var childChannelIdList = await _databaseManager.ChannelRepository.GetChannelIdsAsync(nodeInfo.SiteId, nodeInfo.Id, ScopeType.Descendant); allChannelIdList.AddRange(childChannelIdList); } } var sitePath = await _pathManager.GetSitePathAsync(_site); var siteIe = new SiteIe(_pathManager, _databaseManager, _caching, _site, siteContentDirectoryPath); foreach (var channelId in allChannelIdList) { await siteIe.ExportAsync(_site, channelId, true); } var imageUploadDirectoryPath = PathUtils.Combine(siteContentDirectoryPath, _site.ImageUploadDirectoryName); DirectoryUtils.DeleteDirectoryIfExists(imageUploadDirectoryPath); DirectoryUtils.Copy(PathUtils.Combine(sitePath, _site.ImageUploadDirectoryName), imageUploadDirectoryPath); var videoUploadDirectoryPath = PathUtils.Combine(siteContentDirectoryPath, _site.VideoUploadDirectoryName); DirectoryUtils.DeleteDirectoryIfExists(videoUploadDirectoryPath); DirectoryUtils.Copy(PathUtils.Combine(sitePath, _site.VideoUploadDirectoryName), videoUploadDirectoryPath); var fileUploadDirectoryPath = PathUtils.Combine(siteContentDirectoryPath, _site.FileUploadDirectoryName); DirectoryUtils.DeleteDirectoryIfExists(fileUploadDirectoryPath); DirectoryUtils.Copy(PathUtils.Combine(sitePath, _site.FileUploadDirectoryName), fileUploadDirectoryPath); AtomFeed feed = AtomUtility.GetEmptyFeed(); var entry = AtomUtility.GetEmptyEntry(); AtomUtility.AddDcElement(entry.AdditionalElements, "ImageUploadDirectoryName", _site.ImageUploadDirectoryName); AtomUtility.AddDcElement(entry.AdditionalElements, "VideoUploadDirectoryName", _site.VideoUploadDirectoryName); AtomUtility.AddDcElement(entry.AdditionalElements, "FileUploadDirectoryName", _site.FileUploadDirectoryName); feed.Entries.Add(entry); var uploadFolderPath = PathUtils.Combine(siteContentDirectoryPath, BackupUtility.UploadFolderName); DirectoryUtils.CreateDirectoryIfNotExists(uploadFolderPath); var uploadFilePath = PathUtils.Combine(uploadFolderPath, BackupUtility.UploadFileName); feed.Save(uploadFilePath); _pathManager.CreateZip(filePath, siteContentDirectoryPath); DirectoryUtils.DeleteDirectoryIfExists(siteContentDirectoryPath); return(PathUtils.GetFileName(filePath)); }
public void ImportSiteContent(string siteContentDirectoryPath, string filePath, bool isImportContents) { var siteIe = new SiteIe(_siteInfo, siteContentDirectoryPath); siteIe.ImportChannelsAndContents(filePath, isImportContents, false, 0, _adminName); }
public string ExportChannels(List <int> channelIdList, string filePath) { var siteContentDirectoryPath = PathUtils.Combine(DirectoryUtils.GetDirectoryPath(filePath), PathUtils.GetFileNameWithoutExtension(filePath)); DirectoryUtils.DeleteDirectoryIfExists(siteContentDirectoryPath); DirectoryUtils.CreateDirectoryIfNotExists(siteContentDirectoryPath); var allChannelIdList = new List <int>(); foreach (var channelId in channelIdList) { if (!allChannelIdList.Contains(channelId)) { allChannelIdList.Add(channelId); var nodeInfo = ChannelManager.GetChannelInfo(_siteInfo.Id, channelId); var childChannelIdList = ChannelManager.GetChannelIdList(nodeInfo, EScopeType.Descendant, string.Empty, string.Empty, string.Empty); allChannelIdList.AddRange(childChannelIdList); } } var siteIe = new SiteIe(_siteInfo, siteContentDirectoryPath); foreach (var channelId in allChannelIdList) { siteIe.Export(_siteInfo.Id, channelId, true); } var imageUploadDirectoryPath = PathUtils.Combine(siteContentDirectoryPath, _siteInfo.Additional.ImageUploadDirectoryName); DirectoryUtils.DeleteDirectoryIfExists(imageUploadDirectoryPath); DirectoryUtils.Copy(PathUtils.Combine(_sitePath, _siteInfo.Additional.ImageUploadDirectoryName), imageUploadDirectoryPath); var videoUploadDirectoryPath = PathUtils.Combine(siteContentDirectoryPath, _siteInfo.Additional.VideoUploadDirectoryName); DirectoryUtils.DeleteDirectoryIfExists(videoUploadDirectoryPath); DirectoryUtils.Copy(PathUtils.Combine(_sitePath, _siteInfo.Additional.VideoUploadDirectoryName), videoUploadDirectoryPath); var fileUploadDirectoryPath = PathUtils.Combine(siteContentDirectoryPath, _siteInfo.Additional.FileUploadDirectoryName); DirectoryUtils.DeleteDirectoryIfExists(fileUploadDirectoryPath); DirectoryUtils.Copy(PathUtils.Combine(_sitePath, _siteInfo.Additional.FileUploadDirectoryName), fileUploadDirectoryPath); Atom.Core.AtomFeed feed = AtomUtility.GetEmptyFeed(); var entry = AtomUtility.GetEmptyEntry(); AtomUtility.AddDcElement(entry.AdditionalElements, "ImageUploadDirectoryName", _siteInfo.Additional.ImageUploadDirectoryName); AtomUtility.AddDcElement(entry.AdditionalElements, "VideoUploadDirectoryName", _siteInfo.Additional.VideoUploadDirectoryName); AtomUtility.AddDcElement(entry.AdditionalElements, "FileUploadDirectoryName", _siteInfo.Additional.FileUploadDirectoryName); feed.Entries.Add(entry); var uploadFolderPath = PathUtils.Combine(siteContentDirectoryPath, BackupUtility.UploadFolderName); DirectoryUtils.CreateDirectoryIfNotExists(uploadFolderPath); var uploadFilePath = PathUtils.Combine(uploadFolderPath, BackupUtility.UploadFileName); feed.Save(uploadFilePath); ZipUtils.PackFiles(filePath, siteContentDirectoryPath); DirectoryUtils.DeleteDirectoryIfExists(siteContentDirectoryPath); return(PathUtils.GetFileName(filePath)); }
public async Task ImportSiteContentAsync(string siteContentDirectoryPath, string filePath, bool isImportContents, string guid) { var siteIe = new SiteIe(_pathManager, _databaseManager, _caching, _site, siteContentDirectoryPath); await siteIe.ImportChannelsAndContentsAsync(filePath, isImportContents, false, 0, _adminId, guid); }