public bool ExportContents(SiteInfo siteInfo, List <ContentInfo> contentInfoList) { var filePath = _siteContentDirectoryPath + PathUtils.SeparatorChar + "contents.xml"; var feed = AtomUtility.GetEmptyFeed(); var collection = new NameValueCollection(); foreach (var contentInfo in contentInfoList) { try { ContentUtility.PutImagePaths(siteInfo, contentInfo, collection); } catch { // ignored } var entry = ExportContentInfo(contentInfo); feed.Entries.Add(entry); } feed.Save(filePath); foreach (string imageUrl in collection.Keys) { var sourceFilePath = collection[imageUrl]; var destFilePath = PathUtility.MapPath(_siteContentDirectoryPath, imageUrl); DirectoryUtils.CreateDirectoryIfNotExists(destFilePath); FileUtils.MoveFile(sourceFilePath, destFilePath, true); } return(true); }
public bool ExportContents(SiteInfo siteInfo, int channelId, List <int> contentIdList, bool isPeriods, string dateFrom, string dateTo, ETriState checkedState) { var filePath = _siteContentDirectoryPath + PathUtils.SeparatorChar + "contents.xml"; var channelInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId); var feed = AtomUtility.GetEmptyFeed(); if (contentIdList == null || contentIdList.Count == 0) { var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); contentIdList = DataProvider.ContentDao.GetContentIdList(tableName, channelId, isPeriods, dateFrom, dateTo, checkedState); } if (contentIdList.Count == 0) { return(false); } var collection = new NameValueCollection(); foreach (var contentId in contentIdList) { var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId); try { ContentUtility.PutImagePaths(siteInfo, contentInfo, collection); } catch { // ignored } var entry = ExportContentInfo(contentInfo); feed.Entries.Add(entry); } feed.Save(filePath); foreach (string imageUrl in collection.Keys) { var sourceFilePath = collection[imageUrl]; var destFilePath = PathUtility.MapPath(_siteContentDirectoryPath, imageUrl); DirectoryUtils.CreateDirectoryIfNotExists(destFilePath); FileUtils.MoveFile(sourceFilePath, destFilePath, true); } return(true); }