2022-03-15 18:00:53 +00:00
|
|
|
// (c) Copyright Ascensio System SIA 2010-2022
|
|
|
|
//
|
|
|
|
// This program is a free software product.
|
|
|
|
// You can redistribute it and/or modify it under the terms
|
|
|
|
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
|
|
|
|
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
|
|
|
|
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
|
|
|
|
// any third-party rights.
|
|
|
|
//
|
|
|
|
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
|
|
|
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
|
|
|
|
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
|
|
|
//
|
|
|
|
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
|
|
|
|
//
|
|
|
|
// The interactive user interfaces in modified source and object code versions of the Program must
|
|
|
|
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
|
|
|
|
//
|
|
|
|
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
|
|
|
|
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
|
|
|
|
// trademark law for use of our trademarks.
|
|
|
|
//
|
|
|
|
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
|
|
|
|
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
|
|
|
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
namespace ASC.Data.Backup.Tasks;
|
|
|
|
|
|
|
|
[Scope]
|
|
|
|
public class RestorePortalTask : PortalTaskBase
|
2021-08-31 09:40:28 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
public bool ReplaceDate { get; set; }
|
|
|
|
public bool Dump { get; set; }
|
|
|
|
public string BackupFilePath { get; private set; }
|
|
|
|
public string UpgradesPath { get; private set; }
|
|
|
|
public bool UnblockPortalAfterCompleted { get; set; }
|
|
|
|
|
|
|
|
private ColumnMapper _columnMapper;
|
|
|
|
private readonly CoreBaseSettings _coreBaseSettings;
|
|
|
|
private readonly LicenseReader _licenseReader;
|
2022-04-15 10:27:48 +00:00
|
|
|
private readonly TenantManager _tenantManager;
|
2022-02-09 18:49:52 +00:00
|
|
|
private readonly AscCacheNotify _ascCacheNotify;
|
2022-04-26 17:53:48 +00:00
|
|
|
private readonly ILogger _options;
|
2022-02-09 18:49:52 +00:00
|
|
|
|
|
|
|
public RestorePortalTask(
|
|
|
|
DbFactory dbFactory,
|
2022-04-26 17:53:48 +00:00
|
|
|
ILogger<RestorePortalTask> options,
|
2022-02-09 18:49:52 +00:00
|
|
|
StorageFactory storageFactory,
|
|
|
|
StorageFactoryConfig storageFactoryConfig,
|
|
|
|
CoreBaseSettings coreBaseSettings,
|
|
|
|
LicenseReader licenseReader,
|
|
|
|
TenantManager tenantManager,
|
|
|
|
AscCacheNotify ascCacheNotify,
|
|
|
|
ModuleProvider moduleProvider)
|
|
|
|
: base(dbFactory, options, storageFactory, storageFactoryConfig, moduleProvider)
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
_coreBaseSettings = coreBaseSettings;
|
|
|
|
_licenseReader = licenseReader;
|
|
|
|
_tenantManager = tenantManager;
|
|
|
|
_ascCacheNotify = ascCacheNotify;
|
|
|
|
_options = options;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Init(string toConfigPath, string fromFilePath, int tenantId = -1, ColumnMapper columnMapper = null, string upgradesPath = null)
|
|
|
|
{
|
2022-03-09 17:15:51 +00:00
|
|
|
ArgumentNullOrEmptyException.ThrowIfNullOrEmpty(fromFilePath);
|
2020-06-15 08:19:40 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
if (!File.Exists(fromFilePath))
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
throw new FileNotFoundException("file not found at given path");
|
|
|
|
}
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
BackupFilePath = fromFilePath;
|
|
|
|
UpgradesPath = upgradesPath;
|
|
|
|
_columnMapper = columnMapper ?? new ColumnMapper();
|
|
|
|
Init(tenantId, toConfigPath);
|
|
|
|
}
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
public override void RunJob()
|
|
|
|
{
|
2022-04-25 18:02:18 +00:00
|
|
|
Logger.LogDebug("begin restore portal");
|
2020-06-15 08:19:40 +00:00
|
|
|
|
2022-04-25 18:02:18 +00:00
|
|
|
Logger.LogDebug("begin restore data");
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
using (var dataReader = new ZipReadOperator(BackupFilePath))
|
|
|
|
{
|
|
|
|
using (var entry = dataReader.GetEntry(KeyHelper.GetDumpKey()))
|
|
|
|
{
|
|
|
|
Dump = entry != null && _coreBaseSettings.Standalone;
|
|
|
|
}
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
if (Dump)
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
RestoreFromDump(dataReader);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var modulesToProcess = GetModulesToProcess().ToList();
|
|
|
|
SetStepsCount(ProcessStorage ? modulesToProcess.Count + 1 : modulesToProcess.Count);
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
foreach (var module in modulesToProcess)
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
var restoreTask = new RestoreDbModuleTask(_options, module, dataReader, _columnMapper, DbFactory, ReplaceDate, Dump, StorageFactory, StorageFactoryConfig, ModuleProvider);
|
|
|
|
restoreTask.ProgressChanged += (sender, args) => SetCurrentStepProgress(args.Progress);
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-04-14 19:23:57 +00:00
|
|
|
foreach (var tableName in _ignoredTables)
|
2021-08-31 09:40:28 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
restoreTask.IgnoreTable(tableName);
|
2021-08-31 09:40:28 +00:00
|
|
|
}
|
2020-09-15 15:16:37 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
restoreTask.RunJob();
|
2020-05-20 15:14:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-25 18:02:18 +00:00
|
|
|
Logger.LogDebug("end restore data");
|
2022-02-09 18:49:52 +00:00
|
|
|
|
|
|
|
if (ProcessStorage)
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
if (_coreBaseSettings.Standalone)
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-04-25 18:02:18 +00:00
|
|
|
Logger.LogDebug("clear cache");
|
2022-02-09 18:49:52 +00:00
|
|
|
_ascCacheNotify.ClearCache();
|
2020-05-20 15:14:44 +00:00
|
|
|
}
|
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
DoRestoreStorage(dataReader);
|
2020-05-20 15:14:44 +00:00
|
|
|
}
|
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
if (UnblockPortalAfterCompleted)
|
|
|
|
{
|
|
|
|
SetTenantActive(_columnMapper.GetTenantMapping());
|
|
|
|
}
|
2020-05-20 15:14:44 +00:00
|
|
|
}
|
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
if (_coreBaseSettings.Standalone)
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-04-25 18:02:18 +00:00
|
|
|
Logger.LogDebug("refresh license");
|
2022-02-09 18:49:52 +00:00
|
|
|
try
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
_licenseReader.RejectLicense();
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2022-04-25 18:02:18 +00:00
|
|
|
Logger.LogError(ex, "RunJob");
|
2020-05-20 15:14:44 +00:00
|
|
|
}
|
|
|
|
|
2022-04-25 18:02:18 +00:00
|
|
|
Logger.LogDebug("clear cache");
|
2022-02-09 18:49:52 +00:00
|
|
|
_ascCacheNotify.ClearCache();
|
|
|
|
}
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-04-25 18:02:18 +00:00
|
|
|
Logger.LogDebug("end restore portal");
|
2022-02-09 18:49:52 +00:00
|
|
|
}
|
2021-08-31 09:40:28 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
private void RestoreFromDump(IDataReadOperator dataReader)
|
|
|
|
{
|
|
|
|
var keyBase = KeyHelper.GetDatabaseSchema();
|
|
|
|
var keys = dataReader.GetEntries(keyBase).Select(r => Path.GetFileName(r)).ToList();
|
|
|
|
var upgrades = new List<string>();
|
2021-08-31 09:40:28 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
if (!string.IsNullOrEmpty(UpgradesPath) && Directory.Exists(UpgradesPath))
|
|
|
|
{
|
|
|
|
upgrades = Directory.GetFiles(UpgradesPath).ToList();
|
|
|
|
}
|
2021-08-31 09:40:28 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
var stepscount = keys.Count * 2 + upgrades.Count;
|
2021-08-31 09:40:28 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
SetStepsCount(ProcessStorage ? stepscount + 1 : stepscount);
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
if (ProcessStorage)
|
|
|
|
{
|
|
|
|
var storageModules = StorageFactoryConfig.GetModuleList(ConfigPath).Where(IsStorageModuleAllowed);
|
|
|
|
var tenants = _tenantManager.GetTenants(false);
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
stepscount += storageModules.Count() * tenants.Count;
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
SetStepsCount(stepscount + 1);
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
DoDeleteStorage(storageModules, tenants);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetStepsCount(stepscount);
|
2020-05-20 15:14:44 +00:00
|
|
|
}
|
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
for (var i = 0; i < keys.Count; i += TasksLimit)
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
var tasks = new List<Task>(TasksLimit * 2);
|
|
|
|
|
|
|
|
for (var j = 0; j < TasksLimit && i + j < keys.Count; j++)
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
var key1 = Path.Combine(KeyHelper.GetDatabaseSchema(), keys[i + j]);
|
|
|
|
tasks.Add(RestoreFromDumpFile(dataReader, key1).ContinueWith(r => RestoreFromDumpFile(dataReader, KeyHelper.GetDatabaseData(key1.Substring(keyBase.Length + 1)))));
|
2020-05-20 15:14:44 +00:00
|
|
|
}
|
2022-02-09 18:49:52 +00:00
|
|
|
|
|
|
|
Task.WaitAll(tasks.ToArray());
|
|
|
|
}
|
|
|
|
|
|
|
|
var comparer = new SqlComparer();
|
|
|
|
foreach (var u in upgrades.OrderBy(Path.GetFileName, comparer))
|
|
|
|
{
|
|
|
|
RunMysqlFile(u, true);
|
2020-05-20 15:14:44 +00:00
|
|
|
SetStepCompleted();
|
|
|
|
}
|
2022-02-09 18:49:52 +00:00
|
|
|
}
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
private async Task RestoreFromDumpFile(IDataReadOperator dataReader, string fileName)
|
|
|
|
{
|
2022-04-28 09:15:33 +00:00
|
|
|
Logger.LogDebug("Restore from {fileName}", fileName);
|
2022-02-09 18:49:52 +00:00
|
|
|
using (var stream = dataReader.GetEntry(fileName))
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
await RunMysqlFile(stream);
|
|
|
|
}
|
|
|
|
SetStepCompleted();
|
|
|
|
}
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
private class SqlComparer : IComparer<string>
|
|
|
|
{
|
|
|
|
public int Compare(string x, string y)
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
if (x == y)
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(x))
|
|
|
|
{
|
|
|
|
var splittedX = x.Split('.');
|
|
|
|
if (splittedX.Length <= 2)
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
return -1;
|
2020-05-20 15:14:44 +00:00
|
|
|
}
|
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
if (splittedX[1] == "upgrade")
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
if (splittedX[1].StartsWith("upgrade") && !string.IsNullOrEmpty(y))
|
|
|
|
{
|
|
|
|
var splittedY = y.Split('.');
|
|
|
|
if (splittedY.Length <= 2)
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-02-09 16:46:09 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
if (splittedY[1] == "upgrade")
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
if (splittedY[1].StartsWith("upgrade"))
|
|
|
|
{
|
|
|
|
return string.Compare(x, y, StringComparison.Ordinal);
|
|
|
|
}
|
|
|
|
|
2020-05-20 15:14:44 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
return -1;
|
2020-05-20 15:14:44 +00:00
|
|
|
}
|
2022-02-09 18:49:52 +00:00
|
|
|
|
|
|
|
return string.Compare(x, y, StringComparison.Ordinal);
|
2020-05-20 15:14:44 +00:00
|
|
|
}
|
2022-02-09 18:49:52 +00:00
|
|
|
}
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
private void DoRestoreStorage(IDataReadOperator dataReader)
|
|
|
|
{
|
2022-04-25 18:02:18 +00:00
|
|
|
Logger.LogDebug("begin restore storage");
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
var fileGroups = GetFilesToProcess(dataReader).GroupBy(file => file.Module).ToList();
|
|
|
|
var groupsProcessed = 0;
|
|
|
|
foreach (var group in fileGroups)
|
|
|
|
{
|
|
|
|
foreach (var file in group)
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
var storage = StorageFactory.GetStorage(ConfigPath, Dump ? file.Tenant.ToString() : _columnMapper.GetTenantMapping().ToString(), group.Key);
|
|
|
|
var quotaController = storage.QuotaController;
|
|
|
|
storage.SetQuotaController(null);
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
var adjustedPath = file.Path;
|
|
|
|
var module = ModuleProvider.GetByStorageModule(file.Module, file.Domain);
|
|
|
|
if (module == null || module.TryAdjustFilePath(Dump, _columnMapper, ref adjustedPath))
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
var key = file.GetZipKey();
|
|
|
|
if (Dump)
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
key = CrossPlatform.PathCombine(KeyHelper.GetStorage(), key);
|
2020-05-20 15:14:44 +00:00
|
|
|
}
|
2022-02-09 18:49:52 +00:00
|
|
|
using var stream = dataReader.GetEntry(key);
|
|
|
|
try
|
2022-03-09 17:15:51 +00:00
|
|
|
{
|
|
|
|
storage.SaveAsync(file.Domain, adjustedPath, module != null ? module.PrepareData(key, stream, _columnMapper) : stream).Wait();
|
2022-02-09 18:49:52 +00:00
|
|
|
}
|
|
|
|
catch (Exception error)
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-04-28 09:15:33 +00:00
|
|
|
Logger.LogWarning(error, "can't restore file ({module}:{path})", file.Module, file.Path);
|
2020-05-20 15:14:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-02-09 18:49:52 +00:00
|
|
|
finally
|
|
|
|
{
|
|
|
|
if (quotaController != null)
|
|
|
|
{
|
|
|
|
storage.SetQuotaController(quotaController);
|
|
|
|
}
|
|
|
|
}
|
2020-05-20 15:14:44 +00:00
|
|
|
}
|
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
SetCurrentStepProgress((int)(++groupsProcessed * 100 / (double)fileGroups.Count));
|
2021-08-31 09:40:28 +00:00
|
|
|
}
|
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
if (fileGroups.Count == 0)
|
2021-08-31 09:40:28 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
SetStepCompleted();
|
|
|
|
}
|
2021-08-31 09:40:28 +00:00
|
|
|
|
2022-04-25 18:02:18 +00:00
|
|
|
Logger.LogDebug("end restore storage");
|
2022-02-09 18:49:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void DoDeleteStorage(IEnumerable<string> storageModules, IEnumerable<Tenant> tenants)
|
|
|
|
{
|
2022-04-25 18:02:18 +00:00
|
|
|
Logger.LogDebug("begin delete storage");
|
2022-03-09 17:15:51 +00:00
|
|
|
|
|
|
|
foreach (var tenant in tenants)
|
|
|
|
{
|
|
|
|
foreach (var module in storageModules)
|
|
|
|
{
|
|
|
|
var storage = StorageFactory.GetStorage(ConfigPath, tenant.Id.ToString(), module);
|
|
|
|
var domains = StorageFactoryConfig.GetDomainList(ConfigPath, module).ToList();
|
2021-08-31 09:40:28 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
domains.Add(string.Empty); //instead storage.DeleteFiles("\\", "*.*", true);
|
2021-08-31 09:40:28 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
foreach (var domain in domains)
|
|
|
|
{
|
|
|
|
ActionInvoker.Try(
|
|
|
|
state =>
|
2022-03-09 17:15:51 +00:00
|
|
|
{
|
|
|
|
if (storage.IsDirectoryAsync((string)state).Result)
|
|
|
|
{
|
|
|
|
storage.DeleteFilesAsync((string)state, "\\", "*.*", true).Wait();
|
2022-02-09 18:49:52 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
domain,
|
|
|
|
5,
|
2022-04-28 09:15:33 +00:00
|
|
|
onFailure: error => Logger.LogWarning(error, "Can't delete files for domain {domain}", domain)
|
2022-02-09 18:49:52 +00:00
|
|
|
);
|
2021-08-31 09:40:28 +00:00
|
|
|
}
|
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
SetStepCompleted();
|
|
|
|
}
|
2020-05-20 15:14:44 +00:00
|
|
|
}
|
|
|
|
|
2022-04-25 18:02:18 +00:00
|
|
|
Logger.LogDebug("end delete storage");
|
2022-02-09 18:49:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private IEnumerable<BackupFileInfo> GetFilesToProcess(IDataReadOperator dataReader)
|
|
|
|
{
|
|
|
|
using var stream = dataReader.GetEntry(KeyHelper.GetStorageRestoreInfoZipKey());
|
|
|
|
if (stream == null)
|
2020-05-20 15:14:44 +00:00
|
|
|
{
|
2022-02-09 18:49:52 +00:00
|
|
|
return Enumerable.Empty<BackupFileInfo>();
|
2020-05-20 15:14:44 +00:00
|
|
|
}
|
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
var restoreInfo = XElement.Load(new StreamReader(stream));
|
2022-02-09 18:33:50 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
return restoreInfo.Elements("file").Select(BackupFileInfo.FromXElement).ToList();
|
|
|
|
}
|
2020-05-20 15:14:44 +00:00
|
|
|
|
2022-02-09 18:49:52 +00:00
|
|
|
private void SetTenantActive(int tenantId)
|
|
|
|
{
|
|
|
|
using var connection = DbFactory.OpenConnection();
|
|
|
|
var commandText = string.Format(
|
|
|
|
"update tenants_tenants " +
|
|
|
|
"set " +
|
|
|
|
" status={0}, " +
|
|
|
|
" last_modified='{1}', " +
|
|
|
|
" statuschanged='{1}' " +
|
|
|
|
"where id = '{2}'",
|
|
|
|
(int)TenantStatus.Active,
|
|
|
|
DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"),
|
2022-03-09 17:15:51 +00:00
|
|
|
tenantId);
|
|
|
|
|
|
|
|
var command = connection.CreateCommand().WithTimeout(120);
|
|
|
|
command.CommandText = commandText;
|
|
|
|
command.ExecuteNonQuery();
|
2020-05-20 15:14:44 +00:00
|
|
|
}
|
|
|
|
}
|