public virtual void Publish(ExportDeploymentContext context, ExportDeployment deployment)
        {
            var destinationFolder = deployment.GetDeploymentFolder(true);

            if (destinationFolder.IsEmpty())
                return;

            if (!System.IO.Directory.Exists(destinationFolder))
            {
                System.IO.Directory.CreateDirectory(destinationFolder);
            }

            if (context.CreateZipArchive)
            {
                if (File.Exists(context.ZipPath))
                {
                    var destinationFile = Path.Combine(destinationFolder, Path.GetFileName(context.ZipPath));

                    File.Copy(context.ZipPath, destinationFile, true);

                    context.Log.Information("Copied zipped export data to " + destinationFile);
                }
            }
            else
            {
                if (!FileSystemHelper.CopyDirectory(new DirectoryInfo(context.FolderContent), new DirectoryInfo(destinationFolder)))
                {
                    context.Result.LastError = context.T("Admin.DataExchange.Export.Deployment.CopyFileFailed");
                }

                context.Log.Information("Copied export data files to " + destinationFolder);
            }
        }
        public virtual void Publish(ExportDeploymentContext context, ExportDeployment deployment)
        {
            var targetFolder = deployment.GetDeploymentFolder(true);

            if (!FileSystemHelper.CopyDirectory(new DirectoryInfo(context.FolderContent), new DirectoryInfo(targetFolder)))
            {
                context.Result.LastError = context.T("Admin.DataExchange.Export.Deployment.CopyFileFailed");
            }

            context.Log.Information("Copied export data files to " + targetFolder);
        }
        private bool Deploy(DataExporterContext ctx, string zipPath)
        {
            var allSucceeded = true;
            var deployments = ctx.Request.Profile.Deployments.OrderBy(x => x.DeploymentTypeId).Where(x => x.Enabled);

            if (deployments.Count() == 0)
                return false;

            var context = new ExportDeploymentContext
            {
                T = T,
                Log = ctx.Log,
                FolderContent = ctx.FolderContent,
                ZipPath = zipPath,
                CreateZipArchive = ctx.Request.Profile.CreateZipArchive
            };

            foreach (var deployment in deployments)
            {
                IFilePublisher publisher = null;

                context.Result = new DataDeploymentResult
                {
                    LastExecutionUtc = DateTime.UtcNow
                };

                try
                {
                    switch (deployment.DeploymentType)
                    {
                        case ExportDeploymentType.Email:
                            publisher = new EmailFilePublisher(_emailAccountService.Value, _queuedEmailService.Value);
                            break;
                        case ExportDeploymentType.FileSystem:
                            publisher = new FileSystemFilePublisher();
                            break;
                        case ExportDeploymentType.Ftp:
                            publisher = new FtpFilePublisher();
                            break;
                        case ExportDeploymentType.Http:
                            publisher = new HttpFilePublisher();
                            break;
                        case ExportDeploymentType.PublicFolder:
                            publisher = new PublicFolderPublisher();
                            break;
                    }

                    if (publisher != null)
                    {
                        publisher.Publish(context, deployment);

                        if (!context.Result.Succeeded)
                            allSucceeded = false;
                    }
                }
                catch (Exception exception)
                {
                    allSucceeded = false;

                    if (context.Result != null)
                    {
                        context.Result.LastError = exception.ToAllMessages();
                    }

                    ctx.Log.Error("Deployment \"{0}\" of type {1} failed: {2}".FormatInvariant(
                        deployment.Name, deployment.DeploymentType.ToString(), exception.Message), exception);
                }

                deployment.ResultInfo = XmlHelper.Serialize(context.Result);

                _exportProfileService.Value.UpdateExportDeployment(deployment);
            }

            return allSucceeded;
        }