Exemplo n.º 1
0
        protected override void RunInternal()
        {
            var config = BackupConfigurationSection.GetSection();
            var pathToCurrentWebConfig = FileUtility.GetRootedPath(config.WebConfigs.GetCurrentConfig());
            var pathToTargetWebConfig  = FileUtility.GetRootedPath(config.WebConfigs.GetPathForRegion(targetRegion));
            var tempFolderPath         = config.TempFolder;

            if (!Directory.Exists(tempFolderPath))
            {
                Directory.CreateDirectory(tempFolderPath);
            }

            try
            {
                NotifyHelper.SendAboutTransferStart(TenantId, targetRegion, NotifyOnlyOwner);

                var transferTask = new TransferPortalTask(CoreContext.TenantManager.GetTenant(TenantId), pathToCurrentWebConfig, pathToTargetWebConfig)
                {
                    BackupDirectory = FileUtility.GetRootedPath(config.TempFolder)
                };

                if (!TransferMail)
                {
                    transferTask.IgnoreModule(ModuleName.Mail);
                }

                transferTask.ProgressChanged += (sender, args) => Progress = args.Progress;
                transferTask.Message         += (sender, args) =>
                {
                    if (args.Reason == MessageReason.Info && Log != null)
                    {
                        Log.Debug(args.Message);
                    }
                    else if (args.Reason == MessageReason.Warning && Log != null)
                    {
                        Log.Warn(args.Message);
                    }
                };

                transferTask.Run();

                NotifyHelper.SendAboutTransferComplete(TenantId, targetRegion, GetPortalAddress(pathToTargetWebConfig), NotifyOnlyOwner);
            }
            catch
            {
                NotifyHelper.SendAboutTransferError(TenantId, targetRegion, GetPortalAddress(pathToCurrentWebConfig), NotifyOnlyOwner);
                throw;
            }
        }
Exemplo n.º 2
0
            public void RunJob()
            {
                try
                {
                    NotifyHelper.SendAboutTransferStart(_tenant.TenantId, _targetRegion, _notifyAllUsers);

                    string targetWebConfigPath = ToAbsolute(BackupConfigurationSection.GetSection().RegionConfigs.GetConfig(_targetRegion).Path);

                    var transferTask = new TransferPortalTask(_tenant, currentWebConfigPath, targetWebConfigPath)
                    {
                        BackupDirectory = tmpfolder
                    };

                    if (!_backupMail)
                    {
                        transferTask.IgnoreModule(ModuleName.Mail);
                    }

                    transferTask.ProgressChanged += (sender, args) => Percentage = args.Progress;
                    transferTask.Message         += (sender, args) =>
                    {
                        if (args.Reason == MessageReason.Info)
                        {
                            log.Debug(args.Message);
                        }
                        else if (args.Reason == MessageReason.Warning)
                        {
                            log.Warn(args.Message);
                        }
                    };

                    transferTask.Run();

                    NotifyHelper.SendAboutTransferComplete(_tenant.TenantId, _targetRegion, GetPortalAddress(targetWebConfigPath), _notifyAllUsers);
                }
                catch (Exception error)
                {
                    log.Error(error);
                    NotifyHelper.SendAboutTransferError(_tenant.TenantId, _targetRegion, GetPortalAddress(currentWebConfigPath), error.Message, _notifyAllUsers);
                    Error = error;
                }
                finally
                {
                    IsCompleted = true;
                }
            }
Exemplo n.º 3
0
            public void RunJob()
            {
                var tempFile = PathHelper.GetTempFileName(tempFolder);
                var alias    = CoreContext.TenantManager.GetTenant(TenantId).TenantAlias;

                try
                {
                    NotifyHelper.SendAboutTransferStart(TenantId, TargetRegion, Notify);

                    var transferProgressItem = new TransferPortalTask(Log, TenantId, configPaths[currentRegion], configPaths[TargetRegion])
                    {
                        BackupDirectory = tempFolder
                    };
                    transferProgressItem.ProgressChanged += (sender, args) => Percentage = args.Progress;
                    if (!TransferMail)
                    {
                        transferProgressItem.IgnoreModule(ModuleName.Mail);
                    }
                    transferProgressItem.RunJob();

                    Link = GetLink(alias, false);
                    NotifyHelper.SendAboutTransferComplete(TenantId, TargetRegion, Link, !Notify);
                }
                catch (Exception error)
                {
                    Log.Error(error);
                    Error = error;

                    Link = GetLink(alias, true);
                    NotifyHelper.SendAboutTransferError(TenantId, TargetRegion, Link, !Notify);
                }
                finally
                {
                    if (File.Exists(tempFile))
                    {
                        File.Delete(tempFile);
                    }
                    IsCompleted = true;
                }
            }