public void PlatformExportBackground(PlatformImportExportRequest exportRequest, PlatformExportPushNotification pushNotification)
        {
            Action <ExportImportProgressInfo> progressCallback = x =>
            {
                pushNotification.InjectFrom(x);
                pushNotification.Errors = x.Errors;
                _pushNotifier.Upsert(pushNotification);
            };

            try
            {
                var relativeUrl    = "tmp/exported_data.zip";
                var localTmpFolder = HostingEnvironment.MapPath("~/App_Data/Uploads/tmp");
                var localTmpPath   = Path.Combine(localTmpFolder, "exported_data.zip");
                if (!Directory.Exists(localTmpFolder))
                {
                    Directory.CreateDirectory(localTmpFolder);
                }
                //Import first to local tmp folder because Azure blob storage doesn't support some special file access mode
                using (var stream = File.Open(localTmpPath, FileMode.OpenOrCreate))
                {
                    var manifest = exportRequest.ToManifest();
                    _platformExportManager.Export(stream, manifest, progressCallback);
                }
                //Copy export data to blob provider for get public download url
                using (var localStream = File.Open(localTmpPath, FileMode.Open))
                    using (var blobStream = _blobStorageProvider.OpenWrite(relativeUrl))
                    {
                        localStream.CopyTo(blobStream);
                        //Get a download url
                        pushNotification.DownloadUrl = _blobUrlResolver.GetAbsoluteUrl(relativeUrl);
                    }
            }
            catch (Exception ex)
            {
                pushNotification.Errors.Add(ex.ExpandExceptionMessage());
            }
            finally
            {
                pushNotification.Description = "Export finished";
                pushNotification.Finished    = DateTime.UtcNow;
                _pushNotifier.Upsert(pushNotification);
            }
        }
        public void PlatformExportBackground(PlatformImportExportRequest exportRequest, PlatformExportPushNotification pushNotification)
        {
            Action <ExportImportProgressInfo> progressCallback = (x) =>
            {
                pushNotification.InjectFrom(x);
                pushNotification.Errors = x.Errors;
                _pushNotifier.Upsert(pushNotification);
            };

            try
            {
                using (var stream = new MemoryStream())
                {
                    var manifest = exportRequest.ToManifest();
                    _platformExportManager.Export(stream, manifest, progressCallback);
                    stream.Seek(0, SeekOrigin.Begin);
                    //Upload result  to blob storage
                    var uploadInfo = new UploadStreamInfo
                    {
                        FileName       = string.Format("exported_data.zip"),
                        FileByteStream = stream,
                        FolderName     = "tmp"
                    };
                    var blobKey = _blobStorageProvider.Upload(uploadInfo);
                    //Get a download url
                    pushNotification.DownloadUrl = _blobUrlResolver.GetAbsoluteUrl(blobKey);
                }
            }
            catch (Exception ex)
            {
                pushNotification.Errors.Add(ex.ExpandExceptionMessage());
            }
            finally
            {
                pushNotification.Description = "Export finished";
                pushNotification.Finished    = DateTime.UtcNow;
                _pushNotifier.Upsert(pushNotification);
            }
        }
        public void PlatformExportBackground(PlatformImportExportRequest exportRequest, PlatformExportPushNotification pushNotification)
        {
            Action <ExportImportProgressInfo> progressCallback = x =>
            {
                pushNotification.InjectFrom(x);
                pushNotification.Errors = x.Errors;
                _pushNotifier.Upsert(pushNotification);
            };

            try
            {
                var localTmpFolder = HostingEnvironment.MapPath(_defaultExportFolder);
                var localTmpPath   = Path.Combine(localTmpFolder, _defaultExportFileName);

                if (!Directory.Exists(localTmpFolder))
                {
                    Directory.CreateDirectory(localTmpFolder);
                }
                //Import first to local tmp folder because Azure blob storage doesn't support some special file access mode
                using (var stream = File.Open(localTmpPath, FileMode.OpenOrCreate))
                {
                    var manifest = exportRequest.ToManifest();
                    _platformExportManager.Export(stream, manifest, progressCallback);
                    pushNotification.DownloadUrl = $"api/platform/export/download/{_defaultExportFileName}";
                }
            }
            catch (Exception ex)
            {
                pushNotification.Errors.Add(ex.ExpandExceptionMessage());
            }
            finally
            {
                pushNotification.Description = "Export finished";
                pushNotification.Finished    = DateTime.UtcNow;
                _pushNotifier.Upsert(pushNotification);
            }
        }
        public void PlatformExportBackground(PlatformImportExportRequest exportRequest, PlatformExportPushNotification pushNotification)
        {
            Action <ExportImportProgressInfo> progressCallback = x =>
            {
                pushNotification.InjectFrom(x);
                pushNotification.Errors = x.Errors;
                _pushNotifier.Upsert(pushNotification);
            };

            try
            {
                using (var stream = new MemoryStream())
                {
                    var manifest = exportRequest.ToManifest();
                    _platformExportManager.Export(stream, manifest, progressCallback);
                    stream.Seek(0, SeekOrigin.Begin);
                    var relativeUrl = "tmp/exported_data.zip";
                    using (var targetStream = _blobStorageProvider.OpenWrite(relativeUrl))
                    {
                        stream.CopyTo(targetStream);
                    }
                    //Get a download url
                    pushNotification.DownloadUrl = _blobUrlResolver.GetAbsoluteUrl(relativeUrl);
                }
            }
            catch (Exception ex)
            {
                pushNotification.Errors.Add(ex.ExpandExceptionMessage());
            }
            finally
            {
                pushNotification.Description = "Export finished";
                pushNotification.Finished    = DateTime.UtcNow;
                _pushNotifier.Upsert(pushNotification);
            }
        }