Skip to content

Commit 604585a

Browse files
wangzq
1 parent 9f3de26 commit 604585a

4 files changed

Lines changed: 60 additions & 5 deletions

File tree

source/SiteServer.CMS/ImportExport/BackupUtility.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public class BackupUtility
1212
public const string CacheTotalCount = "_TotalCount";
1313
public const string CacheCurrentCount = "_CurrentCount";
1414
public const string CacheMessage = "_Message";
15+
public const string UploadFolderName = "upload"; // 用于栏目及内容备份时记录图片、视频、文件上传所在文件夹目录
16+
public const string UploadFileName = "upload.xml"; // 用于栏目及内容备份时记录图片、视频、文件上传所在文件名
1517

1618
public static void BackupTemplates(int publishmentSystemId, string filePath)
1719
{
@@ -24,7 +26,7 @@ public static void BackupChannelsAndContents(int publishmentSystemId, string fil
2426
var exportObject = new ExportObject(publishmentSystemId);
2527

2628
var nodeIdList = DataProvider.NodeDao.GetNodeIdListByParentId(publishmentSystemId, publishmentSystemId);
27-
exportObject.ExportChannels(nodeIdList, filePath);
29+
exportObject.ExportChannels(nodeIdList, filePath);
2830
}
2931

3032
public static void BackupFiles(int publishmentSystemId, string filePath)

source/SiteServer.CMS/ImportExport/ExportObject.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,31 @@ public string ExportChannels(List<int> nodeIdList, string filePath)
379379
foreach (int nodeId in allNodeIdList)
380380
{
381381
siteContentIe.Export(Fso.PublishmentSystemId, nodeId, true);
382-
}
382+
}
383+
384+
var imageUploadDirectoryPath = PathUtils.Combine(siteContentDirectoryPath, this.Fso.PublishmentSystemInfo.Additional.ImageUploadDirectoryName);
385+
DirectoryUtils.DeleteDirectoryIfExists(imageUploadDirectoryPath);
386+
DirectoryUtils.Copy(PathUtils.Combine(this.Fso.PublishmentSystemPath, this.Fso.PublishmentSystemInfo.Additional.ImageUploadDirectoryName), imageUploadDirectoryPath);
387+
388+
var videoUploadDirectoryPath = PathUtils.Combine(siteContentDirectoryPath, this.Fso.PublishmentSystemInfo.Additional.VideoUploadDirectoryName);
389+
DirectoryUtils.DeleteDirectoryIfExists(videoUploadDirectoryPath);
390+
DirectoryUtils.Copy(PathUtils.Combine(this.Fso.PublishmentSystemPath, this.Fso.PublishmentSystemInfo.Additional.VideoUploadDirectoryName), videoUploadDirectoryPath);
391+
392+
var fileUploadDirectoryPath = PathUtils.Combine(siteContentDirectoryPath, this.Fso.PublishmentSystemInfo.Additional.FileUploadDirectoryName);
393+
DirectoryUtils.DeleteDirectoryIfExists(fileUploadDirectoryPath);
394+
DirectoryUtils.Copy(PathUtils.Combine(this.Fso.PublishmentSystemPath, this.Fso.PublishmentSystemInfo.Additional.FileUploadDirectoryName), fileUploadDirectoryPath);
395+
396+
Atom.Core.AtomFeed feed = AtomUtility.GetEmptyFeed();
397+
var entry = AtomUtility.GetEmptyEntry();
398+
AtomUtility.AddDcElement(entry.AdditionalElements, "ImageUploadDirectoryName", this.Fso.PublishmentSystemInfo.Additional.ImageUploadDirectoryName);
399+
AtomUtility.AddDcElement(entry.AdditionalElements, "VideoUploadDirectoryName", this.Fso.PublishmentSystemInfo.Additional.VideoUploadDirectoryName);
400+
AtomUtility.AddDcElement(entry.AdditionalElements, "FileUploadDirectoryName", this.Fso.PublishmentSystemInfo.Additional.FileUploadDirectoryName);
401+
402+
feed.Entries.Add(entry);
403+
var UploadFolderPath = PathUtils.Combine(siteContentDirectoryPath, BackupUtility.UploadFolderName);
404+
DirectoryUtils.CreateDirectoryIfNotExists(UploadFolderPath);
405+
var UploadFilePath = PathUtils.Combine(UploadFolderPath, BackupUtility.UploadFileName);
406+
feed.Save(UploadFilePath);
383407

