Пример #1
0
 public TransferTask(TransferRequest request)
 {
     _tenant = CoreContext.TenantManager.GetTenant(request.TenantId);
     _targetRegion = request.TargetRegion;
     _notifyAllUsers = request.NotifyUsers;
     _backupMail = request.BackupMail;
     Id = request.TenantId;
 }
        public string StartTransfer(string targetRegion, bool notify, bool backupmail)
        {
            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
            if (!EnableMigration)
                return null;

            if (CurrentRegion.Equals(targetRegion, StringComparison.OrdinalIgnoreCase))
                return ToJsonError(Resource.ErrorTransferPortalInRegion);

            try
            {
                using (var backupClient = new BackupServiceClient())
                {
                    var transferRequest = new TransferRequest
                        {
                            TenantId = TenantProvider.CurrentTenantID,
                            TargetRegion = targetRegion,
                            NotifyUsers = notify,
                            BackupMail = backupmail
                        };

                    return ToJsonSuccess(backupClient.TransferPortal(transferRequest));
                }
            }
            catch (Exception error)
            {
                return ToJsonError(error.Message);
            }
        }
Пример #3
0
 public BackupResult TransferPortal(TransferRequest request)
 {
     lock (tasks.SynchRoot)
     {
         var task = tasks.GetItems().OfType<TransferTask>().FirstOrDefault(x => (int)x.Id == request.TenantId);
         if (task != null && task.IsCompleted)
         {
             tasks.Remove(task);
             task = null;
         }
         if (task == null)
         {
             if (request.TargetRegion == BackupConfigurationSection.GetSection().RegionConfigs.CurrentRegion)
             {
                 throw new FaultException("Current and target regions are the same!");
             }
             task = new TransferTask(request);
             tasks.Add(task);
         }
         return ToResult(task);
     }
 }
Пример #4
0
 public BackupResult TransferPortal(TransferRequest request)
 {
     return(Channel.TransferPortal(request));
 }