Skip to content

Commit b5e6f71

Browse files
author
starlying
committed
Merge branch 'dev' of https://github.com/siteserver/cms into dev
2 parents 7a2bbc9 + 7c8a157 commit b5e6f71

4 files changed

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

383407
ZipUtils.PackFiles(filePath, siteContentDirectoryPath);
384408

‎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: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,10 @@
22
<configuration>
33
<appSettings>
44
<add key="PageInspector:ServerCodeMappingSupport" value="Disabled" />
5-
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
6-
7-
8-
<add key="IsProtectData" value="False" />
9-
<add key="AdminDirectory" value="SiteServer" />
10-
<add key="SecretKey" value="vEnfkn16t8aeaZKG3a4Gl9UUlzf4vgqU9xwh8ZV5" />
11-
12-
<add key="DatabaseType" value="MySql" />
13-
<add key="ConnectionString" value="server=localhost;uid=root;pwd=root;database=test3" />
14-
15-
<!-- <add key="DatabaseType" value="SqlServer" />
16-
<add key="ConnectionString" value="server=219.138.244.188;uid=sa;uid=tmwcn;pwd=tmwcn!@#$370;database=tmwcm;" /> -->
5+
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
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.1" />
179
</appSettings>
1810
<system.web>
1911
<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)