Ejemplo n.º 1
0
        public override void RunJob()
        {
            Logger.Debug("begin restore portal");

            List <IModuleSpecifics> modulesToProcess = GetModulesToProcess().ToList();

            SetStepsCount(ProcessStorage ? modulesToProcess.Count + 1 : modulesToProcess.Count);

            Logger.Debug("begin restore data");

            using (var dataReader = new ZipReadOperator(BackupFilePath))
            {
                var dbFactory = new DbFactory(ConfigPath);
                foreach (var module in modulesToProcess)
                {
                    var restoreTask = new RestoreDbModuleTask(Logger, module, dataReader, _columnMapper, dbFactory,
                                                              ReplaceDate);
                    restoreTask.ProgressChanged += (sender, args) => SetCurrentStepProgress(args.Progress);
                    foreach (var tableName in IgnoredTables)
                    {
                        restoreTask.IgnoreTable(tableName);
                    }
                    restoreTask.RunJob();
                }

                Logger.Debug("end restore data");

                if (ProcessStorage)
                {
                    DoRestoreStorage(dataReader);
                }
                if (UnblockPortalAfterCompleted)
                {
                    SetTenantActive(dbFactory, _columnMapper.GetTenantMapping());
                }
            }

            if (CoreContext.Configuration.Standalone)
            {
                Logger.Debug("refresh license");
                try
                {
                    LicenseReader.RejectLicense();
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                }

                Logger.Debug("clear cache");
                AscCache.Default.Remove(new Regex(".*"));
            }

            Logger.Debug("end restore portal");
        }
Ejemplo n.º 2
0
        public override void RunJob()
        {
            Logger.Debug("begin restore portal");

            Logger.Debug("begin restore data");

            using (var dataReader = new ZipReadOperator(BackupFilePath))
            {
                using (var entry = dataReader.GetEntry(KeyHelper.GetDumpKey()))
                {
                    Dump = entry != null && CoreBaseSettings.Standalone;
                }

                if (Dump)
                {
                    RestoreFromDump(dataReader);
                }
                else
                {
                    var modulesToProcess = GetModulesToProcess().ToList();
                    SetStepsCount(ProcessStorage ? modulesToProcess.Count + 1 : modulesToProcess.Count);

                    foreach (var module in modulesToProcess)
                    {
                        var restoreTask = new RestoreDbModuleTask(Options, module, dataReader, ColumnMapper, DbFactory, ReplaceDate, Dump, StorageFactory, StorageFactoryConfig, ModuleProvider);
                        restoreTask.ProgressChanged += (sender, args) => SetCurrentStepProgress(args.Progress);
                        foreach (var tableName in IgnoredTables)
                        {
                            restoreTask.IgnoreTable(tableName);
                        }
                        restoreTask.RunJob();
                    }
                }

                Logger.Debug("end restore data");

                if (ProcessStorage)
                {
                    if (CoreBaseSettings.Standalone)
                    {
                        Logger.Debug("clear cache");
                        AscCacheNotify.ClearCache();
                    }

                    DoRestoreStorage(dataReader);
                }
                if (UnblockPortalAfterCompleted)
                {
                    SetTenantActive(ColumnMapper.GetTenantMapping());
                }
            }

            if (CoreBaseSettings.Standalone)
            {
                Logger.Debug("refresh license");
                try
                {
                    LicenseReader.RejectLicense();
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                }

                Logger.Debug("clear cache");
                AscCacheNotify.ClearCache();
            }

            Logger.Debug("end restore portal");
        }