384408
ZipUtils.PackFiles(filePath, siteContentDirectoryPath);
385409

source/SiteServer.CMS/ImportExport/ImportObject.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Generic;
44
using System.Collections.Specialized;
55
using System.Text;
6+
using Atom.Core;
67
using BaiRong.Core;
78
using BaiRong.Core.IO;
89
using BaiRong.Core.Model.Enumerations;
@@ -256,6 +257,34 @@ public void ImportChannelsAndContentsByZipFile(int parentId, string zipFilePath,
256257
ImportChannelsAndContentsFromZip(parentId, siteContentDirectoryPath, isOverride);
257258

258259
DataProvider.NodeDao.UpdateContentNum(Fso.PublishmentSystemInfo);
260+
261+
string filePath = PathUtils.Combine(siteContentDirectoryPath, BackupUtility.UploadFolderName, BackupUtility.UploadFileName);
262+
var UploadFolderPath = PathUtils.Combine(siteContentDirectoryPath, BackupUtility.UploadFolderName);
263+
var UploadFilePath = PathUtils.Combine(UploadFolderPath, BackupUtility.UploadFileName);
264+
if (!FileUtils.IsFileExists(UploadFilePath))
265+
{
266+
return;
267+
}
268+
var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(UploadFilePath));
269+
if (feed != null)
270+
{
271+
AtomEntry entry = feed.Entries[0];
272+
string imageUploadDirectoryPath = AtomUtility.GetDcElementContent(entry.AdditionalElements, "ImageUploadDirectoryName");
273+
if(imageUploadDirectoryPath != null)
274+
{
275+
DirectoryUtils.MoveDirectory(PathUtils.Combine(siteContentDirectoryPath, imageUploadDirectoryPath), PathUtils.Combine(Fso.PublishmentSystemPath, Fso.PublishmentSystemInfo.Additional.ImageUploadDirectoryName), isOverride);
276+
}
277+
string videoUploadDirectoryPath = AtomUtility.GetDcElementContent(entry.AdditionalElements, "VideoUploadDirectoryName");
278+
if (videoUploadDirectoryPath != null)
279+
{
280+
DirectoryUtils.MoveDirectory(PathUtils.Combine(siteContentDirectoryPath, videoUploadDirectoryPath), PathUtils.Combine(Fso.PublishmentSystemPath, Fso.PublishmentSystemInfo.Additional.VideoUploadDirectoryName), isOverride);
281+
}
282+
string fileUploadDirectoryPath = AtomUtility.GetDcElementContent(entry.AdditionalElements, "FileUploadDirectoryName");
283+
if (fileUploadDirectoryPath != null)
284+
{
285+
DirectoryUtils.MoveDirectory(PathUtils.Combine(siteContentDirectoryPath, fileUploadDirectoryPath), PathUtils.Combine(Fso.PublishmentSystemPath, Fso.PublishmentSystemInfo.Additional.FileUploadDirectoryName), isOverride);
286+
}
287+
}
259288
}
260289

261290
public void ImportChannelsAndContentsFromZip(int parentId, string siteContentDirectoryPath, bool isOverride)

source/SiteServer.Web/Web.config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<appSettings>
44
<add key="PageInspector:ServerCodeMappingSupport" value="Disabled" />
55
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
6-
<add key="IsProtectData" value="False" />
7-
<add key="DatabaseType" value="MySql" />
8-
<add key="ConnectionString" value="server=localhost;uid=root;pwd=root;database=test3" />
6+
<add key="IsProtectData" value="False" />
7+
<add key="DatabaseType" value="SqlServer" />
8+
<add key="ConnectionString" value="server=(local);uid=sa;pwd=ekun008;database=cms5.0" />
99
</appSettings>
1010
<system.web>
1111
<httpRuntime targetFramework="4.5" requestValidationMode="2.0" requestPathInvalidCharacters="" maxRequestLength="40960" executionTimeout="2000" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" enableVersionHeader="false" />

0 commit comments

Comments
 (0)