public override void Run()
        {
            InvokeInfo("begin transfer portal ({0})", Tenant.TenantAlias);
            string backupFilePath = GetBackupFilePath();
            var fromDbFactory = new DbFactory(ConfigPath);
            var toDbFactory = new DbFactory(ToConfigPath);
            var columnMapper = new ColumnMapper();
            try
            {
                //target db can have error tenant from the previous attempts
                SaveTenant(toDbFactory, TenantStatus.RemovePending, Tenant.TenantAlias + "_error", "status = " + TenantStatus.Restoring.ToString("d"));

                if (BlockOldPortalAfterStart)
                {
                    SaveTenant(fromDbFactory, TenantStatus.Transfering);
                }

                InitProgress(ProcessStorage ? 3 : 2);

                //save db data to temporary file
                var backupTask = new BackupPortalTask(Tenant, ConfigPath, backupFilePath) {ProcessStorage = false};
                foreach (var moduleName in IgnoredModules)
                {
                    backupTask.IgnoreModule(moduleName);
                }
                RunSubtask(backupTask);
                
                //restore db data from temporary file
                var restoreTask = new RestorePortalTask(ToConfigPath, backupFilePath, columnMapper) {ProcessStorage = false};
                foreach (var moduleName in IgnoredModules)
                {
                    restoreTask.IgnoreModule(moduleName);
                }
                RunSubtask(restoreTask);

                //transfer files
                if (ProcessStorage)
                {
                    DoTransferStorage(columnMapper);
                }

                SaveTenant(toDbFactory, TenantStatus.Active);
                if (DeleteOldPortalAfterCompletion)
                {
                    SaveTenant(fromDbFactory, TenantStatus.RemovePending, Tenant.TenantAlias + "_deleted");
                }
                else if (BlockOldPortalAfterStart)
                {
                    SaveTenant(fromDbFactory, TenantStatus.Active);
                }
            }
            catch
            {
                SaveTenant(fromDbFactory, TenantStatus.Active);
                if (columnMapper.GetTenantMapping() > 0)
                {
                    SaveTenant(toDbFactory, TenantStatus.RemovePending, Tenant.TenantAlias + "_error");
                }
                throw;
            }
            finally
            {
                if (DeleteBackupFileAfterCompletion)
                {
                    File.Delete(backupFilePath);
                }
                InvokeInfo("end transfer portal ({0})", Tenant.TenantAlias);
            }
        }
Пример #2
0
        public override void RunJob()
        {
            Logger.Debug("begin transfer {0}", TenantId);
            var    fromDbFactory  = new DbFactory(ConfigPath);
            var    toDbFactory    = new DbFactory(ToConfigPath);
            string tenantAlias    = GetTenantAlias(fromDbFactory);
            string backupFilePath = GetBackupFilePath(tenantAlias);
            var    columnMapper   = new ColumnMapper();

            try
            {
                //target db can have error tenant from the previous attempts
                SaveTenant(toDbFactory, tenantAlias, TenantStatus.RemovePending, tenantAlias + "_error", "status = " + TenantStatus.Restoring.ToString("d"));

                if (BlockOldPortalAfterStart)
                {
                    SaveTenant(fromDbFactory, tenantAlias, TenantStatus.Transfering);
                }

                SetStepsCount(ProcessStorage ? 3 : 2);

                //save db data to temporary file
                var backupTask = new BackupPortalTask(Logger, TenantId, ConfigPath, backupFilePath, Limit)
                {
                    ProcessStorage = false
                };
                backupTask.ProgressChanged += (sender, args) => SetCurrentStepProgress(args.Progress);
                foreach (var moduleName in IgnoredModules)
                {
                    backupTask.IgnoreModule(moduleName);
                }
                backupTask.RunJob();

                //restore db data from temporary file
                var restoreTask = new RestorePortalTask(Logger, ToConfigPath, backupFilePath, columnMapper)
                {
                    ProcessStorage = false
                };
                restoreTask.ProgressChanged += (sender, args) => SetCurrentStepProgress(args.Progress);
                foreach (var moduleName in IgnoredModules)
                {
                    restoreTask.IgnoreModule(moduleName);
                }
                restoreTask.RunJob();

                //transfer files
                if (ProcessStorage)
                {
                    DoTransferStorage(columnMapper);
                }

                SaveTenant(toDbFactory, tenantAlias, TenantStatus.Active);
                if (DeleteOldPortalAfterCompletion)
                {
                    SaveTenant(fromDbFactory, tenantAlias, TenantStatus.RemovePending, tenantAlias + "_deleted");
                }
                else if (BlockOldPortalAfterStart)
                {
                    SaveTenant(fromDbFactory, tenantAlias, TenantStatus.Active);
                }
            }
            catch
            {
                SaveTenant(fromDbFactory, tenantAlias, TenantStatus.Active);
                if (columnMapper.GetTenantMapping() > 0)
                {
                    SaveTenant(toDbFactory, tenantAlias, TenantStatus.RemovePending, tenantAlias + "_error");
                }
                throw;
            }
            finally
            {
                if (DeleteBackupFileAfterCompletion)
                {
                    File.Delete(backupFilePath);
                }
                Logger.Debug("end transfer {0}", TenantId);
            }
        }
Пример #3
0
        public override void Run()
        {
            InvokeInfo("begin transfer portal ({0})", Tenant.TenantAlias);
            string backupFilePath = GetBackupFilePath();
            var    fromDbFactory  = new DbFactory(ConfigPath);
            var    toDbFactory    = new DbFactory(ToConfigPath);
            var    columnMapper   = new ColumnMapper();

            try
            {
                //target db can have error tenant from the previous attempts
                SaveTenant(toDbFactory, TenantStatus.RemovePending, Tenant.TenantAlias + "_error", "status = " + TenantStatus.Restoring.ToString("d"));

                if (BlockOldPortalAfterStart)
                {
                    SaveTenant(fromDbFactory, TenantStatus.Transfering);
                }

                InitProgress(ProcessStorage ? 3 : 2);

                //save db data to temporary file
                var backupTask = new BackupPortalTask(Tenant, ConfigPath, backupFilePath)
                {
                    ProcessStorage = false
                };
                foreach (var moduleName in IgnoredModules)
                {
                    backupTask.IgnoreModule(moduleName);
                }
                RunSubtask(backupTask);

                //restore db data from temporary file
                var restoreTask = new RestorePortalTask(ToConfigPath, backupFilePath, columnMapper)
                {
                    ProcessStorage = false
                };
                foreach (var moduleName in IgnoredModules)
                {
                    restoreTask.IgnoreModule(moduleName);
                }
                RunSubtask(restoreTask);

                //transfer files
                if (ProcessStorage)
                {
                    DoTransferStorage(columnMapper);
                }

                SaveTenant(toDbFactory, TenantStatus.Active);
                if (DeleteOldPortalAfterCompletion)
                {
                    SaveTenant(fromDbFactory, TenantStatus.RemovePending, Tenant.TenantAlias + "_deleted");
                }
                else if (BlockOldPortalAfterStart)
                {
                    SaveTenant(fromDbFactory, TenantStatus.Active);
                }
            }
            catch
            {
                SaveTenant(fromDbFactory, TenantStatus.Active);
                if (columnMapper.GetTenantMapping() > 0)
                {
                    SaveTenant(toDbFactory, TenantStatus.RemovePending, Tenant.TenantAlias + "_error");
                }
                throw;
            }
            finally
            {
                if (DeleteBackupFileAfterCompletion)
                {
                    File.Delete(backupFilePath);
                }
                InvokeInfo("end transfer portal ({0})", Tenant.TenantAlias);
            }
        }