Skip to content

Commit 595ef7a

Browse files
committed
Added file dialog for export deployment
1 parent abcc435 commit 595ef7a

12 files changed

Lines changed: 222 additions & 94 deletions

File tree

src/Libraries/SmartStore.Services/DataExchange/Export/DataExporter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ private void ExportCoreInner(DataExporterContext ctx, Store store)
10791079

10801080
var publicDeployment = ctx.Request.Profile.Deployments.FirstOrDefault(x => x.DeploymentType == ExportDeploymentType.PublicFolder);
10811081
ctx.ExecuteContext.HasPublicDeployment = (publicDeployment != null);
1082-
ctx.ExecuteContext.PublicFolderPath = publicDeployment.GetPublicFolder(true);
1082+
ctx.ExecuteContext.PublicFolderPath = publicDeployment.GetDeploymentFolder(true);
10831083

10841084
var fileExtension = (ctx.Request.Provider.Value.FileExtension.HasValue() ? ctx.Request.Provider.Value.FileExtension.ToLower().EnsureStartsWith(".") : "");
10851085

src/Libraries/SmartStore.Services/DataExchange/Export/Deployment/FileSystemFilePublisher.cs

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,14 @@ public class FileSystemFilePublisher : IFilePublisher
99
{
1010
public virtual void Publish(ExportDeploymentContext context, ExportDeployment deployment)
1111
{
12-
string destinationFolder = null;
12+
var targetFolder = deployment.GetDeploymentFolder(true);
1313

14-
if (deployment.FileSystemPath.IsEmpty())
15-
{
16-
return;
17-
}
18-
else if (Path.IsPathRooted(deployment.FileSystemPath))
19-
{
20-
destinationFolder = deployment.FileSystemPath;
21-
}
22-
else
23-
{
24-
destinationFolder = FileSystemHelper.ValidateRootPath(deployment.FileSystemPath);
25-
destinationFolder = CommonHelper.MapPath(destinationFolder);
26-
}
27-
28-
if (!System.IO.Directory.Exists(destinationFolder))
29-
{
30-
System.IO.Directory.CreateDirectory(destinationFolder);
31-
}
32-
33-
if (!FileSystemHelper.CopyDirectory(new DirectoryInfo(context.FolderContent), new DirectoryInfo(destinationFolder)))
14+
if (!FileSystemHelper.CopyDirectory(new DirectoryInfo(context.FolderContent), new DirectoryInfo(targetFolder)))
3415
{
3516
context.Result.LastError = context.T("Admin.DataExchange.Export.Deployment.CopyFileFailed");
3617
}
3718

38-
context.Log.Information("Copied export data files to " + destinationFolder);
19+
context.Log.Information("Copied export data files to " + targetFolder);
3920
}
4021
}
4122
}

src/Libraries/SmartStore.Services/DataExchange/Export/Deployment/PublicFolderPublisher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class PublicFolderPublisher : IFilePublisher
99
{
1010
public virtual void Publish(ExportDeploymentContext context, ExportDeployment deployment)
1111
{
12-
var destinationFolder = deployment.GetPublicFolder(true);
12+
var destinationFolder = deployment.GetDeploymentFolder(true);
1313

1414
if (destinationFolder.IsEmpty())
1515
return;

src/Libraries/SmartStore.Services/DataExchange/Export/ExportExtensions.cs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,25 +154,43 @@ public static string ResolveFileNamePattern(this ExportProfile profile, Store st
154154
}
155155

156156
/// <summary>
157-
/// Get path of the public folder
157+
/// Get path of the deployment folder
158158
/// </summary>
159159
/// <param name="deployment">Export deployment</param>
160-
/// <returns>Public folder path</returns>
161-
public static string GetPublicFolder(this ExportDeployment deployment, bool create = false)
160+
/// <returns>Deployment folder path</returns>
161+
public static string GetDeploymentFolder(this ExportDeployment deployment, bool create = false)
162162
{
163+
if (deployment == null)
164+
return null;
165+
163166
string path = null;
164167

165-
if (deployment != null && deployment.DeploymentType == ExportDeploymentType.PublicFolder)
168+
if (deployment.DeploymentType == ExportDeploymentType.PublicFolder)
166169
{
167170
if (deployment.SubFolder.HasValue())
168171
path = Path.Combine(HttpRuntime.AppDomainAppPath, DataExporter.PublicFolder, deployment.SubFolder);
169172
else
170173
path = Path.Combine(HttpRuntime.AppDomainAppPath, DataExporter.PublicFolder);
174+
}
175+
else if (deployment.DeploymentType == ExportDeploymentType.FileSystem)
176+
{
177+
if (deployment.FileSystemPath.IsEmpty())
178+
return null;
171179

172-
if (create && !System.IO.Directory.Exists(path))
173-
System.IO.Directory.CreateDirectory(path);
180+
if (Path.IsPathRooted(deployment.FileSystemPath))
181+
{
182+
path = deployment.FileSystemPath;
183+
}
184+
else
185+
{
186+
path = FileSystemHelper.ValidateRootPath(deployment.FileSystemPath);
187+
path = CommonHelper.MapPath(path);
188+
}
174189
}
175190

191+
if (create && !System.IO.Directory.Exists(path))
192+
System.IO.Directory.CreateDirectory(path);
193+
176194
return path;
177195
}
178196

0 commit comments

Comments
 (0)